WxExtLib - WxExtDialog.h
00001: // -*- c++ -*-
00002: /*
00003: -------------------------------------------------------------------------
00004: This file is part of WxWidgetsExtensions library.
00005: -------------------------------------------------------------------------
00006:
00007: WxExtLib (WxWidgetsExtensions) library
00008: -----------------------------
00009:
00010: COPYRIGHT NOTICE:
00011:
00012: WxExtLib library Copyright (c) 2003-2007 Daniel Käps
00013:
00014: The WxWidgetsExtensions library and associated documentation files (the
00015: "Software") is provided "AS IS". The author(s) disclaim all
00016: warranties, expressed or implied, including, without limitation, the
00017: warranties of merchantability and of fitness for any purpose. The
00018: author(s) assume no liability for direct, indirect, incidental,
00019: special, exemplary, or consequential damages, which may result from
00020: the use of or other dealings in the Software, even if advised of the
00021: possibility of such damage.
00022:
00023: Permission is hereby granted, free of charge, to any person obtaining
00024: a copy of this Software, to deal in the Software without restriction,
00025: including without limitation the rights to use, copy, modify, merge,
00026: publish, distribute, sublicense, and/or sell copies of the Software,
00027: and to permit persons to whom the Software is furnished to do so,
00028: subject to the following conditions:
00029:
00030: 1. The origin of this source code must not be misrepresented.
00031: 2. Altered versions must be plainly marked as such and must not be
00032: misrepresented as being the original source.
00033: 3. This Copyright notice may not be removed or altered from any
00034: source or altered source distribution.
00035:
00036: End of WxExtLib library Copyright Notice
00037:
00038: -------------------------------------------------------------------------
00039: */
00040:
00041: #ifndef _INCLUDED_WxExtDialog_h
00042: #define _INCLUDED_WxExtDialog_h
00043:
00044: #if defined(__GNUG__) && (!defined(__APPLE__)) && (!defined(M_NoPragmaInterface))
00045: # pragma interface "WxExtDialog.h"
00046: #endif
00047:
00048: #include "WxExtLibConfig.h"
00049:
00050: #include <wx/defs.h>
00051:
00052: #ifndef WX_PRECOMP
00053: # include <wx/dialog.h>
00054: # include <wx/intl.h>
00055: # include <wx/checkbox.h>
00056: # include <wx/choice.h>
00057: # include <wx/radiobut.h>
00058: # include <wx/statbmp.h>
00059: # include <wx/sizer.h>
00060: # include <wx/button.h>
00061: # include <wx/stattext.h>
00062: # include <wx/statbox.h>
00063: # include <wx/slider.h>
00064: # include <wx/listbox.h>
00065: # include <wx/combobox.h>
00066: # include <wx/valgen.h>
00067: #endif
00068:
00069: // for wxAppRootFrame only:
00070: #include <wx/frame.h>
00071:
00072: #include <wx/utils.h>
00073: #include <wx/toplevel.h>
00074: #include <wx/busyinfo.h>
00075:
00076: #include "StatusValidators.h"
00077: #include "WxMisc.h"
00078:
00079: #include <accessor_macros.h>
00080:
00081: //-------------------------------------------------------------------------
00082:
00083: #define M_IsDefineExportMagic 1
00084: # include "WxExtLibAliases.h"
00085: #undef M_IsDefineExportMagic
00086:
00087: //-------------------------------------------------------------------------
00088:
00089: // repeat define from 'wx/toplevel.h' for older wxWidgets versions (e.g. wx 2.4):
00090: #define wxCLOSE_BOX 0x1000
00091:
00092: // define for automatically assigned control idents (to improve readability
00093: // of code somewhat)
00094: #define wxID_AUTO (-1)
00095:
00096:
00097: //-------------------------------------------------------------------------
00098:
00099: #ifdef M_WxExtLib_IsMFCCompatibility
00100: //-------------------------------------------------------------------------
00101: // create a wxWindow as child of the specified MFC ParentWindow - this
00102: // is useful for using wxWindows based dialogs together with a MFC
00103: // based parent/frame window
00104: extern wxWindow * MSWCreateChildWindowForMFCFrame (CWnd * ParentWindow);
00105:
00106: #endif // M_WxExtLib_IsMFCCompatibility
00107:
00108: //-------------------------------------------------------------------------
00109:
00110: class wxSizerAdder;
00111: extern wxSizerAdder & wxNullSizerAdder;
00112:
00113: class wxSizerAdderProxy;
00114: extern wxSizerAdderProxy & wxNullSizerAdderProxy;
00115:
00116: //-------------------------------------------------------------------------
00117: // wxExtDlgBase: helper class with following purposes:
00118: // - ease creating and adding controls
00119: // - slightly specialized dialog to work with a MFC main window
00120: // - support for dialog zoom
00121: // - simplification of control-change notification
00122: class wxExtDlgBase
00123: {
00124: public:
00125:
00126: wxExtDlgBase ();
00127: void initCWxDialog ();
00128: virtual ~wxExtDlgBase ();
00129:
00130: // getDialog() actually returns wxWindow, not wxDialog, and is therefore
00131: // (partially) compatible with e.g. wxFrame
00132: virtual wxWindow * getDialog () = 0;
00133:
00134: void setDialogInitializedFlag ();
00135:
00136: #ifdef M_IsNonWxMainIntegration
00137: //-------------------------------------------------------------------------
00138: // find the window to use as parent for this dialog if none has been
00139: // specified explicitly by the user (requires patched version of
00140: // src/msw/dialog.h with this function made virtual)
00141: //
00142: // may return NULL
00143: virtual wxWindow *FindSuitableParent() const;
00144: #endif
00145:
00146: // show modal dialog and enter modal loop
00147: // virtual void DoShowModal();
00148:
00149: #ifdef M_IsNonWxMainIntegration
00150: #if defined(__WXMSW__)
00151: // added for MFC main window compatibility:
00152: // MSWEnableOtherWindows (called by DoShowModal()). Can
00153: // be overwritten for the case that the frame window
00154: // was not created with wxWindows (requires a patched
00155: // version of src/msw/dialog.cpp)
00156: virtual void MSWEnableOtherWindows (bool IsEnable);
00157: #endif
00158: #endif
00159: #if defined(__WXMSW__)
00160: HWND MSWGetHandle();
00161: #endif
00162:
00163:
00164: //-------------------------------------------------------------------------
00165: // helper functions to make creation of certain often-used dialog control
00166: // combinations easier (e.g. a wxStaticText and wxTextCtrl may be created
00167: // with a single call using addTextCtrlWithLabel())
00168: // - for notes on size specifications with regard to zooming, see
00169: // the getAdjusted*Width/Height functions
00170:
00171: wxSizer * addSpace (int Width, int Height, const wxSizerAdderProxy & SizerAdderProxy);
00172:
00173: wxWindow * getAddParentWindow (wxSizerAdder * SizerAdder);
00174:
00175: // DEF ButtonPtrPtr can be NULL
00176: // DEF ButtonId can be -1 to obtain an automatically generated button id
00177: wxButton * addButton (wxButton ** ButtonPtrPtr, wxWindowID id,
00178: wxCommandEventFunction CommandEventFunction,
00179: const wxString& label,
00180: const wxSizerAdderProxy & SizerAdderProxy,
00181: const wxPoint& pos = wxDefaultPosition,
00182: const wxSize& size = wxDefaultSize,
00183: long style = 0, const wxValidator& validator = wxDefaultValidator);
00184:
00185: wxSizer * addCheckBoxWithLabel (wxCheckBox ** CheckBox,
00186: const wxString & LabelString,
00187: const wxValidator & Validator = wxDefaultValidator,
00188: long Flags = 0, // Flags can be 0 or wxTE_READONLY
00189: const wxSizerAdderProxy & SizerAdderProxy = wxNullSizerAdderProxy,
00190: bool IsLabelOnTheLeft = false);
00191:
00192: wxSizer * addRadioButtonWithLabel (wxRadioButton ** RadioButton,
00193: const wxString & LabelString,
00194: const wxValidator & Validator = wxDefaultValidator,
00195: long RadioCtrlStyle = 0,
00196: const wxSizerAdderProxy & SizerAdderProxy = wxNullSizerAdderProxy);
00197:
00198: wxStaticText * addLabel (wxStaticText ** StaticTextCtrl,
00199: const wxString & LabelString,
00200: const wxSizerAdderProxy & SizerAdderProxy = wxNullSizerAdderProxy,
00201: long WindowStyle = wxALIGN_LEFT,
00202: const wxSize & Size = wxDefaultSize,
00203: bool IsTransparent = false,
00204: long TransparentStaticTextFlags = 0);
00205:
00206: wxWindow * addMultiLineText (wxMultiLineText * MultiLineText,
00207: long CtrlStyle = 0,
00208: const wxSize & CtrlSize = wxDefaultSize,
00209: int MultiLineTextStyle = 0,
00210: const wxSizerAdderProxy & SizerAdderProxy = wxNullSizerAdderProxy);
00211: wxWindow * addMultiLineText (wxMultiLineText * MultiLineText,
00212: long CtrlStyle,
00213: const wxSize & CtrlSize,
00214: int MultiLineTextStyle,
00215: const wxSizerAdderProxy & SizerAdderProxy,
00216: const wxString & TextString,
00217: int MinLineCount, int MaxLineCount,
00218: int BorderWidth=0);
00219:
00220: wxTextCtrl * addTextCtrl (wxTextCtrl ** TextCtrl,
00221: const wxValidator & Validator = wxDefaultValidator,
00222: long TextCtrlStyle = wxTE_LEFT,
00223: const wxSize & Size = wxDefaultSize,
00224: const wxSizerAdderProxy & SizerAdderProxy = wxNullSizerAdderProxy);
00225:
00226: // TODO add sizer flags for textctrl, e.g. Expandable TextCtrl, ExtraSizer,
00227: wxSizer * addTextCtrlWithLabel (wxTextCtrl ** TextCtrl,
00228: const wxString & LabelString,
00229: const wxValidator & Validator = wxDefaultValidator,
00230: long TextCtrlStyle = wxTE_LEFT,
00231: const wxSize & Size = wxDefaultSize,
00232: const wxSizerAdderProxy & SizerAdderProxy = wxNullSizerAdderProxy);
00233:
00234: wxSizer * addTextCtrlWithTwoLabels (wxTextCtrl ** TextCtrl,
00235: const wxString & FirstLabelString,
00236: const wxString & SecondLabelString,
00237: const wxValidator & Validator = wxDefaultValidator,
00238: long TextCtrlStyle = wxTE_LEFT,
00239: const wxSize & Size = wxDefaultSize,
00240: const wxSizerAdderProxy & SizerAdderProxy = wxNullSizerAdderProxy);
00241:
00242: // addTextCtrlSliderPairWithLabel():
00243: // - currently, only a horizontal wxSlider control can be created
00244: // TODO:
00245: // - add parameters for wxTextCtrl, wxSlider styles, add size parameters
00246: wxSizer * addTextCtrlSliderPairWithLabel (wxTextCtrl ** TextCtrl,
00247: wxSlider ** SliderCtrl,
00248: const wxString & LabelString,
00249: long * LongValue, long MinLong, long MaxLong,
00250: wxStatusMessageTarget * StatusMessageTarget,
00251: const wxSizerAdderProxy & SizerAdderProxy,
00252: const wxString & FieldNameString);
00253:
00254: wxListBox * addListBox (wxListBox ** ListBox,
00255: const wxValidator & Validator,
00256: int ChoiceCount, const wxString ChoiceStringArray [],
00257: const wxSize& Size = wxDefaultSize,
00258: const wxSizerAdderProxy & SizerAdderProxy = wxNullSizerAdderProxy);
00259:
00260: wxChoice * addChoiceCtrl (wxChoice ** ChoiceCtrl,
00261: const wxValidator & Validator,
00262: int ChoiceCount, const wxString ChoiceStringArray [],
00263: const wxSize& Size = wxDefaultSize,
00264: const wxSizerAdderProxy & SizerAdderProxy = wxNullSizerAdderProxy);
00265: wxSizer * addChoiceCtrlWithLabel (wxChoice ** ChoiceCtrl,
00266: const wxString & LabelString,
00267: const wxValidator & Validator,
00268: int ChoiceCount, const wxString ChoiceStringArray [],
00269: const wxSize & Size = wxDefaultSize,
00270: const wxSizerAdderProxy & SizerAdderProxy = wxNullSizerAdderProxy);
00271:
00272: wxComboBox * addComboBox (wxComboBox ** ComboBox,
00273: const wxValidator & Validator,
00274: int StringCount, const wxString StringArray [],
00275: const wxSize& Size = wxDefaultSize,
00276: const wxSizerAdderProxy & SizerAdderProxy = wxNullSizerAdderProxy);
00277: wxSizer * addComboBoxWithLabel (wxComboBox ** ComboBox,
00278: const wxString & LabelString,
00279: const wxValidator & Validator,
00280: int StringCount, const wxString StringArray [],
00281: const wxSize & Size = wxDefaultSize,
00282: const wxSizerAdderProxy & SizerAdderProxy = wxNullSizerAdderProxy);
00283:
00284: wxSizer * addStaticBitmap (wxStaticBitmap ** StaticBitmapPtr,
00285: const unsigned char * ImageData,
00286: size_t ImageDataSize,
00287: const wxPoint& Position = wxDefaultPosition,
00288: const wxSize& Size = wxDefaultSize,
00289: const wxSizerAdderProxy & SizerAdderProxy = wxNullSizerAdderProxy,
00290: long WindowStyle = 0);
00291: wxSizer * addStaticBitmap (wxStaticBitmap ** StaticBitmapPtr,
00292: const char * ResourceNameString,
00293: const wxPoint& Position,
00294: const wxSize& Size,
00295: const wxSizerAdderProxy & SizerAdderProxy,
00296: long WindowStyle = 0);
00297: wxSizer * addStaticBitmap (wxStaticBitmap ** StaticBitmapPtr,
00298: wxBitmap * Bitmap,
00299: const wxPoint& Position,
00300: const wxSize& Size,
00301: const wxSizerAdderProxy & SizerAdderProxy,
00302: long WindowStyle = 0);
00303:
00304: //-------------------------------------------------------------------------
00305: // creation of status message TextCtrl with required flags (e.g. wxTE_READONLY)
00306:
00307: wxMultiLineText * createErrorMessageCtrl (wxMultiLineText * ErrorMessageMultiLineText,
00308: int LineCount = 2);
00309:
00310: //-------------------------------------------------------------------------
00311: // TODO could write some Sizer for automatic horizontal or vertical layout
00312:
00313: void addFlexGridSizer (wxFlexGridSizer ** FlexGridSizer,
00314: int Columns, int VGap, int HGap);
00315: void addFlexGridSizer (wxFlexGridSizer ** FlexGridSizer,
00316: int Columns, int VGap, int HGap,
00317: wxSizer * OuterSizer, int AddFlags, int AddBorder);
00318:
00319: void addStaticBox (wxFlexGridSizer ** FlexGridSizer,
00320: const wxString & LabelString,
00321: int Columns, int VGap, int HGap,
00322: wxSizer * OuterSizer, int AddFlags, int AddBorder,
00323: const wxSizerAdderProxy & SizerAdderProxy);
00324:
00325: //-------------------------------------------------------------------------
00326:
00327: // createDialogFont()
00328: // - it contains some 'handicrafted' logic to select a well-reable
00329: // (not to small) font depending on the used platform (must specify
00330: // wxDEFAULT as family for this)
00331: wxFont createDialogFont (int PointSize,
00332: int Family,
00333: int Style,
00334: int Weight,
00335: const bool IsUnderlined = false,
00336: const wxString& FaceName = "",
00337: wxFontEncoding Encoding = wxFONTENCODING_DEFAULT,
00338: int * RequestedPointSize = NULL,
00339: bool IsCreateFont = true);
00340:
00341: //-------------------------------------------------------------------------
00342: // functions for calculating pixel widths/heights based on some desired
00343: // zoom value
00344: // Notes:
00345: // - The getAdjusted...Size() functions in part use 'handicrafted' formulas (e.g.
00346: // getAdjustedTextCtrlHeight(), getAdjustedButtonHeight()), specific
00347: // to each of the different platforms/window systems (currently,
00348: // available for wxMSW, wxX11, wxGTK, wxMotif).
00349: // - Currently, these functions assume a font size equal to the font
00350: // size set for the dialog (e.g. set via setDialogZoom()).
00351: // - Currently, the function which creates controls must call the
00352: // getAdjusted*Width/Height functions itself. For cases where this
00353: // flexibility is not needed, a mode should be added so that
00354: // addTextCtrl()/addSlider etc. functions call the corresponding
00355: // getAdjusted*Width/Height() functions implicitely.
00356: virtual int getAdjustedBorderSize (int BorderSize);
00357: virtual int getAdjustedTextCtrlWidth (int TextCtrlWidth);
00358: virtual int getAdjustedTextCtrlHeight (int TextCtrlHeight, bool IsFromLineCount = false);
00359: virtual int getAdjustedChoiceCtrlWidth (int ChoiceCtrlWidth);
00360: virtual int getAdjustedChoiceCtrlHeight (int ChoiceCtrlHeight, bool IsFromLineCount = false);
00361: virtual int getAdjustedListBoxWidth (int ListBoxWidth);
00362: virtual int getAdjustedListBoxHeight (int ListBoxHeight, bool IsFromLineCount = false);
00363: virtual int getAdjustedComboBoxWidth (int ComboBoxWidth);
00364: virtual int getAdjustedComboBoxHeight (int ComboBoxHeight, bool IsFromLineCount = false);
00365: virtual int getAdjustedButtonWidth (int ButtonWidth);
00366: virtual int getAdjustedButtonHeight ();
00367: virtual int getAdjustedSliderWidth (int SliderWidth, bool IsVertical = false);
00368: virtual int getAdjustedSliderHeight (int SliderHeight, bool IsVertical = false);
00369: virtual int getAdjustedBitmapWidth (int BitmapWidth);
00370: virtual int getAdjustedBitmapHeight (int BitmapHeight);
00371:
00372: virtual void adjustMultiLineTextSize (wxMultiLineText & MultiLineText,
00373: int MinLineCount, int MaxLineCount);
00374:
00375: int getDefaultDialogFontSize ();
00376: int getDialogFontSize ();
00377: int getDialogFontHeight ();
00378:
00379: void setIsSetFontIfSameAsDefaultSize (bool IsSetFontIfSameAsDefaultSize);
00380:
00381: virtual int getAdjustedProportionalWidth(int Width);
00382: virtual int getAdjustedProportionalHeight(int Height);
00383: virtual int getAdjustedFontLikeWidth(int Width);
00384: virtual int getAdjustedFontLikeHeight(int Height);
00385:
00386: // aliases for less typing overhead:
00387: int _B(int BorderSize) { return getAdjustedBorderSize (BorderSize); }
00388:
00389: void setDefaultButtonSize (int Width, int Height);
00390:
00391: void setHtmlWindowFonts (wxHtmlWindow * HtmlWindow,
00392: int BaseSize,
00393: bool IsUseReadableFontSizes = true,
00394: bool IsUseScaleableFont = true);
00395: void excludeRange (int & PointSize, int ExcludeRangeMin, int ExcludeRangeMax = -1);
00396:
00397: //-------------------------------------------------------------------------
00398: //-- dialog zoom support:
00399:
00400: // setDialogZoom() should be called before getAdjustedBorderSize() etc.
00401: // is used, because calling setDialogZoom() after having created sizers
00402: // with absolute pixel widths/heights/border sizes etc., setDialogZoom()
00403: // has no effect
00404: // ZoomValue should be something between 0.5 and 1.5
00405: // a value of 1. means no zooming
00406: virtual double getZoom ();
00407: void setDialogZoom (double DialogZoomValue);
00408: double getDialogZoom ();
00409: static void setGlobalDialogZoom (double ZoomValue);
00410: static double getGlobalDialogZoom ();
00411: void setDesktopReferenceSize (const wxSize & Size);
00412: static void setGlobalDesktopReferenceSize (const wxSize & Size);
00413:
00414: // BorderCompressionValue should be something between 0.5 and 1.0
00415: // a value of 1. means no border compression
00416: // border compression may be useful for non-modal dialogs which
00417: // should occupy as least as possible space on the screen (while using
00418: // a still readable font) - using this function, the same dialog
00419: // can be used modal (with setting border compression to the default,
00420: // 1.) and non-modal (with setting border compression to e.g. 0.5)
00421: void setBorderCompression (double BorderCompressionValue);
00422:
00423: //-------------------------------------------------------------------------
00424: wxSize getSizeFromDefaults (const wxSize & Size, const wxSize & DefaultSize);
00425: wxSize getSizeFromAspectRatio (const wxSize & Size, const wxSize & AspectRatioAsSize);
00426:
00427: //-------------------------------------------------------------------------
00428: // support for control change notification
00429: // - most normal notifications are dispatched to handleWatchedControlChange()
00430: // (call addWatchedControl() for desired controls)
00431: // - no need for static message handlers, useful if controls use
00432: // dynamically selected Id's
00433:
00434: virtual void enableWatchedControlChangeNotification (bool IsWatchedControlChangeNotification);
00435: virtual void addWatchedControl (wxWindow * Window);
00436: virtual void handleControlChange(wxCommandEvent & Event);
00437: virtual void handleWatchedControlChange(wxCommandEvent & Event);
00438:
00439: //-------------------------------------------------------------------------
00440: // dialog/window/system close event handling
00441:
00442: virtual void handleCloseEvent(wxCloseEvent & WXUNUSED(Event)) { }
00443: void OnCloseEvent (wxCloseEvent & CloseEvent);
00444:
00445: //-------------------------------------------------------------------------
00446: // notification functions called by the static event handler
00447:
00448: void OnTextCtrlChanged(wxCommandEvent& Event);
00449: // void OnSliderCtrlChanged(wxCommandEvent& Event);
00450: void OnSliderCtrlChanged(wxScrollEvent & Event);
00451: void OnRadioButtonSelected(wxCommandEvent& Event);
00452: void OnRadioBoxSelected(wxCommandEvent& Event);
00453: void OnCheckBoxSelected(wxCommandEvent& Event);
00454: void OnComboBoxSelected(wxCommandEvent& Event);
00455: void OnListBoxSelected(wxCommandEvent& Event);
00456: void OnChoiceCtrlSelected(wxCommandEvent& Event);
00457: void OnButtonClicked(wxCommandEvent& Event);
00458:
00459: //-------------------------------------------------------------------------
00460: // specialized version of wxDialog::TransferDataToWindow() which disables
00461: // control change notifications while data is transferred to the controls
00462: // (otherwise, e.g. wxTextCtrl()->SetValue() would trigger a notification)
00463: virtual bool TransferDataToWindow();
00464:
00465: virtual void initializeDialog ();
00466:
00467: // execute validation with showing a message box for errors
00468: // if ReturnCode != -1, EndDialog(ReturnCode) is called if
00469: // validation was successful
00470: bool ValidateWithMessageBox (int ReturnCode = -1);
00471:
00472: //-------------------------------------------------------------------------
00473:
00474: protected:
00475: wxMultiLineText m_ErrorMessageMultiLineText;
00476: wxStatusMessageTarget * m_StatusMessageTarget;
00477:
00478: int m_DialogFontSize;
00479: int m_DialogFontHeight;
00480:
00481: bool m_IsSetFontIfSameAsDefaultSize;
00482:
00483: wxSize m_DefaultButtonSize;
00484: wxSize m_DefaultTextCtrlSize;
00485: wxSize m_DefaultListBoxSize;
00486: wxSize m_DefaultChoiceCtrlSize;
00487: wxSize m_DefaultComboBoxSize;
00488: double m_ZoomValue;
00489: double m_DialogZoomValue;
00490: static double m_GlobalDialogZoom;
00491: wxSize m_DesktopReferenceSize;
00492: static wxSize m_GlobalDesktopReferenceSize;
00493: double m_BorderCompressionValue;
00494:
00495: bool m_IsWatchedControlChangeNotification;
00496: wxObjectPtrArray m_WatchedObjectArray;
00497: // m_IsDialogInitialized: flag to let control change notification
00498: // appear only after the dialog is initialized:
00499: bool m_IsDialogInitialized;
00500:
00501: // DECLARE_EVENT_TABLE()
00502:
00503: friend class wxExtDialog;
00504: };
00505:
00506: //-------------------------------------------------------------------------
00507:
00508: class wxExtDlgBaseEvtHandler : public wxEvtHandler
00509: {
00510: DECLARE_CLASS(wxExtDlgBaseEvtHandler)
00511: public:
00512:
00513: wxExtDlgBaseEvtHandler() { m_ExtDlgBase = NULL; }
00514: ~wxExtDlgBaseEvtHandler();
00515: wxExtDlgBaseEvtHandler(wxExtDlgBase * ExtDlgBase) { m_ExtDlgBase = ExtDlgBase; }
00516: void setExtDlgBase (wxExtDlgBase * ExtDlgBase) { m_ExtDlgBase = ExtDlgBase; }
00517:
00518: //-------------------------------------------------------------------------
00519:
00520: void OnCloseEvent (wxCloseEvent & CloseEvent) { m_ExtDlgBase -> OnCloseEvent(CloseEvent); }
00521:
00522: //-------------------------------------------------------------------------
00523: // notification functions called by the static event handler
00524:
00525: void OnTextCtrlChanged(wxCommandEvent& Event) { m_ExtDlgBase -> OnTextCtrlChanged(Event); }
00526: // void OnSliderCtrlChanged(wxCommandEvent& Event) { m_ExtDlgBase -> OnSliderCtrlChanged(Event); }
00527: void OnSliderCtrlChanged(wxScrollEvent & Event) { m_ExtDlgBase -> OnSliderCtrlChanged(Event); }
00528: void OnRadioButtonSelected(wxCommandEvent& Event) { m_ExtDlgBase -> OnRadioButtonSelected(Event); }
00529: void OnRadioBoxSelected(wxCommandEvent& Event) { m_ExtDlgBase -> OnRadioBoxSelected(Event); }
00530: void OnCheckBoxSelected(wxCommandEvent& Event) { m_ExtDlgBase -> OnCheckBoxSelected(Event); }
00531: void OnComboBoxSelected(wxCommandEvent& Event) { m_ExtDlgBase -> OnComboBoxSelected(Event); }
00532: void OnListBoxSelected(wxCommandEvent& Event) { m_ExtDlgBase -> OnListBoxSelected(Event); }
00533: void OnChoiceCtrlSelected(wxCommandEvent& Event) { m_ExtDlgBase -> OnChoiceCtrlSelected(Event); }
00534: void OnButtonClicked(wxCommandEvent& Event) { m_ExtDlgBase -> OnButtonClicked(Event); }
00535:
00536: protected:
00537: wxExtDlgBase * m_ExtDlgBase;
00538:
00539: public:
00540: DECLARE_EVENT_TABLE()
00541: DECLARE_NO_COPY_CLASS(wxExtDlgBaseEvtHandler)
00542: };
00543:
00544: //-------------------------------------------------------------------------
00545:
00546: class wxExtDlgHelper : public wxExtDlgBase
00547: {
00548: public:
00549: wxExtDlgHelper();
00550: ~wxExtDlgHelper();
00551: void setup (wxWindow * Window);
00552: void release (wxWindow * Window);
00553:
00554: virtual void setDialog (wxWindow * Window) { m_Window = Window; }
00555: virtual wxWindow * getDialog() { return m_Window; }
00556:
00557: protected:
00558: wxWindow * m_Window;
00559: wxExtDlgBaseEvtHandler m_ExtDlgBaseEvtHandler;
00560: };
00561:
00562: //-------------------------------------------------------------------------
00563:
00564: // wxExtDialog:
00565: // - wxDialog plus all functions from wxExtDlgBase class
00566: class wxExtDialog : public wxDialog, public wxExtDlgBase
00567: {
00568: DECLARE_DYNAMIC_CLASS(wxExtDialog)
00569: public:
00570: wxExtDialog ();
00571:
00572: wxExtDialog(wxWindow *parent, wxWindowID id,
00573: const wxString& title,
00574: const wxPoint& pos = wxDefaultPosition,
00575: const wxSize& size = wxDefaultSize,
00576: long style_DIALOG_STYLE = wxDEFAULT_DIALOG_STYLE,
00577: const wxString& name = wxDialogNameStr);
00578:
00579: virtual wxWindow * getDialog ();
00580:
00581: virtual void InitDialog ();
00582:
00583: ~wxExtDialog ();
00584:
00585: //-------------------------------------------------------------------------
00586:
00587: void OnCloseEvent (wxCloseEvent & CloseEvent) { wxExtDlgBase::OnCloseEvent(CloseEvent); }
00588:
00589: //-------------------------------------------------------------------------
00590: // notification functions called by the static event handler
00591:
00592: void OnTextCtrlChanged(wxCommandEvent& Event) { wxExtDlgBase::OnTextCtrlChanged(Event); }
00593: // void OnSliderCtrlChanged(wxCommandEvent& Event) { wxExtDlgBase::OnSliderCtrlChanged(Event); }
00594: void OnSliderCtrlChanged(wxScrollEvent & Event) { wxExtDlgBase::OnSliderCtrlChanged(Event); }
00595: void OnRadioButtonSelected(wxCommandEvent& Event) { wxExtDlgBase::OnRadioButtonSelected(Event); }
00596: void OnRadioBoxSelected(wxCommandEvent& Event) { wxExtDlgBase::OnRadioBoxSelected(Event); }
00597: void OnCheckBoxSelected(wxCommandEvent& Event) { wxExtDlgBase::OnCheckBoxSelected(Event); }
00598: void OnComboBoxSelected(wxCommandEvent& Event) { wxExtDlgBase::OnComboBoxSelected(Event); }
00599: void OnListBoxSelected(wxCommandEvent& Event) { wxExtDlgBase::OnListBoxSelected(Event); }
00600: void OnChoiceCtrlSelected(wxCommandEvent& Event) { wxExtDlgBase::OnChoiceCtrlSelected(Event); }
00601: void OnButtonClicked(wxCommandEvent& Event) { wxExtDlgBase::OnButtonClicked(Event); }
00602:
00603: #if wxCHECK_VERSION (2, 8, 0)
00604: void OnOK(wxCommandEvent & Event);
00605: void OnCancel(wxCommandEvent & Event);
00606: #endif
00607:
00608: //-------------------------------------------------------------------------
00609: // specialized ShowModal() function which
00610: // centers the dialog before displaying it
00611: virtual int ShowModal ();
00612:
00613: // EndDialog() calls EndModal() for modal, Hide() for non-modal dialogs
00614: // (same as function EndDialog() defined in wxDialog, but with public
00615: // access qualifier)
00616: virtual void EndDialog(int ReturnCode);
00617:
00618: // multiple inheritance ambiguity resolution
00619: virtual bool TransferDataToWindow() { return wxExtDlgBase::TransferDataToWindow(); }
00620:
00621: public:
00622:
00623: DECLARE_EVENT_TABLE()
00624: };
00625:
00626: //-------------------------------------------------------------------------
00627:
00628: extern bool ValidateWithMessageBox(wxWindow * Window, wxStatusMessageTarget * StatusMessageTarget);
00629: extern bool ValidateWithMessageBox(wxDialog * Dialog, wxStatusMessageTarget * StatusMessageTarget,
00630: int ReturnCode);
00631:
00632: //-------------------------------------------------------------------------
00633:
00634: class wxSizerAdder
00635: {
00636: public:
00637: wxSizerAdder ();
00638: virtual ~wxSizerAdder () { };
00639:
00640: wxSizerAdder (wxSizer * Sizer);
00641: wxSizerAdder (wxSizer * Sizer, int SizerColumnCount, int SizerRowCount);
00642: #ifdef M_IsHaveGridBagSizer
00643: wxSizerAdder (wxGridBagSizer * GridBagSizer, int XPos, int YPos, int XSpan, int YSpan);
00644: #endif
00645:
00646: void init (wxSizer * Sizer);
00647: void init (wxSizer * Sizer, int SizerColumnCount, int SizerRowCount);
00648: #ifdef M_IsHaveGridBagSizer
00649: void init (wxGridBagSizer * GridBagSizer, int XPos, int YPos, int XSpan, int YSpan);
00650: #endif
00651:
00652: void setGroupSize (int SizerGroupSize = -1);
00653:
00654: void nextGroup();
00655:
00656: void addWindow (wxWindow * Window, int Flags, int Border);
00657: void addSizer (wxSizer * Sizer, int Flags, int Border);
00658: void addSpace (int Width, int Height, int Flags, int Border);
00659:
00660: wxSizer * getSizer();
00661: wxSizer * getSizerConst() const;
00662:
00663: // ParentWindow is simply a variable that may be read by wxExtDlgBase
00664: // control adder functions
00665: void setParentWindow (wxWindow * ParentWindow);
00666: wxWindow * getParentWindow () const;
00667:
00668: void setColumnGrowable (int ColumnIndex, bool IsGrowable = true);
00669: void setRowGrowable (int RowIndex, bool IsGrowable = true);
00670: void setAllGrowable();
00671:
00672: private:
00673: void init();
00674:
00675: wxSizer * m_Sizer;
00676: #ifdef M_IsHaveGridBagSizer
00677: wxGridBagSizer * m_GridBagSizer;
00678: #endif
00679: int m_CurrentCount;
00680: int m_SizerGroupSize;
00681:
00682: int m_SizerColumnCount;
00683: int m_SizerRowCount;
00684:
00685: int m_GridBagXPos;
00686: int m_GridBagYPos;
00687: int m_GridBagXSpan;
00688: int m_GridBagYSpan;
00689:
00690: wxWindow * m_ParentWindow;
00691: };
00692:
00693: //-------------------------------------------------------------------------
00694:
00695: // wxSizerAdderProxy
00696: // - proxy class for wxExtDialog compatibility: allow wxSizer* arguments
00697: // to wxExtDialog control addition helper functions, implicit creation
00698: // of wxBoxSizer if Sizer == NULL
00699: class wxSizerAdderProxy
00700: {
00701: public:
00702: wxSizerAdderProxy ();
00703: wxSizerAdderProxy (wxSizerAdder * SizerAdder);
00704: wxSizerAdderProxy (wxSizer * Sizer);
00705:
00706: wxSizerAdder * makeSizerAdder(wxSizerAdder & AlternativeSizerAdder) const;
00707:
00708: private:
00709: wxSizerAdder * m_SizerAdderPtr;
00710: wxSizer * m_SizerPtr;
00711: };
00712:
00713: //-------------------------------------------------------------------------
00714:
00715: #define M_DeclareParameter(ParameterName,ParameterType) \
00716: public: \
00717: void set##ParameterName (const ParameterType & ParameterName) \
00718: { \
00719: m_##ParameterName = ParameterName; \
00720: m_Is##ParameterName##Initialized = true; \
00721: } \
00722: const ParameterType & get##ParameterName () const \
00723: { \
00724: return m_##ParameterName; \
00725: } \
00726: bool getIs##ParameterName##Initialized () const \
00727: { \
00728: return m_Is##ParameterName##Initialized; \
00729: } \
00730: void set##ParameterName##InitializedState (bool IsInitialized = true) \
00731: { \
00732: m_Is##ParameterName##Initialized = IsInitialized; \
00733: } \
00734: private: \
00735: ParameterType m_##ParameterName; \
00736: bool m_Is##ParameterName##Initialized \
00737:
00738:
00739: //-------------------------------------------------------------------------
00740:
00741: // wxWindowAdderDefaultParameterSet
00742: // - these parameters are used to customize the various functions of
00743: // wxWindowAdder
00744: // - example:
00745: // > WA.accessDefaults().setSizerBorder (_B(10));
00746: // > WA.accessDefaults().setLabelFontColour (wxColour (*wxBLUE));
00747: // where 'WA' is an instance of wxWindowAdder class
00748: class wxWindowAdderDefaultParameterSet
00749: {
00750: public:
00751: wxWindowAdderDefaultParameterSet();
00752: virtual ~wxWindowAdderDefaultParameterSet();
00753: void resetToDefaults (wxExtDlgBase * ExtDlgBase);
00754:
00755: // set both, horizontal and vertical spacing:
00756: void setSizerSpacing (int SizerSpacing);
00757:
00758: // NOTE currently, IsDebugWarningOnShortcutClash only works if
00759: // also IsFixLabelStringOnShortcutClash is enabled
00760: M_DeclareParameter (IsFixLabelStringOnShortcutClash, bool);
00761: M_DeclareParameter (IsDebugWarningOnShortcutClash, bool);
00762:
00763: M_DeclareParameter (SizerHSpacing, int);
00764: M_DeclareParameter (SizerVSpacing, int);
00765: M_DeclareParameter (SizerBorder, int);
00766:
00767: M_DeclareParameter (WindowFontColour, wxColour);
00768: M_DeclareParameter (WindowBackgroundColour, wxColour);
00769:
00770: M_DeclareParameter (LabelFontColour, wxColour);
00771: M_DeclareParameter (LabelBackgroundColour, wxColour);
00772: M_DeclareParameter (PostTextFontColour, wxColour);
00773: M_DeclareParameter (PostTextBackgroundColour, wxColour);
00774:
00775: M_DeclareParameter (TransparentStaticTextFlags, wxTransparentStaticText::ETransparentStaticTextFlags);
00776:
00777: M_DeclareParameter (IsWatchControl, bool);
00778: };
00779:
00780: //-------------------------------------------------------------------------
00781:
00782: #undef M_DeclareParameter
00783:
00784: //-------------------------------------------------------------------------
00785:
00786: class wxOverlayAdder
00787: {
00788: public:
00789: enum EMode
00790: {
00791: IsAddOnPop = 0x0001,
00792: ZeroModeBits = 0
00793: };
00794:
00795: wxOverlayAdder ();
00796: void init();
00797:
00798: wxWindow * m_OverlayWindow;
00799: wxWindow * m_PreviousParentWindow;
00800: wxSizer * m_OverlaySizer;
00801: EMode m_ModeBits;
00802: };
00803:
00804:
00805: //-------------------------------------------------------------------------
00806:
00807: WX_DECLARE_OBJARRAY(wxWindowAdderDefaultParameterSet, wxWindowAdderDefaultParameterSetArray);
00808:
00809: WX_DECLARE_OBJARRAY(wxSizerAdder, wxExtLibSizerAdderArray);
00810:
00811: WX_DECLARE_OBJARRAY(wxOverlayAdder, wxOverlayAdderArray);
00812:
00813: //-------------------------------------------------------------------------
00814:
00815: // wxWindowAdder
00816: // - simplify handling sizers: maintains a stack of sizers which
00817: // can be manipulated with push and pop functions
00818: // - simplify creation of labels
00819: class wxWindowAdder
00820: {
00821: public:
00822: wxWindowAdder();
00823:
00824: //-------------------------------------------------------------------------
00825: //-- ampersand-shortcut clash detection helper
00826: //
00827: // setDetectShortcutClashs(), checkAndFixLabelString()
00828: // - in debug and release mode, a duplicated short-cut is disabled
00829: // simply by removing the ampersand character
00830: // (unless parameter IsFixLabelStringOnShortcutClash is false)
00831: // - only in debug mode: assert message dialog is shown in case of clash
00832: // (unless parameter IsDebugWarningOnShortcutClash is false)
00833: // - duplicated short-cuts can be confusing or worse: if, in the same
00834: // dialog, a label of some text-control is named '&domain', and a button
00835: // is named '&Delete', it just depends on the current focus if either
00836: // text-control is activated, or '&delete' button gets a click event!
00837: // (scope: WinXP, probably other window systems too)
00838: // - default: short-cut clash detection enabled
00839: //
00840: // note:
00841: // - checkAndFixLabelString() could try to automatically assign a different
00842: // yet unused short-cut, but this may cause other short-cuts
00843: // to be disabled/"moved" then, so this is not really desireable
00844: // - the function could be modified to remove all short-cuts,
00845: // if this is needed in some context (e.g. for some window manager
00846: // that doesn't support the ampersand short-cuts)
00847: //
00848: // see also:
00849: // - related functions for menu items exist:
00850: // wxMenuItem::GetLabelFromText(), ::wxStripMenuCodes()
00851: //
00852: void checkAndFixLabelString (const wxString & InputLabelString,
00853: wxString & CheckedLabelString,
00854: bool IsAlwaysRemoveAmpersand = false);
00855:
00856: //-------------------------------------------------------------------------
00857: // helper functions to make creation of dialog controls easier
00858: // - for notes on size specifications with regard to zooming, see
00859: // the getAdjusted*Width/Height functions
00860:
00861: void setExtDlgBase (wxExtDlgBase * ExtDlgBase);
00862: // for backwards-compat.:
00863: void setDialog (wxExtDialog * ExtDialog);
00864: void setParentWindow (wxWindow * ParentWindow);
00865:
00866: void setSize (const wxSize & Size = wxDefaultSize);
00867: void setSize (int Width, int Height);
00868:
00869: // window style used for functions without Style parameter
00870: // (note that some functions have window style parameters with a
00871: // default)
00872: void setWindowStyle (long WindowStyle);
00873:
00874: void setLabel (const wxString & LabelString);
00875: const wxString & getLabel();
00876: void setPostText (const wxString & PostTextString);
00877: const wxString & getPostString();
00878:
00879: void pushGroup (const wxString & GroupNameString);
00880: void popGroup ();
00881:
00882: wxString getFullName ();
00883:
00884: void setValidator (const wxValidator & Validator);
00885:
00886: void addSpace (int Width, int Height);
00887: void addHSpace (int Width);
00888: void addVSpace (int Height);
00889:
00890: void setSizerHSpacing(int Width);
00891: void setSizerVSpacing(int Height);
00892:
00893: void skipCell ();
00894: void skipCells (int Count);
00895: void nextGroup();
00896: void next(); // alias for nextGroup()
00897:
00898: wxWindow * getWindow();
00899: wxSizer * getSizer();
00900: wxSizerAdder & getSizerAdder();
00901:
00902: //-------------------------------------------------------------------------
00903: void addSizer (wxSizer * Sizer, int AddFlags, int AddBorder);
00904: void pushSizer (wxSizer * Sizer);
00905: void addAndPushSizer (wxSizer * Sizer, int AddFlags, int AddBorder);
00906: void popSizer ();
00907:
00908: //-------------------------------------------------------------------------
00909: void addAndPushFlexGridSizer (int Columns, bool IsAddBorder = false, bool IsAddOnlySizer = true);
00910: void addAndPushStaticBoxAndSizer (const wxString & LabelString,
00911: wxSizer * SubSizer,
00912: int AddFlags, int AddBorder);
00913: void addAndPushStaticBoxAndFlexGridSizer (const wxString & LabelString, int ColumnCount,
00914: bool IsAddBorder = false);
00915:
00916: //-------------------------------------------------------------------------
00917: void pushDefaults();
00918: void popDefaults();
00919: const wxWindowAdderDefaultParameterSet & getDefaults();
00920: wxWindowAdderDefaultParameterSet & accessDefaults();
00921:
00922: //-------------------------------------------------------------------------
00923: // overlay support (put controls onto other control (e.g. background image,
00924: // notebook page etc.)
00925: void pushOverlay (wxWindow * OverlayWindow, wxOverlayAdder::EMode Mode);
00926: void popOverlay ();
00927:
00928: //-------------------------------------------------------------------------
00929:
00930: wxWindow * getAddParentWindow ();
00931:
00932: wxWindow * addWindow (wxWindow * Window);
00933:
00934: // DEF ButtonPtrPtr can be NULL
00935: // DEF ButtonId can be -1 to obtain an automatically generated button id
00936: void addButton (const wxString & LabelString,
00937: wxButton ** ButtonPtrPtr, wxWindowID CtrlIdent,
00938: wxCommandEventFunction CommandEventFunction,
00939: long Style = 0);
00940: void addButton (const wxString & LabelString,
00941: wxCommandEventFunction CommandEventFunction,
00942: long Style = 0);
00943: // removed: param long Style = 0; to allow overload with wxString, wxWindowID
00944: void addButton (const wxString & LabelString);
00945: void addButton (const wxString & LabelString, wxWindowID CtrlIdent);
00946: void setDefaultButton();
00947:
00948: void addCheckBoxWithLabel (wxCheckBox ** CheckBoxPtrPtr,
00949: const wxString & LabelString,
00950: long Flags = 0, // Flags can be 0 or wxTE_READONLY
00951: bool IsLabelOnTheLeft = false);
00952: void addRadioButtonWithLabel (wxRadioButton ** RadioButtonPtrPtr,
00953: const wxString & LabelString,
00954: long RadioCtrlStyle = 0);
00955:
00956: // TODO add sizer flags for textctrl, e.g. Expandable TextCtrl, ExtraSizer,
00957: void addTextCtrl (wxTextCtrl ** TextCtrlPtrPtr,
00958: long TextCtrlStyle = wxTE_LEFT);
00959:
00960: void addLabel (wxStaticText ** StaticTextPtrPtr,
00961: const wxString & LabelString,
00962: long WindowStyle = wxALIGN_LEFT);
00963:
00964: void addMultiLineText (wxMultiLineText * MultiLineText,
00965: long CtrlStyle = 0,
00966: int MultiLineTextStyle = 0);
00967: void addMultiLineText (wxMultiLineText * MultiLineText,
00968: long CtrlStyle,
00969: int MultiLineTextStyle,
00970: const wxString & TextString,
00971: int MinLineCount, int MaxLineCount,
00972: int BorderWidth=0);
00973:
00974: void addListBox (wxListBox ** ListBoxPtrPtr,
00975: int ChoiceCount, const wxString ChoiceStringArray []);
00976: void addChoiceCtrl (wxChoice ** ChoiceCtrlPtrPtr,
00977: int ChoiceCount, const wxString ChoiceStringArray []);
00978: void addComboBox (wxComboBox ** ComboBoxPtrPtr,
00979: int StringCount, const wxString StringArray []);
00980:
00981: void addStaticBitmap (wxStaticBitmap ** StaticBitmapPtrPtr,
00982: const unsigned char * ImageData,
00983: size_t ImageDataSize);
00984: void addStaticBitmap (wxStaticBitmap ** StaticBitmapPtrPtr,
00985: const char * ResourceNameString);
00986: void addStaticBitmap (wxStaticBitmap ** StaticBitmapPtrPtr,
00987: wxBitmap * Bitmap);
00988:
00989: void addStaticLine (long Style = wxLI_HORIZONTAL);
00990:
00991: void addHeadline (const wxString & HeadlineString);
00992:
00993: void watchControl();
00994:
00995: protected:
00996: void createAndAddLabel ();
00997: void setCurrentWindow (wxWindow * Window);
00998: void createAndAddPostText ();
00999:
01000: void decorateWindow (wxWindow * Window);
01001:
01002: //-- shortcut clash detection helper
01003: bool m_IsDetectShortcutClashs;
01004: wxArrayString m_LabelStringArray;
01005: // for each label in m_LabelStringArray, m_ShortcutCharString contains
01006: // characters, which are either shortcut character (if found) or '\001'
01007: // (a probably unused control character)
01008: wxString m_ShortcutCharString;
01009:
01010: // current values:
01011: wxString m_LabelString;
01012: wxString m_PostTextString;
01013: wxWindow * m_Window;
01014: wxExtDlgBase * m_ExtDlgBase;
01015: wxSize m_Size;
01016: long m_WindowStyle;
01017:
01018: bool m_IsLabelCreated;
01019:
01020: wxWindow * m_ParentWindow;
01021:
01022: wxExtLibSizerAdderArray m_SizerAdderArray;
01023: wxArrayString m_GroupNameStringArray;
01024:
01025: wxWindowAdderDefaultParameterSetArray m_WindowAdderDefaultParameterSetArray;
01026:
01027: wxOverlayAdderArray m_OverlayAdderArray;
01028: };
01029:
01030: //-------------------------------------------------------------------------
01031:
01032: class wxWindowAdderAutoPopSizer
01033: {
01034: public:
01035: wxWindowAdderAutoPopSizer(wxWindowAdder * WindowAdder);
01036: wxWindowAdderAutoPopSizer(wxWindowAdder * WindowAdder, wxWindow * OverlayWindow,
01037: wxOverlayAdder::EMode ModeBits);
01038: ~wxWindowAdderAutoPopSizer();
01039: void init();
01040: void reset();
01041: void pop();
01042: void push();
01043:
01044: private:
01045: wxWindowAdder * m_WindowAdder;
01046: wxWindow * m_OverlayWindow;
01047: wxOverlayAdder::EMode m_OverlayAdderModeBits;
01048: };
01049:
01050: #if 0
01051: class wxWindowAdderPopHandler
01052: {
01053: public:
01054: virtual void pop () = 0;
01055: };
01056:
01057: class wxNotebookPageWindowAdderPopHandler
01058: {
01059: public:
01060: virtual void pop ();
01061: protected:
01062: wxWindow * m_PreviousParentWindow;
01063: // maybe:
01064: wxString m_NotebookPageName;
01065: };
01066: #endif
01067:
01068: // example of wxWindowAdderAutoPopSizer usage in macro:
01069: // #define SIZER(WindowAdder,AddAndPushCall)
01070: // WindowAdder. AddAndPushCall ;
01071: // wxWindowAdderAutoPopSizer WindowAdderAutoPopSizer__ (& WindowAdder);
01072: //
01073: // {
01074: // SIZER(addAndPushSizer (new wxBoxSizer (wxVERTICAL),
01075: // wxLEFT|wxRIGHT|wxTOP|wxEXPAND, _B(0)));
01076: // ... add controls here
01077: // }
01078: // {
01079: // SIZER(addAndPushSizer (new wxBoxSizer (wxVERTICAL),
01080: // wxLEFT|wxRIGHT|wxTOP|wxEXPAND, _B(0)));
01081: // ... add controls here
01082: // }
01083:
01084: //-------------------------------------------------------------------------
01085:
01086: class wxNonModalDialogInfo
01087: {
01088: public:
01089: wxNonModalDialogInfo();
01090:
01091: long m_CommandIdent;
01092: wxWindow * m_Window;
01093:
01094: // maybe: long (or int) m_ExitCode
01095: // - would require some extra function in wxNonModalDialogManag
01096: // which would be used in place of EndModal()/EndDialog()
01097: // - there was currently no need for keeping some dialog
01098: // exit code
01099: };
01100:
01101: WX_DECLARE_OBJARRAY(wxNonModalDialogInfo, wxNonModalDialogInfoArray);
01102:
01103: //-------------------------------------------------------------------------
01104:
01105: // wxNonModalDialogManag
01106: // - provide unified handling for non-modal dialogs
01107: // - command idents need to be registered
01108: // - dialog/window creation is done through a callback function
01109: // - a pointer to opened dialog window instance is kept
01110: // for each registered dialog (i.e. command ident), which
01111: // was created through this class
01112: // - default handling for dialog show menu entries
01113: class wxNonModalDialogManag
01114: {
01115: public:
01116: wxNonModalDialogManag();
01117: virtual ~wxNonModalDialogManag();
01118:
01119: // handleMenuCommand()
01120: // - default handling for dialog show/hide menu commands
01121: // - if not yet created: create dialog through
01122: // createWindow() callback
01123: // - if dialog is created but hidden: show dialog and bring to
01124: // front
01125: void handleMenuCommand (long CommandIdent);
01126:
01127: // closeAll():
01128: // - implementation note: uses special hack to close hidden windows
01129: // by showing them before closing (otherwise, application may not
01130: // close properly in some wx ports)
01131: // - todo: support vetoing
01132: void closeAll();
01133:
01134: // callback to create windows/dialogs (needs to be overwritten)
01135: // - this allows the callback to create dialog instance
01136: // by using desired class and constructor arguments
01137: virtual wxWindow * createWindow (long CommandIdent) = 0;
01138:
01139: //-- info array functions
01140: // addInfo(): register CommandIdent
01141: int addInfo (long CommandIdent);
01142: int findInfo (long CommandIdent);
01143: int findInfoFromWindow (wxWindow * Window);
01144: wxNonModalDialogInfo & getInfoByIndex (int InfoIndex);
01145:
01146: protected:
01147: wxNonModalDialogInfoArray m_NonModalDialogInfoArray;
01148: };
01149:
01150: //-------------------------------------------------------------------------
01151:
01152: // wxDisablingBusyInfo
01153: // - wxBusyInfo calls wxYield(), which may cause input events to be processed.
01154: // In many cases nested handling of input events is not not desirable,
01155: // so use wxWindowDisabler() to disable processing input events while
01156: // showing the wxBusyInfo.
01157: // - under wxMSW, use of wxWindowDisabler seems to cause loosing the
01158: // focus or activation of previously focused or activated window, so
01159: // to avoid this, wxFocusRestorer is used
01160: class wxDisablingBusyInfo
01161: {
01162: public:
01163: wxDisablingBusyInfo (const wxString & MessageString, wxWindow * ParentWindow = NULL,
01164: wxWindow * SkipDisableWindow = NULL);
01165:
01166: private:
01167: wxFocusRestorer m_FocusRestorer;
01168: wxWindowDisabler m_WindowDisabler;
01169: wxBusyInfo m_BusyInfo;
01170: };
01171:
01172: //-------------------------------------------------------------------------
01173:
01174: class wxCalendarCtrl;
01175: class wxCalendarEvent;
01176:
01177: // wxCalendarDialog
01178: // - dialog which contains wxCalendarCtrl and wxTraitedDateTimeValidator
01179: // to allow input and validation of single wxDateTime value
01180: // - both date input controls try to mutually update each other
01181: // - currently only the date part can be selected, time part is set to
01182: // zero
01183: class wxCalendarDialog : public wxExtDialog
01184: {
01185: public:
01186: // - default for DateTimeFormatString: as for wxTraitedDateTimeValidator
01187: wxCalendarDialog (wxWindow * ParentWindow,
01188: const wxString & DialogTitleString,
01189: wxDateTime * DateTimePtr,
01190: const wxDateTime & MinDateTime, const wxDateTime & MaxDateTime,
01191: long DateTimeValidatorFlags,
01192: const wxString & DateTimeFormatString = wxEmptyString);
01193: void init();
01194: void addStatusMessageTarget (wxWindowAdder & WA);
01195: void clearControlPointers();
01196: void createControlsMain ();
01197: void createControls (wxWindowAdder & WA);
01198: void fillControlsPostCreate ();
01199:
01200: void OnCalendarDoubleClicked (wxCalendarEvent & Event);
01201: void OnCalendarSelectionChanged (wxCalendarEvent & Event);
01202: void handleSelectionChange(wxCalendarEvent & Event);
01203:
01204: void OnOkayButton (wxCommandEvent & Event);
01205: void handleAcceptInput();
01206:
01207: wxTraitedDateTimeValidator & accessDateTimeValidator();
01208:
01209: private:
01210: long m_DateTimeValidatorFlags;
01211: wxDateTime m_MinDateTime;
01212: wxDateTime m_MaxDateTime;
01213: wxString m_DateTimeFormatString;
01214:
01215: wxMultiLineText m_StatusMessageMultiLineText;
01216: wxCalendarCtrl * m_DateCalendarCtrl;
01217: wxTextCtrl * m_DateTimeTextCtrl;
01218:
01219: // m_TextCtrlDateTime is used to hold a copy of currently selected
01220: // date (which is also displayed in the read-only TextCtrl then)
01221: wxDateTime m_TextCtrlDateTime;
01222: wxDateTime * m_DateTimePtr;
01223: };
01224:
01225: void showCalendarDialog (wxWindow * ParentWindow,
01226: const wxString & CalendarDialogCaptionString,
01227: const wxDateTime & MinDateTime,
01228: const wxDateTime & MaxDateTime,
01229: long DateTimeValidatorFlags,
01230: const wxString & DateTimeFormatString,
01231: wxTextCtrl * DateTimeTextCtrl,
01232: bool IsCallResetTime = false);
01233:
01234: //-------------------------------------------------------------------------
01235:
01236: class wxNonModalDialogManag;
01237:
01238: enum ETopLevelWindowModification
01239: {
01240: HideTLWModification = 1,
01241: ShowAndRaiseTLWModification
01242: };
01243:
01244: // modifyTopLevelWindows()
01245: // - OBSOLETE extended functionality is now in wxAppRootFrame class
01246: // - helper functions for hidden application root frame support,
01247: // this was a first try only and does not do everything that is
01248: // desired (e.g. keeping Z-order of windows)
01249: // - this function however, maybe used for other purposes in the future
01250: void modifyTopLevelWindows (wxWindow * ParentWindow, wxWindow * ExcludeWindow, ETopLevelWindowModification Mode,
01251: wxNonModalDialogManag * NonModalDialogManag,
01252: wxWindow * ExtraWindow);
01253:
01254: //-------------------------------------------------------------------------
01255:
01256: // TLWStateInfo
01257: // - class to save state info on wxTopLevelWindow (wxTopLevelWindowNative)
01258: // windows
01259: class wxTLWStateInfo
01260: {
01261: public:
01262: wxTLWStateInfo();
01263: wxTLWStateInfo (const wxTLWStateInfo & TLWStateInfo);
01264: wxTLWStateInfo (wxWindow * Window, bool IsShownWhenNotIconized);
01265:
01266: // Shown/Hidden state at the time of iconization request:
01267: bool m_IsShownWhenNotIconized;
01268:
01269: // pointer to window:
01270: wxWindow * m_Window;
01271: };
01272:
01273: WX_DECLARE_OBJARRAY(wxTLWStateInfo, wxTLWStateInfoArray);
01274:
01275: //-------------------------------------------------------------------------
01276:
01277: #if (M_WxExtLib_IsUseAppRootFrame == 1)
01278:
01279: // wxAppRootFrame
01280: // - purpose: helper class to allow the application main frame window
01281: // (containing menu etc.) to be raised to the foreground, before
01282: // other top-level windows (TLW) (e.g. non-modal dialogs)
01283: // - this is useful if non-modal dialogs are used, which would
01284: // otherwise be always in front of the main frame window
01285: // (normal behavior of child window having popup style)
01286: // - following structure is intended:
01287: // wxAppRootFrame
01288: // \ //
01289: // |- AppSpecificMainFrame
01290: // |- NonModalDialog1
01291: // |- ...
01292: // |- NonModalDialogN
01293: // - windows of this class are normally never shown
01294: // - however, because of hidden state, iconize/restore behavior needs to
01295: // be implemented manually (which this class tries to emulate)
01296: // - otherwise a small dummy window could be used, but this might
01297: // have other side effects when e.g. user does a "cascade" or other
01298: // alignment of top-level/application windows
01299: // - there should be only one instance of this class per process
01300: // - notation: here, the term TLW is used to denote frame windows and non-modal
01301: // dialogs that are children of an wxAppRootFrame instance
01302: // - compatibility: these functions currently only work, more or less, as
01303: // expected with wxMSW
01304: //
01305: class wxAppRootFrame : public wxFrame
01306: {
01307: DECLARE_DYNAMIC_CLASS(wxAppRootFrame)
01308: public:
01309: wxAppRootFrame ();
01310:
01311: #if wxCHECK_VERSION (2, 5, 0)
01312: typedef wxTopLevelWindowNative wxTopLevelType;
01313: #else
01314: typedef wxWindow wxTopLevelType;
01315: #endif
01316:
01317: wxAppRootFrame(wxWindow *parent, wxWindowID id,
01318: const wxString& title,
01319: const wxPoint& pos = wxDefaultPosition,
01320: const wxSize& size = wxDefaultSize,
01321: long style_DIALOG_STYLE = wxDEFAULT_DIALOG_STYLE,
01322: const wxString& name = wxDialogNameStr);
01323:
01324: ~wxAppRootFrame ();
01325:
01326: void init();
01327:
01328: // ControllingFrame is the frame which contains the application main menu
01329: M_DeclarePtrProperty (wxFrame, ControllingFrame);
01330:
01331: public:
01332: // helper function: returns top-most top-level window (this should be
01333: // set as handler to replace NULL values for ParentWindow specification)
01334: static wxWindow * getDefaultParentWindow (wxWindow * ParentWindow);
01335:
01336: static wxAppRootFrame * create (const wxIcon & Icon);
01337: static void setup (wxFrame * FrameWindow);
01338:
01339: // handlers related to wxAppRootFrame's own window events
01340: void OnDestroyEvent (wxWindowDestroyEvent & DestroyEvent);
01341: void OnCloseEvent (wxCloseEvent & CloseEvent);
01342: void OnShowEvent (wxShowEvent & ShowEvent);
01343: void OnActivateEvent (wxActivateEvent & ActivateEvent);
01344: void OnActivateAppEvent (wxActivateEvent & ActivateEvent);
01345: void OnIconizeEvent (wxIconizeEvent & IconizeEvent);
01346: void OnMaximizeEvent (wxMaximizeEvent & MaximizeEvent);
01347: void OnMoveEvent (wxMoveEvent & MoveEvent);
01348:
01349: // handlers intended for top-level windows which are children of
01350: // this wxAppRootFrame
01351: // - notes:
01352: // - not used: void OnTLWIconizeEvent (wxIconizeEvent & IconizeEvent);
01353: // - CloseEvent and ShowEvent are not used either
01354: // - IMPORTANT: these functions are really called with a different 'this' pointer
01355: // (due to the way the event handler is added using wxEvtHandler::Connect())
01356: // and only act as proxy which forward to instances of this class
01357: // via s_GlobalAppRootFrame pointer)
01358: // - this technique may not be guaranted to work with any C++ compiler or
01359: // by the C++ standard, but probably will work with the binary layout of
01360: // most compilers
01361: // - the method has the advantage that it can be applied without adding
01362: // these handlers to the TLW window classes itself, and thus works
01363: // even for classes from 3rd parties etc.
01364: // - alternatively, it would be required to put the forwarding
01365: // event handlers in all used TLW classes
01366: void OnTLWDestroyEventForward (wxWindowDestroyEvent & DestroyEvent);
01367: void OnTLWCloseEventForward (wxCloseEvent & CloseEvent);
01368: void OnTLWShowEventForward (wxShowEvent & ShowEvent);
01369: void OnTLWActivateEventForward (wxActivateEvent & ActivateEvent);
01370: void OnTLWIconizeEventForward (wxIconizeEvent & IconizeEvent);
01371: void OnTLWMaximizeEventForward (wxMaximizeEvent & MaximizeEvent);
01372: void OnTLWMoveEventForward (wxMoveEvent & MoveEvent);
01373:
01374: //-- TLW event handling
01375: // - some of the event types are not yet used specially (e.g. ShowEvent)
01376: // may not require special handling
01377: // - except for notifyActivateAppEvent(), connectTLWEventHandlers() adds
01378: // handlers which forward to the following functions
01379: // - notifyActivateAppEvent() must be forwarded manually from an
01380: // wxApp::SetActive() overload (see file wxWidgets-base/include/wx/app.h
01381: // for declaration)
01382: bool notifyActivateAppEvent (bool IsActivate, wxWindow * LastFocusWindow);
01383: bool notifyTLWDestroyEvent (wxWindowDestroyEvent & DestroyEvent);
01384: bool notifyTLWCloseEvent (wxCloseEvent & CloseEvent /*, bool IsHideInsteadOfClose */);
01385: bool notifyTLWShowEvent (wxShowEvent & ShowEvent);
01386: // as an exception, notifyTLWActivateEvent() is also used to handle
01387: // activate events of wxAppRootFrame
01388: bool notifyTLWActivateEvent (wxActivateEvent & ActivateEvent);
01389: bool notifyTLWIconizeEvent (wxIconizeEvent & IconizeEvent);
01390: bool notifyTLWMaximizeEvent (wxMaximizeEvent & MaximizeEvent);
01391: bool notifyTLWMoveEvent (wxMoveEvent & MoveEvent);
01392:
01393: // connectTLWEventHandlers()
01394: // - this needs to be called for each managed top-level window once
01395: // - this should be called after window creation and before the first
01396: // Show(true) of the Window, so the window is inserted in the list
01397: // of TLWs at first wxEVT_ACTIVATE event
01398: void connectTLWEventHandlers (wxWindow * Window);
01399:
01400: // obtain wxTopLevelWindowNative pointer by use of wxDynamicCast(), or return
01401: // NULL if not convertible
01402: bool getTLWFromEvent (wxEvent & Event, wxTopLevelType ** TLWNativePtrPtr);
01403:
01404: //-- functions to manipulate list of top-level windows
01405: int pushInfo (const wxTLWStateInfo & TLWStateInfo);
01406: void deleteInfo (int Index);
01407: void deleteInfoFromWindow (wxWindow * Window);
01408: wxTLWStateInfo & getInfoByIndex (int InfoIndex);
01409: int findInfoFromWindow (wxWindow * Window);
01410:
01411: //-- helper variables
01412: // - ignore recursive events which would further complicate issues
01413: bool m_IsLockEventProcessing;
01414: // - ignore multiple same events (if an application is activated, more two
01415: // events indicating this may be generated, for whatever reason (scope:
01416: // wxMSW)
01417: bool m_IsFirstActivateAppEvent;
01418: wxWindow * m_LastFocusWindow;
01419:
01420: protected:
01421: //-- list of top-level windows: this list is used to:
01422: // - raise windows after iconization in correct Z-order
01423: // - save show/hide state at the moment of iconization (so upon restore
01424: // after iconization, Show() and Raise() is called only for the windows
01425: // which were shown before)
01426: // notes:
01427: // - Z-order handling is done without using OS-specific functions
01428: // like ::SetWindowPos() in MSW
01429: // - upon a wxEVT_ACTIVATE event, the window is brought to foreground
01430: // and this is reflected by putting it at the top(end) of the
01431: // array/stack
01432: wxTLWStateInfoArray m_TLWStateInfoArray;
01433:
01434: public:
01435: DECLARE_EVENT_TABLE()
01436: };
01437:
01438: #else
01439:
01440: typedef wxWindow wxAppRootFrame;
01441:
01442: #endif // M_WxExtLib_IsUseAppRootFrame
01443:
01444: // return global singular instance of wxAppRootFrame (or NULL)
01445: wxAppRootFrame * wxGetGlobalAppRootFrame();
01446:
01447: //-------------------------------------------------------------------------
01448:
01449: #define M_IsUndefExportMagic 1
01450: # include "WxExtLibAliases.h"
01451: #undef M_IsUndefExportMagic
01452:
01453: //-------------------------------------------------------------------------
01454:
01455: #endif
01456: