]> git.tdb.fi Git - libs/gltk.git/commitdiff
Support loading dialog action buttons
authorMikko Rasa <tdb@tdb.fi>
Sat, 15 Jun 2013 21:00:30 +0000 (00:00 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 15 Jun 2013 21:00:30 +0000 (00:00 +0300)
source/dialog.cpp
source/dialog.h
source/panel.h

index cc4c1bf6a51f67cd1b00ecd46a9fc3cb2fda0c90..dba276d32d7aa05de119fa2cdf48407cbdcf4fe9 100644 (file)
@@ -1,6 +1,8 @@
 #include "button.h"
 #include "dialog.h"
 
+using namespace std;
+
 namespace Msp {
 namespace GLtk {
 
@@ -35,5 +37,20 @@ void Dialog::response(int code)
        stale = true;
 }
 
+
+Dialog::Loader::Loader(Dialog &d, WidgetMap &wm):
+       DerivedObjectLoader<Dialog, Panel::Loader>(d, wm)
+{
+       add("action_button", &Loader::action_button);
+}
+
+void Dialog::Loader::action_button(const string &n, int c)
+{
+       RefPtr<Button> btn = new Button();
+       load_sub(*btn);
+       obj.add_button(*btn.get(), c);
+       wdg_map[n] = btn.release();
+}
+
 } // namespace GLtk
 } // namespace Msp
index 1365f3a599a8b374ea41f64ab397e8a6102a2bb8..1925c61ee740460cb9897791fdaf6bef8559ed34 100644 (file)
@@ -15,6 +15,14 @@ Dialog's action buttons are clicked, it will emit a signal and delete itself.
 class Dialog: public Panel
 {
 public:
+       class Loader: public DataFile::DerivedObjectLoader<Dialog, Panel::Loader>
+       {
+       public:
+               Loader(Dialog &, WidgetMap &);
+       private:
+               void action_button(const std::string &, int);
+       };
+
        sigc::signal<void, int> signal_response;
 
 private:
index aa94ff317f1402ed6c42a1d360dc1a2e2adbf2af..258d0ceeede592cf19c793da33ddb6a443a7c712 100644 (file)
@@ -21,7 +21,7 @@ public:
        public:
                typedef std::map<std::string, Widget *> WidgetMap;
 
-       private:
+       protected:
                WidgetMap &wdg_map;
        
        public: