Fixed sample; enhanced wxLayoutAlgorithm to give remaining space to
last window git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8185 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -141,5 +141,8 @@ The MDI client window is set to occupy the remaining space.
|
|||||||
|
|
||||||
Lays out the children of a normal frame or other window.
|
Lays out the children of a normal frame or other window.
|
||||||
|
|
||||||
{\it mainWindow} is set to occupy the remaining space.
|
{\it mainWindow} is set to occupy the remaining space. If this is not specified, then
|
||||||
|
the last window that responds to a calculate layout event in query mode will get the remaining space
|
||||||
|
(that is, a non-query OnCalculateLayout event will not be sent to this window and the window will be set
|
||||||
|
to the remaining size).
|
||||||
|
|
||||||
|
@@ -473,7 +473,7 @@ void MyFrame::ModalDlg(wxCommandEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
void MyFrame::ModelessDlg(wxCommandEvent& event)
|
void MyFrame::ModelessDlg(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
bool show = GetMenuBar()->IsChecked(event.GetInt());
|
bool show = GetMenuBar()->IsChecked(event.GetId());
|
||||||
|
|
||||||
if ( show )
|
if ( show )
|
||||||
{
|
{
|
||||||
|
@@ -249,12 +249,35 @@ bool wxLayoutAlgorithm::LayoutWindow(wxWindow* parent, wxWindow* mainWindow)
|
|||||||
wxCalculateLayoutEvent event;
|
wxCalculateLayoutEvent event;
|
||||||
event.SetRect(rect);
|
event.SetRect(rect);
|
||||||
|
|
||||||
|
// Find the last layout-aware window, so we can make it fill all remaining
|
||||||
|
// space.
|
||||||
|
wxWindow* lastAwareWindow = NULL;
|
||||||
wxNode* node = parent->GetChildren().First();
|
wxNode* node = parent->GetChildren().First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxWindow* win = (wxWindow*) node->Data();
|
wxWindow* win = (wxWindow*) node->Data();
|
||||||
|
|
||||||
if (win != mainWindow)
|
if (win->IsShown())
|
||||||
|
{
|
||||||
|
wxCalculateLayoutEvent tempEvent(win->GetId());
|
||||||
|
tempEvent.SetEventObject(win);
|
||||||
|
tempEvent.SetFlags(wxLAYOUT_QUERY);
|
||||||
|
tempEvent.SetRect(event.GetRect());
|
||||||
|
if (win->GetEventHandler()->ProcessEvent(tempEvent))
|
||||||
|
lastAwareWindow = win;
|
||||||
|
}
|
||||||
|
|
||||||
|
node = node->Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
node = parent->GetChildren().First();
|
||||||
|
while (node)
|
||||||
|
{
|
||||||
|
wxWindow* win = (wxWindow*) node->Data();
|
||||||
|
|
||||||
|
// If mainWindow is NULL and we're at the last window,
|
||||||
|
// skip this, because we'll simply make it fit the remaining space.
|
||||||
|
if ((win != mainWindow) && (mainWindow != NULL || win != lastAwareWindow))
|
||||||
{
|
{
|
||||||
event.SetId(win->GetId());
|
event.SetId(win->GetId());
|
||||||
event.SetEventObject(win);
|
event.SetEventObject(win);
|
||||||
@@ -270,6 +293,11 @@ bool wxLayoutAlgorithm::LayoutWindow(wxWindow* parent, wxWindow* mainWindow)
|
|||||||
|
|
||||||
if (mainWindow)
|
if (mainWindow)
|
||||||
mainWindow->SetSize(rect.x, rect.y, rect.width, rect.height);
|
mainWindow->SetSize(rect.x, rect.y, rect.width, rect.height);
|
||||||
|
else if (lastAwareWindow)
|
||||||
|
{
|
||||||
|
// Fit the remaining space
|
||||||
|
lastAwareWindow->SetSize(rect.x, rect.y, rect.width, rect.height);
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user