paragui-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paragui-cvs] CVS: paragui/test animation.cpp,1.1,1.2 dblbuffer.cpp,1.1.


From: Alexander Pipelka <address@hidden>
Subject: [paragui-cvs] CVS: paragui/test animation.cpp,1.1,1.2 dblbuffer.cpp,1.1.1.1,1.2 paratest.cpp,1.2,1.3
Date: Sat, 27 Apr 2002 07:57:26 -0400

Update of /cvsroot/paragui/paragui/test
In directory subversions:/tmp/cvs-serv16543/test

Modified Files:
        animation.cpp dblbuffer.cpp paratest.cpp 
Log Message:
Here we go :))
This is the first version with libsigc++ support.

All internal callback handling mechanisms have been removed.
See include/pgsignals.h for details (BEWARE! Class templates are my friends).



Index: animation.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/test/animation.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** animation.cpp       15 Apr 2002 13:31:31 -0000      1.1
--- animation.cpp       27 Apr 2002 11:57:23 -0000      1.2
***************
*** 19,27 ****
  #define ID_APP_EXIT           1
  
! PARAGUI_CALLBACK(exit_handler) {
  
!       // we can pass in some pointer to any userdata
        // (in this case we get a pointer to the application object)
!       PG_Application* app = (PG_Application*) clientdata;
  
        // exit the application eventloop
--- 19,27 ----
  #define ID_APP_EXIT           1
  
! bool exit_handler(PG_Button* button, PG_Pointer* data) {
  
!       // we can pass in some pointer to data
        // (in this case we get a pointer to the application object)
!       PG_Application* app = static_cast<PG_Application*>(data);
  
        // exit the application eventloop
***************
*** 32,40 ****
  }
  
! PARAGUI_CALLBACK_SELECTMENUITEM(handle_menu_click) {
! 
!       switch (id) {
          case ID_APP_EXIT:
!               static_cast<PG_Application*>(clientdata)->Quit();
                break;
        }
--- 32,41 ----
  }
  
! bool handle_menu_click(PG_MenuItem* item, PG_Pointer* data) {
!       PG_Application* app = static_cast<PG_Application*>(data);
!       
!       switch (item->getId()) {
          case ID_APP_EXIT:
!               app->Quit();
                break;
        }
***************
*** 230,235 ****
  }
  
! PARAGUI_CALLBACK(appidle_handler) {
!       ((PlayField *)clientdata)->timer_callback();
        return true;
  }
--- 231,236 ----
  }
  
! bool appidle_handler(PG_MessageObject* object, PG_Pointer* data) {
!       ((PlayField *)data)->timer_callback();
        return true;
  }
***************
*** 273,278 ****
        PG_PopupMenu   popmenu(NULL, 425, 140, "File");
  
!       popmenu.addMenuItem("Nail", 99, handle_menu_click).
!         addMenuItem("Quit", ID_APP_EXIT, handle_menu_click, &app);
   
        menubar.Add("File", &popmenu);
--- 274,279 ----
        PG_PopupMenu   popmenu(NULL, 425, 140, "File");
  
!       popmenu.addMenuItem("Nail", 99, slot(handle_menu_click)).
!         addMenuItem("Quit", ID_APP_EXIT, slot(handle_menu_click), &app);
   
        menubar.Add("File", &popmenu);
***************
*** 280,284 ****
        menubar.Show();
  
!       myButton.SetEventCallback(MSG_BUTTONCLICK, exit_handler, &app);
  
        // now we have to make the button visible
--- 281,285 ----
        menubar.Show();
  
!       myButton.sigButtonClick.connect(slot(exit_handler), &app);
  
        // now we have to make the button visible
***************
*** 326,330 ****
        SDL_AddTimer(20, timer_callback, (void *)&anim_test2);
  
!       app.SetEventCallback(MSG_APPIDLE, appidle_handler, (void *)&anim_test);
        app.EnableAppIdleCalls();
  
--- 327,331 ----
        SDL_AddTimer(20, timer_callback, (void *)&anim_test2);
  
!       app.sigAppIdle.connect(slot(appidle_handler), &anim_test);
        app.EnableAppIdleCalls();
  

Index: dblbuffer.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/test/dblbuffer.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** dblbuffer.cpp       15 Apr 2002 13:22:29 -0000      1.1.1.1
--- dblbuffer.cpp       27 Apr 2002 11:57:23 -0000      1.2
***************
*** 32,41 ****
  int bForeground = 0;
  
! PARAGUI_CALLBACK(handle_quit) {
        done = 1;
        return true;
  }
  
! PARAGUI_CALLBACK(handle_toggle) {
        bForeground = 1-bForeground;
        return true;
--- 32,41 ----
  int bForeground = 0;
  
! bool handle_quit(PG_Button* button, PG_Pointer* data) {
        done = 1;
        return true;
  }
  
! bool handle_toggle(PG_RadioButton* button, PG_Pointer* data) {
        bForeground = 1-bForeground;
        return true;
***************
*** 207,215 ****
        // get a pointer to the "quit" button
        PG_Button* btn = static_cast<PG_Button*>(app.GetWidgetByName("quit"));
!       btn->SetEventCallback(MSG_BUTTONCLICK, handle_quit);
  
        // get the checkbutton
        PG_CheckButton* toggle = 
static_cast<PG_CheckButton*>(app.GetWidgetByName("toggle"));
!       toggle->SetEventCallback(MSG_BUTTONCLICK, handle_toggle);
  
        // get the label
--- 207,215 ----
        // get a pointer to the "quit" button
        PG_Button* btn = static_cast<PG_Button*>(app.GetWidgetByName("quit"));
!       btn->sigButtonClick.connect(slot(handle_quit));
  
        // get the checkbutton
        PG_CheckButton* toggle = 
static_cast<PG_CheckButton*>(app.GetWidgetByName("toggle"));
!       toggle->sigButtonClick.connect(slot(handle_toggle));
  
        // get the label

Index: paratest.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/test/paratest.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** paratest.cpp        15 Apr 2002 13:31:31 -0000      1.2
--- paratest.cpp        27 Apr 2002 11:57:23 -0000      1.3
***************
*** 16,20 ****
  #include "pgcolumnitem.h"
  #include "pgdropdown.h"
- #include "pgeventobject.h"
  #include "pgpopupmenu.h"
  #include "pgspinnerbox.h"
--- 16,19 ----
***************
*** 22,28 ****
  #include "pgmenubar.h"
  
- #define SetConnection(MSG_TYPE, objDest, objFunc) \
- SetEventObject(MSG_TYPE, objDest, (MSG_CALLBACK_OBJ)&objFunc)
- 
  #define RESX 800
  #define RESY 600
--- 21,24 ----
***************
*** 35,40 ****
  }
  
! PARAGUI_CALLBACK(handle_popup) {
!       PG_PopupMenu* pop = (PG_PopupMenu*)clientdata;
  
        pop->trackMenu(10, 10);
--- 31,36 ----
  }
  
! bool handle_popup(PG_Button* button, PG_Pointer* data) {
!       PG_PopupMenu* pop = static_cast<PG_PopupMenu*>(data);
  
        pop->trackMenu(10, 10);
***************
*** 43,48 ****
  }
  
! PARAGUI_CALLBACK(handle_exit) {
!       PG_Application* app = (PG_Application*)clientdata;
        app->Quit();
        return true;
--- 39,44 ----
  }
  
! bool handle_exit(PG_Pointer* data) {
!       PG_Application* app = static_cast<PG_Application*>(data);
        app->Quit();
        return true;
***************
*** 51,61 ****
  // A new widget with a callback member
  
! class MySliderLabel : public PG_Label , public PG_EventObject {
  public:
        MySliderLabel(PG_Widget* parent, const PG_Rect& r, char* text) : 
PG_Label(parent,r,text) {
        };
  
!       PARAGUI_CALLBACK(handler_slider) {
!               SetTextFormat("%i", (int)data);
                return true;
        }
--- 47,57 ----
  // A new widget with a callback member
  
! class MySliderLabel : public PG_Label {
  public:
        MySliderLabel(PG_Widget* parent, const PG_Rect& r, char* text) : 
PG_Label(parent,r,text) {
        };
  
!       bool handle_slide(long pos) {
!               SetTextFormat("%i", (int)pos);
                return true;
        }
***************
*** 64,68 ****
  // A testwindow class
  
! class TestWindow : public PG_Window, public PG_EventObject {
  public:
  
--- 60,64 ----
  // A testwindow class
  
! class TestWindow : public PG_Window {
  public:
  
***************
*** 73,77 ****
  
        /** a new style callback member */
!       PARAGUI_CALLBACK(handle_show_window) {
                Show(true);
                return true;
--- 69,73 ----
  
        /** a new style callback member */
!       bool handle_show_window(PG_Button* button, PG_Pointer* data) {
                Show(true);
                return true;
***************
*** 79,92 ****
  
        /** callback handler in another flavor */
!       PARAGUI_CALLBACK(handler_slider_btntrans) {
!               PG_Button* b = (PG_Button*)clientdata;
        
                // set transparency of passed in button
!               b->SetTransparency(data, data, data);
!               b->Update();
  
                // set transparency of class member (progress)
!               progress->SetTransparency(data);
!               progress->Update();
                return true;
        }
--- 75,88 ----
  
        /** callback handler in another flavor */
!       bool handle_slide_btntrans(PG_Slider* slider, long pos) {
!               PG_Button* b = NULL; //(PG_Button*)clientdata;
        
                // set transparency of passed in button
!               //b->SetTransparency(data, data, data);
!               //b->Update();
  
                // set transparency of class member (progress)
!               //progress->SetTransparency(data);
!               //progress->Update();
                return true;
        }
***************
*** 94,100 ****
  protected:
  
!       bool eventButtonClick(int id, PG_Widget* widget);
!       bool eventScrollPos(int id, PG_Widget* widget, unsigned long data);
!       bool eventScrollTrack(int id, PG_Widget* widget, unsigned long data);
  
  private:
--- 90,97 ----
  protected:
  
!       bool handleButton(PG_Button* widget, PG_Pointer* data);
!       
!       bool handleScrollPos(PG_ScrollBar* widget, long pos);
!       bool handleScrollTrack(PG_ScrollBar* widget, long pos);
  
  private:
***************
*** 116,121 ****
        WidgetList->EnableScrollBar(true, PG_SB_HORIZONTAL);
                
!       new PG_Button(this, 100, PG_Rect(260,130,110,30), "<< ADD");
!       new PG_Button(this, 101, PG_Rect(260,165,110,30), ">> REMOVE");
        
        PG_Button* b = new PG_Button(NULL, BTN_ID_YES, PG_Rect(0,0, 400,50), 
"YES");
--- 113,121 ----
        WidgetList->EnableScrollBar(true, PG_SB_HORIZONTAL);
                
!       PG_Button* add = new PG_Button(this, 100, PG_Rect(260,130,110,30), "<< 
ADD");
!       add->sigButtonClick.connect(slot(this, &TestWindow::handleButton));
!       
!       PG_Button* remove = new PG_Button(this, 101, PG_Rect(260,165,110,30), 
">> REMOVE");
!       remove->sigButtonClick.connect(slot(this, &TestWindow::handleButton));
        
        PG_Button* b = new PG_Button(NULL, BTN_ID_YES, PG_Rect(0,0, 400,50), 
"YES");
***************
*** 129,133 ****
        s->SetPosition(50);
  
!       s->SetEventObject(MSG_SLIDE, this, 
(MSG_CALLBACK_OBJ)&TestWindow::handler_slider_btntrans, b);
  
        WidgetList->AddWidget(s);
--- 129,133 ----
        s->SetPosition(50);
  
!       s->sigSlide.connect(slot(this, &TestWindow::handle_slide_btntrans));
  
        WidgetList->AddWidget(s);
***************
*** 146,152 ****
--- 146,156 ----
        PG_ScrollBar* scroll = new PG_ScrollBar(this, 1, 
PG_Rect(415,90,20,150));
        scroll->SetRange(0, 100);
+       scroll->sigScrollTrack.connect(slot(this, 
&TestWindow::handleScrollTrack));
+       scroll->sigScrollPos.connect(slot(this, &TestWindow::handleScrollPos));
  
        PG_ScrollBar* scroll1 = new PG_ScrollBar(this, 2, 
PG_Rect(435,90,20,150));
        scroll1->SetRange(0, 255);
+       scroll1->sigScrollTrack.connect(slot(this, 
&TestWindow::handleScrollTrack));
+       scroll1->sigScrollPos.connect(slot(this, &TestWindow::handleScrollPos));
  
        PG_DropDown* drop = new PG_DropDown(this, 15, PG_Rect(260, 60, 200,25));
***************
*** 161,172 ****
  }
  
! bool TestWindow::eventScrollPos(int id, PG_Widget* widget, unsigned long 
data){
        if(id == 1){
!               progress->SetProgress(data);
                return true;
        }
  
        if(id == 2){
!               SetTransparency((unsigned char)data);
                Update();
                return true;
--- 165,178 ----
  }
  
! bool TestWindow::handleScrollPos(PG_ScrollBar* widget, long pos){
!       int id = widget->GetID();
!       
        if(id == 1){
!               progress->SetProgress(pos);
                return true;
        }
  
        if(id == 2){
!               SetTransparency((Uint8)pos);
                Update();
                return true;
***************
*** 176,187 ****
  }
  
! bool TestWindow::eventScrollTrack(int id, PG_Widget* widget, unsigned long 
data) {
        if(id == 1){
!               progress->SetProgress(data);
                return true;
        }
  
        if(id == 2){
!               SetTransparency((unsigned char)data);
                Update();
                return true;
--- 182,195 ----
  }
  
! bool TestWindow::handleScrollTrack(PG_ScrollBar* widget, long pos) {
!       int id = widget->GetID();
!       
        if(id == 1){
!               progress->SetProgress(pos);
                return true;
        }
  
        if(id == 2){
!               SetTransparency((Uint8)pos);
                Update();
                return true;
***************
*** 191,198 ****
  }
  
! bool TestWindow::eventButtonClick(int id, PG_Widget* widget) {
        static int label=0;
  
!       if(id == 100) {
                PG_Label* l = new PG_Label(NULL, PG_Rect(0,0,220,25), "");
                l->SetAlignment(PG_TA_CENTER);
--- 199,206 ----
  }
  
! bool TestWindow::handleButton(PG_Button* widget, PG_Pointer* data) {
        static int label=0;
  
!       if(widget->GetID() == 100) {
                PG_Label* l = new PG_Label(NULL, PG_Rect(0,0,220,25), "");
                l->SetAlignment(PG_TA_CENTER);
***************
*** 203,207 ****
        }
  
!       if(id == 101) {
                PG_Widget* w = WidgetList->FindWidget(4);
                if(w != NULL) {
--- 211,215 ----
        }
  
!       if(widget->GetID() == 101) {
                PG_Widget* w = WidgetList->FindWidget(4);
                if(w != NULL) {
***************
*** 213,230 ****
        }
        
!       return PG_Window::eventButtonClick(id, widget);
  }
  
! PARAGUI_CALLBACK_SELECTMENUITEM(handle_menu_click) {
!       std::cout << "menu item '" << id << "' (\""
                << item->getCaption() << "\") clicked" << std::endl;
  
!       switch (id) {
                case 5:
!                       static_cast<TestWindow*>(clientdata)->Show();
                        break;
  
                case 6:
!                       static_cast<PG_Application*>(clientdata)->Quit();
                        break;
        }
--- 221,238 ----
        }
        
!       return false;
  }
  
! bool handle_menu_click(PG_MenuItem* item, PG_Pointer* data) {
!       std::cout << "menu item '" << item->getId() << "' (\""
                << item->getCaption() << "\") clicked" << std::endl;
  
!       switch (item->getId()) {
                case 5:
!                       static_cast<TestWindow*>(data)->Show();
                        break;
  
                case 6:
!                       static_cast<PG_Application*>(data)->Quit();
                        break;
        }
***************
*** 257,261 ****
  }
  
! PARAGUI_CALLBACK(handle_list) {
  
        PG_LogMSG(" ---- List of objects ----\n");
--- 265,269 ----
  }
  
! bool handle_list() {
  
        PG_LogMSG(" ---- List of objects ----\n");
***************
*** 357,362 ****
        PG_PopupMenu   subsubmenu(NULL, 425, 140, "");
        
!       submenu.SetEventCallback(MSG_SELECTMENUITEM, handle_menu_click);
!       subsubmenu.SetEventCallback(MSG_SELECTMENUITEM, handle_menu_click);
  
        subsubmenu.addMenuItem("Mordor", 1).
--- 365,370 ----
        PG_PopupMenu   subsubmenu(NULL, 425, 140, "");
        
!       submenu.sigMenuItemSelect.connect(slot(handle_menu_click));
!       subsubmenu.sigMenuItemSelect.connect(slot(handle_menu_click));
  
        subsubmenu.addMenuItem("Mordor", 1).
***************
*** 369,380 ****
          addMenuItem("Long ago", &subsubmenu);
                
!     popmenu.addMenuItem("Tasty", 1, handle_menu_click).
!         addMenuItem("Even tastier", 2, handle_menu_click).
!         addMenuItem("I'm third here...", 3, handle_menu_click).
!         addMenuItem("And I'm fourth", 4, handle_menu_click).
                addMenuItem("Saga", &submenu).
          addSeparator().
!         addMenuItem("Open Window", 5, handle_menu_click, &wnd).
!         addMenuItem("Quit", 6, handle_menu_click, &app);
      
        popmenu.disableItem(2);
--- 377,388 ----
          addMenuItem("Long ago", &subsubmenu);
                
!     popmenu.addMenuItem("Tasty", 1, slot(handle_menu_click)).
!         addMenuItem("Even tastier", 2, slot(handle_menu_click)).
!         addMenuItem("I'm third here...", 3, slot(handle_menu_click)).
!         addMenuItem("And I'm fourth", 4, slot(handle_menu_click)).
                addMenuItem("Saga", &submenu).
          addSeparator().
!         addMenuItem("Open Window", 5, slot(handle_menu_click), &wnd).
!         addMenuItem("Quit", 6, slot(handle_menu_click), &app);
      
        popmenu.disableItem(2);
***************
*** 416,431 ****
        PG_Slider slider(NULL, 11, PG_Rect(50, 250, 300,20), PG_SB_HORIZONTAL);
        slider.SetRange(5,20);
-       //slider.SetTransparency(128);
  
        // connect the "MSG_SLIDE" event with "handler_slider" of slider_label 
(see macro above, just for testing)
!       slider.SetConnection(MSG_SLIDE, &slider_label, 
MySliderLabel::handler_slider);
! 
!       // that's the real world implementation
!       //slider.SetEventObject(MSG_SLIDE, &slider_label, 
(MSG_CALLBACK_OBJ)&MySliderLabel::handler_slider);
  
        slider.Show();
  
        PG_Button popbtn(NULL, 20, PG_Rect(430, 250,100,25), "Pop me");
!       popbtn.SetEventCallback(MSG_BUTTONCLICK, handle_popup, &popmenu);
        popbtn.Show();
  
--- 424,435 ----
        PG_Slider slider(NULL, 11, PG_Rect(50, 250, 300,20), PG_SB_HORIZONTAL);
        slider.SetRange(5,20);
  
        // connect the "MSG_SLIDE" event with "handler_slider" of slider_label 
(see macro above, just for testing)
!       slider.sigSlide.connect(slot(&slider_label, 
&MySliderLabel::handle_slide));
  
        slider.Show();
  
        PG_Button popbtn(NULL, 20, PG_Rect(430, 250,100,25), "Pop me");
!       popbtn.sigButtonClick.connect(slot(handle_popup), &popmenu);
        popbtn.Show();
  
***************
*** 445,460 ****
  
        PG_Button list(NULL, BTN_ID_OK, PG_Rect(400,450,100,30), "List");
!       list.SetEventCallback(MSG_BUTTONCLICK, handle_list, NULL);
        list.Show();
  
        PG_Button quit(NULL, BTN_ID_CLOSE, PG_Rect(600,450,100,30), "Quit");
!       quit.SetEventCallback(MSG_BUTTONCLICK, handle_exit, &app);
        quit.Show();
  
-       // hehe, now it gets interesting ...
        PG_Button show_wnd(NULL, BTN_ID_APPLY, PG_Rect(500,450,100,30), 
"Window");
! 
!       // yeah, man.. believe your eyes
!       show_wnd.SetEventObject(MSG_BUTTONCLICK, &wnd, 
(MSG_CALLBACK_OBJ)&TestWindow::handle_show_window, (void*)&show_wnd);
      
        show_wnd.Show();
--- 449,461 ----
  
        PG_Button list(NULL, BTN_ID_OK, PG_Rect(400,450,100,30), "List");
!       list.sigButtonClick.connect(slot(handle_list));
        list.Show();
  
        PG_Button quit(NULL, BTN_ID_CLOSE, PG_Rect(600,450,100,30), "Quit");
!       quit.sigButtonClick.connect(slot(handle_exit), &app);
        quit.Show();
  
        PG_Button show_wnd(NULL, BTN_ID_APPLY, PG_Rect(500,450,100,30), 
"Window");
!       show_wnd.sigButtonClick.connect(slot(&wnd, 
&TestWindow::handle_show_window));
      
        show_wnd.Show();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]