- // functions to help with dialog layout
- // ------------------------------------
-
- // constants used in dialog layout
- static const long LAYOUT_X_MARGIN;
- static const long LAYOUT_Y_MARGIN;
- static const long MARGIN_BETWEEN_BUTTONS;
-
- // Split the message in lines putting them into the array and calculating
- // the maximum line width/height which is returned as wxSize.
- wxSize SplitTextMessage(const wxString& message, wxArrayString *lines);
-
- // Creates the (possibly multiline) message, assuming each line has the
- // size sizeText (which can be retrieved from SplitTextMessage). Returns
- // the bottom border of the multiline text zone.
- long CreateTextMessage(const wxArrayString& lines,
- const wxPoint& posText,
- const wxSize& sizeText);
-
- // Returns the preferred size for the buttons in the dialog
- wxSize GetStandardButtonSize(bool hasCancel = TRUE);
-
- // Create the standard [Ok] and [Cancel] (if hasCancel) buttons centering
- // them with respect to the dialog width wDialog at vertical position y.
- // wButton and hButton is the size of the button (which can be retrieved
- // from GetStandardButtonSize)
- void CreateStandardButtons(long wDialog,
- long y,
- long wButton,
- long hButton,
- bool hasCancel = TRUE);
-
- // Returns the standard height of single line text ctrl (it's not the same
- // as the height of just text which may be retrieved from
- // wxGetCharHeight())
- long GetStandardTextHeight();
+ // emulate click of a button with the given id if it's present in the dialog
+ //
+ // return true if button was "clicked" or false if we don't have it
+ bool EmulateButtonClickIfPresent(int id);
+
+ // this function is used by OnCharHook() to decide whether the given key
+ // should close the dialog
+ //
+ // for most platforms the default implementation (which just checks for
+ // Esc) is sufficient, but Mac port also adds Cmd-. here and other ports
+ // could do something different if needed
+ virtual bool IsEscapeKey(const wxKeyEvent& event);
+
+ // end either modal or modeless dialog, for the modal dialog rc is used as
+ // the dialog return code
+ void EndDialog(int rc);
+
+ // call Validate() and TransferDataFromWindow() and close dialog with
+ // wxID_OK return code
+ void AcceptAndClose();
+
+
+ // The return code from modal dialog
+ int m_returnCode;
+
+ // The identifier for the affirmative button (usually wxID_OK)
+ int m_affirmativeId;
+
+ // The identifier for cancel button (usually wxID_CANCEL)
+ int m_escapeId;
+
+ // Flags whether layout adaptation has been done for this dialog
+ bool m_layoutAdaptationDone;
+
+ // Extra button identifiers to be taken as 'main' button identifiers
+ // to be placed in the non-scrolling area
+ wxArrayInt m_mainButtonIds;
+
+ // Adaptation level
+ int m_layoutAdaptationLevel;
+
+ // Local override for global adaptation enabled status
+ wxDialogLayoutAdaptationMode m_layoutAdaptationMode;
+
+ // Global layout adapter
+ static wxDialogLayoutAdapter* sm_layoutAdapter;
+
+ // Global adaptation switch
+ static bool sm_layoutAdaptation;
+
+private:
+ // common part of all ctors
+ void Init();
+
+ // handle Esc key presses
+ void OnCharHook(wxKeyEvent& event);
+
+ // handle closing the dialog window
+ void OnCloseWindow(wxCloseEvent& event);
+
+ // handle the standard buttons
+ void OnButton(wxCommandEvent& event);
+
+ // update the background colour
+ void OnSysColourChanged(wxSysColourChangedEvent& event);
+
+
+ DECLARE_NO_COPY_CLASS(wxDialogBase)
+ DECLARE_EVENT_TABLE()
+};
+
+/*!
+ * Base class for layout adapters - code that, for example, turns a dialog into a
+ * scrolling dialog if there isn't enough screen space. You can derive further
+ * adapter classes to do any other kind of adaptation, such as applying a watermark, or adding
+ * a help mechanism.
+ */
+
+class WXDLLEXPORT wxDialogLayoutAdapter: public wxObject
+{
+ DECLARE_CLASS(wxDialogLayoutAdapter)
+public:
+ wxDialogLayoutAdapter() {}
+
+ // Override this function to indicate that adaptation should be done
+ virtual bool CanDoLayoutAdaptation(wxDialog* dialog) = 0;
+
+ // Override this function to do the adaptation
+ virtual bool DoLayoutAdaptation(wxDialog* dialog) = 0;
+};
+
+/*!
+ * Standard adapter. Does scrolling adaptation for paged and regular dialogs.
+ *
+ */
+
+class WXDLLEXPORT wxStandardDialogLayoutAdapter: public wxDialogLayoutAdapter
+{
+ DECLARE_CLASS(wxStandardDialogLayoutAdapter)
+public:
+ wxStandardDialogLayoutAdapter() {}
+
+// Overrides
+
+ // Indicate that adaptation should be done
+ virtual bool CanDoLayoutAdaptation(wxDialog* dialog);
+
+ // Do layout adaptation
+ virtual bool DoLayoutAdaptation(wxDialog* dialog);
+
+// Implementation
+
+ // Create the scrolled window
+ virtual wxScrolledWindow* CreateScrolledWindow(wxWindow* parent);
+
+ // Find a standard or horizontal box sizer
+ virtual wxSizer* FindButtonSizer(bool stdButtonSizer, wxDialog* dialog, wxSizer* sizer, int& retBorder, int accumlatedBorder = 0);
+
+ // Check if this sizer contains standard buttons, and so can be repositioned in the dialog
+ virtual bool IsOrdinaryButtonSizer(wxDialog* dialog, wxBoxSizer* sizer);
+
+ // Check if this is a standard button
+ virtual bool IsStandardButton(wxDialog* dialog, wxButton* button);
+
+ // Find 'loose' main buttons in the existing layout and add them to the standard dialog sizer
+ virtual bool FindLooseButtons(wxDialog* dialog, wxStdDialogButtonSizer* buttonSizer, wxSizer* sizer, int& count);
+
+ // Reparent the controls to the scrolled window, except those in buttonSizer
+ virtual void ReparentControls(wxWindow* parent, wxWindow* reparentTo, wxSizer* buttonSizer = NULL);
+ static void DoReparentControls(wxWindow* parent, wxWindow* reparentTo, wxSizer* buttonSizer = NULL);
+
+ // A function to fit the dialog around its contents, and then adjust for screen size.
+ // If scrolled windows are passed, scrolling is enabled in the required orientation(s).
+ virtual bool FitWithScrolling(wxDialog* dialog, wxScrolledWindow* scrolledWindow);
+ virtual bool FitWithScrolling(wxDialog* dialog, wxWindowList& windows);
+ static bool DoFitWithScrolling(wxDialog* dialog, wxScrolledWindow* scrolledWindow);
+ static bool DoFitWithScrolling(wxDialog* dialog, wxWindowList& windows);
+
+ // Find whether scrolling will be necessary for the dialog, returning wxVERTICAL, wxHORIZONTAL or both
+ virtual int MustScroll(wxDialog* dialog, wxSize& windowSize, wxSize& displaySize);
+ static int DoMustScroll(wxDialog* dialog, wxSize& windowSize, wxSize& displaySize);