#include "paragui.h" #include "pgapplication.h" #include "pgsignals.h" #include "pglabel.h" #include <string> // create a custom class derived from SigC::Object class MySigC : public virtual SigC::Object { public: SigC::Signal1<bool, const std::string&> msg; }; // MyLabel uses PG_Label (which has the bas class SigC::Object) // and MySigC (also derived from SigC::Object) class MyLabel : public PG_Label, public MySigC { public: MyLabel(PG_Widget* parent, const PG_Rect& r) : PG_Label(parent, r, "") { msg.connect(slot(*this, &MyLabel::MySlot)); }; bool MySlot(const std::string& text) { SetText(text.c_str()); return true; }; }; int main(int argc, char* argv[]) { PG_Application app; app.LoadTheme("default"); app.InitScreen(640, 480, 0); app.SetEmergencyQuit(true); MyLabel l(NULL, PG_Rect(50, 50, 300, 25)); l.msg("test"); l.Show(); app.Run(); }
00001 00002 #include "paragui.h" 00003 #include "pgapplication.h" 00004 #include "pgsignals.h" 00005 #include "pglabel.h" 00006 00007 #include <string> 00008 00009 // create a custom class derived from SigC::Object 00010 class MySigC : public virtual SigC::Object { 00011 public: 00012 SigC::Signal1<bool, const std::string&> msg; 00013 }; 00014 00015 // MyLabel uses PG_Label (which has the bas class SigC::Object) 00016 // and MySigC (also derived from SigC::Object) 00017 class MyLabel : public PG_Label, public MySigC { 00018 public: 00019 MyLabel(PG_Widget* parent, const PG_Rect& r) : PG_Label(parent, r, "") { 00020 msg.connect(slot(*this, &MyLabel::MySlot)); 00021 }; 00022 00023 bool MySlot(const std::string& text) { 00024 SetText(text.c_str()); 00025 return true; 00026 }; 00027 }; 00028 00029 int main(int argc, char* argv[]) { 00030 PG_Application app; 00031 app.LoadTheme("default"); 00032 00033 app.InitScreen(640, 480, 0); 00034 app.SetEmergencyQuit(true); 00035 00036 MyLabel l(NULL, PG_Rect(50, 50, 300, 25)); 00037 l.msg("test"); 00038 l.Show(); 00039 00040 app.Run(); 00041 }