wxTopLevelWindow (only for wxGTK for now)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11612 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2001-09-15 22:13:08 +00:00
parent 280df08533
commit 7d9f12f3b9
21 changed files with 2588 additions and 2529 deletions

View File

@@ -41,15 +41,18 @@
#include "wx/statusbr.h"
#endif
// FIXME - temporary hack in absence of wxTLW in all ports!
#ifndef wxTopLevelWindowNative
#define wxTopLevelWindow wxTopLevelWindowBase
#endif
// ----------------------------------------------------------------------------
// event table
// ----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxFrameBase, wxWindow)
BEGIN_EVENT_TABLE(wxFrameBase, wxTopLevelWindow)
EVT_IDLE(wxFrameBase::OnIdle)
EVT_CLOSE(wxFrameBase::OnCloseWindow)
EVT_MENU_HIGHLIGHT_ALL(wxFrameBase::OnMenuHighlight)
EVT_SIZE(wxFrameBase::OnSize)
END_EVENT_TABLE()
// ============================================================================
@@ -75,16 +78,6 @@ wxFrameBase::wxFrameBase()
#endif // wxUSE_STATUSBAR
}
bool wxFrameBase::Destroy()
{
// delayed destruction: the frame will be deleted during the next idle
// loop iteration
if ( !wxPendingDelete.Member(this) )
wxPendingDelete.Append(this);
return TRUE;
}
wxFrame *wxFrameBase::New(wxWindow *parent,
wxWindowID id,
const wxString& title,
@@ -152,7 +145,7 @@ bool wxFrameBase::IsOneOfBars(const wxWindow *win) const
// get the origin of the client area in the client coordinates
wxPoint wxFrameBase::GetClientAreaOrigin() const
{
wxPoint pt(0, 0);
wxPoint pt = wxTopLevelWindow::GetClientAreaOrigin();
#if wxUSE_TOOLBAR
if ( GetToolBar() && GetToolBar()->IsShown() )
@@ -174,48 +167,10 @@ wxPoint wxFrameBase::GetClientAreaOrigin() const
return pt;
}
void wxFrameBase::DoScreenToClient(int *x, int *y) const
{
wxWindow::DoScreenToClient(x, y);
// We may be faking the client origin.
// So a window that's really at (0, 30) may appear
// (to wxWin apps) to be at (0, 0).
wxPoint pt(GetClientAreaOrigin());
*x -= pt.x;
*y -= pt.y;
}
void wxFrameBase::DoClientToScreen(int *x, int *y) const
{
// We may be faking the client origin.
// So a window that's really at (0, 30) may appear
// (to wxWin apps) to be at (0, 0).
wxPoint pt1(GetClientAreaOrigin());
*x += pt1.x;
*y += pt1.y;
wxWindow::DoClientToScreen(x, y);
}
// ----------------------------------------------------------------------------
// misc
// ----------------------------------------------------------------------------
// make the window modal (all other windows unresponsive)
void wxFrameBase::MakeModal(bool modal)
{
if ( modal )
{
wxEnableTopLevelWindows(FALSE);
Enable(TRUE); // keep this window enabled
}
else
{
wxEnableTopLevelWindows(TRUE);
}
}
bool wxFrameBase::ProcessCommand(int id)
{
#if wxUSE_MENUS
@@ -245,67 +200,6 @@ bool wxFrameBase::ProcessCommand(int id)
// event handlers
// ----------------------------------------------------------------------------
// default resizing behaviour - if only ONE subwindow, resize to fill the
// whole client area
void wxFrameBase::OnSize(wxSizeEvent& WXUNUSED(event))
{
// if we're using constraints - do use them
#if wxUSE_CONSTRAINTS
if ( GetAutoLayout() )
{
Layout();
}
else
#endif // wxUSE_CONSTRAINTS
{
// do we have _exactly_ one child?
wxWindow *child = (wxWindow *)NULL;
for ( wxWindowList::Node *node = GetChildren().GetFirst();
node;
node = node->GetNext() )
{
wxWindow *win = node->GetData();
// exclude top level and managed windows (status bar isn't
// currently in the children list except under wxMac anyhow, but
// it makes no harm to test for it)
if ( !win->IsTopLevel() && !IsOneOfBars(win) )
{
if ( child )
{
return; // it's our second subwindow - nothing to do
}
child = win;
}
}
// do we have any children at all?
if ( child )
{
// exactly one child - set it's size to fill the whole frame
int clientW, clientH;
DoGetClientSize(&clientW, &clientH);
// for whatever reasons, wxGTK wants to have a small offset - it
// probably looks better with it?
#ifdef __WXGTK__
static const int ofs = 1;
#else
static const int ofs = 0;
#endif
child->SetSize(ofs, ofs, clientW - 2*ofs, clientH - 2*ofs);
}
}
}
// The default implementation for the close window event.
void wxFrameBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
{
Destroy();
}
void wxFrameBase::OnMenuHighlight(wxMenuEvent& event)
{
#if wxUSE_STATUSBAR
@@ -313,14 +207,6 @@ void wxFrameBase::OnMenuHighlight(wxMenuEvent& event)
#endif // wxUSE_STATUSBAR
}
bool wxFrameBase::SendIconizeEvent(bool iconized)
{
wxIconizeEvent event(GetId(), iconized);
event.SetEventObject(this);
return GetEventHandler()->ProcessEvent(event);
}
void wxFrameBase::OnIdle(wxIdleEvent& WXUNUSED(event) )
{
#if wxUSE_MENUS