[main]    [up]  

WxExtLib - MessageExtDialog.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: #include "WxExtLibConfig.h"
00044: 
00045: #if defined(__GNUG__) && (!defined(__APPLE__)) && (!(defined M_NoPragmaInterface))
00046: #   pragma implementation "MessageExtDialog.h"
00047: #endif
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 MessageExtDialog.h with definitions for both, C and C++
00057: // interface:
00058: #define M_MessageExtDialog_EnableCInterface
00059: #define M_MessageExtDialog_EnableCxxInterface
00060: #include "MessageExtDialog.h"
00061: 
00062: #include <wx/statline.h>
00063: #include <wx/image.h>
00064: #include <wx/artprov.h>
00065: 
00066: #include "WxMisc.h"
00067: #include "StatusValidators.h"
00068: 
00069: #endif // _NO_HEADER_INCLUDE
00070: 
00071: //-------------------------------------------------------------------------
00072: 
00073: double wxMessageExtDialog::s_GlobalMessageExtDialogZoom = 1.05;
00074: long wxMessageExtDialog::s_GlobalFlags = wxMessageExtDialog::DisplayColourBar;
00075: wxString wxMessageExtDialog::s_GlobalTitlePostfix;
00076: 
00077: //=========================================================================
00078: 
00079: BEGIN_EVENT_TABLE (wxMessageExtDialog, wxExtDialog)
00080:     // EVT_MENU   (wxID_HELP, wxMessageExtDialog::OnHelp)
00081:     EVT_BUTTON (wxID_ANY, wxMessageExtDialog::OnButtonEvent)
00082:     EVT_CHAR   (wxMessageExtDialog::OnChar)
00083:     EVT_KEY_DOWN   (wxMessageExtDialog::OnKeyDown)
00084: END_EVENT_TABLE()
00085: 
00086: //-------------------------------------------------------------------------
00087: 
00088: wxMessageExtDialog::wxMessageExtDialog()
00089: {
00090: }
00091: 
00092: wxMessageExtDialog::wxMessageExtDialog (wxWindow *ParentWindow,
00093:                                         const wxString & MessageString,
00094:                                         const wxString & TitleString)
00095:   : wxExtDialog (getUsedParentWindow (ParentWindow),
00096:                  -1, "" /*TitleString*/,
00097:                  wxDefaultPosition, wxDefaultSize,
00098:                  wxDEFAULT_DIALOG_STYLE | wxWANTS_CHARS)
00099: {
00100:     init (MessageString, TitleString);
00101: }
00102: 
00103: void wxMessageExtDialog::Create (wxWindow *ParentWindow,
00104:                                  const wxString & MessageString,
00105:                                  const wxString & TitleString)
00106: {
00107:     wxExtDialog::Create (getUsedParentWindow (ParentWindow),
00108:                          -1, "" /* TitleString */,
00109:                          wxDefaultPosition, wxDefaultSize,
00110:                          wxDEFAULT_DIALOG_STYLE | wxWANTS_CHARS);
00111:     
00112:     init (MessageString, TitleString);
00113: }
00114: 
00115: 
00116: void wxMessageExtDialog::init (const wxString & MessageString, const wxString & TitleString)
00117: {
00118:     m_IsControlsCreated = FALSE;
00119: 
00120:     m_TitleString = TitleString;
00121: 
00122:     m_DefaultButton = NULL;
00123:     m_LastAddedButton = NULL;
00124:     m_LastAddedAutoButtonIdent = FirstAutoButtonIdent - 1;
00125:     m_CurrentButtonIndex = 0;
00126: 
00127:     m_Style = MessageStyle;
00128: 
00129:     // m_TextCtrl = NULL;
00130: 
00131:     //-------------------------------------------------------------------------
00132: 
00133:     m_StatusMessageTarget = NULL;
00134:     // wxWindow * PanelWnd = this;
00135:     m_PanelSizer = new wxBoxSizer (wxVERTICAL);
00136: 
00137:     setDialogZoom (s_GlobalMessageExtDialogZoom);
00138: 
00139:     //-------------------------------------------------------------------------
00140:     m_DialogMessageString = MessageString;
00141: 
00142:     //-------------------------------------------------------------------------
00143: 
00144:     m_TextCtrlFont  = createDialogFont(getDialogFontSize(), 
00145: #if defined(__WXMOTIF__)
00146:                                        // wxTextCtrl under Motif seems to ignore requests
00147:                                        // to set a different font, even if the font is of
00148:                                        // type wxMODERN (should be a fixed-pitch font)
00149:                                        wxMODERN /* family */,
00150: #else
00151:                                        wxDEFAULT /* family */,
00152: #endif
00153:                                        wxNORMAL  /* upright/slant/italic */, 
00154:                                        wxNORMAL  /* weight */,
00155:                                        FALSE  /* underlined? */, 
00156:                                        _T("") /* face name */,
00157:                                        wxFONTENCODING_DEFAULT /* wxFONTENCODING_ISO8859_1 */
00158:                                        );
00159:     // create the button font: shall be a little larger than the normal
00160:     // dialog font:
00161: #if defined(__WXMSW__)
00162:     int ButtonFontSize = getDialogFontSize();
00163: 
00164:     // under MSW, the font created with the bold attribute will appear
00165:     // higher and wider with the normal dialog font size already
00166:     // (scope: the default dialog font, things may be different for other
00167:     // fonts and/or true type fonts)
00168:     // so reduce (nominal) font size by one point
00169:     if (ButtonFontSize > 8 /* DefaultDialogFontSize */)
00170:       --ButtonFontSize;
00171: 
00172:     m_ButtonFont  = createDialogFont(ButtonFontSize, 
00173:                                      wxDEFAULT /* family */, 
00174:                                      wxNORMAL /* upright/slant/italic */, 
00175:                                      wxBOLD /* weight */,
00176:                                      FALSE /* underlined? */, 
00177:                                      _T("") /* face name */,
00178:                                      wxFONTENCODING_DEFAULT /* wxFONTENCODING_ISO8859_1 */);
00179: #else // e.g. __WXGTK__
00180:     m_ButtonFont  = createDialogFont(getDialogFontSize(), 
00181:                                      wxDEFAULT /* family */, 
00182:                                      wxNORMAL /* upright/slant/italic */,
00183:                                      wxBOLD /* weight */,
00184:                                      FALSE /* underlined? */, 
00185:                                      _T("") /* face name */,
00186:                                      wxFONTENCODING_DEFAULT /* wxFONTENCODING_ISO8859_1 */);
00187: #endif
00188: 
00189:     m_ButtonFlexGridSizer = new wxFlexGridSizer (1, 0, _B(0), _B(10));
00190: 
00191: }
00192: 
00193: //-------------------------------------------------------------------------
00194: 
00195: void wxMessageExtDialog::setDialogMessage (const wxString & MessageString)
00196: {
00197:     m_DialogMessageString = MessageString;
00198:     m_MessageMultiLineText.setText (m_DialogMessageString);
00199: }
00200: 
00201: //-------------------------------------------------------------------------
00202: 
00203: wxMessageExtDialog & wxMessageExtDialog::addStatusTextCtrl ()
00204: {
00205:     if (m_StatusMessageTarget == NULL)
00206:       {
00207:         m_StatusMessageTarget 
00208:           = new wxStatusMessageTarget (createErrorMessageCtrl (& m_ErrorMessageMultiLineText), "");
00209:       }
00210: 
00211:     return *this;
00212: }
00213: 
00214: //-------------------------------------------------------------------------
00215: 
00216: wxMessageExtDialog & wxMessageExtDialog::addButton (const wxString & Label,
00217:                                                 int ButtonIdent)
00218: {
00219:     if (m_CurrentButtonIndex > 0)
00220:       {
00221:         m_ButtonFlexGridSizer -> Add (1, 1);
00222:         m_ButtonFlexGridSizer -> AddGrowableCol (m_CurrentButtonIndex * 2 - 1);
00223:       }
00224: 
00225:     wxSizerAdder ButtonSizerAdder (m_ButtonFlexGridSizer);
00226: 
00227:     wxButton * Button;
00228:     // WARN don't know if syntax for function pointer conversion is correct
00229:     wxExtDialog::addButton (& Button, ButtonIdent, (wxCommandEventFunction) (& wxMessageExtDialog::OnButtonEvent), 
00230:                             Label, 
00231:                             & ButtonSizerAdder);
00232: 
00233:     Button -> SetFont (m_ButtonFont);
00234: 
00235:     int MajorVersionInt = 0;
00236:     int MinorVersionInt = 0;
00237:     int OsSpecifierInt = wxGetOsVersion (& MajorVersionInt, & MinorVersionInt);
00238:     // WinXP: do not set button's background colour because this prevents
00239:     // WinXP from using new WinXP button style (Win version 5.1)
00240:     if (!(OsSpecifierInt == wxWINDOWS_NT 
00241:           && ((MajorVersionInt > 5) 
00242:               || (MajorVersionInt == 5 && MinorVersionInt >= 1))))
00243:       {
00244:         Button -> SetBackgroundColour (wxColour (224, 224, 224));
00245:       }
00246: 
00247: //     if (!m_LastAddedButton)
00248: //    Button -> SetFocus();
00249: 
00250:     m_LastAddedButton = Button;
00251:     ++m_CurrentButtonIndex;
00252: 
00253:     return *this;
00254: }
00255: 
00256: int wxMessageExtDialog::addButton (const wxString & Label)
00257: {
00258:     int ButtonIdent = ++m_LastAddedAutoButtonIdent;
00259:     addButton (Label, ButtonIdent);
00260: 
00261:     return ButtonIdent;
00262: }
00263: 
00264: void wxMessageExtDialog::makeLastAddedButtonDefault ()
00265: {
00266:     if (m_LastAddedButton)
00267:       {
00268:         m_DefaultButton = m_LastAddedButton;
00269:       }
00270: }
00271: 
00272: //-------------------------------------------------------------------------
00273: 
00274: void wxMessageExtDialog::OnOK(wxCommandEvent& Event) 
00275: {
00276:     handleButtonEvent (Event);
00277: }
00278: 
00279: void wxMessageExtDialog::OnCancel(wxCommandEvent& Event)
00280: {
00281:     handleButtonEvent (Event);
00282: }
00283: 
00284: void wxMessageExtDialog::OnButtonEvent(wxCommandEvent& Event)
00285: {
00286:     handleButtonEvent (Event);
00287: }
00288: 
00289: void wxMessageExtDialog::handleButtonEvent (wxCommandEvent& Event)
00290: {
00291:     // events with event-id == wxID_CANCEL will be accepted
00292:     // only if the message dialog has a cancel button, or if the 
00293:     // message dialog only contains a single OK button 
00294:     // - otherwise the meaning of pressing the <Esc> button or clicking
00295:     //   the window-close icon of the dialog would be unclear to the user 
00296:     // NOTE 
00297:     // - OnCancel() is generated automatically e.g. when 
00298:     //   pressing the <Esc> key even if the dialog doesn't have a 
00299:     //   Cancel button
00300: 
00301:     if (Event.GetId() == wxID_CANCEL)
00302:       {
00303:         wxWindow * CancelButton = FindWindowById (wxID_CANCEL, this);
00304:         wxWindow * OkayButton = FindWindowById (wxID_OK, this);
00305:     
00306:         if (CancelButton != NULL            
00307:             || (m_CurrentButtonIndex == 1 && 
00308:                 OkayButton != NULL))
00309:           {
00310:             if (m_CurrentButtonIndex == 1 && OkayButton != NULL)
00311:               {
00312:                 // modify to event object to simulate that the only
00313:                 // available button was pressed:
00314:                 Event.SetId (OkayButton -> GetId());
00315:                 Event.SetEventObject (OkayButton);
00316:               }
00317:           }
00318:         else
00319:           {
00320:             // ignore event:
00321:             return;
00322:           }
00323:       }
00324: 
00325:     int ButtonIdent = Event.GetId(); // Event.m_id
00326:     if (ButtonIdent == wxID_OK)
00327:       {
00328:         // WARN since wxWidgets 2.8 or so, OnOK() doesn't exist enymore, what
00329:         // can we do, except for disabling OnOK()?
00330:         // - solution is to provide our own OnOK(), OnCancel() by wxExtDialog
00331: 
00332:         wxExtDialog::OnOK (Event);
00333:         // // EndModal (wxID_OK);
00334:       }
00335:     else if (ButtonIdent == wxID_CANCEL)
00336:       {
00337:         wxExtDialog::OnCancel (Event);
00338:       }
00339:     else
00340:       {
00341:         EndModal (ButtonIdent);
00342:       }
00343: }
00344: 
00345: //-------------------------------------------------------------------------
00346: 
00347: // BUG for whatever reason, the OnChar() and OnKeyDown() message handlers
00348: // are never called
00349: void wxMessageExtDialog::OnChar (wxKeyEvent & KeyEvent)
00350: {
00351:     wxButton * Button = NULL; // TEST findButtonForKey (KeyEvent.KeyCode());
00352: 
00353:     if (Button != NULL)
00354:       {
00355:         if (Button -> IsEnabled())
00356:           {
00357:             // we must generate a command event to simulate the button click:
00358:             wxCommandEvent CommandEvent (wxEVT_COMMAND_BUTTON_CLICKED, Button -> GetId());
00359:             CommandEvent.SetEventObject (Button);
00360:             // Button -> InitCommandEvent (CommandEvent);
00361:             Button -> GetEventHandler() -> ProcessEvent (CommandEvent);
00362:           }
00363:       }
00364:     else
00365:       {
00366:         KeyEvent.Skip ();
00367:       }
00368: }
00369: 
00370: void wxMessageExtDialog::OnKeyDown (wxKeyEvent & KeyEvent)
00371: {
00372:     KeyEvent.Skip ();
00373: }
00374: 
00375: //-------------------------------------------------------------------------
00376: 
00377: int wxMessageExtDialog::ShowModal()
00378: {
00379:     if (!m_IsControlsCreated)
00380:       {
00381:         createControls ();
00382:         m_IsControlsCreated = true;
00383:       }
00384: 
00385:     return wxExtDialog::ShowModal();
00386: }
00387: 
00388: //-------------------------------------------------------------------------
00389: 
00390: void wxMessageExtDialog::createControls()
00391: {
00392:     // wxColour BackgroundColor (192, 192, 192);
00393:     // this -> SetBackgroundColour (BackgroundColor);
00394:     wxColour BackgroundColor = this -> GetBackgroundColour ();
00395: 
00396:     //-------------------------------------------------------------------------
00397:     // create colour bar if required
00398: 
00399:     int Style = (m_Style & StyleMask);
00400:     bool IsColourBar = (((s_GlobalFlags & DisplayColourBar) != 0) 
00401:                         && (Style != MessageStyle));
00402:     bool IsImage = (((s_GlobalFlags & DisplayImage) != 0)
00403:                     && (Style != MessageStyle));
00404:                     
00405:     wxBoxSizer * GroupAllBoxSizer = new wxBoxSizer (wxHORIZONTAL);
00406:     m_PanelSizer -> Add (GroupAllBoxSizer, 0, wxEXPAND, _B(0));
00407: 
00408:     if (IsColourBar)
00409:       {
00410:         int Style = m_Style & StyleMask;
00411: 
00412:         wxColour BarColour = wxColour (255, 255, 255);
00413:         if (Style == InformationStyle)
00414:           BarColour = wxColour (255, 255, 255);
00415:         else if (Style == WarningStyle)
00416:           BarColour = wxColour (128, 160, 32);
00417:         else if (Style == ErrorStyle)
00418:           BarColour = wxColour (160, 64, 64);
00419:         else if (Style == CriticalErrorStyle)
00420:           BarColour = wxColour (192, 64, 96);
00421:         else if (Style == QuestionStyle)
00422:           BarColour = wxColour (32, 160, 160);
00423: 
00424:         wxWindow * Window = new wxColourBarWindow (this, -1, BarColour);
00425: 
00426:         GroupAllBoxSizer -> Add (Window, 0, wxEXPAND, _B(0));
00427:         GroupAllBoxSizer -> SetItemMinSize (Window, _B(20), _B(0));
00428:         GroupAllBoxSizer -> Add (new wxStaticLine (this, -1, 
00429:                                                    wxDefaultPosition, wxDefaultSize,
00430:                                                    wxVERTICAL), 
00431:                                  0, wxEXPAND, _B(0));
00432: 
00433:         GroupAllBoxSizer -> Add (_B(5), _B(0));
00434:       }
00435: 
00436:     // sizer for message text and buttons
00437:     wxBoxSizer * GroupContentBoxSizer = new wxBoxSizer (wxVERTICAL);
00438:     GroupAllBoxSizer -> Add (GroupContentBoxSizer, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, _B(14));
00439: 
00440:     wxBoxSizer * GroupSubContentBoxSizer = new wxBoxSizer (wxHORIZONTAL);
00441:     GroupContentBoxSizer -> Add (GroupSubContentBoxSizer, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, _B(0));
00442: 
00443:     //-------------------------------------------------------------------------
00444:     // setup image control
00445: 
00446:     if (IsImage)
00447:       {
00448:         wxArtID ArtId 
00449:           = Style == InformationStyle ? wxART_INFORMATION
00450:           : Style == WarningStyle     ? wxART_WARNING
00451:           : Style == ErrorStyle       ? wxART_ERROR
00452:           : Style == CriticalErrorStyle ? wxART_ERROR
00453:           : Style == QuestionStyle    ? wxART_QUESTION
00454:           : wxEmptyString;
00455: 
00456:         wxASSERT (ArtId != wxEmptyString);
00457: 
00458:         if (ArtId != wxEmptyString)
00459:           {
00460:             wxBitmap Bitmap = wxArtProvider::GetBitmap (ArtId, wxART_MESSAGE_BOX, wxDefaultSize);
00461:             wxWindow * Window 
00462:               = new wxStaticBitmap (this, -1, 
00463:                                     Bitmap,
00464:                                     wxDefaultPosition, wxSize (Bitmap.GetWidth(), Bitmap.GetHeight()),
00465:                                     0 /* style */);
00466: 
00467:             GroupSubContentBoxSizer -> Add (Window, 0, wxEXPAND, _B(0));
00468:             GroupSubContentBoxSizer -> Add (_B(10), _B(0));
00469:           }
00470:       }
00471: 
00472:     //-------------------------------------------------------------------------
00473:     // setup text control for message
00474: 
00475:     // to improve readability, the background is set to white 
00476:     // for longer message texts - a message is considered to be "long"
00477:     // if it contains at least one newline character or if it contains
00478:     // more than 300 characters
00479:     bool IsNewlineInMessage = (m_DialogMessageString.Find ('\n') != -1);
00480:     bool IsLongMessage = IsNewlineInMessage || (m_DialogMessageString.Len() >= 300);
00481: 
00482:     wxSize TextCtrlSize = wxSize (getAdjustedTextCtrlWidth (IsLongMessage ? 400 : 350),
00483:                                   getAdjustedTextCtrlHeight (1, 1));
00484: 
00485:     // wxMultiLineText: create without border because the dialog is so simple
00486:     // that borders as structuring elements are not really needed
00487:     m_MessageMultiLineText.create (this, -1, 
00488:                                    IsLongMessage ? wxBORDER_SIMPLE : wxBORDER_NONE, 
00489:                                    TextCtrlSize,
00490:                                    (m_Style & IsHtmlMode) ? wxMultiLineText::wxHTML_MODE 
00491: #if wxCHECK_VERSION (2, 5, 0)
00492:                                    // HACK: use Html window always because of wxTextCtrl size
00493:                                    // setting problem with new wxWidgets version (2.5.2)
00494:                                    : wxMultiLineText::wxFORCE_HTMLWINDOW
00495: #else
00496:                                    : 0
00497: #endif
00498:                                    );
00499:     if (m_MessageMultiLineText.getTextCtrl() != NULL)
00500:       {
00501:         m_MessageMultiLineText.getTextCtrl() -> SetFont (m_TextCtrlFont);
00502:       }
00503:     else if (m_MessageMultiLineText.getHtmlWindow() != NULL)
00504:       {
00505:         setHtmlWindowFonts (m_MessageMultiLineText.getHtmlWindow(),
00506:                             m_TextCtrlFont.GetPointSize(),
00507:                             true,
00508:                             FALSE);
00509:         m_MessageMultiLineText.getHtmlWindow() -> SetBorders (5);
00510:       }
00511:     m_MessageMultiLineText.getWindow() -> SetBackgroundColour (IsLongMessage ? *wxWHITE : BackgroundColor);
00512:     m_MessageMultiLineText.setText (m_DialogMessageString);
00513:     adjustMultiLineTextSize (m_MessageMultiLineText, 3, 10);
00514: 
00515:     GroupSubContentBoxSizer -> Add (m_MessageMultiLineText.getWindow(), 0, wxEXPAND, _B(0));
00516: 
00517:     //-------------------------------------------------------------------------
00518:     GroupContentBoxSizer -> Add (new wxStaticLine (this, -1), 0, 
00519:                                  wxTOP|wxEXPAND, _B(14));
00520: 
00521:     //-------------------------------------------------------------------------
00522:     // add sizer for buttons
00523: 
00524:     int AdditionalButtonSizerFlags = (m_CurrentButtonIndex >= 2)
00525:       ? cast_enum (wxEXPAND) : cast_enum (wxALIGN_CENTRE_HORIZONTAL);
00526: 
00527:     GroupContentBoxSizer -> Add (m_ButtonFlexGridSizer, 0, 
00528:                                  wxTOP
00529:                                  | AdditionalButtonSizerFlags, _B(14));
00530:     
00531:     // add message text control
00532:     if (m_StatusMessageTarget 
00533:         && (m_ErrorMessageMultiLineText.getWindow() != NULL))
00534:       GroupContentBoxSizer -> Add (m_ErrorMessageMultiLineText.getWindow(),
00535:                                    0, wxTOP|wxEXPAND, _B(14));
00536: 
00537:     GroupContentBoxSizer -> Add (0, _B(14));
00538: 
00539:     // append postfix to title
00540:     if (s_GlobalTitlePostfix != wxEmptyString)
00541:       {
00542:         if (m_TitleString != wxEmptyString)
00543:           m_TitleString.Append (" - ");
00544:         m_TitleString.Append (s_GlobalTitlePostfix);
00545:       }
00546:     SetTitle (m_TitleString);
00547: 
00548:     //-------------------------------------------------------------------------
00549:     SetSizerAndFit (m_PanelSizer);
00550: 
00551:     enableWatchedControlChangeNotification (true);
00552: 
00553:     if (m_DefaultButton)
00554:       {
00555:         m_DefaultButton -> SetDefault();
00556:         m_DefaultButton -> SetFocus();
00557:       }
00558: }
00559: 
00560: //-------------------------------------------------------------------------
00561: 
00562: void wxMessageExtDialog::setStyle (/* EStyle */ long Style)
00563: {
00564:     m_Style = Style;
00565: }
00566: 
00567: void wxMessageExtDialog::setGlobalFlags (/* EFlags */ long Flags)
00568: {
00569:     s_GlobalFlags = Flags;
00570: }
00571: 
00572: //-------------------------------------------------------------------------
00573: 
00574: void  wxMessageExtDialog::setGlobalTitlePostfix (const wxString & String) // (static)
00575: {
00576:     s_GlobalTitlePostfix = String;
00577: }
00578: 
00579: void  wxMessageExtDialog::getGlobalTitlePostfix (wxString & String) // (static)
00580: {
00581:     String = s_GlobalTitlePostfix;
00582: }
00583: 
00584: void wxMessageExtDialog::setGlobalMessageExtDialogZoom (double ZoomValue) // (static)
00585: {
00586:      s_GlobalMessageExtDialogZoom = ZoomValue;
00587: }
00588: 
00589: double wxMessageExtDialog::getGlobalMessageExtDialogZoom () // (static)
00590: {
00591:     return s_GlobalMessageExtDialogZoom;
00592: }
00593: 
00594: void wxMessageExtDialog::setGlobalGetDefaultParentWindowFunc (wxDefaultParentWindowFunc Func)
00595: {
00596:     wxSetGlobalDefaultParentWindowFunc (Func);
00597: }
00598: 
00599: wxWindow * wxMessageExtDialog::getUsedParentWindow (wxWindow * ParentWindow)
00600: {
00601:     return wxGetDefaultParentWindow (ParentWindow);
00602: }
00603: 
00604: //-------------------------------------------------------------------------
00605: 
00606: wxButton * wxMessageExtDialog::findButtonForKey (char KeyChar)
00607: {
00608:     wxWindowList::Node *CurrentWindowNode = GetChildren().GetFirst();
00609:     wxString SearchString = "&";
00610:     SearchString.Append (KeyChar);
00611: 
00612:     wxButton * FoundButton = NULL;
00613:     bool IsDuplicatedKey = FALSE;
00614: 
00615:     while (CurrentWindowNode != NULL)
00616:     {
00617:         wxWindow *Window = CurrentWindowNode->GetData();
00618: 
00619:         if (Window -> IsKindOf (CLASSINFO(wxButton)))
00620:           {
00621:             wxString LabelString = Window -> GetLabel ();
00622:             int CharIndex = LabelString.Find (SearchString);
00623:             if (CharIndex != -1 
00624:                 && (CharIndex == 0 || LabelString.GetChar (CharIndex-1) != '&'))
00625:               {
00626:                 if (FoundButton == NULL)
00627:                   FoundButton = (wxButton *) Window;
00628:                 else
00629:                   IsDuplicatedKey = true;
00630:               }
00631:           }
00632: 
00633:         CurrentWindowNode = CurrentWindowNode->GetNext();
00634:     }
00635: 
00636:     return IsDuplicatedKey ? NULL : FoundButton;
00637: }
00638: 
00639: //-------------------------------------------------------------------------
00640: 
00641: wxButton * wxMessageExtDialog::getButton (int ButtonIdent)
00642: {
00643:     wxWindow * Window = FindWindowById (ButtonIdent, this);
00644: 
00645:     bool IsButton = Window -> IsKindOf (CLASSINFO (wxButton));
00646:     // wxCHECK_MSG (IsButton, FALSE,
00647:     //           _T("getButton(): FindWindowById() did not return a valid button"));
00648: 
00649:     return IsButton ? (wxButton *) Window : NULL;
00650: }
00651: 
00652: void wxMessageExtDialog::enableButton (int ButtonIdent, bool IsEnable)
00653: {
00654:     wxWindow * Window = FindWindowById (ButtonIdent, this);
00655:     if (Window)
00656:       {
00657:         Window -> Enable (IsEnable);
00658:       }
00659: }
00660: 
00661: void wxMessageExtDialog::setButtonLabel (int ButtonIdent, const wxString & LabelString)
00662: {
00663:     wxButton * Button = getButton (ButtonIdent);
00664:     if (Button)
00665:       {
00666:         Button -> SetLabel (LabelString);
00667:       }
00668: }
00669: 
00670: //=========================================================================
00671: 
00672: int MessageExtDialog (wxWindow * ParentWindow,
00673:                      const wxString & MessageString,
00674:                      const wxString & TitleString,
00675:                      /* wxMessageExtDialog::EStyle */ long Style)
00676: {
00677:     wxMessageExtDialog MessageExtDialog (ParentWindow, MessageString, TitleString);
00678:     MessageExtDialog.addButton (_("&OK"), wxID_OK);
00679:     MessageExtDialog.makeLastAddedButtonDefault ();
00680:     MessageExtDialog.setStyle (Style);
00681:     int PressedButtonIdent = MessageExtDialog.ShowModal ();
00682:     return PressedButtonIdent;
00683: }
00684: 
00685: int MessageExtDialog (const wxString & MessageString,
00686:                      const wxString & TitleString,
00687:                      /* wxMessageExtDialog::EStyle */ long Style)
00688: {
00689:     return MessageExtDialog (NULL, MessageString, TitleString, Style);
00690: }
00691: 
00692: int MessageExtDialog (const wxString & MessageString,
00693:                      /* wxMessageExtDialog::EStyle */ long Style)
00694: {
00695:     return MessageExtDialog (NULL, MessageString, wxEmptyString, Style);
00696: }
00697: 
00698: int MessageExtDialog (const wxString & MessageString)
00699: {
00700:     return MessageExtDialog (NULL, MessageString, wxEmptyString, wxMessageExtDialog::MessageStyle);
00701: }
00702: 
00703: //=========================================================================
00704: 
00705: extern "C" int MessageExtDialog_ (const char * MessageString,
00706:                                  EMessageExtDialogStyle Style)
00707: {
00708:     // wxMessageBox (MessageString);
00709:     return MessageExtDialog (MessageString, 
00710:                             Style);
00711: }
00712: 
00713: //=========================================================================
00714: 
  [main]    [up]  
DaicasWeb v.1.50.0102  //   Daniel Käps  //   April 12, 2007  //   Impressum / Imprint 
http://www.daicas.net/WxExtLib/src/MessageExtDialog.cpp.html