GIDForums  

Go Back   GIDForums > Computer Programming Forums > FLTK Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 27-Oct-2005, 03:30
paolo paolo is offline
New Member
 
Join Date: Oct 2005
Posts: 1
paolo is on a distinguished road

drawing widget


hi,
i created my personal Widget, extending FL_widget and implementig the draw method to show my widget using FLTK Drawing Functions.

But if i put my widget in the FL_Scroll, scrolling the window, i obtain that my widget will be corrupted or disappear, why ?

What i have to do ?

thanks you...
Paolo
  #2  
Old 14-Nov-2005, 06:37
automatedreason automatedreason is offline
New Member
 
Join Date: Nov 2005
Location: germany
Posts: 2
automatedreason is on a distinguished road

Re: drawing widget


maybe you can post the code, that'll make it easier to find the bug
(maybe not even yours but FLTK's)
  #3  
Old 16-Apr-2006, 08:21
Manish Kumar Manish Kumar is offline
New Member
 
Join Date: Feb 2006
Posts: 6
Manish Kumar is on a distinguished road

Re: drawing widget


same problem i am facing. I have drawn a widget extending fl_widget class overriding draw function . And placed in fl_scroll group. But hell when i scroll the window everything disappears.

Help!!!!!!
  #4  
Old 16-Apr-2006, 08:42
cable_guy_67's Avatar
cable_guy_67 cable_guy_67 is offline
Senior Member
 
Join Date: Oct 2004
Location: Nescopeck, PA
Posts: 1,109
cable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the rough

Re: drawing widget


Quote:
Originally Posted by Manish Kumar
I have drawn a widget extending fl_widget class overriding draw function . And placed in fl_scroll group. But hell when i scroll the window everything disappears.

Could you post an example of this? Strip it down as simply as possible and be specific about your FLTK version. Perhaps someone can offer some help or see if it is an FLTK problem. Since you are overriding draw() that would be my guess for a starting point for sure.

Mark
__________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work."
--Thomas Alva Edison
"Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety."
--Benjamin Franklin
"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes."
--Hugh Downs
  #5  
Old 16-Apr-2006, 10:27
Manish Kumar Manish Kumar is offline
New Member
 
Join Date: Feb 2006
Posts: 6
Manish Kumar is on a distinguished road

Re: drawing widget


THe code is below

CPP / C++ / C Code:
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Value_Output.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Scroll.H>
#include <FL/Fl_Group.H>




class Drawing : public Fl_Widget {
  void draw() {
    fl_color(FL_WHITE);
    fl_arc(140,140,70,0,-360);
    fl_end_line();
  }
public:
  Drawing(int X,int Y,int W,int H) : Fl_Widget(X,Y,W,H) {}
};


class MyClass : public Fl_Scroll {
 
  
 public:
  MyClass(int X,int Y,int W,int H) : Fl_Scroll(X,Y,W,H) {
  Drawing *d=new Drawing(X,Y,W,500);
  }
  
  

 };

int main(int argc, char** argv) {
  Fl_Window window(300,300);
  MyClass *o= new MyClass(10,10,280,280);
  
  

  window.end();
  window.show(argc,argv);


  return Fl::run();
}

Thanx for help

Manish Kumar
Last edited by cable_guy_67 : 16-Apr-2006 at 16:03. Reason: Please enclose c++ code in [c++] ... [/c++] tags
  #6  
Old 17-Apr-2006, 01:54
Manish Kumar Manish Kumar is offline
New Member
 
Join Date: Feb 2006
Posts: 6
Manish Kumar is on a distinguished road

Re: drawing widget


i was tring to draw something in FLTK actually a graph with scrolling window. But it seems thats not possible to do as FLTK disorts the objects whose dimensions are less than dimensions of widget.
  #7  
Old 17-Apr-2006, 04:16
Manish Kumar Manish Kumar is offline
New Member
 
Join Date: Feb 2006
Posts: 6
Manish Kumar is on a distinguished road

Re: drawing widget


hey i finally found why was that happening.... After going through documentation on fl_Scroll i got the mistake i was making. We need to reposition the widget as we scroll. The corrected code look like this.

CPP / C++ / C Code:
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Value_Output.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Scroll.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Box.H>
#include<stdio.h>
#include<math.h>
#define M_PI 3.14159

Fl_Scroll* thescroll;
class Drawing :public Fl_Widget
{

	
	void draw() 
	{
	  draw_box();	
          fl_begin_line();
          fl_color(FL_BLACK);
	  fl_arc(140-thescroll->xposition(),140-thescroll->yposition(),70,0,-360);
	  fl_end_line();
	}


public:
  Drawing(int X,int Y,int W,int H) :Fl_Widget(X,Y,W,H) 
  {
   align(FL_ALIGN_TOP);
   box(FL_FLAT_BOX);
   color(FL_WHITE);
  }
};


int main(int argc, char** argv) {
 Fl_Window window(600,500);
  Fl_Scroll *o= new Fl_Scroll(10,10,280,300);
  Drawing drawin(	o->x(),o->y(),800,800);
  o->end(); 
  o->end();
  thescroll=o;
  window.resizable(o);
  window.end();
  window.show();


  return Fl::run();
}



Have Fun With FLTK

Manish Kumar
 
 

Recent GIDBlogMore photos on Flickr by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to save a drawing to the file amgturk MS Visual C++ / MFC Forum 2 25-Jul-2005 00:29
FLTK clock box widget cable_guy_67 FLTK Forum 0 09-Jul-2005 18:51
Using the FL_File_Chooser widget maveganzones FLTK Forum 3 18-Apr-2005 09:48
widget coordinate relative to parent ? Marius Giurgi FLTK Forum 10 10-Mar-2005 06:21
How to refresh a widget immediately dsmith FLTK Forum 8 11-Dec-2004 00:54

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:11.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.