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 08-Jun-2008, 17:01
./mr ./mr is offline
New Member
 
Join Date: Jun 2008
Posts: 2
./mr is on a distinguished road

Change widget image using event function


Hi !

I tried to change position and image for this widget (inhareted from Fl_Button) when user press up key. Changeing position is working fine but the part where i change image, creates "segmentation fault".

Here is code:

CPP / C++ / C Code:
class foo : public Fl_Button{
    
    public:
        foo(int x, int y) : Fl_Button(x, y, 30, 30) 
        { }

    int handle(int e){
        int ret = Fl_Button::handle(e);
        switch(e){
            case FL_KEYDOWN:
                if(Fl::event_key() == FL_Up){
                    
                    //This part is making problem
                    fl_register_image()
                    Fl_JPEG_Image jpg ("image.jpg"),
                    image(jpg);
                   //end

                    position(x(), y() - 5);
                    window()->redraw();
                }             
        }
       return ret;
    }
};

int main(int argc, char** argv){
     Fl_Window *win = new Fl_Window(500, 500);
          foo *obj = new foo(30, 30);

          fl_register_images();
          Fl_JPEG_Image jpg("test.jpg");

          obj->image(jpg);
     win->show();
     return Fl::run();
}

I'm using fltk 1.1.8 on Linux ...
Last edited by admin : 08-Jun-2008 at 20:25. Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
 
 

Recent GIDBlogPh.D. progress 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
run script command on ns2.26 newbie06 Computer Software Forum - Linux 66 16-Jan-2010 10:53
Flex and bison coding lucky88star C++ Forum 5 24-Dec-2007 11:57
Image onto JFrame tedds Java Forum 8 25-Oct-2007 20:04
[Include] Doubly-linked List dsmith C Programming Language 6 14-Apr-2006 13:12
GIM gidedit - a fltk fluid resize project cable_guy_67 FLTK Forum 2 01-Jun-2005 15:00

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

All times are GMT -6. The time now is 18:45.


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