26 #if defined(__WXGTK__) && !wxCHECK_VERSION(3, 0, 0)    27 #define wxEXTRA_DIALOG_HEIGHT 30    29 #define wxEXTRA_DIALOG_HEIGHT 0    32 #if !wxCHECK_VERSION(3, 0, 0)    41 bool wxDialogHelper::sm_layoutAdaptation = 
true;
    43 void wxDialogHelper::Init()
    45     m_layoutAdaptationLevel = 3;
    46     m_layoutLayoutAdaptationDone = FALSE;
    50 bool wxDialogHelper::DoLayoutAdaptation()
    52     if (GetLayoutAdapter())
    53         return GetLayoutAdapter()->DoLayoutAdaptation(
this);
    59 bool wxDialogHelper::CanDoLayoutAdaptation()
    61     return (GetLayoutAdaptation() && !m_layoutLayoutAdaptationDone && GetLayoutAdaptationLevel() != 0 && GetLayoutAdapter() != 
NULL && GetLayoutAdapter()->CanDoLayoutAdaptation(
this));
    68     sm_layoutAdapter = adapter;
    69     return oldLayoutAdapter;
    78 bool wxStandardDialogLayoutAdapter::CanDoLayoutAdaptation(wxDialogHelper* dialog)
    81     if (dialog->GetDialog()->GetSizer())
    83         wxSize windowSize, displaySize;
    84         return MustScroll(dialog->GetDialog(), windowSize, displaySize) != 0;
    90 bool wxStandardDialogLayoutAdapter::DoLayoutAdaptation(wxDialogHelper* dialog)
    92     if (dialog->GetDialog()->GetSizer())
    95         if (bookContentWindow)
    99             for (
size_t i = 0; i < bookContentWindow->
GetPageCount(); i++)
   101                 wxWindow* page = bookContentWindow->GetPage(i);
   105                     windows.Append(scrolledWindow);
   106                 else if (!scrolledWindow && page->GetSizer())
   110                     wxSizer* oldSizer = page->GetSizer();
   113                     newSizer->Add(scrolledWindow,1, 
wxEXPAND, 0);
   115                     page->SetSizer(newSizer, 
false );
   117                     scrolledWindow->SetSizer(oldSizer);
   119                     ReparentControls(page, scrolledWindow, 
NULL);
   121                     windows.Append(scrolledWindow);
   125             FitWithScrolling(dialog->GetDialog(), windows);
   133             int buttonSizerBorder = 0;
   136             wxSizer* buttonSizer = FindButtonSizer(
true , dialog, dialog->GetDialog()->GetSizer(), buttonSizerBorder);
   139             if (!buttonSizer && dialog->GetLayoutAdaptationLevel() > 1)
   140                 buttonSizer = FindButtonSizer(
false , dialog, dialog->GetDialog()->GetSizer(), buttonSizerBorder);
   143             if (!buttonSizer && dialog->GetLayoutAdaptationLevel() > 2)
   147                 buttonSizer = stdButtonSizer;
   149                 FindLooseButtons(dialog, stdButtonSizer, dialog->GetDialog()->GetSizer(), count);
   159             if (buttonSizerBorder == 0)
   160                 buttonSizerBorder = 5;
   162             ReparentControls(dialog->GetDialog(), scrolledWindow, buttonSizer);
   165             wxSizer* oldSizer = dialog->GetDialog()->GetSizer();
   167             dialog->GetDialog()->SetSizer(newTopSizer, 
false );
   171                 newTopSizer->Add(buttonSizer, 0, 
wxEXPAND|
wxALL, buttonSizerBorder);
   173             scrolledWindow->SetSizer(oldSizer);
   175             FitWithScrolling(dialog->GetDialog(), scrolledWindow);
   179     dialog->SetLayoutAdaptationDone(
true);
   184 wxSizer* wxStandardDialogLayoutAdapter::FindButtonSizer(
bool stdButtonSizer, wxDialogHelper* dialog, 
wxSizer* sizer, 
int& retBorder, 
int accumlatedBorder)
   186     for ( wxSizerItemList::compatibility_iterator node = sizer->GetChildren().GetFirst();
   187           node; node = node->GetNext() )
   190         wxSizer *childSizer = item->GetSizer();
   194             int newBorder = accumlatedBorder;
   195             if (item->GetFlag() & 
wxALL)
   196                 newBorder += item->GetBorder();
   203                     sizer->Detach(childSizer);
   204                     retBorder = newBorder;
   211                 if (buttonSizer && IsOrdinaryButtonSizer(dialog, buttonSizer))
   213                     sizer->Detach(childSizer);
   214                     retBorder = newBorder;
   219             wxSizer* s = FindButtonSizer(stdButtonSizer, dialog, childSizer, retBorder, newBorder);
   228 bool wxStandardDialogLayoutAdapter::IsOrdinaryButtonSizer(wxDialogHelper* dialog, 
wxBoxSizer* sizer)
   233     for ( wxSizerItemList::compatibility_iterator node = sizer->
GetChildren().GetFirst();
   234           node; node = node->GetNext() )
   239         if (childButton && IsStandardButton(dialog, childButton))
   246 bool wxStandardDialogLayoutAdapter::IsStandardButton(wxDialogHelper* dialog, 
wxButton* button)
   255 bool wxStandardDialogLayoutAdapter::FindLooseButtons(wxDialogHelper* dialog, 
wxStdDialogButtonSizer* buttonSizer, 
wxSizer* sizer, 
int& count)
   257     wxSizerItemList::compatibility_iterator node = sizer->GetChildren().GetFirst();
   260         wxSizerItemList::compatibility_iterator next = node->GetNext();
   262         wxSizer *childSizer = item->GetSizer();
   265         if (childButton && IsStandardButton(dialog, childButton))
   267             sizer->Detach(childButton);
   273             FindLooseButtons(dialog, buttonSizer, childSizer, count);
   281 void wxStandardDialogLayoutAdapter::ReparentControls(
wxWindow* parent, 
wxWindow* reparentTo, 
wxSizer* buttonSizer)
   283     wxWindowList::compatibility_iterator node = parent->GetChildren().GetFirst();
   286         wxWindowList::compatibility_iterator next = node->GetNext();
   291         if (win != reparentTo && (!buttonSizer || !buttonSizer->GetItem(win)))
   293             win->Reparent(reparentTo);
   296             ::SetWindowPos((HWND) win->GetHWND(), HWND_BOTTOM, -1, -1, -1, -1, SWP_NOMOVE|SWP_NOSIZE);
   305 int wxStandardDialogLayoutAdapter::MustScroll(
wxDialog* dialog, 
wxSize& windowSize, 
wxSize& displaySize)
   307     wxSize minWindowSize = dialog->GetSizer()->GetMinSize();
   308     windowSize = dialog->GetSize();
   309     windowSize = 
wxSize(wxMax(windowSize.x, minWindowSize.x), wxMax(windowSize.y, minWindowSize.y));
   327     if (windowSize.x >= displaySize.x)
   335 bool wxStandardDialogLayoutAdapter::FitWithScrolling(
wxDialog* dialog, wxWindowList& windows)
   337     wxSizer* sizer = dialog->GetSizer();
   341     sizer->SetSizeHints(dialog);
   343     wxSize windowSize, displaySize;
   344     int scrollFlags = MustScroll(dialog, windowSize, displaySize);
   345     int scrollBarSize = 20;
   349         int scrollBarExtraX = 0, scrollBarExtraY = 0;
   350         bool resizeHorizontally = (scrollFlags & 
wxHORIZONTAL) != 0;
   351         bool resizeVertically = (scrollFlags & 
wxVERTICAL) != 0;
   353         if (windows.GetCount() != 0)
   356             if ((resizeVertically && !resizeHorizontally) && (windowSize.x < (displaySize.x - scrollBarSize)))
   357                 scrollBarExtraX = scrollBarSize;
   358             if ((resizeHorizontally && !resizeVertically) && (windowSize.y < (displaySize.y - scrollBarSize)))
   359                 scrollBarExtraY = scrollBarSize;
   362         wxWindowList::compatibility_iterator node = windows.GetFirst();
   369                 scrolledWindow->SetScrollRate(resizeHorizontally ? 10 : 0, resizeVertically ? 10 : 0);
   371                 if (scrolledWindow->GetSizer())
   372                     scrolledWindow->GetSizer()->Fit(scrolledWindow);
   375             node = node->GetNext();
   378         wxSize limitTo = windowSize + 
wxSize(scrollBarExtraX, scrollBarExtraY);
   379         if (resizeVertically)
   381         if (resizeHorizontally)
   382             limitTo.x = displaySize.x;
   384         dialog->SetMinSize(limitTo);
   385         dialog->SetSize(limitTo);
   387         dialog->SetSizeHints( limitTo.x, limitTo.y, dialog->GetMaxWidth(), dialog->GetMaxHeight() );
   397     wxWindowList windows;
   398     windows.Append(scrolledWindow);
   399     return FitWithScrolling(dialog, windows);
   406 class wxDialogLayoutAdapterModule: 
public wxModule   408     DECLARE_DYNAMIC_CLASS(wxDialogLayoutAdapterModule)
   410     wxDialogLayoutAdapterModule() {}
   411     void OnExit()
 override { 
delete wxDialogHelper::SetLayoutAdapter(
NULL); }
   412     bool OnInit()
 override { wxDialogHelper::SetLayoutAdapter(
new wxStandardDialogLayoutAdapter); 
return true; }
   416 #endif //#if !wxCHECK_VERSION(3, 0, 0)   424 #if !wxCHECK_VERSION(3, 0, 0)   425 void wxScrollingDialog::Init()
   427     wxDialogHelper::SetDialog(
this);
   432     return wxDialog::Create(parent, 
id, title, pos, size, style, name);
   436 bool wxScrollingDialog::Show(
bool show)
   438     if (CanDoLayoutAdaptation())
   439         DoLayoutAdaptation();
   441     return wxDialog::Show(show);
   447     if (CanDoLayoutAdaptation())
   448         DoLayoutAdaptation();
   452 #endif //#if !wxCHECK_VERSION(3, 0, 0)   460 #if !wxCHECK_VERSION(3, 0, 0)   461 void wxScrollingPropertySheetDialog::Init()
   463     wxDialogHelper::SetDialog(
this);
   467 wxWindow* wxScrollingPropertySheetDialog::GetContentWindow()
 const   469     return GetBookCtrl();
   473 bool wxScrollingPropertySheetDialog::Show(
bool show)
   475     if (CanDoLayoutAdaptation())
   476         DoLayoutAdaptation();
   478     return wxPropertySheetDialog::Show(show);
   484     if (CanDoLayoutAdaptation())
   485         DoLayoutAdaptation();
   489 #endif //#if !wxCHECK_VERSION(3, 0, 0) 
#define wxDynamicCast(ptr, classname)
virtual size_t GetPageCount() const
wxRect GetClientArea() const
int GetOrientation() const
wxScrolled< wxPanel > wxScrolledWindow
const wxSize wxDefaultSize
const wxPoint wxDefaultPosition
IMPLEMENT_DYNAMIC_CLASS(cbDummyEditor, wxPGEditor)
static int GetFromWindow(const wxWindow *win)
wxSizerItemList & GetChildren()