]>
git.saurik.com Git - wxWidgets.git/blob - src/common/toplvcmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: common/toplvcmn.cpp
3 // Purpose: common (for all platforms) wxTopLevelWindow functions
4 // Author: Julian Smart, Vadim Zeitlin
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
20 #pragma implementation "toplevelbase.h"
23 // For compilers that support precompilation, includes "wx.h".
24 #include "wx/wxprec.h"
31 #include "wx/toplevel.h"
32 #include "wx/dcclient.h"
35 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
39 BEGIN_EVENT_TABLE(wxTopLevelWindowBase
, wxWindow
)
40 EVT_CLOSE(wxTopLevelWindowBase::OnCloseWindow
)
41 EVT_SIZE(wxTopLevelWindowBase::OnSize
)
44 // ============================================================================
46 // ============================================================================
48 // FIXME: some platforms don't have wxTopLevelWindow yet
49 #ifdef wxTopLevelWindowNative
50 IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow
, wxWindow
)
53 // ----------------------------------------------------------------------------
54 // construction/destruction
55 // ----------------------------------------------------------------------------
57 wxTopLevelWindowBase::wxTopLevelWindowBase()
61 wxTopLevelWindowBase::~wxTopLevelWindowBase()
63 // this destructor is required for Darwin
66 bool wxTopLevelWindowBase::Destroy()
68 // delayed destruction: the frame will be deleted during the next idle
70 if ( !wxPendingDelete
.Member(this) )
71 wxPendingDelete
.Append(this);
76 // ----------------------------------------------------------------------------
77 // wxTopLevelWindow size management: we exclude the areas taken by
78 // menu/status/toolbars from the client area, so the client area is what's
79 // really available for the frame contents
80 // ----------------------------------------------------------------------------
82 void wxTopLevelWindowBase::DoScreenToClient(int *x
, int *y
) const
84 wxWindow::DoScreenToClient(x
, y
);
86 // translate the wxWindow client coords to our client coords
87 wxPoint
pt(GetClientAreaOrigin());
94 void wxTopLevelWindowBase::DoClientToScreen(int *x
, int *y
) const
96 // our client area origin (0, 0) may be really something like (0, 30) for
97 // wxWindow if we have a toolbar, account for it before translating
98 wxPoint
pt(GetClientAreaOrigin());
104 wxWindow::DoClientToScreen(x
, y
);
108 // ----------------------------------------------------------------------------
110 // ----------------------------------------------------------------------------
112 // default resizing behaviour - if only ONE subwindow, resize to fill the
114 void wxTopLevelWindowBase::OnSize(wxSizeEvent
& WXUNUSED(event
))
116 // if we're using constraints - do use them
117 #if wxUSE_CONSTRAINTS
118 if ( GetAutoLayout() )
123 #endif // wxUSE_CONSTRAINTS
125 // do we have _exactly_ one child?
126 wxWindow
*child
= (wxWindow
*)NULL
;
127 for ( wxWindowList::Node
*node
= GetChildren().GetFirst();
129 node
= node
->GetNext() )
131 wxWindow
*win
= node
->GetData();
133 // exclude top level and managed windows (status bar isn't
134 // currently in the children list except under wxMac anyhow, but
135 // it makes no harm to test for it)
136 if ( !win
->IsTopLevel() && !IsOneOfBars(win
) )
143 return; // it's our second subwindow - nothing to do
150 // do we have any children at all?
153 // exactly one child - set it's size to fill the whole frame
154 int clientW
, clientH
;
155 DoGetClientSize(&clientW
, &clientH
);
157 // for whatever reasons, wxGTK wants to have a small offset - it
158 // probably looks better with it?
160 static const int ofs
= 1;
162 static const int ofs
= 0;
165 child
->SetSize(ofs
, ofs
, clientW
- 2*ofs
, clientH
- 2*ofs
);
167 UpdateInternalSize(child
, clientH
);
173 // The default implementation for the close window event.
174 void wxTopLevelWindowBase::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
))
179 bool wxTopLevelWindowBase::SendIconizeEvent(bool iconized
)
181 wxIconizeEvent
event(GetId(), iconized
);
182 event
.SetEventObject(this);
184 return GetEventHandler()->ProcessEvent(event
);