gwenhywfar 4.0.3

fox16_gui_dialog_l.hpp

Go to the documentation of this file.
00001 /***************************************************************************
00002     begin       : Fri Jan 22 2010
00003     copyright   : (C) 2010 by Martin Preuss
00004     email       : martin@libchipcard.de
00005 
00006  ***************************************************************************
00007  *          Please see toplevel file COPYING for license details           *
00008  ***************************************************************************/
00009 
00010 #ifndef FOX16_GUI_DIALOG_L_HPP
00011 #define FOX16_GUI_DIALOG_L_HPP
00012 
00013 #include "cppdialog.hpp"
00014 #include "fox16_gui.hpp"
00015 
00016 #include <fx.h>
00017 
00018 #include <gwenhywfar/dialog_be.h>
00019 #include <gwenhywfar/widget_be.h>
00020 
00021 #include <list>
00022 #include <string>
00023 
00024 
00025 
00026 class FOX16_GuiDialog: public FXObject, public CppDialog {
00027   FXDECLARE(FOX16_GuiDialog)
00028 
00029 protected:
00030   class RadioButtonGroup {
00031   protected:
00032     FXDataTarget m_radioTarget;
00033     int m_groupId;
00034     FXint m_radioValue;
00035     int m_buttonCount;
00036     std::list<FXRadioButton*> m_buttonList;
00037 
00038   public:
00039     RadioButtonGroup(int groupId, FXObject* tgt=NULL, FXSelector sel=0)
00040       :m_radioTarget(m_radioValue, tgt, sel), m_groupId(groupId), m_radioValue(0), m_buttonCount(0) {};
00041     ~RadioButtonGroup() {
00042       std::list<FXRadioButton*>::iterator it;
00043 
00044       for (it=m_buttonList.begin(); it!=m_buttonList.end(); it++)
00045         /* reset target pointer in buttons because we are about to destroy the FXDataTarget */
00046         (*it)->setTarget(NULL);
00047     };
00048 
00049     int getGroupId() { return m_groupId;};
00050 
00051     FXDataTarget *getDataTarget() { return &m_radioTarget;};
00052 
00053     int getButtonCount() { return m_buttonList.size();};
00054 
00055     FXint getRadioValue() const { return m_radioValue;};
00056 
00057     void addButton(FXRadioButton *rb) {
00058       m_buttonList.push_back(rb);
00059     };
00060   };
00061 
00062 
00063 public:
00064   enum {
00065     ID_WIDGET_FIRST=1,
00066     ID_WIDGET_LAST=1000,
00067     ID_LAST
00068   };
00069 
00070   FOX16_GuiDialog(FOX16_Gui *gui, GWEN_DIALOG *dlg);
00071   virtual ~FOX16_GuiDialog();
00072 
00073   static FOX16_GuiDialog *getDialog(GWEN_DIALOG *dlg);
00074 
00075   long onSelCommand(FXObject *sender, FXSelector sel, void *ptr);
00076   long onSelChanged(FXObject *sender, FXSelector sel, void *ptr);
00077   long onSelKeyPress(FXObject *sender, FXSelector sel, void *ptr);
00078   long onSelKeyRelease(FXObject *sender, FXSelector sel, void *ptr);
00079 
00080   FXIcon *getIcon(const char *fileName);
00081 
00082   bool setup(FXWindow *parentWindow);
00083 
00084   int execute();
00085   int cont();
00086 
00087   int openDialog();
00088   int closeDialog();
00089 
00090 
00091   FXDialogBox *getMainWindow() { return _mainWidget;};
00092 
00093 protected:
00094   FOX16_Gui *_gui;
00095   int _widgetCount;
00096   FXDialogBox *_mainWidget;
00097   FXIconSource *m_iconSource;
00098   std::list<FXIcon*> m_iconList;
00099   std::list<RadioButtonGroup*> m_radioGroups;
00100 
00101   FOX16_GuiDialog();
00102 
00103   FXWindow *setupTree(FXWindow *parentWindow, GWEN_WIDGET *w);
00104 
00105   void guiUpdate();
00106 
00107   virtual int setIntProperty(GWEN_WIDGET *w,
00108                              GWEN_DIALOG_PROPERTY prop,
00109                              int index,
00110                              int value,
00111                              int doSignal);
00112 
00113   virtual int getIntProperty(GWEN_WIDGET *w,
00114                              GWEN_DIALOG_PROPERTY prop,
00115                              int index,
00116                              int defaultValue);
00117 
00118   virtual int setCharProperty(GWEN_WIDGET *w,
00119                               GWEN_DIALOG_PROPERTY prop,
00120                               int index,
00121                               const char *value,
00122                               int doSignal);
00123 
00124   virtual const char *getCharProperty(GWEN_WIDGET *w,
00125                                       GWEN_DIALOG_PROPERTY prop,
00126                                       int index,
00127                                       const char *defaultValue);
00128 
00129 };
00130 
00131 
00132 
00133 
00134 #endif /* FOX16_DIALOG_L_HPP */
00135 
00136