core/vgui/impl/wx/vgui_wx_dialog_impl.h
Go to the documentation of this file.
00001 // This is core/vgui/impl/wx/vgui_wx_dialog_impl.h
00002 #ifndef vgui_wx_dialog_impl_h_
00003 #define vgui_wx_dialog_impl_h_
00004 //=========================================================================
00005 //:
00006 // \file
00007 // \brief  wxWidgets implementation of vgui_dialog_impl.
00008 // \author Miguel A. Figueroa-Villanueva (miguelfv)
00009 //
00010 // \verbatim
00011 //  Modifications
00012 //   04/05/2006 - File created. (miguelfv)
00013 // \endverbatim
00014 //=========================================================================
00015 
00016 #include <vgui/internals/vgui_dialog_impl.h>
00017 class  vgui_wx_adaptor;
00018 class  vgui_dialog_field;
00019 struct vgui_wx_dialog_choice;
00020 
00021 #include <vcl_string.h>
00022 #include <vcl_cstddef.h>
00023 
00024 class wxDialog;
00025 class wxTextCtrl;
00026 class wxSizer;
00027 
00028 //-------------------------------------------------------------------------
00029 //: wxWidgets implementation of vgui_dialog_impl.
00030 //
00031 // Creates a dialog box in wxWidgets and provides methods for its
00032 // customization.
00033 //-------------------------------------------------------------------------
00034 class vgui_wx_dialog_impl : public vgui_dialog_impl
00035 {
00036  public:
00037   //: Constructor - create an empty dialog with the given title.
00038   vgui_wx_dialog_impl(const char* name);
00039 
00040  protected:
00041   //: Destructor.
00042   virtual ~vgui_wx_dialog_impl();
00043 
00044   //: Display the dialog box form and collect data from the user.
00045   virtual bool ask();
00046 
00047   //: Create a choice widget.
00048   virtual void* choice_field_widget(const char* txt,
00049                                     const vcl_vector<vcl_string>& labels,
00050                                     int& val);
00051 
00052   //: Create the inline_tableau_widget (OpenGL area).
00053   virtual void* inline_tableau_widget(const vgui_tableau_sptr tab,
00054                                       unsigned int width,
00055                                       unsigned int height);
00056 
00057   //: Set the modality of the dialog box.
00058   virtual void modal(bool m) { is_modal_ = m; }
00059 
00060  private:
00061   // private helpers
00062   void build_wx_dialog();
00063   void destroy_wx_dialog();
00064   bool has_changed() const;
00065   int probe_for_max_label_width();
00066 
00067   // set of helpers to setup the different widgets in the dialog
00068   wxSizer* separator_element(int min_width);
00069   wxSizer* bool_element     (vgui_dialog_field* field);
00070   wxSizer* choice_element   (vgui_dialog_field* field,
00071                              vgui_wx_dialog_choice* choices);
00072   wxSizer* text_element     (vgui_dialog_field* field);
00073   wxSizer* text_with_button_element(vgui_dialog_field* field,
00074                                     wxTextCtrl*& text_control,
00075                                     const vcl_string& button,
00076                                     int event_id);
00077   wxSizer* exit_buttons_element();
00078 
00079   //: Title of the dialog widget.
00080   vcl_string title_;
00081 
00082   //: Pointer to wxWidgets dialog widget.
00083   wxDialog* dialog_;
00084 
00085   //: Element count at the last dialog construction (i.e., ask()).
00086   vcl_size_t last_element_count_;
00087 
00088   //: The width of the largest label; used for graphical alignment.
00089   int max_label_width_;
00090 
00091   //: True if the dialog box is modal (true by default).
00092   bool is_modal_;
00093 
00094   vgui_wx_adaptor* adaptor_;
00095 };
00096 
00097 #endif // vgui_wx_dialog_impl_h_