[main]    [up]  

WxExtLib - WxExtDialog.cpp

00001: 
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 _NO_HEADER_INCLUDE
00042: 
00043: #if defined(__GNUG__) && (!defined(__APPLE__)) && (!(defined M_NoPragmaInterface))
00044:     #pragma implementation "WxExtDialog.h"
00045: #endif
00046: 
00047: #include "WxExtLibConfig.h"
00048: 
00049: // For compilers that support precompilation, includes "wx.h".
00050: #include <wx/wxprec.h>
00051: 
00052: #ifdef __BORLANDC__
00053:     #pragma hdrstop
00054: #endif
00055: 
00056: #include <wx/statline.h>
00057: 
00058: #ifdef M_IsHaveGridBagSizer
00059: #   include <wx/gbsizer.h>
00060: #endif
00061: 
00062: #include <wx/busyinfo.h>
00063: #include <wx/calctrl.h>
00064: // #include <wx/html/htmprint.h>
00065: 
00066: #include "WxExtDialog.h"
00067: #include "WxMisc.h"
00068: 
00069: #include "TextCtrlSliderPairValidators.h"
00070: 
00071: #include <math.h>
00072: 
00073: #include "safecast.h"
00074: 
00075: #endif // _NO_HEADER_INCLUDE
00076: 
00077: #include <wx/arrimpl.cpp>
00078: 
00079: #if (M_WxExtLib_IsUseStxLogging == 1)
00080:     #include <StxConfig.h>
00081:     #include <StxSimpleLog.h>
00082:     #include <StxException.h>
00083: #endif
00084: 
00085: //-------------------------------------------------------------------------
00086: 
00087: #if (M_WxExtLib_IsUseStxLogging == 1)
00088:     #define __try M_StxException_Try
00089:     #define __catch_rethrow M_StxException_Rethrow
00090:     #define __catch_displayMessageBox M_StxException_DisplayException
00091: #endif
00092: 
00093: //=========================================================================
00094: 
00095: #ifdef M_WxExtLib_IsMFCCompatibility
00096: 
00097: wxWindow * MSWCreateChildWindowForMFCFrame (CWnd * ParentWindow)
00098: {
00099:     //-------------------------------------------------------------------------
00100:     // creating a wxFrame has following disadvantages:
00101:     // - non-modal dialogs are hidden if the MFC main frame is activated
00102:     // - wxDialogs will have an own icon in the task-switch window
00103:     // - when activating an other application and switching back to this
00104:     //   application, modal and non-modal dialogs having the wxFrame
00105:     //   as parent are hidden
00106:     //
00107:     //  wxWindow * Window = new wxFrame (NULL, -1, "Dummy Frame", 
00108:     //                                   wxPoint(10, 10), wxSize(300, 300),
00109:     //                                   wxFRAME_NO_TASKBAR); // wxDEFAULT_FRAME_STYLE
00110: 
00111:     //-------------------------------------------------------------------------
00112:     // create a normal MFC child window for the specified parent:
00113:     CWnd * Wnd = new CWnd();
00114:     RECT Rect = { 0, 0, 100, 100 };
00115:     Wnd -> Create (NULL, "Dummy Frame", 
00116:                    WS_CHILD, 
00117:                    Rect, 
00118:                    ParentWindow,
00119:                    NULL,
00120:                    NULL);
00121: 
00122:     WXHWND WxHwnd = Wnd != NULL ? (long) Wnd -> m_hWnd : 0;
00123: 
00124:     // make the MFC window wxWindow class compatible (this seems to work!)
00125:     wxWindow * Window = new wxWindow ();
00126:     if (Window)
00127:     {
00128:         Window -> SetEventHandler (Window);
00129:         Window -> SetHWND (WxHwnd);
00130:         Window -> SetId (-1);
00131:         Window -> SubclassWin (WxHwnd);
00132:         Window -> AdoptAttributesFromHWND ();
00133:         Window -> SetupColours ();
00134:     }
00135: 
00136:     return Window;
00137: }
00138: 
00139: #endif
00140: 
00141: //=========================================================================
00142: 
00143: enum
00144: {
00145: #if defined(__WXMSW__)
00146:     DefaultDialogFontSize = 8
00147: #elif defined(__WXGTK__)
00148:     DefaultDialogFontSize = 12
00149: #elif defined(__WXX11__)
00150: #   pragma message ("Please adjust DefaultDialogFontSize for your wxWindows port.")
00151:     DefaultDialogFontSize = 12
00152: #elif defined(__WXMOTIF__)
00153: #   pragma message ("Please adjust DefaultDialogFontSize for your wxWindows port.")
00154:     DefaultDialogFontSize = 12
00155: #else
00156: #   pragma message Please adjust DefaultDialogFontSize for your wxWindows port.
00157:     DefaultDialogFontSize = 12
00158: #endif
00159: };
00160: 
00161: //-------------------------------------------------------------------------
00162: 
00163: #if 0
00164:     // EVT_QUERY_END_SESSION and EVT_END_SESSION apply only to wxApp
00165:     EVT_QUERY_END_SESSION (ClassName::OnCloseEvent) 
00166:     EVT_END_SESSION (ClassName::OnCloseEvent) 
00167: #endif
00168: 
00169: #define M_WxExtDlgBase_ImplementWatchedControlChangeEventHandlers(ClassName) \
00170:     EVT_CLOSE (ClassName::OnCloseEvent)  \
00171:  \
00172:     EVT_TEXT  (wxID_ANY, ClassName::OnTextCtrlChanged) \
00173:     EVT_COMMAND_SCROLL_ENDSCROLL (wxID_ANY, ClassName::OnSliderCtrlChanged) \
00174:     EVT_RADIOBUTTON (wxID_ANY, ClassName::OnRadioButtonSelected) \
00175:     EVT_RADIOBOX (wxID_ANY, ClassName::OnRadioBoxSelected) \
00176:     EVT_CHECKBOX (wxID_ANY, ClassName::OnCheckBoxSelected) \
00177:     EVT_COMBOBOX (wxID_ANY, ClassName::OnComboBoxSelected) \
00178:     EVT_LISTBOX (wxID_ANY, ClassName::OnListBoxSelected) \
00179:     EVT_CHOICE (wxID_ANY, ClassName::OnChoiceCtrlSelected) \
00180:     EVT_BUTTON (wxID_ANY, ClassName::OnButtonClicked) \
00181: 
00182: //=========================================================================
00183: 
00184: wxExtDlgBase::wxExtDlgBase()
00185: {
00186:     // not here: initCWxDialog();
00187: }
00188: 
00189: void wxExtDlgBase::initCWxDialog ()
00190: {
00191:     m_ZoomValue = 1.; 
00192:     m_DialogZoomValue = 1.;
00193:     m_DesktopReferenceSize = wxSize (-1, -1);
00194:     m_BorderCompressionValue = 1.;
00195: 
00196:     m_DialogFontSize = DefaultDialogFontSize;
00197:     m_DialogFontHeight = DefaultDialogFontSize;
00198: 
00199:     m_IsSetFontIfSameAsDefaultSize = false;
00200: 
00201:     m_IsWatchedControlChangeNotification = false;
00202:     m_IsDialogInitialized = false;
00203:     m_StatusMessageTarget = NULL;
00204:     // m_ErrorMessageMultiLineText = NULL;
00205: }
00206: 
00207: wxExtDlgBase::~wxExtDlgBase()
00208: {
00209:     delete m_StatusMessageTarget;
00210:     m_StatusMessageTarget = NULL;
00211: }
00212: 
00213: //-------------------------------------------------------------------------
00214: 
00215: void wxExtDlgBase::setDialogInitializedFlag()
00216: {
00217:     m_IsDialogInitialized = true;
00218: }
00219: 
00220: //=========================================================================
00221: 
00222: #ifdef M_IsNonWxMainIntegration
00223: 
00224: wxWindow *wxExtDlgBase::FindSuitableParent() const
00225: {
00226:     wxWindow * ParentWindow = NULL;
00227: 
00228: #if 0
00229:     // TODO: GetModalDialogList() should be a const function
00230:     // HACK: cast away const from 'this' pointer to be able to use
00231:     // GetModalDialogList()
00232:     // WARN cast
00233:     wxWindowList & ModalDialogList = ((wxDialog *) getDialog()) -> GetModalDialogList ();
00234:     if (ModalDialogList.GetCount() > 0)
00235:       {
00236:         // TEST: if another modal dialog is shown, use this one as parent
00237:         // (otherwise, no input is possible to any modal dialogs anymore
00238:         // if another modal dialog is shown already, and the dialog is created 
00239:         // only once)
00240:         // (has not helped)
00241:         // Finally, the problem was solved by calling new/Create() everytime
00242:         // the dialog is shown modally. This way, the dialog gets the a correct
00243:         // parent window automatically.
00244:         wxWindowList::Node * LastWindowNode = ModalDialogList.GetLast();
00245:         ParentWindow = LastWindowNode->GetData();
00246:       }
00247:     else
00248: #endif
00249:       {
00250:         wxWindow * ParentWindow = wxDialog::FindSuitableParent();
00251: 
00252:         if (ParentWindow == NULL)
00253:           {
00254:             ParentWindow = wxTheApp->GetTopWindow();
00255:             // we use this window even if it is not shown:
00256:             // it is our special child window that has the MFC frame
00257:             // as parent (wxDialog::FindSuitableParent() above will
00258:             // return NULL because it is not shown)
00259:           }
00260:       }
00261: 
00262:     return ParentWindow;
00263: }
00264: 
00265: #endif // M_IsNonWxMainIntegration
00266: 
00267: //-------------------------------------------------------------------------
00268: 
00269: #ifdef M_IsNonWxMainIntegration
00270: #if defined(__WXMSW__)
00271: 
00272: void wxExtDlgBase::MSWEnableOtherWindows (bool IsEnable)
00273: {
00274:     // for MFC main window compatibility:
00275:     AfxGetApp() -> EnableModeless (IsEnable);
00276:     AfxGetMainWnd() -> EnableWindow (IsEnable);
00277: }
00278: 
00279: #endif // defined(__WXMSW__)
00280: #endif
00281: 
00282: #if defined(__WXMSW__)
00283: HWND wxExtDlgBase::MSWGetHandle()
00284: {
00285:     return (HWND) (getDialog() -> GetHWND());
00286: }
00287: #endif
00288: 
00289: //=========================================================================
00290: 
00291: wxSizer * wxExtDlgBase::addSpace (int Width, int Height, const wxSizerAdderProxy & SizerAdderProxy)
00292: {
00293:     wxSizerAdder AlternativeSizerAdder;
00294:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00295: 
00296:     SizerAdder -> addSpace (Width, Height, 0, 0);
00297: 
00298:     return SizerAdder -> getSizer();
00299: }
00300: 
00301: //-------------------------------------------------------------------------
00302: 
00303: wxWindow * wxExtDlgBase::getAddParentWindow (wxSizerAdder * SizerAdder)
00304: {
00305:     if (SizerAdder -> getParentWindow() != NULL)
00306:       {
00307:         return SizerAdder -> getParentWindow();
00308:       }
00309: 
00310:     return getDialog();
00311: }
00312: 
00313: //-------------------------------------------------------------------------
00314: 
00315: wxButton * wxExtDlgBase::addButton (wxButton ** ButtonPtrPtr,
00316:                                    wxWindowID ButtonId, 
00317:                                    wxCommandEventFunction CommandEventFunction,
00318:                                    const wxString& LabelString, 
00319:                                    const wxSizerAdderProxy & SizerAdderProxy,
00320:                                    const wxPoint& Position,
00321:                                    const wxSize& Size,
00322:                                    long Style, const wxValidator& Validator)
00323: {
00324:     wxSizerAdder AlternativeSizerAdder;
00325:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00326: 
00327:     wxButton * Button = NULL;
00328: 
00329:     wxSize UsedSize = getSizeFromDefaults (Size, m_DefaultButtonSize);
00330: 
00331:     // to use wxBU_EXACTFIT, wxDefaultSize must be specifed as size
00332:     if (Style & wxBU_EXACTFIT)
00333:       UsedSize = wxDefaultSize;
00334: 
00335:     Button = new wxButton (getAddParentWindow (SizerAdder), ButtonId, LabelString, Position, UsedSize, 
00336:                            Style, Validator);
00337: 
00338:     if (CommandEventFunction != (wxCommandEventFunction) NULL)
00339:       {
00340:         getDialog() -> Connect (Button -> GetId(),
00341:                                 wxEVT_COMMAND_BUTTON_CLICKED,
00342:                                 (wxObjectEventFunction) (wxEventFunction) CommandEventFunction);
00343:       }
00344: 
00345:     if (SizerAdder != NULL)
00346:       SizerAdder -> addWindow (Button, 0, _B(0));
00347: 
00348:     if (ButtonPtrPtr != NULL)
00349:       *ButtonPtrPtr = Button;
00350:     return Button;
00351: }
00352: 
00353: //-------------------------------------------------------------------------
00354: 
00355: wxSizer * wxExtDlgBase::addCheckBoxWithLabel (wxCheckBox ** CheckBox,
00356:              const wxString & LabelString, const wxValidator & Validator,
00357:              long TextCtrlStyle, const wxSizerAdderProxy & SizerAdderProxy, bool IsLabelOnTheLeft)
00358: {
00359:     wxSizerAdder AlternativeSizerAdder;
00360:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00361:     wxWindow *PanelWnd = getAddParentWindow (SizerAdder);
00362: 
00363:     // if (SizerAdder == NULL)
00364:     //  {
00365:     //    Sizer = new wxBoxSizer (wxHORIZONTAL);
00366:     //  }
00367: 
00368:     bool IsExtraLabelControl = TextCtrlStyle & wxTE_READONLY || IsLabelOnTheLeft;
00369:     int CheckBoxStyle = TextCtrlStyle;
00370:     CheckBoxStyle = CheckBoxStyle & ~wxTE_READONLY;
00371: 
00372:     *CheckBox = new wxCheckBox (PanelWnd, -1, 
00373:                                 wxString (IsExtraLabelControl ? wxString("") : LabelString), 
00374:                                 // IsExtraLabelControl ? wxString("") : wxString(LabelString), 
00375:                                 wxDefaultPosition, wxDefaultSize, CheckBoxStyle, Validator);
00376:     wxStaticText * StaticText = NULL;
00377: 
00378:     if (TextCtrlStyle & wxTE_READONLY)
00379:       {
00380:         (*CheckBox) -> Enable (false);
00381:       }
00382: 
00383:     if (IsExtraLabelControl)
00384:       {
00385:         StaticText = new wxStaticText (PanelWnd, -1, LabelString);
00386:       }
00387: 
00388:     if (! IsLabelOnTheLeft)
00389:       {
00390:         SizerAdder -> addWindow (*CheckBox, wxEXPAND|wxALIGN_CENTER_VERTICAL, _B(5));
00391:         if (IsExtraLabelControl)
00392:             SizerAdder -> addWindow (StaticText, wxLEFT|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, _B(5));
00393:       }
00394:     else
00395:       {
00396:         SizerAdder -> addWindow (StaticText, wxRIGHT|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, _B(8));
00397:         SizerAdder -> addWindow (*CheckBox, wxEXPAND|wxALIGN_CENTER_VERTICAL, _B(8));
00398:       }
00399: 
00400:     return SizerAdder -> getSizer();
00401: }
00402: 
00403: //-------------------------------------------------------------------------
00404: 
00405: wxSizer * wxExtDlgBase::addRadioButtonWithLabel (wxRadioButton ** RadioButton,
00406:              const wxString & LabelString, const wxValidator & Validator,
00407:              long RadioCtrlStyle, const wxSizerAdderProxy & SizerAdderProxy)
00408: {
00409:     wxSizerAdder AlternativeSizerAdder;
00410:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00411:     wxWindow *PanelWnd = getAddParentWindow (SizerAdder);
00412: 
00413:     // if (SizerAdder == NULL)
00414:     //  {
00415:     //    Sizer = new wxBoxSizer (wxHORIZONTAL);
00416:     //  }
00417: 
00418:     *RadioButton = new wxRadioButton (PanelWnd, -1, 
00419:                                       LabelString, 
00420:                                       wxDefaultPosition, wxDefaultSize, 
00421:                                       RadioCtrlStyle, Validator);
00422: 
00423: //  if (TextCtrlStyle & wxTE_READONLY)
00424: //    {
00425: //      (*RadioButton) -> Enable (false);
00426: //    }
00427: 
00428:     SizerAdder -> addWindow (*RadioButton, wxEXPAND|wxALIGN_CENTER_VERTICAL, _B(5));
00429: 
00430:     return SizerAdder -> getSizer();
00431: }
00432: 
00433: //-------------------------------------------------------------------------
00434: 
00435: wxStaticText * wxExtDlgBase::addLabel (wxStaticText ** StaticTextCtrl,
00436:                                        const wxString & LabelString,
00437:                                        const wxSizerAdderProxy & SizerAdderProxy,
00438:                                        long WindowStyle,
00439:                                        const wxSize & Size,
00440:                                        bool IsTransparent,
00441:                                        long TransparentStaticTextFlags)
00442: {
00443:     wxSizerAdder AlternativeSizerAdder;
00444:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00445: 
00446:     wxStaticText * TempStaticTextCtrl = NULL;
00447: 
00448:     if (!IsTransparent)
00449:       {
00450:         TempStaticTextCtrl = new wxStaticText (getAddParentWindow (SizerAdder), -1, LabelString,
00451:                                                wxDefaultPosition, Size,
00452:                                                WindowStyle);
00453:       }
00454:     else
00455:       {
00456:         wxTransparentStaticText::ETransparentStaticTextFlags SpecialFlags
00457:           = (wxTransparentStaticText::ETransparentStaticTextFlags) TransparentStaticTextFlags;
00458:         TempStaticTextCtrl = new wxTransparentStaticText (getAddParentWindow (SizerAdder), -1, LabelString,
00459:                                                           wxDefaultPosition, Size,
00460:                                                           WindowStyle,
00461:                                                           SpecialFlags);
00462:       }
00463:     
00464:     if (StaticTextCtrl != NULL)
00465:       *StaticTextCtrl = TempStaticTextCtrl;
00466:     
00467:     if (SizerAdder != NULL)
00468:       SizerAdder -> addWindow (TempStaticTextCtrl, wxRIGHT|wxALIGN_CENTER_VERTICAL, _B(8));
00469: 
00470:     return TempStaticTextCtrl;
00471: }
00472: 
00473: wxWindow * wxExtDlgBase::addMultiLineText (wxMultiLineText * MultiLineText,
00474:                                         long CtrlStyle,
00475:                                         const wxSize & CtrlSize,
00476:                                         int MultiLineTextStyle,
00477:                                         const wxSizerAdderProxy & SizerAdderProxy)
00478: {
00479:     wxSizerAdder AlternativeSizerAdder;
00480:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00481: 
00482:     wxSize UsedSize = getSizeFromDefaults (CtrlSize, m_DefaultTextCtrlSize);
00483: 
00484:     MultiLineText -> create (getAddParentWindow (SizerAdder), -1, 
00485:                              CtrlStyle, 
00486:                              UsedSize,
00487:                              MultiLineTextStyle);
00488: 
00489:     if (MultiLineText -> getHtmlWindow() != NULL)
00490:       {
00491:         setHtmlWindowFonts (MultiLineText -> getHtmlWindow(),
00492:                             m_DialogFontSize,
00493:                             true,
00494:                             false);
00495: 
00496:         MultiLineText -> getHtmlWindow() -> SetBackgroundColour (getDialog() -> GetBackgroundColour ());
00497:       }
00498: 
00499:     if (SizerAdder != NULL)
00500:       SizerAdder -> addWindow (MultiLineText -> getWindow(), wxEXPAND, _B(0));
00501: 
00502:     return MultiLineText -> getWindow ();
00503: }
00504: 
00505: wxWindow * wxExtDlgBase::addMultiLineText (wxMultiLineText * MultiLineText,
00506:                                           long CtrlStyle,
00507:                                           const wxSize & CtrlSize,
00508:                                           int MultiLineTextStyle,
00509:                                           const wxSizerAdderProxy & SizerAdderProxy,
00510:                                           const wxString & TextString,
00511:                                           int MinLineCount, int MaxLineCount, 
00512:                                           int BorderWidth)
00513: {
00514:     wxSizerAdder AlternativeSizerAdder;
00515:     // wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00516: 
00517:     wxWindow * Window = addMultiLineText (MultiLineText,
00518:                                           CtrlStyle,
00519:                                           CtrlSize,
00520:                                           MultiLineTextStyle,
00521:                                           SizerAdderProxy);
00522: 
00523:     if (MultiLineText -> getHtmlWindow() != NULL)
00524:       {
00525:         MultiLineText -> getHtmlWindow() -> SetBorders (BorderWidth);
00526:       }
00527: 
00528:     MultiLineText -> setText (TextString);
00529:     adjustMultiLineTextSize (* MultiLineText, MinLineCount, MaxLineCount);
00530: 
00531:     return Window;
00532: }
00533: 
00534: wxTextCtrl * wxExtDlgBase::addTextCtrl
00535:    (
00536:     wxTextCtrl ** TextCtrl, const wxValidator & Validator,
00537:     long TextCtrlStyle,
00538:     const wxSize& Size,
00539:     const wxSizerAdderProxy & SizerAdderProxy
00540:     )
00541: {
00542:     wxSizerAdder AlternativeSizerAdder;
00543:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00544: 
00545:     wxSize UsedSize = getSizeFromDefaults (Size, m_DefaultTextCtrlSize);
00546: 
00547:     *TextCtrl = new wxTextCtrl (getAddParentWindow (SizerAdder), -1, _T(""),
00548:                                 wxDefaultPosition, UsedSize,
00549:                                 TextCtrlStyle, Validator);
00550: 
00551:     if (TextCtrlStyle & wxTE_READONLY)
00552:       {
00553:         // (*TextCtrl) -> SetBackgroundColour (*wxLIGHT_GREY);
00554:         (*TextCtrl) -> SetBackgroundColour (getDialog() -> GetBackgroundColour ());
00555:       }
00556: 
00557:     if (SizerAdder != NULL)
00558:       {
00559:         SizerAdder -> addWindow (*TextCtrl, 0, _B(0));
00560:       }
00561: 
00562:     return *TextCtrl;
00563: }
00564: 
00565: wxSizer * wxExtDlgBase::addTextCtrlWithLabel (wxTextCtrl ** TextCtrl,
00566:                                            const wxString & LabelString, 
00567:                                            const wxValidator & Validator,
00568:                                            long TextCtrlStyle,
00569:                                            const wxSize & Size,
00570:                                            const wxSizerAdderProxy & SizerAdderProxy)
00571: {
00572:     wxSizerAdder AlternativeSizerAdder;
00573:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00574: 
00575:     // if (Sizer == NULL)
00576:     // {
00577:     //  Sizer = new wxBoxSizer (wxHORIZONTAL);
00578:     //  }
00579:     if (! LabelString.IsEmpty())
00580:       {
00581:         SizerAdder -> addWindow (new wxStaticText (getAddParentWindow (SizerAdder), -1, LabelString),
00582:                                  wxRIGHT|wxALIGN_CENTER_VERTICAL, _B(8));
00583:       }
00584: 
00585:     wxSize UsedSize = getSizeFromDefaults (Size, m_DefaultTextCtrlSize);
00586:     SizerAdder -> addWindow (addTextCtrl (TextCtrl,
00587:                                           Validator, TextCtrlStyle, 
00588:                                           UsedSize),
00589:                              wxALIGN_CENTER_VERTICAL, _B(8));
00590:     
00591:     return SizerAdder -> getSizer();
00592: }
00593: 
00594: wxSizer * wxExtDlgBase::addTextCtrlWithTwoLabels (wxTextCtrl ** TextCtrl,
00595:                                                const wxString & FirstLabelString,
00596:                                                const wxString & SecondLabelString,
00597:                                                const wxValidator & Validator,
00598:                                                long TextCtrlStyle, 
00599:                                                const wxSize & Size,
00600:                                                const wxSizerAdderProxy & SizerAdderProxy)
00601: {
00602:     // NOTE: OtherSizer is possibly the same as Sizer
00603:     wxSizer * OtherSizer = addTextCtrlWithLabel (TextCtrl, FirstLabelString, Validator,
00604:                                                  TextCtrlStyle, Size, SizerAdderProxy);
00605:     // TODO (maybe) use wxSizerAdder, getAddParentWindow (SizerAdder)
00606:     OtherSizer -> Add (new wxStaticText (getDialog(), -1, SecondLabelString),
00607:                        0, wxLEFT|wxALIGN_CENTER_VERTICAL, _B(5));
00608: 
00609:     return OtherSizer;
00610: }
00611: 
00612: wxSizer * wxExtDlgBase::addTextCtrlSliderPairWithLabel (wxTextCtrl ** TextCtrl,
00613:                                                      wxSlider ** SliderCtrl,
00614:                                                      const wxString & LabelString,
00615:                                                      long * LongValue, long MinLong, long MaxLong,
00616:                                                      wxStatusMessageTarget * StatusMessageTarget,
00617:                                                      const wxSizerAdderProxy & SizerAdderProxy,
00618:                                                      const wxString & FieldNameString)
00619: {
00620:     wxSizerAdder AlternativeSizerAdder;
00621:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00622: 
00623:     // if (SizerAdder == NULL)
00624:     // {
00625:     //    Sizer = new wxBoxSizer (wxHORIZONTAL);
00626:     //  }
00627: 
00628:     SizerAdder -> addWindow (new wxStaticText (getAddParentWindow (SizerAdder), -1, LabelString),
00629:                              wxALIGN_CENTER_VERTICAL, _B(5));
00630: 
00631:     *TextCtrl = new wxTextCtrl (getAddParentWindow (SizerAdder), -1, _T(""),
00632:                                 wxDefaultPosition,
00633:                                 wxSize(getAdjustedTextCtrlWidth(60), getAdjustedTextCtrlHeight (1, true)),
00634:                                 wxTE_LEFT,
00635:                                 wxTextCtrlSliderPairTextCtrlValidator (LongValue, MinLong, 
00636:                                                                        MaxLong, StatusMessageTarget,
00637:                                                                        FieldNameString));
00638:     SizerAdder -> addWindow (*TextCtrl, wxLEFT|wxALIGN_CENTER_VERTICAL, _B(5));
00639:     
00640:     // specify 'MinLong' as initial value for the slider just in case it is not yet initialized correctly:
00641:     *SliderCtrl = new wxSlider(getAddParentWindow (SizerAdder), -1, MinLong , MinLong, MaxLong, wxDefaultPosition, 
00642:                                wxSize (getAdjustedSliderWidth(160), getAdjustedSliderHeight(22)), 
00643:                                wxSL_HORIZONTAL,
00644:                                wxTextCtrlSliderPairSliderValidator ());
00645:     SizerAdder -> addWindow (*SliderCtrl, wxLEFT|wxALIGN_CENTER_VERTICAL, _B(5));
00646: 
00647: //  wxTextCtrlSliderPairSliderValidator * TextCtrlSliderPairSliderValidator =
00648: //    wxDynamicCast ((**SliderCtrl).GetValidator(), wxTextCtrlSliderPairSliderValidator);
00649: //  wxTextCtrlSliderPairTextCtrlValidator * TextCtrlSliderPairTextCtrlValidator =
00650: //    wxDynamicCast ((**TextCtrl).GetValidator(), wxTextCtrlSliderPairTextCtrlValidator);
00651:     wxTextCtrlSliderPairSliderValidator * TextCtrlSliderPairSliderValidator =
00652:       (wxTextCtrlSliderPairSliderValidator *) (**SliderCtrl).GetValidator();
00653:     wxTextCtrlSliderPairTextCtrlValidator * TextCtrlSliderPairTextCtrlValidator =
00654:       (wxTextCtrlSliderPairTextCtrlValidator *) (**TextCtrl).GetValidator();
00655: 
00656:     if (TextCtrlSliderPairSliderValidator)
00657:       TextCtrlSliderPairSliderValidator -> setAssociatedTextCtrlValidator (TextCtrlSliderPairTextCtrlValidator);
00658: 
00659:     if (TextCtrlSliderPairTextCtrlValidator)
00660:       TextCtrlSliderPairTextCtrlValidator -> setAssociatedSliderValidator (TextCtrlSliderPairSliderValidator);
00661: 
00662:     return SizerAdder -> getSizer();
00663: }
00664: 
00665: //-------------------------------------------------------------------------
00666: 
00667: wxListBox * wxExtDlgBase::addListBox
00668:    (
00669:     wxListBox ** ListBox, const wxValidator & Validator,
00670:     int ChoiceCount, const wxString ChoiceStringArray [],
00671:     const wxSize& Size,
00672:     const wxSizerAdderProxy & SizerAdderProxy
00673:     )
00674: {
00675:     wxSizerAdder AlternativeSizerAdder;
00676:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00677: 
00678:     wxSize UsedSize = getSizeFromDefaults (Size, m_DefaultListBoxSize);
00679: 
00680:     long WindowStyle = 0;
00681:     *ListBox = new wxListBox (getAddParentWindow (SizerAdder), -1,
00682:                               wxDefaultPosition, UsedSize,
00683:                               ChoiceCount, ChoiceStringArray,
00684:                               WindowStyle, Validator);
00685: 
00686:     return *ListBox;
00687: }
00688: 
00689: //-------------------------------------------------------------------------
00690: 
00691: wxChoice * wxExtDlgBase::addChoiceCtrl
00692:    (
00693:     wxChoice ** ChoiceCtrl, const wxValidator & Validator,
00694:     int ChoiceCount, const wxString ChoiceStringArray [],
00695:     const wxSize& Size,
00696:     const wxSizerAdderProxy & SizerAdderProxy
00697:     )
00698: {
00699:     wxSizerAdder AlternativeSizerAdder;
00700:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00701: 
00702:     wxSize UsedSize = getSizeFromDefaults (Size, m_DefaultChoiceCtrlSize);
00703: 
00704:     long WindowStyle = 0;
00705:     *ChoiceCtrl = new wxChoice (getAddParentWindow (SizerAdder), -1,
00706:                                 wxDefaultPosition, UsedSize,
00707:                                 ChoiceCount, ChoiceStringArray,
00708:                                 WindowStyle, Validator);
00709: 
00710:     return *ChoiceCtrl;
00711: }
00712: 
00713: wxSizer * wxExtDlgBase::addChoiceCtrlWithLabel (wxChoice ** ChoiceCtrl,
00714:                                              const wxString & LabelString, 
00715:                                              const wxValidator & Validator,
00716:                                              int ChoiceCount, const wxString ChoiceStringArray [],
00717:                                              const wxSize & Size,
00718:                                              const wxSizerAdderProxy & SizerAdderProxy)
00719: {
00720:     wxSizerAdder AlternativeSizerAdder;
00721:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00722: 
00723:     // if (Sizer == NULL)
00724:     // {
00725:     //    Sizer = new wxBoxSizer (wxHORIZONTAL);
00726:     //  }
00727:     if (! LabelString.IsEmpty())
00728:       {
00729:         SizerAdder -> addWindow (new wxStaticText (getAddParentWindow (SizerAdder), -1, LabelString),
00730:                                  wxRIGHT|wxALIGN_CENTER_VERTICAL, _B(8));
00731:       }
00732: 
00733:     SizerAdder -> addWindow (addChoiceCtrl (ChoiceCtrl, Validator,
00734:                                             ChoiceCount, ChoiceStringArray,
00735:                                             Size),
00736:                              wxALIGN_CENTER_VERTICAL, _B(8));
00737:     
00738:     return SizerAdder -> getSizer();
00739: }
00740: 
00741: //-------------------------------------------------------------------------
00742: 
00743: wxComboBox * wxExtDlgBase::addComboBox
00744:    (
00745:     wxComboBox ** ComboBox, const wxValidator & Validator,
00746:     int StringCount, const wxString StringArray [],
00747:     const wxSize& Size,
00748:     const wxSizerAdderProxy & SizerAdderProxy
00749:     )
00750: {
00751:     wxSizerAdder AlternativeSizerAdder;
00752:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00753: 
00754:     wxSize UsedSize = getSizeFromDefaults (Size, m_DefaultComboBoxSize);
00755: 
00756:     long WindowStyle = 0;
00757:     *ComboBox = new wxComboBox (getAddParentWindow (SizerAdder), -1, "",
00758:                                 wxDefaultPosition, UsedSize,
00759:                                 StringCount, StringArray,
00760:                                 WindowStyle, Validator);
00761: 
00762:     return *ComboBox;
00763: }
00764: 
00765: wxSizer * wxExtDlgBase::addComboBoxWithLabel (wxComboBox ** ComboBox,
00766:                                              const wxString & LabelString, 
00767:                                              const wxValidator & Validator,
00768:                                              int StringCount, const wxString StringArray [],
00769:                                              const wxSize & Size,
00770:                                              const wxSizerAdderProxy & SizerAdderProxy)
00771: {
00772:     wxSizerAdder AlternativeSizerAdder;
00773:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00774: 
00775:     // if (Sizer == NULL)
00776:     // {
00777:     // Sizer = new wxBoxSizer (wxHORIZONTAL);
00778:     // }
00779:     if (! LabelString.IsEmpty())
00780:       {
00781:         SizerAdder -> addWindow (new wxStaticText (getAddParentWindow (SizerAdder), -1, LabelString),
00782:                                  wxRIGHT|wxALIGN_CENTER_VERTICAL, _B(8));
00783:       }
00784: 
00785:     SizerAdder -> addWindow (addComboBox (ComboBox, Validator,
00786:                                           StringCount, StringArray,
00787:                                           Size),
00788:                              wxALIGN_CENTER_VERTICAL, _B(8));
00789:     
00790:     return SizerAdder -> getSizer();
00791: }
00792: 
00793: //-------------------------------------------------------------------------
00794: 
00795: // DEF if (ImageDataSize==-1) then ImageData is the name of a
00796: // resource RCDATA (raw data) block
00797: wxSizer * wxExtDlgBase::addStaticBitmap (wxStaticBitmap ** StaticBitmapPtr,
00798:                                         const unsigned char * ImageData,
00799:                                         size_t ImageDataSize,
00800:                                         const wxPoint& Position,
00801:                                         const wxSize& Size,
00802:                                         const wxSizerAdderProxy & SizerAdderProxy,
00803:                                         long WindowStyle)
00804: {
00805:     wxSizerAdder AlternativeSizerAdder;
00806:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00807: 
00808:     for_once
00809:       {
00810:         // if (Sizer == NULL)
00811:         //  {
00812:         //    Sizer = new wxBoxSizer (wxHORIZONTAL);
00813:         //    if (Sizer == NULL)
00814:         //      break;
00815:         //  }
00816: 
00817:         wxBitmap * Bitmap = NULL;
00818: 
00819:         if (cast_is_equal (ImageDataSize, -2))
00820:           {
00821:             // transport Bitmap pointer in ImageData const unsigned char pointer
00822:             Bitmap = (wxBitmap *) ImageData;
00823:           }
00824:         else if (cast_is_not_equal (ImageDataSize, -1))
00825:           {
00826:             if (!loadBitmapFromMemory (ImageData, ImageDataSize, & Bitmap))
00827:               break;
00828:           }
00829:         else
00830:           {
00831: #if defined(__WXMSW__)
00832:             if (!loadBitmapFromResource (ImageData, & Bitmap))
00833:               break;
00834: #endif // defined(__WXMSW__)
00835:           }
00836: 
00837:         if (Bitmap == NULL)
00838:           break;
00839: 
00840:         wxSize BitmapSize (Bitmap -> GetWidth(), Bitmap -> GetHeight());
00841:         wxSize UsedSize = getSizeFromAspectRatio (Size, BitmapSize);
00842: 
00843:         wxStaticBitmap * StaticBitmap = new wxStaticBitmap (getAddParentWindow (SizerAdder), -1, *Bitmap, 
00844:                                                             Position, UsedSize, WindowStyle);
00845:         if (StaticBitmap == NULL)
00846:           break;
00847: 
00848:         SizerAdder -> addWindow (StaticBitmap, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, _B(0));
00849:         
00850:         if (StaticBitmapPtr != NULL)
00851:           *StaticBitmapPtr = StaticBitmap;
00852:       }
00853: 
00854:     return SizerAdder -> getSizer();
00855: }
00856: 
00857: wxSizer * wxExtDlgBase::addStaticBitmap (wxStaticBitmap ** StaticBitmapPtr,
00858:                                         const char * ResourceNameString,
00859:                                         const wxPoint& Position,
00860:                                         const wxSize& Size,
00861:                                         const wxSizerAdderProxy & SizerAdderProxy,
00862:                                         long WindowStyle)
00863: {
00864:     wxSizerAdder AlternativeSizerAdder;
00865:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00866: 
00867:     return addStaticBitmap (StaticBitmapPtr, 
00868:                             (const unsigned char *) ResourceNameString, cast_unsigned (-1),
00869:                             Position, Size, SizerAdder, WindowStyle);
00870: }
00871: 
00872: wxSizer * wxExtDlgBase::addStaticBitmap (wxStaticBitmap ** StaticBitmapPtr,
00873:                                         wxBitmap * Bitmap,
00874:                                         const wxPoint& Position,
00875:                                         const wxSize& Size,
00876:                                         const wxSizerAdderProxy & SizerAdderProxy,
00877:                                         long WindowStyle)
00878: {
00879:     wxSizerAdder AlternativeSizerAdder;
00880:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00881: 
00882:     // transport Bitmap pointer in ImageData const unsigned char pointer
00883:     return addStaticBitmap (StaticBitmapPtr, 
00884:                             (const unsigned char *) Bitmap, cast_unsigned (-2),
00885:                             Position, Size, SizerAdder, WindowStyle);
00886: }
00887: 
00888: //-------------------------------------------------------------------------
00889: 
00890: wxMultiLineText * wxExtDlgBase::createErrorMessageCtrl (wxMultiLineText * ErrorMessageMultiLineTextPtr,
00891:                                                        int LineCount)
00892: {
00893:     wxMultiLineText & ErrorMessageMultiLineText = *ErrorMessageMultiLineTextPtr;
00894:     wxSize Size (1 /* width: -1 worked for wxTextCtrl but doesn't for wxHtmlWindow */, 
00895:                  getAdjustedTextCtrlHeight (LineCount, true) /* height */);
00896: 
00897:     // flags used for wxTextCtrl were: wxTE_READONLY | wxTE_LINEWRAP | wxTE_MULTILINE | wxVSCROLL
00898:     addMultiLineText (& ErrorMessageMultiLineText, 
00899:                       0,
00900:                       Size,
00901:                       0);
00902: 
00903:     return ErrorMessageMultiLineTextPtr;
00904:     
00905: }
00906: 
00907: //-------------------------------------------------------------------------
00908: 
00909: void wxExtDlgBase::addFlexGridSizer (wxFlexGridSizer ** FlexGridSizer,
00910:                                     int Columns, int VGap, int HGap)
00911: {
00912:     *FlexGridSizer = new wxFlexGridSizer (Columns, VGap, HGap);
00913: }
00914: 
00915: void wxExtDlgBase::addFlexGridSizer (wxFlexGridSizer ** FlexGridSizer,
00916:                                     int Columns, int VGap, int HGap,
00917:                                     wxSizer * OuterSizer, int AddFlags, int AddBorder)
00918: {
00919:     *FlexGridSizer = new wxFlexGridSizer (Columns, VGap, HGap);
00920: 
00921:     OuterSizer -> Add (*FlexGridSizer, 0, AddFlags, AddBorder);
00922: }
00923: 
00924: void wxExtDlgBase::addStaticBox (wxFlexGridSizer ** FlexGridSizer,
00925:                                 const wxString & LabelString,
00926:                                 int Columns, int VGap, int HGap,
00927:                                 wxSizer * OuterSizer, int AddFlags, int AddBorder,
00928:                                 const wxSizerAdderProxy & SizerAdderProxy)
00929: {
00930:     wxSizerAdder AlternativeSizerAdder;
00931:     wxSizerAdder * SizerAdder = SizerAdderProxy.makeSizerAdder(AlternativeSizerAdder);
00932: 
00933:     wxStaticBoxSizer *StaticBoxSizer
00934:       = new wxStaticBoxSizer (new wxStaticBox (getAddParentWindow (SizerAdder), -1, LabelString), wxVERTICAL);
00935: 
00936:     *FlexGridSizer = new wxFlexGridSizer (Columns, VGap, HGap);
00937: 
00938:     StaticBoxSizer -> Add (*FlexGridSizer, 0, wxALL|wxEXPAND, _B(5));
00939: 
00940:     OuterSizer -> Add (StaticBoxSizer, 0, AddFlags, AddBorder);
00941: }
00942: 
00943: //-------------------------------------------------------------------------
00944: 
00945: wxFont wxExtDlgBase::createDialogFont (int PointSize, int Family, int Style, int Weight,
00946:                                     const bool IsUnderlined, const wxString& FaceName,
00947:                                     wxFontEncoding Encoding, int * RequestedPointSize,
00948:                                     bool IsCreateFont)
00949: {
00950:     const char * UsedFaceNameString = FaceName;
00951: 
00952:     int MinReadablePointSize = 3; // probably not a sensible value
00953: 
00954: #if defined(__WXMSW__)
00955: 
00956:     if (Family == wxDEFAULT && 
00957:         (Weight == wxNORMAL || Weight == wxBOLD))
00958:       {
00959:         // this is the minimal readable font size at least for some wxSWISS
00960:         // font face under Windows 
00961:         // MinReadablePointSize = 7;
00962: 
00963:         // this is the minimal readable font size at least for 'Small Fonts'
00964:         // under Windows 
00965:         MinReadablePointSize = 6;
00966: 
00967:         if (PointSize <= 7)
00968:           {
00969:             UsedFaceNameString = "Small Fonts";
00970:             // ?? Family=wxSWISS;
00971:           }
00972:         else if (PointSize == 8 || PointSize == 10 || PointSize == 12)
00973:           {
00974:             UsedFaceNameString = "MS Sans Serif";
00975:             // ?? Family=wxSWISS;
00976:           }
00977:         else
00978:           {
00979:             // because wxDEFAULT will override requested point size and there seems to
00980:             // be only one size available for wxDEFAULT (9), we must specify an other 
00981:             // (similar) font family if we want other font sizes than the only
00982:             // one available for the wxDEFAULT font
00983:             Family=wxSWISS;
00984: 
00985:             // NOTE the same problem may exist for other parameters (e.g. wxITALIC),
00986:             // may have to apply similar modification of font family (TODO)
00987:           }
00988: 
00989:         if (FaceName == "Small Fonts")
00990:           {
00991:             // these font sizes look ugly, so use the next smaller size instead:
00992:             excludeRange (PointSize, 8, 127);
00993:           }
00994:         else if (FaceName == "MS Sans Serif")
00995:           {
00996:           }
00997: 
00998:       }
00999: 
01000: #elif (defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXX11__))
01001: 
01002:     if (Family == wxDEFAULT && 
01003:         (Weight == wxNORMAL || Weight == wxBOLD))
01004:       {
01005: 
01006:         // 8 seems to be the minimal readable font size under X (no font name provided) 
01007:         // (not much testing done to find special fonts which are readable
01008:         // at smaller sizes)
01009:         MinReadablePointSize = 8;
01010: 
01011:         // these font sizes look ugly, so use the next smaller size instead:
01012:         excludeRange (PointSize, 9);
01013:         excludeRange (PointSize, 15);
01014:         excludeRange (PointSize, 17);
01015:         excludeRange (PointSize, 19, 23);
01016:         excludeRange (PointSize, 25, 29);
01017: 
01018:         // could try 'xfontsel' to look for a nicely scaling font for big font
01019:         // sizes
01020: 
01021: //      if (PointSize > 12)
01022: //        {
01023: //          // bigger font sizes don't look well - no scalable fonts seem to
01024: //          // be used - specfiying wxSWISS doesn't help either (scope: GTK 1.2.7)
01025: //          Family = wxSWISS;
01026: //        }
01027:       }
01028: 
01029:     // UsedFaceNameString = wxEmptyString;
01030:     // TEST:
01031:     // encoding = wxFONTENCODING_DEFAULT;
01032: 
01033: // #elif defined(__WXX11__)
01034: 
01035: #else
01036: #   pragma message ("Please adjust function createDialogFont() for your wxWindows port.")
01037: #endif
01038: 
01039:     if (PointSize < MinReadablePointSize)
01040:       {
01041:         PointSize = MinReadablePointSize;
01042:       }
01043: 
01044:     if (RequestedPointSize != NULL)
01045:       *RequestedPointSize = PointSize;
01046: 
01047:     if (IsCreateFont)
01048:       {
01049:         wxFont TempFont (PointSize,
01050:                          Family, Style, Weight,
01051:                          IsUnderlined, UsedFaceNameString,
01052:                          Encoding);
01053:         // wxString NativeFontInfoDescString = TempFont.GetNativeFontInfoDesc ();
01054:         // int ActualPointSize = TempFont.GetPointSize ();
01055: 
01056:         return TempFont;
01057:       }
01058:     else
01059:       {
01060:         return wxNullFont;
01061:       }
01062: }
01063: 
01064: //-------------------------------------------------------------------------
01065: 
01066: void wxExtDlgBase::excludeRange (int & PointSize, int ExcludeRangeMin, int ExcludeRangeMax)
01067: {
01068:     if (ExcludeRangeMax == -1)
01069:       ExcludeRangeMax = ExcludeRangeMin;
01070: 
01071:     if (PointSize >= ExcludeRangeMin
01072:         && PointSize <= ExcludeRangeMax)
01073:       PointSize = ExcludeRangeMin - 1;
01074: }
01075: 
01076: //-------------------------------------------------------------------------
01077: 
01078: void wxExtDlgBase::adjustMultiLineTextSize (wxMultiLineText & MultiLineText,
01079:                                          int MinLineCount, int MaxLineCount)
01080: {
01081:   int Height = getAdjustedTextCtrlHeight (/* LineCount */ 1, true);
01082:   if (MultiLineText.getTextCtrl() != NULL)
01083:     {
01084:       wxTextCtrl * TextCtrl = MultiLineText.getTextCtrl();
01085:       // adjust size of TextCtrl:
01086:       //
01087:       // under WXGTK, the function GetNumberOfLines() will only count the number
01088:       // of newline characters in the text, which is not really useful since with
01089:       // wxTE_LINEWRAP the number of lines after doing the linebreak will usually
01090:       // differ from the number of newline characters in the text
01091:       // int LineCount = 7;
01092:       //
01093:       // under MSW, the number of lines actually used (after the (Rich) text control 
01094:       // does linebreak internally) can be obtained with GetNumberOfLines(). 
01095:       //
01096:       // since now we doTextLineWrap(), the number of newline-characters
01097:       // is the same as the number of lines after wrapping also for GTK,
01098:       // Lesstif/Motif, X11
01099:       int LineCount = TextCtrl -> GetNumberOfLines();
01100: 
01101:       if (LineCount < MinLineCount)
01102:         LineCount = MinLineCount;
01103: 
01104:       // limit height of wxTextCtrl:
01105:       if (LineCount > MaxLineCount)
01106:         LineCount = MaxLineCount;
01107: 
01108:       // NOTE getAdjustedTextCtrlHeight (LineCount, 1)
01109:       // is not fully correct here, because the font height of the
01110:       // wxTextCtrl may be different from the font height specified
01111:       // for the dialog
01112: 
01113:       Height = getAdjustedTextCtrlHeight (LineCount, true);
01114:     }
01115:   else if (MultiLineText.getHtmlWindow() != NULL)
01116:     {
01117:       wxHtmlWindow * HtmlWindow = MultiLineText.getHtmlWindow();
01118: 
01119:       int MinHeight = getAdjustedTextCtrlHeight (MinLineCount, true); // WARN
01120:       int MaxHeight = getAdjustedTextCtrlHeight (MaxLineCount, true); // WARN
01121: 
01122:       // the required height for the HTML text is contained
01123:       // in the outermost HTML cell's height member
01124:       wxHtmlContainerCell * Cell = HtmlWindow -> GetInternalRepresentation();
01125:       int RenderedHeight = Cell -> GetHeight();
01126:       
01127:       if (RenderedHeight < MinHeight)
01128:         Height = MinHeight;
01129:       else if (RenderedHeight > MaxHeight)
01130:         Height = MaxHeight;
01131:       else
01132:         Height = RenderedHeight;
01133: 
01134:     }
01135: 
01136:   wxWindow * Window = MultiLineText.getWindow();
01137:   wxSize WindowSize = Window -> GetSize ();
01138:   WindowSize.SetHeight (Height);
01139:   Window -> SetSize (WindowSize);
01140: 
01141:   // if the window is already assigned to a sizer, the associated
01142:   // sizer's minimum size must be updated as well (it would otherwise
01143:   // override the size specified via wxWindow::SetSize() above)
01144:   wxSizer * ContainingSizer = Window -> GetContainingSizer();
01145:   if (ContainingSizer != NULL)
01146:     {
01147:       ContainingSizer -> SetItemMinSize (Window, WindowSize);
01148:     }
01149: }
01150: 
01151: //-------------------------------------------------------------------------
01152: 
01153: int wxExtDlgBase::getAdjustedBorderSize (int BorderSize)
01154: {
01155:     // int AdjustedBorderSize = m_BorderCompressionValue * BorderSize;
01156:     int AdjustedBorderSize;
01157: 
01158:     if (BorderSize == 0)
01159:       return 0;
01160: 
01161:     AdjustedBorderSize = (BorderSize * m_DialogFontSize) / DefaultDialogFontSize;
01162: 
01163:     if (m_BorderCompressionValue < 1 /*&& m_IsBorderHyperZoom*/)
01164:       {
01165:         double AdjustedBorderSizeDouble = AdjustedBorderSize;
01166:         cast_round_assign (AdjustedBorderSize, pow (AdjustedBorderSizeDouble, m_BorderCompressionValue));
01167:       }
01168:     else
01169:       {
01170:         cast_round_assign (AdjustedBorderSize, AdjustedBorderSize * m_BorderCompressionValue);
01171:       }
01172:     // if the border size was greater zero, the adjusted size shall be
01173:     // at least 1 (pixel)
01174:     if (AdjustedBorderSize < 1)
01175:       AdjustedBorderSize = 1;
01176:     return AdjustedBorderSize;
01177: }
01178: 
01179: int wxExtDlgBase::getAdjustedTextCtrlWidth (int TextCtrlWidth)
01180: {
01181:     return getAdjustedFontLikeWidth (TextCtrlWidth);
01182: }
01183: 
01184: int wxExtDlgBase::getAdjustedTextCtrlHeight (int TextCtrlHeight, bool IsFromLineCount)
01185: {
01186:     // TODO: calculation should include type of border and font set
01187:     // for the used control
01188: #if defined(__WXMSW__)
01189:     int TotalBorderingHeight = 10;
01190: #elif defined(__WXMOTIF__)
01191:     int TotalBorderingHeight = 18;
01192: #elif defined(__WXGTK__)
01193:     int TotalBorderingHeight = 18;
01194: #else
01195: #   pragma message ("Please adjust function getAdjustedTextCtrlHeight() for your wxWindows port.")
01196:     int TotalBorderingHeight = 10;
01197: #endif
01198: 
01199:     if (IsFromLineCount)
01200:       {
01201:         int LineCount = TextCtrlHeight;
01202: 
01203: #if defined(__WXMOTIF__)
01204:         // under Lesstif(Motif?), requests to set a different font for
01205:         // wxTextCtrl are ignored so always some fixed char width font is used
01206:         int FontHeight = 12;
01207: #else
01208:         int FontHeight = getDialogFontHeight();
01209: #endif
01210: 
01211: #if defined(__WXMSW__)
01212:         int LineSpacing = 2;
01213: #elif defined(__WXMOTIF__)
01214:         int LineSpacing = 1;
01215: #elif defined(__WXGTK__)
01216:         int LineSpacing = 0;
01217: #else
01218: #       pragma message "Please adjust function getAdjustedTextCtrlHeight() for your wxWindows port."
01219:         int LineSpacing = 0;
01220: #endif
01221: 
01222:         int TotalHeight = TotalBorderingHeight;
01223: //      if (LineCount >= 1)
01224: //        TotalHeight += (FontHeight) * LineCount
01225: //          + LineSpacing * (LineCount - 1);
01226:         if (LineCount >= 1)
01227:           {
01228:             TotalHeight += (FontHeight + LineSpacing) * (LineCount -1)
01229:               + getDialogFontSize();
01230:           }
01231: 
01232:         return TotalHeight;
01233:       }
01234:     else
01235:       return getAdjustedFontLikeHeight (TextCtrlHeight - TotalBorderingHeight) + TotalBorderingHeight;
01236: }
01237: 
01238: int wxExtDlgBase::getAdjustedChoiceCtrlWidth (int ChoiceCtrlWidth)
01239: {
01240:     return getAdjustedFontLikeWidth (ChoiceCtrlWidth);
01241: }
01242: 
01243: int wxExtDlgBase::getAdjustedChoiceCtrlHeight (int ChoiceCtrlHeight, bool IsFromLineCount)
01244: {
01245:     // HACK just use text ctrl height calculation plus fixed offset
01246:     return getAdjustedTextCtrlHeight (ChoiceCtrlHeight, IsFromLineCount) + 2;
01247: }
01248: 
01249: int wxExtDlgBase::getAdjustedListBoxWidth (int ListBoxWidth)
01250: {
01251:     return getAdjustedFontLikeWidth (ListBoxWidth);
01252: }
01253: 
01254: int wxExtDlgBase::getAdjustedListBoxHeight (int ListBoxHeight, bool IsFromLineCount)
01255: {
01256:     // HACK just use text ctrl height calculation plus fixed offset
01257:     return getAdjustedTextCtrlHeight (ListBoxHeight, IsFromLineCount) + 2;
01258: }
01259: 
01260: int wxExtDlgBase::getAdjustedComboBoxWidth (int ComboBoxWidth)
01261: {
01262:     return getAdjustedFontLikeWidth (ComboBoxWidth);
01263: }
01264: 
01265: int wxExtDlgBase::getAdjustedComboBoxHeight (int ComboBoxHeight, bool IsFromLineCount)
01266: {
01267:     // HACK just use text ctrl height calculation plus fixed offset
01268:     return getAdjustedTextCtrlHeight (ComboBoxHeight, IsFromLineCount) + 2;
01269: }
01270: 
01271: int wxExtDlgBase::getAdjustedButtonWidth (int ButtonWidth)
01272: {
01273:     return getAdjustedFontLikeWidth (ButtonWidth);
01274: }
01275: 
01276: int wxExtDlgBase::getAdjustedButtonHeight ()
01277: {
01278: #if defined(__WXMOTIF__)
01279:     // NOTE Lesstif(Motif?) uses a lot of space around the actual
01280:     // button to indicate which is the default button. If a dialog
01281:     // has a default button, the actual (visible) button height
01282:     // is much smaller than the provided height. If there is no
01283:     // default button, the button has a large height. Unfortunately,
01284:     // here we cannot know if the dialog will get any default buttons, 
01285:     // so must assume that there might be any.
01286:     return m_DialogFontSize + 28;
01287: #elif defined(__WXMSW__)
01288:     return m_DialogFontSize + 16;
01289: #elif defined(__WXGTK__)
01290:     return m_DialogFontSize + 20;
01291: #elif defined(__WXX11__)
01292: #   pragma message "Please adjust function getAdjustedButtonHeight() for your wxWindows port."
01293:     return m_DialogFontSize + 12;
01294: #else
01295: #   pragma message "Please adjust function getAdjustedButtonHeight() for your wxWindows port."
01296:     return m_DialogFontSize + 12;
01297: #endif
01298: }
01299: 
01300: int wxExtDlgBase::getAdjustedSliderWidth (int SliderWidth, bool IsVertical)
01301: {
01302:     int AdjustedSliderWidth;
01303:     if (!IsVertical)
01304:       AdjustedSliderWidth = getAdjustedProportionalWidth (SliderWidth);
01305:     else
01306:       AdjustedSliderWidth = getAdjustedFontLikeHeight (SliderWidth);
01307: 
01308:     return AdjustedSliderWidth;
01309: }
01310: 
01311: int wxExtDlgBase::getAdjustedSliderHeight (int SliderHeight, bool IsVertical)
01312: {
01313:     int AdjustedSliderHeight;
01314: 
01315:     if (!IsVertical)
01316:       AdjustedSliderHeight = getAdjustedFontLikeHeight (SliderHeight);
01317:     else
01318:       AdjustedSliderHeight = getAdjustedProportionalHeight (SliderHeight);
01319:     
01320:     return AdjustedSliderHeight;
01321: }
01322: 
01323: int wxExtDlgBase::getAdjustedBitmapWidth (int BitmapWidth)
01324: {
01325:     return getAdjustedProportionalWidth (BitmapWidth);
01326: }
01327: 
01328: int wxExtDlgBase::getAdjustedBitmapHeight (int BitmapHeight)
01329: {
01330:     return getAdjustedProportionalHeight (BitmapHeight);
01331: }
01332: 
01333: //-------------------------------------------------------------------------
01334: 
01335: int wxExtDlgBase::getDefaultDialogFontSize ()
01336: {
01337:     return DefaultDialogFontSize;
01338: }
01339: 
01340: int wxExtDlgBase::getDialogFontSize ()
01341: {
01342:     return m_DialogFontSize;
01343: }
01344: 
01345: int wxExtDlgBase::getDialogFontHeight ()
01346: {
01347:     return m_DialogFontHeight;
01348: }
01349: 
01350: void wxExtDlgBase::setIsSetFontIfSameAsDefaultSize (bool IsSetFontIfSameAsDefaultSize)
01351: {
01352:     m_IsSetFontIfSameAsDefaultSize = IsSetFontIfSameAsDefaultSize;
01353: }
01354: 
01355: //-------------------------------------------------------------------------
01356: 
01357: int wxExtDlgBase::getAdjustedProportionalWidth(int Width)
01358: {
01359:     int AdjustedWidth;
01360: 
01361:     cast_round_assign (AdjustedWidth, Width * m_ZoomValue);
01362: 
01363:     return AdjustedWidth;
01364: }
01365: 
01366: int wxExtDlgBase::getAdjustedProportionalHeight(int Height)
01367: {
01368:     int AdjustedHeight;
01369: 
01370:     cast_round_assign (AdjustedHeight, Height * m_ZoomValue);
01371: 
01372:     return AdjustedHeight;
01373: }
01374: 
01375: int wxExtDlgBase::getAdjustedFontLikeWidth(int Width)
01376: {
01377:     int AdjustedWidth;
01378: 
01379:     AdjustedWidth = (Width * m_DialogFontSize) / DefaultDialogFontSize;
01380: 
01381:     return AdjustedWidth;
01382: }
01383: 
01384: int wxExtDlgBase::getAdjustedFontLikeHeight(int Height)
01385: {
01386:     int AdjustedHeight;
01387: 
01388:     AdjustedHeight = (Height * m_DialogFontSize) / DefaultDialogFontSize;
01389: 
01390:     return AdjustedHeight;
01391: }
01392: 
01393: //-------------------------------------------------------------------------
01394: 
01395: void wxExtDlgBase::setDefaultButtonSize (int Width, int Height)
01396: {
01397:     m_DefaultButtonSize = wxSize (Width, Height);
01398: }
01399: 
01400: //-------------------------------------------------------------------------
01401: 
01402: void wxExtDlgBase::setHtmlWindowFonts (wxHtmlWindow * HtmlWindow,
01403:                                     int BaseSize,
01404:                                     bool IsUseReadableFontSizes,
01405:                                     bool IsUseScaleableFont)
01406: {
01407: 
01408:     int FontSizeArray [7];
01409: 
01410:     cast_round_assign (FontSizeArray [0], BaseSize * 0.7);
01411:     cast_round_assign (FontSizeArray [1], BaseSize * 0.85);
01412:     cast_round_assign (FontSizeArray [2], BaseSize * 1.0);
01413:     cast_round_assign (FontSizeArray [3], BaseSize * 1.2);
01414:     cast_round_assign (FontSizeArray [4], BaseSize * 1.4);
01415:     cast_round_assign (FontSizeArray [5], BaseSize * 2.0);
01416:     cast_round_assign (FontSizeArray [6], BaseSize * 2.5);
01417: 
01418:     int Family = 0;
01419:     wxString FaceName;
01420:     if (IsUseScaleableFont)
01421:       {
01422:         Family = wxSWISS;
01423:       }
01424:     else
01425:       {
01426:         Family = wxDEFAULT;
01427:         FaceName = getDialog() -> GetFont().GetFaceName();
01428:       }
01429: 
01430:     if (IsUseReadableFontSizes)
01431:       {
01432:         for (int Index=0; cast_is_smaller (Index, WXSIZEOF(FontSizeArray)); ++Index)
01433:           {
01434:             int RequestedPointSize = 0;
01435:             createDialogFont (FontSizeArray[Index],
01436:                               Family,
01437:                               wxNORMAL /* upright/slant/italic */, 
01438:                               wxNORMAL /* weight */,
01439:                               false /* underlined? */, 
01440:                               FaceName /* face name */,
01441:                               wxFONTENCODING_DEFAULT /* wxFONTENCODING_ISO8859_1 */,
01442:                               & RequestedPointSize,
01443:                               false /* create font? */);
01444:                               
01445:             FontSizeArray[Index] = RequestedPointSize;
01446:           }
01447:       }
01448: 
01449:     HtmlWindow -> SetFonts (FaceName, "", FontSizeArray);
01450: }
01451: 
01452: //-------------------------------------------------------------------------
01453: 
01454: double wxExtDlgBase::getZoom ()
01455: {
01456:     double GlobalZoom = m_GlobalDialogZoom;
01457:     double DialogZoom = m_DialogZoomValue;
01458:     if (m_GlobalDesktopReferenceSize != wxSize (-1, -1)
01459:         || m_DesktopReferenceSize != wxSize (-1, -1))
01460:       {
01461:         int Width = 0;
01462:         int Height = 0;
01463:         wxClientDisplayRect (NULL, NULL, & Width, & Height);
01464: 
01465:         wxSize DesktopReferenceSize = m_GlobalDesktopReferenceSize;
01466:         if (m_DesktopReferenceSize != wxSize (-1, -1))
01467:           DesktopReferenceSize = m_DesktopReferenceSize;
01468: 
01469:         double WidthRatio = Width / ((double) DesktopReferenceSize.GetWidth());
01470:         double HeightRatio = Height / ((double) DesktopReferenceSize.GetHeight());
01471: 
01472:         if (WidthRatio <= HeightRatio)
01473:           GlobalZoom *= WidthRatio;
01474:         else
01475:           GlobalZoom *= HeightRatio;
01476:       }
01477: 
01478:     return DialogZoom * GlobalZoom;
01479: }
01480: 
01481: void wxExtDlgBase::setDialogZoom (double DialogZoomValue)
01482: {
01483:     m_DialogZoomValue = DialogZoomValue;
01484:     m_ZoomValue = getZoom ();
01485: 
01486:     int AdjustedFontSize;
01487:     cast_round_assign (AdjustedFontSize, DefaultDialogFontSize * m_ZoomValue);
01488: 
01489:     if (m_IsSetFontIfSameAsDefaultSize
01490:         || (AdjustedFontSize != DefaultDialogFontSize)
01491:         || (!(getDialog() -> GetFont().Ok())))
01492:       {
01493:         getDialog() -> SetFont (createDialogFont(AdjustedFontSize,
01494:                                                  wxDEFAULT /* family */, 
01495:                                                  wxNORMAL /* upright/slant/italic */, 
01496:                                                  wxNORMAL /* weight */,
01497:                                                  false /* underlined? */, 
01498:                                                  _T("") /* face name */,
01499:                                                  wxFONTENCODING_DEFAULT /* wxFONTENCODING_ISO8859_1 */ ));
01500:       }
01501: 
01502:     // determine actually used font size (may differ from requested size)
01503:     m_DialogFontSize = getDialog() -> GetFont().GetPointSize();
01504: 
01505:     // GetCharHeight() doesn't seem to be sensible for all fonts
01506:     // int CharHeight = GetCharHeight();
01507:     int TextWidth, TextHeight, Descent, ExternalLeading;
01508:     getDialog() -> GetTextExtent ("Ág-test", & TextWidth, & TextHeight, & Descent, & ExternalLeading);
01509:     m_DialogFontHeight = TextHeight;
01510: 
01511:     m_DefaultButtonSize = wxSize (getAdjustedButtonWidth (100), 
01512:                                   getAdjustedButtonHeight());
01513: 
01514:     m_DefaultTextCtrlSize = wxSize (getAdjustedTextCtrlWidth (60),
01515:                                     getAdjustedTextCtrlHeight (1, true));
01516: 
01517:     m_DefaultListBoxSize = wxSize (getAdjustedTextCtrlWidth (80),
01518:                                    getAdjustedTextCtrlHeight (1, true));
01519: 
01520:     m_DefaultChoiceCtrlSize = wxSize (getAdjustedTextCtrlWidth (80),
01521:                                       getAdjustedTextCtrlHeight (1, true));
01522: 
01523:     m_DefaultComboBoxSize = wxSize (getAdjustedTextCtrlWidth (80),
01524:                                     getAdjustedTextCtrlHeight (1, true));
01525: 
01526:     // setBorderZoom (ZoomValue);
01527: }
01528: 
01529: double wxExtDlgBase::getDialogZoom ()
01530: {
01531:     return m_DialogZoomValue;
01532: }
01533: 
01534: double wxExtDlgBase::m_GlobalDialogZoom = 1.;
01535: 
01536: void wxExtDlgBase::setGlobalDialogZoom (double ZoomValue)
01537: {
01538:     m_GlobalDialogZoom = ZoomValue;
01539: }
01540: 
01541: double wxExtDlgBase::getGlobalDialogZoom ()
01542: {
01543:     return m_GlobalDialogZoom;
01544: }
01545: 
01546: void wxExtDlgBase::setDesktopReferenceSize (const wxSize & Size)
01547: {
01548:     m_DesktopReferenceSize = Size;
01549: }
01550: 
01551: wxSize wxExtDlgBase::m_GlobalDesktopReferenceSize = wxSize (-1, -1);
01552: 
01553: void wxExtDlgBase::setGlobalDesktopReferenceSize (const wxSize & Size)
01554: {
01555:     m_GlobalDesktopReferenceSize = Size;
01556: }
01557: 
01558: void wxExtDlgBase::setBorderCompression (double BorderCompressionValue)
01559: {
01560:     m_BorderCompressionValue = BorderCompressionValue;
01561: }
01562: 
01563: //-------------------------------------------------------------------------
01564: 
01565: wxSize wxExtDlgBase::getSizeFromDefaults (const wxSize & Size, const wxSize & DefaultSize)
01566: {
01567:     wxSize UsedSize;
01568:     // if (& Size == & wxDefaultSize)
01569:     if (Size == wxDefaultSize)
01570:       UsedSize = DefaultSize;
01571:     else
01572:       UsedSize = Size;
01573: 
01574:     if (UsedSize.GetWidth () == -1)
01575:       UsedSize.SetWidth (DefaultSize.GetWidth());
01576:     if (UsedSize.GetHeight () == -1)
01577:       UsedSize.SetHeight (DefaultSize.GetHeight());
01578: 
01579:     return UsedSize;
01580: }
01581: 
01582: wxSize wxExtDlgBase::getSizeFromAspectRatio (const wxSize & Size, const wxSize & AspectRatioAsSize)
01583: {
01584:     wxSize UsedSize;
01585:     if (& Size == & wxDefaultSize)
01586:       UsedSize = AspectRatioAsSize;
01587:     else
01588:       UsedSize = Size;
01589: 
01590:     if (UsedSize.GetWidth () == -1)
01591:       UsedSize.SetWidth ((AspectRatioAsSize.GetWidth() * UsedSize.GetHeight()) / AspectRatioAsSize.GetHeight());
01592:     if (UsedSize.GetHeight () == -1)
01593:       UsedSize.SetHeight ((AspectRatioAsSize.GetHeight() * UsedSize.GetWidth()) / AspectRatioAsSize.GetWidth());
01594: 
01595:     return UsedSize;
01596: }
01597: 
01598: //-------------------------------------------------------------------------
01599: 
01600: void wxExtDlgBase::enableWatchedControlChangeNotification (bool IsWatchedControlChangeNotification)
01601: {
01602:     m_IsWatchedControlChangeNotification = IsWatchedControlChangeNotification;
01603: }
01604: 
01605: void wxExtDlgBase::addWatchedControl(wxWindow * Window)
01606: {
01607:     m_WatchedObjectArray.Add (Window);
01608: }
01609: 
01610: void wxExtDlgBase::handleControlChange(wxCommandEvent& Event)
01611: {
01612:     if (m_IsDialogInitialized 
01613:         && m_IsWatchedControlChangeNotification 
01614:         && m_WatchedObjectArray.Index (Event.GetEventObject()) != wxNOT_FOUND)
01615:       {
01616:         handleWatchedControlChange (Event);
01617:       }
01618: }
01619: 
01620: void wxExtDlgBase::handleWatchedControlChange(wxCommandEvent & WXUNUSED(Event))
01621: {
01622: }
01623: 
01624: //-------------------------------------------------------------------------
01625: 
01626: void wxExtDlgBase::OnCloseEvent (wxCloseEvent & CloseEvent)
01627: {
01628:     handleCloseEvent (CloseEvent);
01629: 
01630:     if (CloseEvent.GetVeto())
01631:       return;
01632: 
01633:     // default handling destroys window then, under the
01634:     // condition that window is modal or in non-modal and
01635:     // contains some button (or control?) with wxID_CANCEL
01636:     // ident (?)
01637:     CloseEvent.Skip();
01638: }
01639: 
01640: //-------------------------------------------------------------------------
01641: 
01642: void wxExtDlgBase::OnTextCtrlChanged(wxCommandEvent& Event)
01643: {
01644:     handleControlChange (Event);
01645:     Event.Skip();
01646: }
01647: 
01648: // void wxExtDlgBase::OnSliderCtrlChanged(wxCommandEvent& Event)
01649: void wxExtDlgBase::OnSliderCtrlChanged(wxScrollEvent & Event)
01650: {
01651:     handleControlChange (Event);
01652:     Event.Skip();
01653: }
01654: 
01655: void wxExtDlgBase::OnRadioButtonSelected(wxCommandEvent& Event)
01656: {
01657:     handleControlChange (Event);
01658:     Event.Skip();
01659: }
01660: 
01661: void wxExtDlgBase::OnRadioBoxSelected(wxCommandEvent& Event)
01662: {
01663:     handleControlChange (Event);
01664:     Event.Skip();
01665: }
01666: 
01667: void wxExtDlgBase::OnCheckBoxSelected(wxCommandEvent& Event)
01668: {
01669:     handleControlChange (Event);
01670:     Event.Skip();
01671: }
01672: 
01673: void wxExtDlgBase::OnComboBoxSelected(wxCommandEvent& Event)
01674: {
01675:     handleControlChange (Event);
01676:     Event.Skip();
01677: }
01678: 
01679: void wxExtDlgBase::OnListBoxSelected(wxCommandEvent& Event)
01680: {
01681:     handleControlChange (Event);
01682:     Event.Skip();
01683: }
01684: 
01685: void wxExtDlgBase::OnChoiceCtrlSelected(wxCommandEvent& Event)
01686: {
01687:     handleControlChange (Event);
01688:     Event.Skip();
01689: }
01690: 
01691: void wxExtDlgBase::OnButtonClicked (wxCommandEvent& Event)
01692: {
01693:     handleControlChange (Event);
01694:     Event.Skip();
01695: }
01696: 
01697: //-------------------------------------------------------------------------
01698: 
01699: bool wxExtDlgBase::TransferDataToWindow()
01700: {
01701:     bool PreviousIsWatchedControlChangeNotification = 
01702:       m_IsWatchedControlChangeNotification;
01703:     m_IsWatchedControlChangeNotification = false;
01704:     bool IsOk = getDialog() -> wxWindow::TransferDataToWindow();
01705:     m_IsWatchedControlChangeNotification =
01706:       PreviousIsWatchedControlChangeNotification;
01707:     return IsOk;
01708: }
01709: 
01710: void wxExtDlgBase::initializeDialog ()
01711: {
01712: #if (defined(__WXMOTIF__) || defined(__WXX11__)) // maybe others required here
01713:     TransferDataToWindow ();
01714: #elif (defined(__WXGTK__) || defined(__WXMSW__))
01715:     // GTK, MSW: TransferDataToWindow() is called by OnInitDialog()
01716:     // OnInitDialog() itself is called automatically after the dialog was 
01717:     // created.
01718: #else
01719: #   pragma message "Please adjust function initializeDialog() for your wxWindows port."
01720:     TransferDataToWindow (); // may not be required here
01721: #endif
01722: }
01723: 
01724: bool wxExtDlgBase::ValidateWithMessageBox(int ReturnCode)
01725: {
01726:     wxDialog * Dialog = wxDynamicCast (getDialog(), wxDialog);
01727:     wxASSERT (Dialog != NULL);
01728: 
01729:     return ::ValidateWithMessageBox (Dialog, (this -> m_StatusMessageTarget), 
01730:                                      ReturnCode);
01731: }
01732: 
01733: //-------------------------------------------------------------------------
01734: 
01735: bool ValidateWithMessageBox(wxWindow * Window, wxStatusMessageTarget * StatusMessageTarget)
01736: {
01737:     bool IsOk;
01738:     if (StatusMessageTarget != NULL)
01739:       StatusMessageTarget -> enableShowMessageBox (true);
01740:     IsOk = Window -> Validate ();
01741:     if (StatusMessageTarget != NULL)
01742:       StatusMessageTarget -> enableShowMessageBox (false);
01743: 
01744:     if (IsOk)
01745:       Window -> TransferDataFromWindow();
01746: 
01747:     return IsOk;
01748: }
01749: 
01750: bool ValidateWithMessageBox(wxDialog * Dialog, wxStatusMessageTarget * StatusMessageTarget, 
01751:                             int ReturnCode)
01752: {
01753:     bool IsOk = ValidateWithMessageBox (Dialog, StatusMessageTarget);
01754: 
01755:     if (IsOk && ReturnCode != -1)
01756:       Dialog -> EndModal (ReturnCode);
01757: 
01758:     return IsOk;
01759: }
01760: 
01761: //=========================================================================
01762: 
01763: IMPLEMENT_CLASS(wxExtDlgBaseEvtHandler, wxEvtHandler)
01764: 
01765: // generic handlers for all controls to allow simplyfied handling
01766: // of all event-types from all controls in a single handler function
01767: BEGIN_EVENT_TABLE (wxExtDlgBaseEvtHandler, wxEvtHandler)
01768:     M_WxExtDlgBase_ImplementWatchedControlChangeEventHandlers(wxExtDlgBaseEvtHandler)
01769: END_EVENT_TABLE()
01770: 
01771: //-------------------------------------------------------------------------
01772: 
01773: wxExtDlgBaseEvtHandler::~wxExtDlgBaseEvtHandler()
01774: {
01775:     m_ExtDlgBase = NULL;
01776: }
01777: 
01778: //=========================================================================
01779: 
01780: wxExtDlgHelper::wxExtDlgHelper()
01781: {
01782:     m_Window = NULL;
01783: }
01784: 
01785: wxExtDlgHelper::~wxExtDlgHelper()
01786: {
01787:     if (m_Window != NULL)
01788:       m_Window -> RemoveEventHandler (& m_ExtDlgBaseEvtHandler);
01789:     m_Window = NULL;
01790: }
01791: 
01792: void wxExtDlgHelper::setup (wxWindow * Window)
01793: {
01794:     // give EvtHelper pointer to wxExtDlgBase so it can forward events
01795:     m_ExtDlgBaseEvtHandler.setExtDlgBase (this);
01796: 
01797:     // setup pointer to dialog/window so getDialog() works, and initialize
01798:     setDialog (Window); 
01799:     initCWxDialog(); 
01800: 
01801:     Window -> PushEventHandler (& m_ExtDlgBaseEvtHandler);
01802: }
01803: 
01804: //=========================================================================
01805: 
01806: IMPLEMENT_DYNAMIC_CLASS(wxExtDialog, wxDialog)
01807: 
01808: // generic handlers for all controls to allow simplyfied handling
01809: // of all event-types from all controls in a single handler function
01810: BEGIN_EVENT_TABLE (wxExtDialog, wxDialog)
01811:     M_WxExtDlgBase_ImplementWatchedControlChangeEventHandlers(wxExtDialog)
01812: END_EVENT_TABLE()
01813: 
01814: //-------------------------------------------------------------------------
01815: 
01816: wxExtDialog::wxExtDialog()
01817: {
01818:     initCWxDialog();
01819: 
01820:     setDialogZoom (1.);
01821: }
01822: 
01823: wxExtDialog::wxExtDialog(wxWindow *parent, wxWindowID id,
01824:                          const wxString& title,
01825:                          const wxPoint& pos,
01826:                          const wxSize& size,
01827:                          long style,
01828:                          const wxString& name)
01829:   : wxDialog (parent, id, title, pos, size, style, name)
01830: {
01831:     initCWxDialog ();
01832: 
01833:     setDialogZoom (1.);
01834: }
01835: 
01836: wxWindow * wxExtDialog::getDialog()
01837: {
01838:     return this; 
01839: }
01840: 
01841: wxExtDialog::~wxExtDialog()
01842: {
01843: }
01844: 
01845: //-------------------------------------------------------------------------
01846: 
01847: void wxExtDialog::InitDialog ()
01848: {
01849:     wxDialog::InitDialog ();
01850:     setDialogInitializedFlag ();
01851: }
01852: 
01853: //-------------------------------------------------------------------------
01854: 
01855: #if wxCHECK_VERSION (2, 8, 0)
01856: // provide old behavior of wxDialog versions before 2.8
01857: void wxExtDialog::OnOK (wxCommandEvent & WXUNUSED (Event))
01858: {
01859:     if (Validate() && TransferDataFromWindow())
01860:       {
01861:         EndDialog(wxID_OK);
01862:       }
01863: }
01864: 
01865: void wxExtDialog::OnCancel (wxCommandEvent & WXUNUSED (Event))
01866: {
01867:     EndDialog (wxID_CANCEL);
01868: }
01869: #endif
01870: 
01871: //-------------------------------------------------------------------------
01872: 
01873: int wxExtDialog::ShowModal ()
01874: {
01875:     Centre (wxBOTH);
01876:     return wxDialog::ShowModal ();
01877: }
01878: 
01879: void wxExtDialog::EndDialog(int ReturnCode)
01880: {
01881:     if (IsModal())
01882:       {
01883:         EndModal (ReturnCode);
01884:       }
01885:     else
01886:       {
01887:         // TODO support other alternative to Hide() for non-modal dialogs:
01888:         // call Close() or Destroy()
01889:         
01890:         Hide();
01891:       }
01892: }
01893: 
01894: //=========================================================================
01895: 
01896: wxSizerAdder::wxSizerAdder()
01897: {
01898:     init ();
01899: }
01900: 
01901: wxSizerAdder::wxSizerAdder (wxSizer * Sizer)
01902: {
01903:     init (Sizer);
01904: }
01905: 
01906: wxSizerAdder::wxSizerAdder (wxSizer * Sizer, int SizerColumnCount, int SizerRowCount)
01907: {
01908:     init (Sizer, SizerColumnCount, SizerRowCount);
01909: }
01910: 
01911: #ifdef M_IsHaveGridBagSizer
01912: wxSizerAdder (wxGridBagSizer * GridBagSizer, int XPos, int YPos, int XSpan, int YSpan)
01913: {
01914:     init (GridBagSizer, XPos, YPos, XSpan, YSpan);
01915: }
01916: #endif
01917: 
01918: //-------------------------------------------------------------------------
01919: 
01920: void wxSizerAdder::init()
01921: {
01922:     m_Sizer = NULL;
01923: #ifdef M_IsHaveGridBagSizer
01924:     m_GridBagSizer = NULL;
01925: #endif
01926: 
01927:     m_SizerGroupSize = -1;
01928:     m_CurrentCount = 0;
01929: 
01930:     m_SizerColumnCount = -1;
01931:     m_SizerRowCount = -1;
01932: }
01933: 
01934: //-------------------------------------------------------------------------
01935: 
01936: void wxSizerAdder::init (wxSizer * Sizer)
01937: {
01938:     init ();
01939:     m_Sizer = Sizer;
01940:     m_ParentWindow = NULL;
01941: }
01942: 
01943: void wxSizerAdder::init (wxSizer * Sizer, int SizerColumnCount, int SizerRowCount)
01944: {
01945:     init ();
01946: 
01947:     m_Sizer = Sizer;
01948:     m_SizerColumnCount = SizerColumnCount;
01949:     m_SizerRowCount = SizerRowCount;
01950: 
01951: }
01952: 
01953: #ifdef M_IsHaveGridBagSizer
01954: void wxSizerAdder::init (wxGridBagSizer * GridBagSizer, int XPos, int YPos, int XSpan, int YSpan)
01955: {
01956:     init ();
01957:     m_GridBagSizer = GridBagSizer;
01958: 
01959:     m_XPos = XPos;
01960:     m_YPos = YPos;
01961:     m_XSpan = XSpan;
01962:     m_YSpan = YSpan;
01963: }
01964: #endif
01965: 
01966: //-------------------------------------------------------------------------
01967: 
01968: wxSizer * wxSizerAdder::getSizer()
01969: {
01970:     return getSizerConst();
01971: }
01972: 
01973: wxSizer * wxSizerAdder::getSizerConst() const
01974: {
01975:     if (m_Sizer != NULL)
01976:       {
01977:         return m_Sizer;
01978:       }
01979: #ifdef M_IsHaveGridBagSizer
01980:     else if (m_GridBagSizer != NULL)
01981:       {
01982:         return m_GridBagSizer;
01983:       }
01984: #endif
01985:     return NULL;
01986: }
01987: 
01988: void wxSizerAdder::setGroupSize (int SizerGroupSize)
01989: {
01990:     m_SizerGroupSize = SizerGroupSize;
01991: }
01992: 
01993: void wxSizerAdder::nextGroup()
01994: {
01995:     if (getSizer() != NULL)
01996:       {
01997:         if (m_SizerGroupSize != -1)
01998:           {
01999:             // if m_SizerGroupSize is defined, we add sizers
02000:             // until next row
02001:             while (true)
02002:               {
02003:                 if (m_CurrentCount % m_SizerGroupSize != 0)
02004:                   {
02005:                     getSizer() -> Add (0, 0);
02006:                     ++ m_CurrentCount;
02007:                   }
02008:                 else
02009:                   break;
02010:               }
02011:           }
02012:       }    
02013: }
02014: 
02015: //-------------------------------------------------------------------------
02016: 
02017: void wxSizerAdder::setColumnGrowable (int ColumnIndex, bool IsGrowable)
02018: {
02019:     wxFlexGridSizer * FlexGridSizer = wxDynamicCast (getSizer(), wxFlexGridSizer);
02020:     if (FlexGridSizer != NULL)
02021:       {
02022:         // int ColumnCount = FlexGridSizer -> GetCols();
02023:         if (true) // (ColumnIndex < ColumnCount)
02024:           {
02025:             if (IsGrowable)
02026:               {
02027:                 FlexGridSizer -> AddGrowableCol (ColumnIndex); // , 1 /* proportion */);
02028:               }
02029:             else
02030:               {
02031:                 FlexGridSizer -> RemoveGrowableCol (ColumnIndex); // , 1 /* proportion */);
02032:               }
02033:           }
02034:       }
02035: }
02036: 
02037: void wxSizerAdder::setRowGrowable (int RowIndex, bool IsGrowable)
02038: {
02039:     wxFlexGridSizer * FlexGridSizer = wxDynamicCast (getSizer(), wxFlexGridSizer);
02040:     if (FlexGridSizer != NULL)
02041:       {
02042:         // int RowCount = FlexGridSizer -> GetRows();
02043:         if (true) // (RowIndex < RowCount)
02044:           {
02045:             if (IsGrowable)
02046:               {
02047:                 FlexGridSizer -> AddGrowableRow (RowIndex); // , 1 /* proportion */);
02048:               }
02049:             else
02050:               {
02051:                 FlexGridSizer -> RemoveGrowableRow (RowIndex); // , 1 /* proportion */);
02052:               }
02053:           }
02054:       }
02055: }
02056: 
02057: void wxSizerAdder::setAllGrowable()
02058: {
02059:     wxFlexGridSizer * FlexGridSizer = wxDynamicCast (getSizer(), wxFlexGridSizer);
02060:     if (FlexGridSizer != NULL)
02061:       {
02062:         int RowCount = FlexGridSizer -> GetRows();
02063:         for (int RowIndex = 0; RowIndex < RowCount; ++RowIndex)
02064:           {
02065:             FlexGridSizer -> AddGrowableRow (RowIndex); // , 1 /* proportion */);
02066:           }
02067:         int ColumnCount = FlexGridSizer -> GetCols();
02068:         for (int ColumnIndex = 0; ColumnIndex < ColumnCount; ++ColumnIndex)
02069:           {
02070:             FlexGridSizer -> AddGrowableCol (ColumnIndex); // , 1 /* proportion */);
02071:           }
02072:       }
02073: }
02074: 
02075: //-------------------------------------------------------------------------
02076: 
02077: // ParentWindow is simply a variable that may be read by wxExtDialog
02078: // control adder functions
02079: void wxSizerAdder::setParentWindow (wxWindow * ParentWindow)
02080: {
02081:     m_ParentWindow = ParentWindow;
02082: }
02083: 
02084: wxWindow * wxSizerAdder::getParentWindow () const
02085: {
02086:     return m_ParentWindow;
02087: }
02088: 
02089: //-------------------------------------------------------------------------
02090: 
02091: void wxSizerAdder::addWindow (wxWindow * Window, int Flags, int Border)
02092: {
02093:     if (m_Sizer != NULL)
02094:       {
02095:         m_Sizer -> Add (Window, 0, Flags, Border);
02096:       }
02097: #ifdef M_IsHaveGridBagSizer
02098:     else if (m_GridBagSizer != NULL)
02099:       {
02100:         m_GridBagSizer -> Add (Window, 0, 
02101:                                wxGBPosition (m_XPos, m_YPos),
02102:                                wxGBSpan (m_XSpan, m_YSpan), 
02103:                                Flags, Border);
02104:       }
02105: #endif
02106: 
02107:     ++m_CurrentCount;
02108: }
02109: 
02110: void wxSizerAdder::addSizer (wxSizer * Sizer, int Flags, int Border)
02111: {
02112:     if (m_Sizer != NULL)
02113:       {
02114:         m_Sizer -> Add (Sizer, 0, Flags, Border);
02115:       }
02116: #ifdef M_IsHaveGridBagSizer
02117:     else if (m_GridBagSizer != NULL)
02118:       {
02119:         m_GridBagSizer -> Add (Window, 0, 
02120:                                wxGBPosition (m_XPos, m_YPos),
02121:                                wxGBSpan (m_XSpan, m_YSpan), 
02122:                                Flags, Border);
02123:       }
02124: #endif
02125: 
02126:     ++m_CurrentCount;
02127: }
02128: 
02129: void wxSizerAdder::addSpace (int Width, int Height, int Flags, int Border)
02130: {
02131:     if (m_Sizer != NULL)
02132:       {
02133:         m_Sizer -> Add (Width, Height, 0, Flags, Border);
02134:       }
02135: #ifdef M_IsHaveGridBagSizer
02136:     else if (m_GridBagSizer != NULL)
02137:       {
02138:         m_GridBagSizer -> Add (Width, Height, 
02139:                                wxGBPosition (m_XPos, m_YPos),
02140:                                wxGBSpan (m_XSpan, m_YSpan), 
02141:                                Flags, Border);
02142:       }
02143: #endif
02144: 
02145:     ++m_CurrentCount;
02146: }
02147: 
02148: //=========================================================================
02149: 
02150: wxSizerAdderProxy::wxSizerAdderProxy ()
02151: {
02152:     m_SizerAdderPtr = NULL;
02153:     m_SizerPtr = NULL;
02154: }
02155: 
02156: wxSizerAdderProxy::wxSizerAdderProxy (wxSizerAdder * SizerAdder)
02157: {
02158:     m_SizerAdderPtr = SizerAdder;
02159:     m_SizerPtr = NULL;
02160: }
02161: 
02162: wxSizerAdderProxy::wxSizerAdderProxy (wxSizer * Sizer)
02163: {
02164:     m_SizerAdderPtr = NULL;
02165:     m_SizerPtr = Sizer;
02166: }
02167: 
02168: wxSizerAdder * wxSizerAdderProxy::makeSizerAdder(wxSizerAdder & AlternativeSizerAdder) const
02169: {
02170:     if (m_SizerAdderPtr != NULL)
02171:       {
02172:         wxASSERT (m_SizerAdderPtr -> getSizerConst() != NULL);
02173:         return m_SizerAdderPtr;
02174:       }
02175: 
02176:     wxSizer * Sizer = m_SizerPtr;
02177:     if (Sizer == NULL)
02178:       {
02179:         Sizer = new wxBoxSizer (wxHORIZONTAL);
02180:       }
02181:     AlternativeSizerAdder.init (Sizer);
02182:     wxASSERT (AlternativeSizerAdder.getSizerConst() != NULL);
02183:     return & AlternativeSizerAdder;
02184: }
02185: 
02186: //-------------------------------------------------------------------------
02187: 
02188: wxSizerAdderProxy s_NullSizerAdderProxy;
02189: wxSizerAdderProxy & wxNullSizerAdderProxy = s_NullSizerAdderProxy;
02190: 
02191: //=========================================================================
02192: 
02193: wxWindowAdderDefaultParameterSet::wxWindowAdderDefaultParameterSet()
02194: {
02195: }
02196: 
02197: wxWindowAdderDefaultParameterSet::~wxWindowAdderDefaultParameterSet()
02198: {
02199: }
02200: 
02201: void wxWindowAdderDefaultParameterSet::resetToDefaults(wxExtDlgBase * ExtDlgBase)
02202: {
02203:     setIsFixLabelStringOnShortcutClash (true);
02204:     setIsDebugWarningOnShortcutClash (true);
02205: 
02206:     setSizerSpacing (ExtDlgBase -> _B(5));
02207:     setSizerBorder (ExtDlgBase -> _B(14));
02208: 
02209:     setWindowFontColourInitializedState (false);
02210:     setWindowBackgroundColourInitializedState (false);
02211: 
02212:     setLabelFontColourInitializedState (false);
02213:     setLabelBackgroundColourInitializedState (false);
02214:     setPostTextFontColourInitializedState (false);
02215:     setPostTextBackgroundColourInitializedState (false);
02216: 
02217:     setTransparentStaticTextFlags (wxTransparentStaticText::IsOpaque);
02218: }
02219: 
02220: void wxWindowAdderDefaultParameterSet::setSizerSpacing (int SizerSpacing)
02221: {
02222:     setSizerHSpacing (SizerSpacing);
02223:     setSizerVSpacing (SizerSpacing);
02224: }
02225: 
02226: //=========================================================================
02227: 
02228: wxOverlayAdder::wxOverlayAdder()
02229: {
02230:     init();
02231: }
02232: 
02233: 
02234: void wxOverlayAdder::init()
02235: {
02236:     m_OverlayWindow = NULL;
02237: 
02238:     m_PreviousParentWindow = NULL;
02239:     m_OverlaySizer = NULL;
02240: 
02241:     m_ModeBits = ZeroModeBits;
02242: }
02243: 
02244: //=========================================================================
02245: 
02246: WX_DEFINE_OBJARRAY(wxExtLibSizerAdderArray)
02247: 
02248: WX_DEFINE_OBJARRAY(wxWindowAdderDefaultParameterSetArray)
02249: 
02250: WX_DEFINE_OBJARRAY(wxOverlayAdderArray)
02251: 
02252: //-------------------------------------------------------------------------
02253: 
02254: wxWindowAdder::wxWindowAdder()
02255: {
02256:     m_Window = NULL;
02257:     m_ExtDlgBase = NULL;
02258: 
02259:     m_ParentWindow = NULL;
02260: 
02261:     m_IsLabelCreated = false;
02262: 
02263:     m_IsDetectShortcutClashs = true;
02264: }
02265: 
02266: void wxWindowAdder::setExtDlgBase (wxExtDlgBase * ExtDlgBase)
02267: {
02268:     m_ExtDlgBase = ExtDlgBase;
02269:     pushDefaults();
02270: }
02271: 
02272: void wxWindowAdder::setDialog (wxExtDialog * ExtDialog)
02273: {
02274:     setExtDlgBase (ExtDialog);
02275: }
02276: 
02277: void wxWindowAdder::setParentWindow (wxWindow * ParentWindow)
02278: {
02279:     m_ParentWindow = ParentWindow;
02280: }
02281: 
02282: void wxWindowAdder::setSize (const wxSize & Size)
02283: {
02284:     m_Size = Size;
02285: }
02286: 
02287: void wxWindowAdder::setSize (int Width, int Height)
02288: {
02289:     m_Size = wxSize (Width, Height);
02290: }
02291: 
02292: void wxWindowAdder::setWindowStyle (long WindowStyle)
02293: {
02294:     m_WindowStyle = WindowStyle;
02295: }
02296: 
02297: void wxWindowAdder::setLabel (const wxString & LabelString)
02298: {
02299:     next();
02300: 
02301:     m_LabelString = LabelString;
02302: }
02303: 
02304: const wxString & wxWindowAdder::getLabel()
02305: {
02306:     return m_LabelString;
02307: }
02308: 
02309: void wxWindowAdder::setPostText (const wxString & PostTextString)
02310: {
02311:     m_PostTextString = PostTextString;
02312: }
02313: 
02314: const wxString & wxWindowAdder::getPostString()
02315: {
02316:     return m_PostTextString;
02317: }
02318: 
02319: void wxWindowAdder::pushGroup (const wxString & GroupNameString)
02320: {
02321:     m_GroupNameStringArray.Add (GroupNameString);
02322: }
02323: 
02324: void wxWindowAdder::popGroup ()
02325: {
02326:     wxASSERT (m_GroupNameStringArray.GetCount() > 0);
02327:     // remove last element:
02328:     m_GroupNameStringArray.RemoveAt (m_GroupNameStringArray.GetCount() - 1);
02329: }
02330: 
02331: wxString wxWindowAdder::getFullName ()
02332: {
02333:     // TODO: add group names
02334: 
02335:     // add all current group names before label string
02336:     wxString FullName;
02337:     for (int Index = 0; cast_is_smaller (Index, m_GroupNameStringArray.GetCount());
02338:          ++Index)
02339:       {
02340:         FullName << m_GroupNameStringArray.Item (Index) << " / ";
02341:       }
02342:     FullName << m_LabelString;
02343: 
02344:     // simply remove ampersand character used to indicate shortcut
02345:     // to move focus to control
02346:     // TODO handle '&&' sequence
02347:     FullName.Replace ("&", "");
02348: 
02349:     return FullName;
02350: }
02351: 
02352: void wxWindowAdder::setValidator (const wxValidator & Validator)
02353: {
02354:     wxASSERT (getWindow() != NULL);
02355:     getWindow() -> SetValidator (Validator);
02356: }
02357: 
02358: void wxWindowAdder::addSpace (int Width, int Height)
02359: {
02360:     getSizerAdder().addSpace (Width, Height, wxALL|wxEXPAND, m_ExtDlgBase -> _B(0));
02361: }
02362: 
02363: void wxWindowAdder::addHSpace (int Width)
02364: {
02365:     getSizerAdder().addSpace (Width, 0, wxALL|wxEXPAND, m_ExtDlgBase -> _B(0));
02366: }
02367: 
02368: void wxWindowAdder::addVSpace (int Height)
02369: {
02370:     getSizerAdder().addSpace (0, Height, wxALL|wxEXPAND, m_ExtDlgBase -> _B(0));
02371: }
02372: 
02373: void wxWindowAdder::setSizerHSpacing(int Width)
02374: {
02375:     wxGridSizer * GridSizer = wxDynamicCast (getSizer(), wxGridSizer);
02376:     if (GridSizer != NULL)
02377:       {
02378:         GridSizer -> SetHGap (Width);
02379:       }
02380: }
02381: 
02382: void wxWindowAdder::setSizerVSpacing(int Height)
02383: {
02384:     wxGridSizer * GridSizer = wxDynamicCast (getSizer(), wxGridSizer);
02385:     if (GridSizer != NULL)
02386:       {
02387:         GridSizer -> SetVGap (Height);
02388:       }
02389: }
02390: 
02391: void wxWindowAdder::skipCell ()
02392: {
02393:     getSizerAdder().addSpace (1, 1, wxALL|wxEXPAND, m_ExtDlgBase -> _B(0));
02394: }
02395: 
02396: void wxWindowAdder::skipCells (int Count)
02397: {
02398:     for (int Index = 0; Index < Count; ++Index)
02399:       {
02400:         skipCell ();
02401:       }
02402: }
02403: 
02404: void wxWindowAdder::nextGroup()
02405: {
02406:     getSizerAdder().nextGroup();
02407: 
02408:     m_IsLabelCreated = false;
02409:     m_LabelString = "";
02410:     m_PostTextString = "";
02411:     m_Window = NULL;
02412:     m_Size = wxSize (-1, -1);
02413:     m_WindowStyle = 0;
02414: }
02415: 
02416: void wxWindowAdder::next()
02417: {
02418:     nextGroup();
02419: }
02420: 
02421: wxWindow * wxWindowAdder::getWindow()
02422: {
02423:     wxASSERT (m_Window != NULL);
02424:     return m_Window;
02425: }
02426: 
02427: wxSizer * wxWindowAdder::getSizer()
02428: {
02429:     wxASSERT (m_SizerAdderArray.GetCount() > 0);
02430:     return m_SizerAdderArray.Item (m_SizerAdderArray.GetCount() - 1).getSizer();
02431: }
02432: 
02433: wxSizerAdder & wxWindowAdder::getSizerAdder()
02434: {
02435:     wxASSERT (m_SizerAdderArray.GetCount() > 0);
02436:     return m_SizerAdderArray.Item (m_SizerAdderArray.GetCount() - 1);
02437: }
02438: 
02439: //-------------------------------------------------------------------------
02440: 
02441: void wxWindowAdder::addSizer (wxSizer * Sizer, int AddFlags, int AddBorder)
02442: {
02443:     // getSizer() -> Add (Sizer, 0, AddFlags, AddBorder);
02444: 
02445:     getSizerAdder().addSizer (Sizer,
02446:                               AddFlags, 
02447:                               m_ExtDlgBase -> _B(AddBorder));
02448: }
02449: 
02450: void wxWindowAdder::pushSizer (wxSizer * Sizer)
02451: {
02452:     wxSizerAdder SizerAdder (Sizer);
02453:     SizerAdder.setParentWindow (m_ParentWindow);
02454:     m_SizerAdderArray.Add (SizerAdder);
02455: }
02456: 
02457: void wxWindowAdder::addAndPushSizer (wxSizer * Sizer, int AddFlags, int AddBorder)
02458: {
02459:     addSizer (Sizer, AddFlags, AddBorder);
02460:     pushSizer (Sizer);
02461: }
02462: 
02463: void wxWindowAdder::popSizer ()
02464: {
02465:     next();
02466: 
02467:     wxASSERT (m_SizerAdderArray.GetCount() > 0);
02468: 
02469:     // TEST:
02470:     // getSizerAdder().setAllGrowable();
02471: 
02472:     // remove last element:
02473:     m_SizerAdderArray.RemoveAt (m_SizerAdderArray.GetCount() - 1);
02474: }
02475: 
02476: //-------------------------------------------------------------------------
02477: 
02478: void wxWindowAdder::addAndPushFlexGridSizer (int ColumnCount, bool IsAddBorder, bool IsAddOnlySizer)
02479: {
02480:     if (!IsAddOnlySizer)
02481:       createAndAddLabel ();
02482: 
02483:     // TODO use settings from parameter object
02484:     addAndPushSizer (new wxFlexGridSizer (ColumnCount, 
02485:                                           getDefaults().getSizerVSpacing(), 
02486:                                           getDefaults().getSizerHSpacing()),
02487:                      wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxEXPAND, 
02488:                      IsAddBorder ? getDefaults().getSizerBorder() : 0);
02489: 
02490:     getSizerAdder().setGroupSize (ColumnCount);
02491: 
02492:     if (!IsAddOnlySizer)
02493:       createAndAddPostText();
02494: }
02495: 
02496: //-------------------------------------------------------------------------
02497: 
02498: void wxWindowAdder::addAndPushStaticBoxAndSizer (const wxString & LabelString,
02499:                                                  wxSizer * SubSizer,
02500:                                                  int AddFlags, int AddBorder)
02501: {
02502:     wxStaticBoxSizer *StaticBoxSizer
02503:       = new wxStaticBoxSizer (new wxStaticBox (getAddParentWindow(), -1, LabelString), wxVERTICAL);
02504: 
02505:     addSizer (StaticBoxSizer, AddFlags, AddBorder);
02506: 
02507:     StaticBoxSizer -> Add (SubSizer, 0, wxALL|wxEXPAND, m_ExtDlgBase -> _B(5));
02508: 
02509:     pushSizer (SubSizer);
02510: }
02511: 
02512: void wxWindowAdder::addAndPushStaticBoxAndFlexGridSizer (const wxString & LabelString, int ColumnCount,
02513:                                                          bool IsAddBorder)
02514: {
02515:     addAndPushStaticBoxAndSizer (LabelString,
02516:                                  new wxFlexGridSizer (ColumnCount, 
02517:                                                       getDefaults().getSizerVSpacing(), 
02518:                                                       getDefaults().getSizerHSpacing()),
02519:                                  wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxEXPAND, 
02520:                                  IsAddBorder ? getDefaults().getSizerBorder() : 0);
02521: 
02522:     getSizerAdder().setGroupSize (ColumnCount);
02523: }
02524: 
02525: //-------------------------------------------------------------------------
02526: 
02527: void wxWindowAdder::pushDefaults()
02528: {
02529:     int Count = m_WindowAdderDefaultParameterSetArray.GetCount();
02530:     if (Count > 0)
02531:       {
02532:         wxWindowAdderDefaultParameterSet * DefaultParameterSet
02533:           = new wxWindowAdderDefaultParameterSet (m_WindowAdderDefaultParameterSetArray [Count - 1]);
02534:         m_WindowAdderDefaultParameterSetArray.Add (DefaultParameterSet);
02535:       }
02536:     else
02537:       {
02538:         wxWindowAdderDefaultParameterSet * DefaultParameterSet
02539:           = new wxWindowAdderDefaultParameterSet;
02540:         DefaultParameterSet -> resetToDefaults (m_ExtDlgBase);
02541:         m_WindowAdderDefaultParameterSetArray.Add (DefaultParameterSet);
02542:       }
02543: 
02544:     // TEST
02545:     getDefaults();
02546: }
02547: 
02548: void wxWindowAdder::popDefaults()
02549: {
02550:     // don't remove first(bottom) defaults setting from stack
02551:     wxASSERT (m_WindowAdderDefaultParameterSetArray.GetCount() > 1);
02552: 
02553:     // TEST
02554:     getDefaults();
02555: 
02556:     // remove last element:
02557:     m_WindowAdderDefaultParameterSetArray.RemoveAt (m_WindowAdderDefaultParameterSetArray.GetCount() - 1);
02558: }
02559: 
02560: const wxWindowAdderDefaultParameterSet & wxWindowAdder::getDefaults()
02561: {
02562:     wxASSERT (m_WindowAdderDefaultParameterSetArray.GetCount() > 0);
02563:     wxWindowAdderDefaultParameterSet & WindowAdderDefaultParameterSet 
02564:       = m_WindowAdderDefaultParameterSetArray [m_WindowAdderDefaultParameterSetArray.GetCount() - 1];
02565:     return WindowAdderDefaultParameterSet;
02566: }
02567: 
02568: wxWindowAdderDefaultParameterSet & wxWindowAdder::accessDefaults()
02569: {
02570:     wxASSERT (m_WindowAdderDefaultParameterSetArray.GetCount() > 0);
02571:     wxWindowAdderDefaultParameterSet & WindowAdderDefaultParameterSet 
02572:       = m_WindowAdderDefaultParameterSetArray [m_WindowAdderDefaultParameterSetArray.GetCount() - 1];
02573:     return WindowAdderDefaultParameterSet;
02574: }
02575: 
02576: //-------------------------------------------------------------------------
02577: 
02578: void wxWindowAdder::pushOverlay (wxWindow * OverlayWindow, wxOverlayAdder::EMode ModeBits)
02579: {
02580:     wxOverlayAdder OverlayAdder;
02581:     OverlayAdder.m_OverlayWindow = OverlayWindow;
02582:     OverlayAdder.m_PreviousParentWindow = this -> getAddParentWindow();
02583:     OverlayAdder.m_OverlaySizer = new wxBoxSizer (wxVERTICAL);
02584:     OverlayAdder.m_ModeBits = ModeBits;
02585:     
02586:     this -> setParentWindow (OverlayAdder.m_OverlayWindow);
02587:     this -> pushSizer (OverlayAdder.m_OverlaySizer);
02588: 
02589:     m_OverlayAdderArray.Add (OverlayAdder);
02590: }
02591: 
02592: void wxWindowAdder::popOverlay ()
02593: {
02594:     wxASSERT (m_OverlayAdderArray.GetCount() > 0);
02595:     wxOverlayAdder & OverlayAdder = m_OverlayAdderArray [m_OverlayAdderArray.GetCount() - 1];
02596: 
02597:     this -> popSizer (); // should pop m_OverlaySizer
02598: 
02599:     // maybe: 
02600:     OverlayAdder.m_OverlayWindow -> Layout();
02601:     OverlayAdder.m_OverlayWindow -> SetSizerAndFit (OverlayAdder.m_OverlaySizer);
02602:     // m_OverlayWindow -> Fit();
02603:     // m_OverlayWindow -> SetSize (m_OverlaySizer -> GetMinSize());
02604: 
02605:     if (OverlayAdder.m_ModeBits & wxOverlayAdder::IsAddOnPop)
02606:       {
02607:         this -> addWindow (OverlayAdder.m_OverlayWindow);
02608:       }
02609: 
02610:     this -> setParentWindow (OverlayAdder.m_PreviousParentWindow);
02611: 
02612:     // remove last element:
02613:     m_OverlayAdderArray.RemoveAt (m_OverlayAdderArray.GetCount() - 1);
02614: }
02615: 
02616: //-------------------------------------------------------------------------
02617: 
02618: wxWindow * wxWindowAdder::getAddParentWindow ()
02619: {
02620:     if (getSizerAdder().getParentWindow() != NULL)
02621:       {
02622:         return getSizerAdder().getParentWindow();
02623:       }
02624: 
02625:     return m_ExtDlgBase -> getDialog();
02626: }
02627: 
02628: //-------------------------------------------------------------------------
02629: 
02630: wxWindow * wxWindowAdder::addWindow (wxWindow * Window)
02631: {
02632:     createAndAddLabel();
02633: 
02634:     getSizerAdder().addWindow (Window,
02635:                                wxALL|wxEXPAND, 
02636:                                m_ExtDlgBase -> _B(0));
02637:     setCurrentWindow (Window);
02638: 
02639:     return Window;
02640: }
02641: 
02642: void wxWindowAdder::addButton (const wxString & LabelString,
02643:                                wxButton ** ButtonPtrPtr, wxWindowID CtrlIdent,
02644:                                wxCommandEventFunction CommandEventFunction,
02645:                                long Style)
02646: {
02647:     createAndAddLabel();
02648: 
02649:     wxButton * Button = NULL;
02650: 
02651:     wxString FixedLabelString;
02652:     checkAndFixLabelString (LabelString, FixedLabelString);
02653:     m_ExtDlgBase -> addButton (& Button, CtrlIdent, CommandEventFunction,
02654:                               FixedLabelString, & getSizerAdder(),
02655:                               wxDefaultPosition, m_Size, 
02656:                               Style, wxDefaultValidator);
02657: 
02658:     if (0)
02659:       {
02660:         // test automatic setting of tooltip from provided label:
02661:         wxString AmpersandRemovedLabelString;
02662:         checkAndFixLabelString (LabelString, AmpersandRemovedLabelString, true);
02663:         Button -> SetToolTip (AmpersandRemovedLabelString);
02664:       }
02665: 
02666:     if (ButtonPtrPtr != NULL)
02667:       *ButtonPtrPtr = Button;
02668:     setCurrentWindow (Button);
02669: 
02670:     createAndAddPostText();
02671: }
02672: 
02673: void wxWindowAdder::addButton (const wxString & LabelString,
02674:                                wxCommandEventFunction CommandEventFunction,
02675:                                long Style)
02676: {
02677:     addButton (LabelString, NULL, -1, CommandEventFunction, Style);
02678: }
02679: 
02680: void wxWindowAdder::addButton (const wxString & LabelString
02681:                                /*long Style */)
02682: {
02683:     long Style = 0;
02684:     addButton (LabelString, NULL, Style);
02685: }
02686: 
02687: void wxWindowAdder::addButton (const wxString & LabelString, wxWindowID CtrlIdent)
02688: {
02689:     long Style = 0;
02690:     addButton (LabelString, NULL, CtrlIdent, NULL, Style);
02691: }
02692: 
02693: void wxWindowAdder::setDefaultButton()
02694: {
02695:     wxButton * Button = wxDynamicCast (getWindow(), wxButton);
02696: 
02697:     wxASSERT (Button != NULL);
02698: 
02699:     // leave next check in code also in release versions:
02700:     if (Button != NULL)
02701:       {
02702:         Button -> SetDefault();
02703:       }
02704: }
02705: 
02706: void wxWindowAdder::addCheckBoxWithLabel (wxCheckBox ** CheckBoxPtrPtr,
02707:                                           const wxString & LabelString,
02708:                                           long Flags,  // Flags can be 0 or wxTE_READONLY
02709:                                           bool IsLabelOnTheLeft)
02710: {
02711:     wxCheckBox * CheckBox = NULL;
02712:     wxString FixedLabelString;
02713:     checkAndFixLabelString (LabelString, FixedLabelString);
02714:     m_ExtDlgBase -> addCheckBoxWithLabel (& CheckBox,
02715:                                          FixedLabelString,
02716:                                          wxDefaultValidator,
02717:                                          Flags,  // Flags can be 0 or wxTE_READONLY
02718:                                          & getSizerAdder(),
02719:                                          IsLabelOnTheLeft);
02720:     if (CheckBoxPtrPtr != NULL)
02721:       *CheckBoxPtrPtr = CheckBox;
02722: 
02723:     setCurrentWindow (CheckBox);
02724: }
02725: 
02726: void wxWindowAdder::addRadioButtonWithLabel (wxRadioButton ** RadioButtonPtrPtr,
02727:                                              const wxString & LabelString,
02728:                                              long RadioCtrlStyle)
02729: {
02730:     wxRadioButton * RadioButton = NULL;
02731: 
02732:     wxString FixedLabelString;
02733:     checkAndFixLabelString (LabelString, FixedLabelString);
02734:     m_ExtDlgBase -> addRadioButtonWithLabel (& RadioButton,
02735:                                             FixedLabelString,
02736:                                             wxDefaultValidator,
02737:                                             RadioCtrlStyle, 
02738:                                             & getSizerAdder());
02739:     if (RadioButtonPtrPtr != NULL)
02740:       *RadioButtonPtrPtr = RadioButton;
02741: 
02742:     setCurrentWindow (RadioButton);
02743: }
02744: 
02745: 
02746: void wxWindowAdder::addTextCtrl (wxTextCtrl ** TextCtrlPtrPtr,
02747:                                  long TextCtrlStyle)
02748: {
02749:     createAndAddLabel();
02750: 
02751:     wxTextCtrl * TextCtrl = NULL;
02752:     m_ExtDlgBase -> addTextCtrl (& TextCtrl,
02753:                                 wxDefaultValidator,
02754:                                 TextCtrlStyle,
02755:                                 m_Size,
02756:                                 & getSizerAdder());
02757: 
02758:     if (TextCtrlPtrPtr != NULL)
02759:       *TextCtrlPtrPtr = TextCtrl;
02760: 
02761:     setCurrentWindow (TextCtrl);
02762: 
02763:     createAndAddPostText();
02764: }
02765: 
02766: 
02767: void wxWindowAdder::addLabel (wxStaticText ** StaticTextPtrPtr,
02768:                               const wxString & LabelString,
02769:                               long WindowStyle)
02770: {
02771:     wxString FixedLabelString;
02772:     checkAndFixLabelString (LabelString, FixedLabelString);
02773: 
02774:     wxStaticText * StaticText = NULL;
02775:     // TEST: use transparent labels
02776:     m_ExtDlgBase -> addLabel (& StaticText,
02777:                               FixedLabelString,
02778:                               & getSizerAdder(),
02779:                               WindowStyle,
02780:                               m_Size,
02781:                               true /* IsTransparent */,
02782:                               getDefaults().getTransparentStaticTextFlags());
02783: 
02784:     if (StaticTextPtrPtr != NULL)
02785:       *StaticTextPtrPtr = StaticText;
02786: 
02787:     setCurrentWindow (StaticText);
02788: }
02789: 
02790: 
02791: void wxWindowAdder::addMultiLineText (wxMultiLineText * MultiLineText,
02792:                                       long CtrlStyle,
02793:                                       int MultiLineTextStyle)
02794: {
02795:     createAndAddLabel();
02796: 
02797:     m_ExtDlgBase -> addMultiLineText (MultiLineText,
02798:                                      CtrlStyle,
02799:                                      m_Size,
02800:                                      MultiLineTextStyle,
02801:                                      & getSizerAdder());
02802: 
02803:     setCurrentWindow (MultiLineText -> getWindow());
02804: 
02805:     createAndAddPostText();
02806: }
02807: 
02808: void wxWindowAdder::addMultiLineText (wxMultiLineText * MultiLineText,
02809:                                       long CtrlStyle,
02810:                                       int MultiLineTextStyle,
02811:                                       const wxString & TextString,
02812:                                       int MinLineCount, int MaxLineCount,
02813:                                       int BorderWidth)
02814: {
02815:     createAndAddLabel();
02816: 
02817:     m_ExtDlgBase -> addMultiLineText (MultiLineText,
02818:                                      CtrlStyle,
02819:                                      m_Size,
02820:                                      MultiLineTextStyle,
02821:                                      & getSizerAdder(),
02822:                                      TextString,
02823:                                      MinLineCount, MaxLineCount,
02824:                                      BorderWidth);
02825: 
02826:     setCurrentWindow (MultiLineText -> getWindow());
02827: 
02828:     createAndAddPostText();
02829: }
02830: 
02831: 
02832: 
02833: void wxWindowAdder::addListBox (wxListBox ** ListBoxPtrPtr, 
02834:                                 int ChoiceCount, const wxString ChoiceStringArray [])
02835: {
02836:     createAndAddLabel();
02837: 
02838:     wxListBox * ListBox = NULL;
02839:     m_ExtDlgBase -> addListBox (& ListBox, 
02840:                                wxDefaultValidator,
02841:                                ChoiceCount, ChoiceStringArray,
02842:                                m_Size,
02843:                                & getSizerAdder());
02844: 
02845:     if (ListBoxPtrPtr != NULL)
02846:       *ListBoxPtrPtr = ListBox;
02847:     setCurrentWindow (ListBox);
02848: 
02849:     getSizerAdder().addWindow (ListBox, wxALIGN_CENTER_VERTICAL, 
02850:                                m_ExtDlgBase -> _B(8));
02851: 
02852:     createAndAddPostText();
02853: }
02854: 
02855: void wxWindowAdder::addChoiceCtrl (wxChoice ** ChoiceCtrlPtrPtr, 
02856:                                    int ChoiceCount, const wxString ChoiceStringArray [])
02857: {
02858:     createAndAddLabel();
02859: 
02860:     wxChoice * ChoiceCtrl = NULL;
02861:     m_ExtDlgBase -> addChoiceCtrl (& ChoiceCtrl, 
02862:                                   wxDefaultValidator,
02863:                                   ChoiceCount, ChoiceStringArray,
02864:                                   m_Size,
02865:                                   & getSizerAdder());
02866:     if (ChoiceCtrlPtrPtr != NULL)
02867:       *ChoiceCtrlPtrPtr = ChoiceCtrl;
02868:     setCurrentWindow (ChoiceCtrl);
02869: 
02870:     getSizerAdder().addWindow (ChoiceCtrl, wxALIGN_CENTER_VERTICAL, 
02871:                                m_ExtDlgBase -> _B(8));
02872: 
02873:     createAndAddPostText();
02874: }
02875: 
02876: void wxWindowAdder::addComboBox (wxComboBox ** ComboBoxPtrPtr, 
02877:                                  int StringCount, const wxString StringArray [])
02878: {
02879:     createAndAddLabel();
02880: 
02881:     wxComboBox * ComboBox = NULL;
02882:     m_ExtDlgBase -> addComboBox (& ComboBox, 
02883:                                 wxDefaultValidator,
02884:                                 StringCount, StringArray,
02885:                                 m_Size,
02886:                                 & getSizerAdder());
02887:     if (ComboBoxPtrPtr != NULL)
02888:       *ComboBoxPtrPtr = ComboBox;
02889:     setCurrentWindow (ComboBox);
02890: 
02891:     getSizerAdder().addWindow (ComboBox, wxALIGN_CENTER_VERTICAL, 
02892:                                m_ExtDlgBase -> _B(8));
02893: 
02894:     createAndAddPostText();
02895: }
02896: 
02897: 
02898: void wxWindowAdder::addStaticBitmap (wxStaticBitmap ** StaticBitmapPtrPtr,
02899:                                      const unsigned char * ImageData,
02900:                                      size_t ImageDataSize)
02901: {
02902:     createAndAddLabel();
02903: 
02904:     wxStaticBitmap * StaticBitmap = NULL;
02905:     m_ExtDlgBase -> addStaticBitmap (& StaticBitmap,
02906:                                     ImageData,
02907:                                     ImageDataSize,
02908:                                     wxDefaultPosition,
02909:                                     m_Size,
02910:                                     & getSizerAdder(),
02911:                                     m_WindowStyle);
02912: 
02913:     if (StaticBitmapPtrPtr != NULL)
02914:       *StaticBitmapPtrPtr = StaticBitmap;
02915: 
02916:     setCurrentWindow (StaticBitmap);
02917: 
02918:     createAndAddPostText();
02919: }
02920: 
02921: void wxWindowAdder::addStaticBitmap (wxStaticBitmap ** StaticBitmapPtrPtr,
02922:                                      const char * ResourceNameString)
02923: {
02924:     createAndAddLabel();
02925: 
02926:     wxStaticBitmap * StaticBitmap = NULL;
02927:     m_ExtDlgBase -> addStaticBitmap (& StaticBitmap,
02928:                                     ResourceNameString,
02929:                                     wxDefaultPosition,
02930:                                     m_Size,
02931:                                     & getSizerAdder(),
02932:                                     m_WindowStyle);
02933: 
02934:     if (StaticBitmapPtrPtr != NULL)
02935:       *StaticBitmapPtrPtr = StaticBitmap;
02936: 
02937:     setCurrentWindow (StaticBitmap);
02938: 
02939:     createAndAddPostText();
02940: }
02941: 
02942: void wxWindowAdder::addStaticBitmap (wxStaticBitmap ** StaticBitmapPtrPtr,
02943:                                      wxBitmap * Bitmap)
02944: {
02945:     createAndAddLabel();
02946: 
02947:     wxStaticBitmap * StaticBitmap = NULL;
02948:     m_ExtDlgBase -> addStaticBitmap (& StaticBitmap,
02949:                                     Bitmap,
02950:                                     wxDefaultPosition,
02951:                                     m_Size,
02952:                                     & getSizerAdder(),
02953:                                     m_WindowStyle);
02954: 
02955:     if (StaticBitmapPtrPtr != NULL)
02956:       *StaticBitmapPtrPtr = StaticBitmap;
02957: 
02958:     setCurrentWindow (StaticBitmap);
02959: 
02960:     createAndAddPostText();
02961: }
02962: 
02963: //-------------------------------------------------------------------------
02964: 
02965: void wxWindowAdder::watchControl()
02966: {
02967:     wxASSERT (getWindow() != NULL);
02968:     m_ExtDlgBase -> addWatchedControl (getWindow());
02969: }
02970: 
02971: //-------------------------------------------------------------------------
02972: 
02973: void wxWindowAdder::createAndAddLabel ()
02974: {
02975:     if ((!m_IsLabelCreated)
02976:         && (! m_LabelString.IsEmpty()))
02977:       {
02978:         wxString FixedLabelString;
02979:         checkAndFixLabelString (m_LabelString, FixedLabelString);
02980: 
02981:         // TEST: use wxTransparentStaticText
02982:         wxStaticText * StaticText = new wxTransparentStaticText (getAddParentWindow(), -1, 
02983:                                                                  FixedLabelString,
02984:                                                                  wxDefaultPosition, wxDefaultSize,
02985:                                                                  0,
02986:                                                                  getDefaults().getTransparentStaticTextFlags());
02987: 
02988:         if (getDefaults().getIsLabelFontColourInitialized())
02989:           {
02990:             StaticText -> SetForegroundColour (getDefaults().getLabelFontColour());
02991:           }
02992:         if (getDefaults().getIsLabelBackgroundColourInitialized())
02993:           {
02994:             StaticText -> SetBackgroundColour (getDefaults().getLabelBackgroundColour());
02995:           }
02996: 
02997:         getSizerAdder().addWindow (StaticText,
02998:                                    wxRIGHT|wxALIGN_CENTER_VERTICAL, 
02999:                                    m_ExtDlgBase -> _B(8));
03000:         m_IsLabelCreated = true;
03001:       }
03002: }
03003: 
03004: void wxWindowAdder::setCurrentWindow (wxWindow * Window)
03005: {
03006:     m_Window = Window;
03007: 
03008:     // TEST use decorateWindow() for all window types
03009:     decorateWindow (m_Window);
03010: 
03011:     if (getDefaults().getIsWatchControl())
03012:       {
03013:         watchControl();
03014:       }
03015: }
03016: 
03017: void wxWindowAdder::createAndAddPostText ()
03018: {
03019:     if (! m_PostTextString.IsEmpty())
03020:       {
03021:         wxString FixedPostTextString;
03022:         checkAndFixLabelString (m_PostTextString, FixedPostTextString);
03023: 
03024:         // TEST: use wxTransparentStaticText
03025:         wxStaticText * StaticText = new wxTransparentStaticText (getAddParentWindow(), -1, 
03026:                                                                  FixedPostTextString,
03027:                                                                  wxDefaultPosition, wxDefaultSize,
03028:                                                                  0,
03029:                                                                  getDefaults().getTransparentStaticTextFlags());
03030: 
03031: 
03032:         if (getDefaults().getIsPostTextFontColourInitialized())
03033:           {
03034:             StaticText -> SetForegroundColour (getDefaults().getPostTextFontColour());
03035:           }
03036:         if (getDefaults().getIsPostTextBackgroundColourInitialized())
03037:           {
03038:             StaticText -> SetBackgroundColour (getDefaults().getPostTextBackgroundColour());
03039:           }
03040: 
03041:         getSizerAdder().addWindow (StaticText,
03042:                                    wxLEFT|wxALIGN_CENTER_VERTICAL, 
03043:                                    m_ExtDlgBase -> _B(5));
03044:       }
03045: }
03046: 
03047: //-------------------------------------------------------------------------
03048: 
03049: void wxWindowAdder::decorateWindow (wxWindow * Window)
03050: {
03051:     if (getDefaults().getIsWindowFontColourInitialized())
03052:       {
03053:         Window -> SetForegroundColour (getDefaults().getWindowFontColour());
03054:       }
03055:     if (getDefaults().getIsWindowBackgroundColourInitialized())
03056:       {
03057:         Window -> SetBackgroundColour (getDefaults().getWindowBackgroundColour());
03058:       }
03059: }
03060: 
03061: //-------------------------------------------------------------------------
03062: 
03063: void wxWindowAdder::addStaticLine (long Style)
03064: {
03065:     wxStaticLine * StaticLine
03066:       = new wxStaticLine (getAddParentWindow(), -1, wxDefaultPosition, wxDefaultSize,
03067:                           Style);
03068: 
03069:     getSizerAdder().addWindow (StaticLine,
03070:                                wxALL|wxEXPAND, 
03071:                                m_ExtDlgBase -> _B(0));
03072: }
03073: 
03074: //-------------------------------------------------------------------------
03075: 
03076: void wxWindowAdder::addHeadline (const wxString & HeadlineString)
03077: {
03078:     // wxPanel * Panel = new wxPanel (getAddParentWindow(), -1);
03079:     // Panel -> SetBackgroundColour (*wxBLUE);
03080:     wxColour BackgroundColour (48, 48, 164);
03081:     wxColour FontColour (*wxWHITE);
03082:     // wxColour BackgroundColour (192, 192, 255);
03083:     // wxColour FontColour (*wxBLACK);
03084: 
03085:     wxColourBarWindow * ColourBarWindow = new wxColourBarWindow (getAddParentWindow(), -1,
03086:                                                                  BackgroundColour);
03087: 
03088:     ColourBarWindow -> setBrush (wxBrush (BackgroundColour, wxSOLID));
03089:     // ColourBarWindow -> setBrush (*wxTRANSPARENT_BRUSH);
03090:     ColourBarWindow -> setRoundedCornerRadius (3.);
03091:     ColourBarWindow -> setPen (wxPen (*wxWHITE, 1, wxSOLID));
03092: 
03093:     // TEST: use wxTransparentStaticText
03094:     wxStaticText * StaticText = new wxTransparentStaticText (ColourBarWindow, -1, HeadlineString, 
03095:                                                              wxDefaultPosition, wxDefaultSize,
03096:                                                              0,
03097:                                                              getDefaults().getTransparentStaticTextFlags());
03098: 
03099:     StaticText -> SetForegroundColour (FontColour);
03100:     // wxFont HeadlineFont (10, wxSWISS, wxNORMAL, wxBOLD);
03101:     wxFont HeadlineFont (m_ExtDlgBase -> createDialogFont(m_ExtDlgBase -> getAdjustedFontLikeHeight((m_ExtDlgBase -> getDefaultDialogFontSize() * 14) / 10) /* 10 */,
03102:                                                          wxDEFAULT /* family */, 
03103:                                                          wxNORMAL /* upright/slant/italic */, 
03104:                                                          wxNORMAL /* weight */,
03105:                                                          false /* underlined? */, 
03106:                                                          _T("") /* face name */,
03107:                                                          wxFONTENCODING_DEFAULT /* wxFONTENCODING_ISO8859_1 */ ));
03108:     StaticText -> SetFont (HeadlineFont);
03109: 
03110:     wxBoxSizer * SubSizer = new wxBoxSizer (wxHORIZONTAL);
03111:     SubSizer -> Add (StaticText,
03112:                      0,
03113:                      wxEXPAND | wxALL | wxADJUST_MINSIZE | wxALIGN_CENTRE,
03114:                      m_ExtDlgBase -> _B(0));
03115: 
03116:     wxSizer * BoxSizer = new wxBoxSizer (wxHORIZONTAL);
03117:     BoxSizer -> Add (SubSizer,
03118:                      0,
03119:                      wxALL | wxALIGN_CENTRE_HORIZONTAL,
03120:                      m_ExtDlgBase -> _B (3));
03121: 
03122:     ColourBarWindow -> SetSizer (BoxSizer);
03123:     ColourBarWindow -> Layout();
03124:     ColourBarWindow -> Fit();
03125: 
03126:     getSizerAdder().addWindow (ColourBarWindow,
03127:                                wxALL | wxEXPAND, 
03128:                                m_ExtDlgBase -> _B(0));
03129: 
03130: }
03131: 
03132: //-------------------------------------------------------------------------
03133: 
03134: void wxWindowAdder::checkAndFixLabelString (const wxString & InputLabelString, 
03135:                                             wxString & FixedLabelString,
03136:                                             bool IsAlwaysRemoveAmpersand)
03137: {
03138:     FixedLabelString = InputLabelString;
03139: 
03140:     if (!getDefaults().getIsFixLabelStringOnShortcutClash()
03141:         && (!IsAlwaysRemoveAmpersand))
03142:       {
03143:         FixedLabelString = InputLabelString;
03144:         return;
03145:       }
03146: 
03147:     int CurrentIndex = 0;
03148:     while (true)
03149:       {
03150:         const char * FoundCharPtr = NULL;
03151:         // must obtain start of string again because it may have changed:
03152:         const char * LabelCharPtr = FixedLabelString.c_str();
03153: 
03154:         // wxString::Find() doesn't support a starting position
03155:         FoundCharPtr = strchr (LabelCharPtr + CurrentIndex, '&');
03156: 
03157:         int AmpersandIndex = -1;
03158:         if (FoundCharPtr != NULL)
03159:           AmpersandIndex = (FoundCharPtr - LabelCharPtr);
03160:         else
03161:           break;
03162: 
03163:         CurrentIndex = AmpersandIndex;
03164: 
03165:         if (AmpersandIndex != -1)
03166:           {
03167:             if (cast_is_smaller (AmpersandIndex + 1, FixedLabelString.Length()))
03168:               {
03169:                 char FollowingChar = FixedLabelString.GetChar (AmpersandIndex + 1);
03170:                 FollowingChar = wxTolower (FollowingChar);
03171:                 if (FollowingChar == '&')
03172:                   {
03173:                     // just an escape for ampersand itself ("&&")
03174:                   }
03175:                 else if (IsAlwaysRemoveAmpersand)
03176:                   {
03177:                     FixedLabelString.Remove (AmpersandIndex, 1);
03178:                     // adjust CurrentIndex (it is incremented by two again,
03179:                     // see below)
03180:                     CurrentIndex -= 1;
03181:                   }
03182:                 else
03183:                   {
03184:                     int FoundIndex = m_ShortcutCharString.Find (FollowingChar);
03185:                     if (FoundIndex == -1)
03186:                       {
03187:                         m_LabelStringArray.Add (InputLabelString);
03188:                         m_ShortcutCharString.Append (FollowingChar);
03189:                       }
03190:                     else
03191:                       {
03192:                         if (getDefaults().getIsDebugWarningOnShortcutClash())
03193:                           {
03194:                             wxString MessageString;
03195:                             MessageString 
03196:                               << "character '" << FollowingChar << "'\n used as short-cut for label \n"
03197:                               << "\"" << InputLabelString << "\n is already used by label\n"
03198:                               << "\"" << m_LabelStringArray [FoundIndex] << "\".";
03199:                             
03200:                             wxASSERT_MSG (false, MessageString);
03201:                           }
03202: 
03203:                         // remove ampersand character then, to avoid ambiguity
03204:                         FixedLabelString.Remove (AmpersandIndex, 1);
03205:                         // adjust CurrentIndex (it is incremented by two again,
03206:                         // see below)
03207:                         CurrentIndex -= 1;
03208:                       }
03209:                   }
03210:                 // adjust index
03211:                 ++CurrentIndex;
03212:               }
03213:             else
03214:               {
03215:                 // ignore if ampersand is last character in string
03216:                 // TODO should report warning here too
03217:               }
03218:           }
03219:         ++CurrentIndex;
03220:       }
03221: }
03222: 
03223: //=========================================================================
03224: 
03225: wxWindowAdderAutoPopSizer::wxWindowAdderAutoPopSizer (wxWindowAdder * WindowAdder)
03226: {
03227:     init();
03228: 
03229:     m_WindowAdder = WindowAdder;
03230:     push();
03231: }
03232: 
03233: wxWindowAdderAutoPopSizer::wxWindowAdderAutoPopSizer(wxWindowAdder * WindowAdder, wxWindow * OverlayWindow,
03234:                                                      wxOverlayAdder::EMode ModeBits)
03235: {
03236:     init();
03237:     m_WindowAdder = WindowAdder;
03238:     m_OverlayWindow = OverlayWindow;
03239:     m_OverlayAdderModeBits = ModeBits;
03240:     push();
03241: }
03242: 
03243: wxWindowAdderAutoPopSizer::~wxWindowAdderAutoPopSizer()
03244: {
03245:     if (m_WindowAdder != NULL)
03246:       {
03247:         pop();
03248:       }
03249: }
03250: 
03251: void wxWindowAdderAutoPopSizer::init()
03252: {
03253:     reset();
03254: }
03255: 
03256: void wxWindowAdderAutoPopSizer::reset()
03257: {
03258:     m_WindowAdder = NULL;
03259:     m_OverlayWindow = NULL;
03260:     m_OverlayAdderModeBits = wxOverlayAdder::ZeroModeBits;
03261: }
03262: 
03263: void wxWindowAdderAutoPopSizer::push()
03264: {
03265:     wxASSERT (m_WindowAdder != NULL);
03266: 
03267:     if (m_OverlayWindow != NULL)
03268:       {
03269:         m_WindowAdder -> pushOverlay (m_OverlayWindow, m_OverlayAdderModeBits);
03270:       }
03271: 
03272:     m_WindowAdder -> pushDefaults();
03273: }
03274: 
03275: void wxWindowAdderAutoPopSizer::pop()
03276: {
03277:     wxASSERT (m_WindowAdder != NULL);
03278: 
03279:     m_WindowAdder -> popDefaults();
03280:     m_WindowAdder -> popSizer();
03281: 
03282:     if (m_OverlayWindow != NULL)
03283:       {
03284:         m_WindowAdder -> popOverlay ();
03285:       }
03286: 
03287:     // note: reset() will also set m_WindowAdder to NULL
03288:     reset();
03289: }
03290: 
03291: //=========================================================================
03292: 
03293: wxNonModalDialogInfo::wxNonModalDialogInfo()
03294: {
03295:     m_CommandIdent = 0L;
03296:     m_Window = NULL;
03297: }
03298: 
03299: //-------------------------------------------------------------------------
03300: 
03301: WX_DEFINE_OBJARRAY(wxNonModalDialogInfoArray)
03302: 
03303: //-------------------------------------------------------------------------
03304: 
03305: wxNonModalDialogManag::wxNonModalDialogManag()
03306: {
03307: }
03308: 
03309: wxNonModalDialogManag::~wxNonModalDialogManag()
03310: {
03311: }
03312: 
03313: void wxNonModalDialogManag::handleMenuCommand (long CommandIdent)
03314: {
03315:     int InfoIndex = findInfo (CommandIdent);
03316:     if (InfoIndex == -1)
03317:       {
03318:         InfoIndex = addInfo (CommandIdent);
03319:       }
03320: 
03321:     wxWindow * Window = getInfoByIndex(InfoIndex).m_Window;
03322:     if (Window == NULL)
03323:       {
03324:         Window = createWindow (CommandIdent);
03325:         getInfoByIndex (InfoIndex).m_Window = Window;
03326:       }
03327: 
03328:     if (Window != NULL)
03329:       {
03330:         Window -> Show();
03331:         Window -> Raise();
03332:       }
03333: }
03334: 
03335: // closeAll()
03336: // - TODO: add support for Veto-ing
03337: void wxNonModalDialogManag::closeAll()
03338: {
03339:     int InfoCount = m_NonModalDialogInfoArray.GetCount();
03340:     for (int InfoIndex = 0; InfoIndex < InfoCount; ++InfoIndex)
03341:       {
03342:         wxWindow * Window = getInfoByIndex (InfoIndex).m_Window;
03343:         if (Window != NULL)
03344:           {
03345:             // call Show() before Close()
03346:             // - (scope: WinXP)
03347:             // - need to call Show() before, because otherwise, if dialog
03348:             //   was hidden, the application hangs (for whatever reason)
03349:             //   (this was the case if only Close(), not Destroy() was
03350:             //   called afterwards)
03351:             // - todo: check if Show() is required also if only
03352:             //   Destroy() (or Close() + Destroy()) is called
03353:             // - problem of hanging also exists if task-manager is
03354:             //   used to terminate task(application) (not process, this 
03355:             //   is more forceful) (this happens e.g. under the condition,
03356:             //   that only the main frame and some modal dialog is shown)
03357:             //   (it may be a bug in wxWidgets code)
03358:             Window -> Show();
03359: 
03360:             // calling Close(false) may cause query if closing dialog is desired
03361:             // setting force==true disables CanVeto-flag
03362:             bool CloseRetVal = Window -> Close (true /* force */);
03363:             // avoid warning about unused variable:
03364:             CloseRetVal = CloseRetVal;
03365: 
03366:             // NonModalDialog's Destroy() seems not to be called if dialog 
03367:             // close results from application/main dialog close (only 
03368:             // destructor is called, but calling removeListener() there 
03369:             // causes crash)
03370:             // - so try to call Destroy() explicitly for all managed non-modal
03371:             //   windows
03372:             Window -> Destroy();
03373: 
03374:             // TODO:
03375:             // - should set Window to NULL after calling Destroy() or
03376:             //   remove info from info-array
03377: 
03378:             // TODO: call Destroy() only if non of the dialogs has issued Veto(),
03379:             // add return value indicating if closing is allowed,
03380:             // - also, need to split up into check-can-close phase plus
03381:             //   actual destroy phase (e.g. for integration with other non-modal
03382:             //   dialog handlers)
03383:           }
03384:       }
03385: }
03386: 
03387: //-------------------------------------------------------------------------
03388: 
03389: int wxNonModalDialogManag::findInfo (long CommandIdent)
03390: {
03391:     int InfoCount = m_NonModalDialogInfoArray.GetCount();
03392:     for (int InfoIndex = 0; InfoIndex < InfoCount; ++InfoIndex)
03393:       {
03394:         wxNonModalDialogInfo & NonModalDialogInfo
03395:           = m_NonModalDialogInfoArray [InfoIndex];
03396: 
03397:         if (NonModalDialogInfo.m_CommandIdent == CommandIdent)
03398:           return InfoIndex;
03399:       }
03400:     return -1;
03401: }
03402: 
03403: int wxNonModalDialogManag::findInfoFromWindow (wxWindow * Window)
03404: {
03405:     int InfoCount = m_NonModalDialogInfoArray.GetCount();
03406:     for (int InfoIndex = 0; InfoIndex < InfoCount; ++InfoIndex)
03407:       {
03408:         wxNonModalDialogInfo & NonModalDialogInfo
03409:           = m_NonModalDialogInfoArray [InfoIndex];
03410: 
03411:         if (NonModalDialogInfo.m_Window == Window)
03412:           return InfoIndex;
03413:       }
03414:     return -1;
03415: }
03416: 
03417: int wxNonModalDialogManag::addInfo (long CommandIdent)
03418: {
03419:     int InfoCount = m_NonModalDialogInfoArray.GetCount();
03420: 
03421:     // TEST: use new
03422:     wxNonModalDialogInfo * NonModalDialogInfo = new wxNonModalDialogInfo;
03423:     NonModalDialogInfo -> m_CommandIdent = CommandIdent;
03424:     NonModalDialogInfo -> m_Window = NULL;
03425: 
03426:     // WARN use of reference to Add() call okay?
03427:     m_NonModalDialogInfoArray.Add (NonModalDialogInfo);
03428:     // m_NonModalDialogInfoArray.Add (NonModalDialogInfo);
03429: 
03430:     // InfoCount should be index of currently added element:
03431:     return InfoCount;
03432: }
03433: 
03434: wxNonModalDialogInfo & wxNonModalDialogManag::getInfoByIndex (int InfoIndex)
03435: {
03436:     return m_NonModalDialogInfoArray [InfoIndex];
03437: }
03438: 
03439: //=========================================================================
03440: 
03441: wxDisablingBusyInfo::wxDisablingBusyInfo (const wxString & MessageString, wxWindow * ParentWindow,
03442:                                           wxWindow * SkipDisableWindow)
03443:   : m_FocusRestorer (),  // call wxFocusRestorer ctor first
03444:     m_WindowDisabler (SkipDisableWindow), // call wxWindowDisabler ctor second
03445:     m_BusyInfo (MessageString, ParentWindow)
03446: {
03447: }
03448: 
03449: //=========================================================================
03450: 
03451: wxCalendarDialog::wxCalendarDialog (wxWindow * ParentWindow,
03452:                                     const wxString & DialogTitleString,
03453:                                     wxDateTime * DateTimePtr,
03454:                                     const wxDateTime & MinDateTime, const wxDateTime & MaxDateTime,
03455:                                     long DateTimeValidatorFlags,
03456:                                     const wxString & DateTimeFormatString)
03457:   : wxExtDialog (ParentWindow, 
03458:                  -1, 
03459:                  DialogTitleString,
03460:                  wxDefaultPosition, 
03461:                  wxDefaultSize,
03462:                  wxCAPTION | wxRESIZE_BORDER | wxSYSTEM_MENU /*| wxCLOSE_BOX*/)
03463: {
03464:     init ();
03465:     wxASSERT (DateTimePtr != NULL);
03466: 
03467:     m_DateTimePtr = DateTimePtr;
03468:     m_MinDateTime = MinDateTime;
03469:     m_MaxDateTime = MaxDateTime;
03470:     m_DateTimeValidatorFlags = DateTimeValidatorFlags;
03471:     m_DateTimeFormatString = DateTimeFormatString;
03472: 
03473:     m_TextCtrlDateTime = *m_DateTimePtr;
03474:     m_TextCtrlDateTime.ResetTime();
03475: 
03476:     createControlsMain();
03477: }
03478: 
03479: void wxCalendarDialog::init()
03480: {
03481:     clearControlPointers();
03482:     m_DateTimePtr = NULL;
03483: }
03484: 
03485: void wxCalendarDialog::clearControlPointers()
03486: {
03487:     m_DateCalendarCtrl = NULL;
03488: }
03489: 
03490: void wxCalendarDialog::createControlsMain()
03491: {
03492:     clearControlPointers();
03493: 
03494:     wxSizer * MainSizer = new wxBoxSizer (wxVERTICAL);
03495: 
03496:     wxWindowAdder WA;
03497:     WA.setDialog (this);
03498: 
03499:     this -> SetExtraStyle (this -> GetExtraStyle()
03500:                            | wxWS_EX_VALIDATE_RECURSIVELY);
03501:     
03502:     WA.pushSizer (MainSizer);
03503:     wxWindowAdderAutoPopSizer WindowAdderAutoPopSizer (& WA);
03504:     {
03505:       WA.accessDefaults().setSizerSpacing (_B(4));
03506: 
03507:       WA.addAndPushFlexGridSizer (1, false /* IsAddBorder */);
03508:       wxWindowAdderAutoPopSizer WindowAdderAutoPopSizer (& WA);
03509:       
03510:       MainSizer = WA.getSizer();
03511:       createControls (WA);
03512:     }
03513: 
03514:     TransferDataToWindow();
03515:     fillControlsPostCreate();
03516: 
03517:     if (MainSizer != NULL)
03518:       {
03519:         SetSizerAndFit (MainSizer);
03520:       }
03521: 
03522:     initializeDialog ();
03523:     enableWatchedControlChangeNotification (true);
03524: }
03525: 
03526: void wxCalendarDialog::addStatusMessageTarget (wxWindowAdder & WA)
03527: {
03528:     wxMultiLineText * ErrorMessageMultiLineText
03529:       = createErrorMessageCtrl (& m_StatusMessageMultiLineText, 3 /* LineCount */);
03530:     // avoid warning about unused variable:
03531:     ErrorMessageMultiLineText = ErrorMessageMultiLineText;
03532: 
03533:     m_StatusMessageTarget -> setStatusOutput (& m_StatusMessageMultiLineText);
03534:     m_StatusMessageTarget -> enableShowMessageBox (FALSE);
03535:     wxWindow * Window = m_StatusMessageMultiLineText.getWindow();
03536:     // avoid warning about unused variable:
03537:     Window = Window;
03538: 
03539:     WA.pushDefaults();
03540:     WA.accessDefaults().setWindowBackgroundColour (*wxWHITE);
03541:     WA.addWindow (m_StatusMessageMultiLineText.getWindow ());
03542:     WA.popDefaults();
03543: 
03544:     // TEST after addWindow():
03545:     // try to remove border
03546:     long WindowStyle = m_StatusMessageMultiLineText.getWindow() -> GetWindowStyleFlag();
03547:     WindowStyle &= ~wxBORDER_MASK;
03548:     WindowStyle |= wxBORDER_NONE;
03549:     m_StatusMessageMultiLineText.getWindow() -> SetWindowStyleFlag (WindowStyle);
03550: }
03551: 
03552: void wxCalendarDialog::createControls (wxWindowAdder & WA)
03553: {
03554:     WA.accessDefaults().setSizerBorder (_B(4));
03555:     if (true)
03556:       {
03557:         WA.addAndPushFlexGridSizer (1, false);
03558: 
03559:         wxWindowAdderAutoPopSizer WindowAdderAutoPopSizer (& WA);
03560:         {
03561:           WA.pushDefaults();
03562:           // WA.accessDefaults().setSizerBorder (_B(20));
03563: 
03564:           WA.addAndPushFlexGridSizer (3, true);
03565:           wxWindowAdderAutoPopSizer WindowAdderAutoPopSizer (& WA);
03566: 
03567:           WA.addHSpace (_B(40));
03568: 
03569:           {
03570:           WA.addAndPushFlexGridSizer (3, false);
03571:           wxWindowAdderAutoPopSizer WindowAdderAutoPopSizer (& WA);
03572: 
03573:           m_StatusMessageTarget = new wxStatusMessageTarget (NULL, "");
03574:           m_StatusMessageTarget -> enableShowMessageBox (FALSE);
03575: 
03576:           WA.addVSpace (_B(12));
03577:           WA.next();
03578:           
03579:           WA.setLabel ("");
03580:           m_DateCalendarCtrl = new wxCalendarCtrl;
03581:           m_DateCalendarCtrl -> Create (WA.getAddParentWindow(), 
03582:                                         -1 /* ident == wxID_AUTO */, 
03583:                                         wxDateTime(),
03584:                                         wxDefaultPosition, wxSize(170, 135), 
03585:                                         wxCAL_MONDAY_FIRST | wxCAL_SHOW_SURROUNDING_WEEKS | wxSIMPLE_BORDER);
03586:           m_DateCalendarCtrl -> SetBackgroundColour(wxColour(255, 255, 255));
03587:           WA.addWindow (m_DateCalendarCtrl);
03588:           WA.next();
03589:           
03590:           wxCalendarEventFunction CalendarEventFunction 
03591:             = (wxCalendarEventFunction) (& wxCalendarDialog::OnCalendarDoubleClicked);
03592:           this -> Connect (m_DateCalendarCtrl -> GetId(),
03593:                            wxEVT_CALENDAR_DOUBLECLICKED,
03594:                            (wxObjectEventFunction) (wxEventFunction) CalendarEventFunction);
03595: 
03596:           CalendarEventFunction = (wxCalendarEventFunction) (& wxCalendarDialog::OnCalendarSelectionChanged);
03597:           this -> Connect (m_DateCalendarCtrl -> GetId(),
03598:                            wxEVT_CALENDAR_SEL_CHANGED,
03599:                            (wxObjectEventFunction) (wxEventFunction) CalendarEventFunction);
03600: 
03601:           WA.setLabel (_(""));
03602:           WA.setSize (170 /* getAdjustedTextCtrlWidth (170) */,
03603:                       getAdjustedTextCtrlHeight (1, true));
03604:           WA.addTextCtrl (& m_DateTimeTextCtrl, 0 /* TEST may be wxTE_READONLY */);
03605: 
03606:           WA.setValidator (wxTraitedDateTimeValidator (& m_TextCtrlDateTime, 
03607:                                                        m_MinDateTime, m_MaxDateTime,
03608:                                                        m_StatusMessageTarget, 
03609:                                                        _("date"),
03610:                                                        m_DateTimeValidatorFlags,
03611:                                                        wxInvalidDateTime,
03612:                                                        m_DateTimeFormatString));
03613:           }
03614: 
03615:           WA.addHSpace (_B(40));
03616: 
03617:           WA.popDefaults();
03618:         }
03619: 
03620:         WA.addStaticLine();
03621:         addStatusMessageTarget (WA);
03622: 
03623:         {        
03624:           WA.addAndPushFlexGridSizer (3, true);
03625:           wxWindowAdderAutoPopSizer WindowAdderAutoPopSizer (& WA);
03626:           
03627:           WA.addSpace (1, 1);
03628:           WA.getSizerAdder().setColumnGrowable (0);
03629:           
03630:           WA.addButton (_("&Cancel"), wxID_CANCEL);
03631:           WA.addButton (_("&OK"), (wxCommandEventFunction) (& wxCalendarDialog::OnOkayButton));
03632:         }
03633:         
03634:       }
03635: }
03636: 
03637: void wxCalendarDialog::fillControlsPostCreate ()
03638: {
03639:     m_DateCalendarCtrl -> SetDate (m_TextCtrlDateTime);
03640: }
03641: 
03642: //-------------------------------------------------------------------------
03643: 
03644: void wxCalendarDialog::OnCalendarSelectionChanged (wxCalendarEvent & Event)
03645: {    
03646:     handleSelectionChange (Event);
03647: }
03648: 
03649: void wxCalendarDialog::OnCalendarDoubleClicked (wxCalendarEvent & Event)
03650: {
03651:     handleSelectionChange (Event);
03652:     handleAcceptInput();
03653: }
03654: 
03655: void wxCalendarDialog::handleSelectionChange (wxCalendarEvent & Event)
03656: {
03657:     wxDateTime DateTime = Event.GetDate();
03658:     // formatDateTimeInISOFormat (Basictype, String);
03659:     m_TextCtrlDateTime = DateTime;
03660:     transferDataToControl (m_DateTimeTextCtrl);
03661:     // now validate to check date to get output on StatusMessageTarget:
03662:     validateControl (m_DateTimeTextCtrl);
03663: }
03664: 
03665: //-------------------------------------------------------------------------
03666: 
03667: void wxCalendarDialog::OnOkayButton (wxCommandEvent & WXUNUSED(Event))
03668: {
03669:     handleAcceptInput();
03670: }
03671: 
03672: void wxCalendarDialog::handleAcceptInput()
03673: {
03674:     if (ValidateWithMessageBox (wxID_OK))
03675:       {
03676:         *m_DateTimePtr = m_TextCtrlDateTime;
03677:       }
03678: }
03679: 
03680: //-------------------------------------------------------------------------
03681: 
03682: wxTraitedDateTimeValidator & wxCalendarDialog::accessDateTimeValidator()
03683: {
03684:     wxValidator * Validator = m_DateTimeTextCtrl -> GetValidator();
03685:     wxTraitedDateTimeValidator * DateTimeValidator 
03686:       = wxDynamicCast (Validator, wxTraitedDateTimeValidator);
03687: 
03688:     wxASSERT (DateTimeValidator != NULL);
03689:     return *DateTimeValidator;
03690: }
03691: 
03692: //=========================================================================
03693: 
03694: void showCalendarDialog (wxWindow * ParentWindow,
03695:                          const wxString & CalendarDialogCaptionString,
03696:                          const wxDateTime & MinDateTime,
03697:                          const wxDateTime & MaxDateTime,                         
03698:                          long DateTimeValidatorFlags,
03699:                          const wxString & DateTimeFormatString,
03700:                          wxTextCtrl * DateTimeTextCtrl, 
03701:                          bool IsCallResetTime)
03702: {
03703:     wxString TempDateTimeString;
03704:     TempDateTimeString = DateTimeTextCtrl -> GetValue ();
03705: 
03706:     wxDateTime TempDateTime;
03707:     if (!parseDateTimeWithFormat (TempDateTimeString, TempDateTime,
03708:                                  DateTimeFormatString))
03709:       {
03710:         TempDateTime = wxDateTime::Now();
03711:         // TODO: check flags if Min, Max is not ignored
03712:         if (TempDateTime < MinDateTime)
03713:           TempDateTime = MinDateTime;
03714:         if (TempDateTime > MaxDateTime)
03715:           TempDateTime = MaxDateTime;
03716:       }
03717: 
03718:     if (IsCallResetTime)
03719:       TempDateTime.ResetTime();
03720: 
03721:     wxCalendarDialog CalendarDialog (ParentWindow, CalendarDialogCaptionString, 
03722:                                      & TempDateTime,
03723:                                      MinDateTime, 
03724:                                      MaxDateTime,
03725:                                      DateTimeValidatorFlags,
03726:                                      DateTimeFormatString);
03727:     int DialogResultInt = CalendarDialog.ShowModal ();
03728: 
03729:     // wxTraitedDateTimeValidator::IsIgnoreMinimum
03730:     // | wxTraitedDateTimeValidator::IsIgnoreMaximum 
03731: 
03732:     if (DialogResultInt == wxID_OK)
03733:       {
03734:         wxString FormattedDateTime;
03735:         formatDateTimeWithFormat (TempDateTime, FormattedDateTime,
03736:                                   DateTimeFormatString);
03737:         DateTimeTextCtrl -> SetValue (FormattedDateTime);
03738:       }
03739: }
03740: 
03741: //=========================================================================
03742: 
03743: void modifyTopLevelWindows (wxWindow * ParentWindow, wxWindow * ExcludeWindow, ETopLevelWindowModification Mode,
03744:                             wxNonModalDialogManag * NonModalDialogManag,
03745:                             wxWindow * ExtraWindow)
03746: 
03747: {
03748:     wxWindowList ModifyWindowList;
03749: 
03750:     // wxWindowList::compatibility_iterator Node;
03751:     wxWindowListNode * Node = NULL;
03752: 
03753:     //-- make copy of list of windows which are to be activated/hidden etc.
03754:     for (Node = ParentWindow->GetChildren().GetFirst();
03755:          Node != NULL;
03756:          Node = Node->GetNext())
03757:       {
03758:         wxWindow * Window = Node->GetData();
03759: #if wxCHECK_VERSION (2, 5, 0)
03760:         wxTopLevelWindowNative * TopLevelWindow = wxDynamicCast (Window, wxTopLevelWindowNative);
03761: #else
03762:         // older wxWidgets versions don't seem to have appropriate wxTopLevelWindowNative
03763:         // class info support
03764:         wxWindow * TopLevelWindow = Window;
03765: #endif
03766: 
03767:         if ((TopLevelWindow != NULL)
03768:             && (TopLevelWindow != ExcludeWindow))
03769:           {
03770:             ModifyWindowList.Append (TopLevelWindow);
03771:           }
03772:       }
03773: 
03774:     //-- send activation (raise) or hide messages
03775:     for (Node = ModifyWindowList.GetFirst(); Node != NULL; Node = Node -> GetNext())
03776:       {
03777:         wxWindow * Window = Node -> GetData();
03778: #if wxCHECK_VERSION (2, 5, 0)
03779:         wxTopLevelWindowNative * TopLevelWindow = wxDynamicCast (Window, wxTopLevelWindowNative);
03780: #else
03781:         // older wxWidgets versions don't seem to have appropriate wxTopLevelWindowNative
03782:         // class info support
03783:         wxWindow * TopLevelWindow = Window;
03784: #endif
03785: 
03786:         if (Mode == HideTLWModification)
03787:           {
03788:             // TopLevelWindow -> Reparent (ExcludeWindow);
03789:             TopLevelWindow -> Hide();
03790:             // TopLevelWindow -> Iconize();
03791:           }
03792:         else if (Mode == ShowAndRaiseTLWModification)
03793:           {
03794: #if defined (__WXMSW__)
03795:             WXHWND WindowHandle = Window -> GetHWND();
03796:             bool IsWindowOkay = (WindowHandle != NULL) ? ::IsWindow ((struct HWND__ *) WindowHandle) : false;
03797: #endif
03798:             bool IsShown = Window -> IsShown();
03799:             // avoid compiler warning about unused variable:
03800:             IsShown = IsShown;
03801:             bool IsInNonModalDialogInfoList = false;
03802:             bool IsExtraWindow = (Window == ExtraWindow);
03803: 
03804:             if (NonModalDialogManag != NULL)
03805:               {
03806:                 int Index = NonModalDialogManag -> findInfoFromWindow (Window);
03807:                 IsInNonModalDialogInfoList = Index != -1;
03808:               }
03809: 
03810:             if (IsExtraWindow || IsInNonModalDialogInfoList)
03811:               {
03812:                 // TopLevelWindow -> Restore();
03813: 
03814:                 if (!TopLevelWindow -> IsShown())
03815:                   TopLevelWindow -> Show();
03816: 
03817:                 TopLevelWindow -> Raise();
03818:               }
03819:           }
03820:         else
03821:           {
03822:             wxASSERT_MSG (false, "modifyTopLevelWindows(): unhandled ETopLevelWindowModification argument");
03823:           }
03824:       }
03825: }
03826: 
03827: //=========================================================================
03828: 
03829: wxTLWStateInfo::wxTLWStateInfo()
03830: {
03831:     m_Window = NULL;
03832:     m_IsShownWhenNotIconized = false;
03833: }
03834: 
03835: wxTLWStateInfo::wxTLWStateInfo (const wxTLWStateInfo & TLWStateInfo)
03836: {
03837:     m_Window = TLWStateInfo.m_Window;
03838:     m_IsShownWhenNotIconized = TLWStateInfo.m_IsShownWhenNotIconized;
03839: }
03840: 
03841: wxTLWStateInfo::wxTLWStateInfo (wxWindow * Window, bool IsShownWhenNotIconized)
03842: {
03843:     m_Window = Window;
03844:     m_IsShownWhenNotIconized = IsShownWhenNotIconized;
03845: }
03846: 
03847: //-------------------------------------------------------------------------
03848: 
03849: WX_DEFINE_OBJARRAY(wxTLWStateInfoArray)
03850: 
03851: //-------------------------------------------------------------------------
03852: 
03853: wxAppRootFrame * s_GlobalAppRootFrame = NULL;
03854: 
03855: #if (M_WxExtLib_IsUseAppRootFrame == 1)
03856: 
03857: IMPLEMENT_DYNAMIC_CLASS(wxAppRootFrame, wxFrame)
03858: 
03859: BEGIN_EVENT_TABLE(wxAppRootFrame, wxFrame)
03860: 
03861:     EVT_QUERY_END_SESSION (wxAppRootFrame::OnCloseEvent)
03862:     EVT_END_SESSION (wxAppRootFrame::OnCloseEvent)
03863:     EVT_CLOSE (wxAppRootFrame::OnCloseEvent)
03864: 
03865:     EVT_SHOW (wxAppRootFrame::OnShowEvent)
03866: 
03867:     EVT_ACTIVATE (wxAppRootFrame::OnActivateEvent)
03868:     EVT_ACTIVATE_APP (wxAppRootFrame::OnActivateAppEvent)
03869: 
03870:     EVT_ICONIZE (wxAppRootFrame::OnIconizeEvent)
03871:     EVT_MAXIMIZE (wxAppRootFrame::OnMaximizeEvent)
03872: 
03873:     EVT_MOVE (wxAppRootFrame::OnMoveEvent)
03874: 
03875:    // EVT_MENU(ID_Quit,  wxAppRootFrame::OnQuit)
03876: END_EVENT_TABLE()
03877: 
03878: //-------------------------------------------------------------------------
03879: 
03880: #if 1
03881: #   define LOG_WindowInfo(Window) \
03882:        { }
03883: 
03884: // HACK undefine LOG_message(), and LOG_var() macros
03885: //
03886: #   ifdef LOG_message
03887: #       define SAVE_LOG_message LOG_message
03888: #       define SAVE_LOG_var LOG_var
03889: #       define M_IsNeedLogMessageRestore
03890: #   endif
03891: 
03892: #       define LOG_message(StreamArgs) { }
03893: 
03894: #       define LOG_var(StreamArgs) 
03895: 
03896: 
03897: #else
03898: 
03899: #define LOG_WindowInfo(Window) \
03900:   { \
03901:     if (Window != NULL) \
03902:       { \
03903:         if (wxVerifyWindowPtr (AppRootFrame, Window)) \
03904:           { \
03905:             wxString WindowName = Window -> GetName();  \
03906:             wxTopLevelWindowNative * TLWN = wxDynamicCast (Window, wxTopLevelWindowNative); \
03907:             \
03908:             wxString WindowTitle; \
03909:             if (TLWN != NULL) \
03910:               WindowTitle = TLWN -> GetTitle(); \
03911:             \
03912:             LOG_message ("Window: " << LOG_var (cast_genericptr (Window)) \
03913:                          << LOG_var(WindowName) << LOG_var(WindowTitle)); \
03914:           } \
03915:         else \
03916:           { \
03917:             LOG_message ("WARNING Window: " << LOG_var (cast_genericptr (Window)) \
03918:                          << " not found anymore."); \
03919:           } \
03920:       } \
03921:     else \
03922:       { \
03923:         LOG_message ("Window: " << LOG_var (cast_genericptr (Window))); \
03924:       } \
03925:   } \
03926: 
03927: #endif
03928: 
03929: //-------------------------------------------------------------------------
03930: 
03931: wxAppRootFrame::wxAppRootFrame ()
03932: {
03933:     init ();
03934: }
03935: 
03936: wxAppRootFrame::wxAppRootFrame (wxWindow * ParentWindow, wxWindowID id,
03937:                                       const wxString & title, const wxPoint& pos, const wxSize& size, long style,
03938:                                       const wxString & name)
03939:   : wxFrame (ParentWindow, id, title, pos, size, style, name)
03940: { 
03941:     init ();
03942: }
03943: 
03944: void wxAppRootFrame::init()
03945: {
03946:     m_ControllingFrame = NULL;
03947:     m_IsLockEventProcessing = false;
03948:     m_IsFirstActivateAppEvent = true;
03949:     m_LastFocusWindow = NULL;
03950: 
03951:     wxASSERT_MSG (s_GlobalAppRootFrame == NULL, "there  must be only one wxAppRootFrame window");
03952:     s_GlobalAppRootFrame = this;
03953: }
03954: 
03955: wxAppRootFrame::~wxAppRootFrame ()
03956: {
03957:     s_GlobalAppRootFrame = NULL;
03958: }
03959: 
03960: //-------------------------------------------------------------------------
03961: 
03962: wxWindow * wxAppRootFrame::getDefaultParentWindow (wxWindow * ParentWindow)
03963: {
03964:     wxWindow * NewParentWindow = ParentWindow;
03965:     wxAppRootFrame * AppRootFrame = s_GlobalAppRootFrame;
03966:     if (AppRootFrame == NULL)
03967:       return NewParentWindow;
03968: 
03969:     // if ParentWindow is not null: just use it
03970:     if (NewParentWindow != NULL)
03971:       return NewParentWindow;
03972: 
03973:     // search windows in backward order to find top-most
03974:     // non-hidden window
03975:     int InfoCount = AppRootFrame -> m_TLWStateInfoArray.GetCount();
03976:     LOG_message (LOG_var (InfoCount));
03977:     for (int InfoIndex = 0; InfoIndex < InfoCount; ++InfoIndex)
03978:       {
03979:         wxTLWStateInfo & TLWStateInfo
03980:           = AppRootFrame -> m_TLWStateInfoArray [InfoCount - InfoIndex - 1];
03981: 
03982:         wxWindow * Window = TLWStateInfo.m_Window;
03983:         LOG_WindowInfo (Window)
03984:         LOG_message (LOG_var(TLWStateInfo.m_IsShownWhenNotIconized) << LOG_var (Window -> IsShown()));
03985:         
03986:         if (Window -> IsShown())
03987:           {
03988:             LOG_message ("using this window as default parent");
03989:             NewParentWindow = Window;
03990:             break;
03991:           }
03992:       }
03993: 
03994:     // fallback: use controlling frame as parent
03995:     if (NewParentWindow == NULL)
03996:       {
03997:         LOG_message ("using controlling frame as default parent");
03998:         NewParentWindow = s_GlobalAppRootFrame -> getControllingFrame();
03999:       }
04000: 
04001:     return NewParentWindow;
04002: }
04003: 
04004: wxAppRootFrame * wxAppRootFrame::create (const wxIcon & Icon)
04005: {
04006:     // long WindowStyle = wxDEFAULT_FRAME_STYLE;
04007:     long WindowStyle = wxDEFAULT_FRAME_STYLE | wxFRAME_TOOL_WINDOW | wxFRAME_NO_TASKBAR;
04008: 
04009:     // TEST DummyMain
04010:     wxAppRootFrame * AppRootFrame = new wxAppRootFrame(NULL, wxID_AUTO, "AppRootFrame", 
04011:                                                        wxDefaultPosition, wxDefaultSize, WindowStyle);
04012:     // set the frame icon
04013:     AppRootFrame -> SetIcon (Icon);
04014:     
04015:     // AppRootFrame -> Show (true);
04016:     
04017:     wxSetGlobalDefaultParentWindowFunc (wxAppRootFrame::getDefaultParentWindow);
04018: 
04019:     return AppRootFrame;
04020: }
04021: 
04022: void wxAppRootFrame::setup (wxFrame * FrameWindow)
04023: {
04024:     wxAppRootFrame * AppRootFrame = wxGetGlobalAppRootFrame();
04025:     if (AppRootFrame != NULL)
04026:       {
04027:         AppRootFrame -> setControllingFrame (FrameWindow);
04028:         AppRootFrame -> connectTLWEventHandlers (FrameWindow);
04029:       }
04030: }
04031: 
04032: //-------------------------------------------------------------------------
04033: 
04034: void wxAppRootFrame::OnDestroyEvent (wxWindowDestroyEvent & DestroyEvent)
04035: {
04036:     DestroyEvent.Skip();
04037: }
04038: 
04039: void wxAppRootFrame::OnCloseEvent (wxCloseEvent & CloseEvent)
04040: {
04041:     CloseEvent.Skip();
04042: }
04043: 
04044: void wxAppRootFrame::OnShowEvent (wxShowEvent & ShowEvent)
04045: {
04046:     ShowEvent.Skip();
04047: }
04048: 
04049: void wxAppRootFrame::OnActivateEvent (wxActivateEvent & Event)
04050: {
04051:     notifyTLWActivateEvent (Event);
04052:     Event.Skip();
04053: }
04054: 
04055: void wxAppRootFrame::OnActivateAppEvent (wxActivateEvent & Event)
04056: {
04057:     // wxEVT_ACTIVATE_APP may not work, must use special notifyActivateAppEvent() 
04058:     // instead
04059:     bool IsActive = Event.GetActive();
04060:     LOG_message (LOG_var (IsActive));
04061: 
04062:     Event.Skip();
04063: }
04064: 
04065: void wxAppRootFrame::OnIconizeEvent (wxIconizeEvent & IconizeEvent)
04066: {
04067:     bool IsIconize = IconizeEvent.Iconized();
04068:     LOG_message (LOG_var (IsIconize));
04069: 
04070:     IconizeEvent.Skip();
04071: }
04072: 
04073: void wxAppRootFrame::OnMaximizeEvent (wxMaximizeEvent & MaximizeEvent)
04074: {
04075:     MaximizeEvent.Skip();
04076: }
04077: 
04078: void wxAppRootFrame::OnMoveEvent (wxMoveEvent & MoveEvent)
04079: {
04080:     MoveEvent.Skip();
04081: }
04082: 
04083: //-------------------------------------------------------------------------
04084: 
04085: #define M_implementEventForward(EventName,ShortEventName) \
04086:   void wxAppRootFrame::OnTLW ## ShortEventName ## Forward (wx ## EventName & ShortEventName) \
04087:   { \
04088:     if (wxGetGlobalAppRootFrame () != NULL) \
04089:       { \
04090:         wxGetGlobalAppRootFrame() -> notifyTLW ## ShortEventName (ShortEventName); \
04091:       } \
04092:     ShortEventName.Skip(); \
04093:   } \
04094: 
04095: M_implementEventForward (WindowDestroyEvent, DestroyEvent)
04096: M_implementEventForward (CloseEvent, CloseEvent)
04097: M_implementEventForward (ShowEvent, ShowEvent)
04098: M_implementEventForward (ActivateEvent, ActivateEvent)
04099: M_implementEventForward (IconizeEvent, IconizeEvent)
04100: M_implementEventForward (MaximizeEvent, MaximizeEvent)
04101: M_implementEventForward (MoveEvent, MoveEvent)
04102: 
04103: #undef M_implementEventForward
04104: 
04105: //-------------------------------------------------------------------------
04106: 
04107: #define M_implementEventHandlerEntry(EventVar)  \
04108:     wxTopLevelType * TLWNative = NULL; \
04109:     if (!getTLWFromEvent (EventVar, & TLWNative)) \
04110:       return false; \
04111:       \
04112:     if (m_IsLockEventProcessing) \
04113:       { \
04114:         LOG_message ("locked, returning"); \
04115:         return false; \
04116:       } \
04117:     wxScopedSetToTrue ScopedSetToTrue (m_IsLockEventProcessing); \
04118: 
04119: //-------------------------------------------------------------------------
04120: 
04121: bool wxAppRootFrame::notifyTLWDestroyEvent (wxWindowDestroyEvent & DestroyEvent)
04122: {
04123:     M_implementEventHandlerEntry(DestroyEvent)
04124: 
04125:     if (TLWNative != m_ControllingFrame)
04126:       {
04127:         deleteInfoFromWindow (TLWNative);
04128:       }
04129:     return false;
04130: }
04131: 
04132: bool wxAppRootFrame::notifyTLWCloseEvent (wxCloseEvent & CloseEvent /*, bool IsHideInsteadOfClose */)
04133: {
04134:     bool IsHideInsteadOfClose = false;
04135: 
04136:     M_implementEventHandlerEntry(CloseEvent)
04137: 
04138:     if (TLWNative != m_ControllingFrame)
04139:       {
04140:         // WARN TODO CloseEvent() may be close or just hide
04141:         int InfoIndex = findInfoFromWindow (TLWNative);
04142:         if (InfoIndex == -1)
04143:           {
04144:             LOG_message ("could not find corresponding info");
04145:           }
04146:         else
04147:           {
04148:             if (IsHideInsteadOfClose)
04149:               {
04150:                 // do nothing here
04151:                 // wxCloseEvent is used to hide non-modal dialogs
04152:                 // caller must indicate behavior of class
04153:                 LOG_message ("ignoring close event: IsHideInsteadOfClose == true");
04154:               }
04155:             else
04156:               {
04157:                 LOG_message ("ignoring close event: IsHideInsteadOfClose == false, but don't trust");
04158:                 // deleteInfo (InfoIndex);
04159:               }
04160:           }
04161:       }
04162:     return false;
04163: }
04164: 
04165: bool wxAppRootFrame::notifyTLWShowEvent (wxShowEvent & ShowEvent)
04166: {
04167:     M_implementEventHandlerEntry(ShowEvent)
04168: 
04169:     return false;
04170: }
04171: 
04172: bool wxAppRootFrame::notifyTLWActivateEvent (wxActivateEvent & ActivateEvent)
04173: {
04174:     bool IsActive = ActivateEvent.GetActive();
04175: 
04176:     LOG_message (((ActivateEvent.GetEventType() == wxEVT_ACTIVATE_APP) 
04177:                   ? "wxEVT_ACTIVATE_APP" : 
04178:                   ((ActivateEvent.GetEventType() == wxEVT_ACTIVATE) ? "wxEVT_ACTIVATE" : "(other)"))
04179:                  << LOG_var (IsActive));
04180: 
04181:     M_implementEventHandlerEntry(ActivateEvent)
04182: 
04183:     wxWindow * AppRootFrame = this;
04184: 
04185:     if (TLWNative == this)
04186:       {
04187:         if (IsActive)
04188:           {
04189:             wxWindow * Window = getDefaultParentWindow (NULL);
04190:             if (Window != NULL)
04191:               {
04192:                 // Window -> Show();
04193:                 LOG_WindowInfo (Window);
04194:                 LOG_message ("calling Raise()");
04195:                 Window -> Raise();
04196:               }
04197:           }
04198:       }
04199:     else if (TLWNative != m_ControllingFrame)
04200:       {
04201:         if (IsActive)
04202:           {
04203:             int InfoIndex = findInfoFromWindow (TLWNative);
04204:             if (InfoIndex == -1)
04205:               {
04206:                 // add add top of array/stack
04207:                 LOG_message ("window not in list");
04208:                 pushInfo (wxTLWStateInfo (TLWNative, true));
04209:               }
04210:             else
04211:               {
04212:                 // move to top of array/stack:
04213:                 wxTLWStateInfo TLWStateInfo = getInfoByIndex (InfoIndex);
04214:                 deleteInfo (InfoIndex);
04215:                 pushInfo (TLWStateInfo);
04216:               }
04217:           }
04218:       }
04219:     return false;
04220: }
04221: 
04222: bool wxAppRootFrame::notifyActivateAppEvent (bool IsActivate, wxWindow * LastFocusWindow)
04223: {
04224:     wxWindow * AppRootFrame = this;
04225: 
04226:     LOG_message (LOG_var (m_IsLockEventProcessing) 
04227:                  << LOG_var (IsActivate)
04228:                  << LOG_var (m_IsFirstActivateAppEvent));
04229:     LOG_WindowInfo (LastFocusWindow);
04230:     
04231:     if (m_IsLockEventProcessing)
04232:       {
04233:         LOG_message ("locked, returning");
04234:         return false;
04235:       }
04236:     wxScopedSetToTrue ScopedSetToTrue (m_IsLockEventProcessing);
04237: 
04238:     if (IsActivate == false)
04239:       {
04240:         m_IsFirstActivateAppEvent = true;
04241:         m_LastFocusWindow = LastFocusWindow;
04242:       }
04243: 
04244:     if (m_IsFirstActivateAppEvent
04245:         && IsActivate)
04246:       {
04247:         int InfoCount = m_TLWStateInfoArray.GetCount();
04248:         LOG_message (LOG_var (InfoCount));
04249:         for (int InfoIndex = 0; InfoIndex < InfoCount; ++InfoIndex)
04250:           {
04251:             // raise windows in Z-order, starting with lowest
04252:             wxTLWStateInfo & TLWStateInfo
04253:               = m_TLWStateInfoArray [InfoIndex];
04254: 
04255:             wxWindow * Window = TLWStateInfo.m_Window;
04256:             bool IsNeedShow = Window -> IsShown();
04257:             
04258:             LOG_WindowInfo (Window);
04259:             LOG_message (LOG_var(IsNeedShow));
04260:             
04261:             if (IsNeedShow)
04262:               {
04263:                 LOG_message ("calling Show()");
04264:                 __try
04265:                   {
04266:                     Window -> Show (true);
04267:                   }
04268:                 __catch_displayMessageBox
04269:               }
04270:             LOG_message ("calling Raise()");
04271:             __try
04272:               {
04273:                 Window -> Raise ();
04274:               }
04275:             __catch_displayMessageBox
04276:           }
04277: 
04278:         if (m_LastFocusWindow != NULL)
04279:           {
04280:             // first need to verify that window pointer is still
04281:             // valid (sometimes an active-app message arrived "late", 
04282:             // and a window/dialog may have been closed meanwhile, 
04283:             // scope was wxGTK)
04284:             if (wxVerifyWindowPtr (this, m_LastFocusWindow))
04285:               {
04286:                 LOG_WindowInfo (m_LastFocusWindow);
04287: 
04288:                 // make sure that the window still can get the focus (if 
04289:                 // setting focus to a window that is disabled, the application/
04290:                 // message loop may lock up)
04291:                 if (m_LastFocusWindow -> IsEnabled())
04292:                   {
04293:                     LOG_message ("setting focus to LastFocusWindow");
04294:                     m_LastFocusWindow -> SetFocus();
04295:                   }
04296:                 else
04297:                   {
04298:                     // TODO: set focus to first enabled parent window
04299:                     // (or maybe siblings-window?)
04300:                   }
04301:               }
04302:           }
04303:       }
04304: 
04305:     if (IsActivate)
04306:       {
04307:         m_IsFirstActivateAppEvent = false;
04308:       }
04309:     return false;
04310: }
04311: 
04312: bool wxAppRootFrame::notifyTLWIconizeEvent (wxIconizeEvent & IconizeEvent)
04313: {
04314:     M_implementEventHandlerEntry(IconizeEvent)
04315: 
04316:     wxWindow * AppRootFrame = this;
04317: 
04318:     if (TLWNative == m_ControllingFrame)
04319:       {
04320:         // minimizing hidden dummy window:
04321:         // - because of tool-window style, this causes as minimalistic
04322:         //   title bar to appear in lower left corner of screen, so
04323:         //   don't do it (scope: wxWidgets 2.5.3, WinXP)
04324:         //     getApp().getAppRootFrame().Iconize();
04325:         // - restore causes the hidden main window to become visible,
04326:         //   so don't do it (scope: wxWidgets 2.5.3, WinXP)
04327:         //     getApp().getAppRootFrame().Restore();
04328: 
04329: 
04330:         bool IsIconize = IconizeEvent.Iconized();
04331:         if (IsIconize)
04332:           {
04333:             // hide windows, and remember Show/Hide state before hiding
04334:             int InfoCount = m_TLWStateInfoArray.GetCount();
04335:             for (int InfoIndex = 0; InfoIndex < InfoCount; ++InfoIndex)
04336:               {
04337:                 wxTLWStateInfo & TLWStateInfo
04338:                   = m_TLWStateInfoArray [InfoIndex];
04339: 
04340:                 wxWindow * Window = TLWStateInfo.m_Window;
04341:                 bool IsCurrentlyShown = Window -> IsShown();
04342: 
04343:                 LOG_WindowInfo (Window)
04344:                 LOG_message (LOG_var(IsCurrentlyShown));
04345:                 TLWStateInfo.m_IsShownWhenNotIconized = IsCurrentlyShown;
04346: 
04347:                 LOG_message ("calling Hide()");
04348:                 Window -> Hide();                
04349:               }
04350:           }
04351:         else
04352:           {
04353:             // it is required to restore e.g. non-modal dialogs (having popup style) 
04354:             // manually: raise windows in Z-order, starting with lowest
04355:             int InfoCount = m_TLWStateInfoArray.GetCount();
04356:             for (int InfoIndex = 0; InfoIndex < InfoCount; ++InfoIndex)
04357:               {
04358:                 wxTLWStateInfo & TLWStateInfo
04359:                   = m_TLWStateInfoArray [InfoIndex];
04360: 
04361:                 wxWindow * Window = TLWStateInfo.m_Window;
04362:                 bool IsNeedShowAndRaise = TLWStateInfo.m_IsShownWhenNotIconized;
04363: 
04364:                 LOG_WindowInfo (Window)
04365:                 LOG_message (LOG_var(IsNeedShowAndRaise));
04366: 
04367:                 if (IsNeedShowAndRaise)
04368:                   {
04369:                     LOG_message ("calling Show() and Raise()");
04370:                     Window -> Show (true);
04371:                     Window -> Raise ();
04372:                   }
04373:               }
04374:           }
04375:       }
04376:     return false;
04377: }
04378: 
04379: bool wxAppRootFrame::notifyTLWMaximizeEvent (wxMaximizeEvent & MaximizeEvent)
04380: {
04381:     M_implementEventHandlerEntry(MaximizeEvent)
04382: 
04383:     return false;
04384: }
04385: 
04386: bool wxAppRootFrame::notifyTLWMoveEvent (wxMoveEvent & MoveEvent)
04387: {
04388:     M_implementEventHandlerEntry(MoveEvent)
04389: 
04390:     if (TLWNative == m_ControllingFrame)
04391:       {
04392:         wxPoint Point = MoveEvent.GetPosition();
04393:         wxSize Size = TLWNative -> GetSize();
04394:         this -> Move (Point.x + Size.GetWidth()/2, Point.y + Size.GetHeight()/2);
04395:       }
04396:     return false;
04397: }
04398: 
04399: #undef M_implementEventHandlerEntry
04400: 
04401: //-------------------------------------------------------------------------
04402: 
04403: #define M_connectEventHandler(EventName,EventShortName,EventTypeName)   \
04404:   { \
04405:     wx ## EventName ## EventFunction  EventShortName ## EventFunction \
04406:       = (wx ## EventName ## EventFunction) (& wxAppRootFrame::OnTLW ## EventShortName ## EventForward); \
04407:     \
04408:     /* HACK use of non-static member function of wrong object */   \
04409:     Window -> Connect (Window -> GetId(), \
04410:                        EventTypeName, \
04411:                        (wxObjectEventFunction) (wxEventFunction) EventShortName ## EventFunction); \
04412:   } \
04413: 
04414: void wxAppRootFrame::connectTLWEventHandlers (wxWindow * Window)
04415: {
04416:     wxActivateEventFunction ActivateEventFunction
04417:       = (wxActivateEventFunction) (& wxAppRootFrame::OnTLWActivateEventForward);
04418: 
04419:     // HACK use of non-static member function of wrong object
04420:     Window -> Connect (Window -> GetId(),
04421:                        wxEVT_ACTIVATE,
04422:                        (wxObjectEventFunction) (wxEventFunction) ActivateEventFunction);
04423: 
04424:     M_connectEventHandler (WindowDestroy, Destroy, wxEVT_DESTROY)
04425:     M_connectEventHandler (Close, Close, wxEVT_CLOSE_WINDOW)
04426:     M_connectEventHandler (Show, Show, wxEVT_SHOW)
04427:     M_connectEventHandler (Activate, Activate, wxEVT_ACTIVATE)
04428:     // wxEVT_ACTIVATE_APP may not work, must use special notifyActivateAppEvent() 
04429:     // instead
04430:     M_connectEventHandler (Activate, Activate, wxEVT_ACTIVATE_APP)
04431:     M_connectEventHandler (Iconize, Iconize, wxEVT_ICONIZE)
04432:     M_connectEventHandler (Maximize, Maximize, wxEVT_MAXIMIZE)
04433:     M_connectEventHandler (Move, Move, wxEVT_MOVE)
04434: }
04435: 
04436: #undef M_connectEventHandler
04437: 
04438: bool wxAppRootFrame::getTLWFromEvent (wxEvent & Event, wxTopLevelType ** TLWNativePtrPtr)
04439: {
04440:     if (Event.GetEventObject() == NULL)
04441:       return false;
04442: 
04443:     wxWindow * AppRootFrame = this;
04444:       
04445: #if wxCHECK_VERSION (2, 5, 0)
04446:     wxTopLevelType * TLWNative = wxDynamicCast (Event.GetEventObject(), wxTopLevelWindowNative);
04447: #else
04448:     // older wxWidgets versions don't seem to have appropriate wxTopLevelWindowNative
04449:     // class info support
04450:     wxTopLevelType * TLWNative = wxDynamicCast (Event.GetEventObject(), wxWindow);
04451: #endif
04452:     if (TLWNative == NULL)
04453:       return false;
04454: 
04455:     LOG_message ("found TLW: ");
04456:     LOG_WindowInfo (TLWNative);
04457:     *TLWNativePtrPtr = TLWNative;
04458:     return true;
04459: }
04460: 
04461: //-------------------------------------------------------------------------
04462: 
04463: int wxAppRootFrame::pushInfo (const wxTLWStateInfo & TLWStateInfo)
04464: {
04465:     int InfoCount = m_TLWStateInfoArray.GetCount();
04466:     m_TLWStateInfoArray.Add (new wxTLWStateInfo (TLWStateInfo));
04467: 
04468:     // InfoCount should be index of currently added element:
04469:     return InfoCount;
04470: }
04471: 
04472: void wxAppRootFrame::deleteInfo (int Index)
04473: {
04474:     LOG_message ("removing info");
04475:     m_TLWStateInfoArray.RemoveAt (Index);
04476: }
04477: 
04478: void wxAppRootFrame::deleteInfoFromWindow (wxWindow * Window)
04479: {
04480:     int InfoIndex = findInfoFromWindow (Window);
04481:     if (InfoIndex != -1)
04482:       {
04483:         LOG_message ("removing info");
04484:         m_TLWStateInfoArray.RemoveAt (InfoIndex);
04485:       }
04486:     else
04487:       {
04488:         wxASSERT_MSG (false, "deleteInfoFromWindow(): window not found");
04489:       }
04490: }
04491: 
04492: wxTLWStateInfo & wxAppRootFrame::getInfoByIndex (int InfoIndex)
04493: {
04494:     return m_TLWStateInfoArray [InfoIndex];
04495: }
04496: 
04497: int wxAppRootFrame::findInfoFromWindow (wxWindow * Window)
04498: {
04499:     int InfoCount = m_TLWStateInfoArray.GetCount();
04500:     for (int InfoIndex = 0; InfoIndex < InfoCount; ++InfoIndex)
04501:       {
04502:         wxTLWStateInfo & TLWStateInfo
04503:           = m_TLWStateInfoArray [InfoIndex];
04504: 
04505:         if (TLWStateInfo.m_Window == Window)
04506:           return InfoIndex;
04507:       }
04508:     return -1;
04509: }
04510: 
04511: 
04512: //-------------------------------------------------------------------------
04513: 
04514: #undef LOG_WindowInfo
04515: 
04516: #ifdef M_IsNeedLogMessageRestore
04517: #   define LOG_message SAVE_LOG_message
04518: #   define LOG_var SAVE_LOG_var
04519: #endif
04520: 
04521: #endif // M_WxExtLib_IsUseAppRootFrame
04522: 
04523: //-------------------------------------------------------------------------
04524: 
04525: wxAppRootFrame * wxGetGlobalAppRootFrame()
04526: {
04527:     return s_GlobalAppRootFrame;
04528: }
04529: 
04530: //=========================================================================
04531: 
04532: #if (M_WxExtLib_IsUseStxLogging == 1)
04533:     #undef __try
04534:     #undef __catch_rethrow
04535:     #undef __catch_displayMessageBox
04536: #endif
04537: 
04538: //=========================================================================
04539: 
  [main]    [up]  
DaicasWeb v.1.50.0102  //   Daniel Käps  //   April 12, 2007  //   Impressum / Imprint 
http://www.daicas.net/WxExtLib/src/WxExtDialog.cpp.html