X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/46ccb5107ff22cb5cc1b36ef2a28ea1e31b0fc91..585266618c27ac77a5e5316c03e06ffc514715c9:/src/stubs/window.cpp?ds=sidebyside diff --git a/src/stubs/window.cpp b/src/stubs/window.cpp index 6a538b0e80..0eeda07dfc 100644 --- a/src/stubs/window.cpp +++ b/src/stubs/window.cpp @@ -31,7 +31,7 @@ #include "wx/menuitem.h" #include "wx/log.h" -#if USE_DRAG_AND_DROP +#if wxUSE_DRAG_AND_DROP #include "wx/dnd.h" #endif @@ -39,24 +39,25 @@ extern wxList wxPendingDelete; -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler) BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler) EVT_CHAR(wxWindow::OnChar) + EVT_KEY_DOWN(wxWindow::OnKeyDown) + EVT_KEY_UP(wxWindow::OnKeyUp) EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground) EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged) EVT_INIT_DIALOG(wxWindow::OnInitDialog) EVT_IDLE(wxWindow::OnIdle) END_EVENT_TABLE() -#endif // Constructor wxWindow::wxWindow() { // Generic + m_isWindow = TRUE; // An optimization m_windowId = 0; m_windowStyle = 0; m_windowParent = NULL; @@ -75,12 +76,11 @@ wxWindow::wxWindow() m_caretWidth = 0; m_caretHeight = 0; m_caretEnabled = FALSE; m_caretShown = FALSE; - m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; + m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; + // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; m_foregroundColour = *wxBLACK; - m_defaultForegroundColour = *wxBLACK ; - m_defaultBackgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; -#if USE_DRAG_AND_DROP +#if wxUSE_DRAG_AND_DROP m_pDropTarget = NULL; #endif } @@ -91,7 +91,7 @@ wxWindow::~wxWindow() // Have to delete constraints/sizer FIRST otherwise // sizers may try to look at deleted windows as they // delete themselves. -#if USE_CONSTRAINTS +#if wxUSE_CONSTRAINTS DeleteRelatedConstraints(); if (m_constraints) { @@ -145,6 +145,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, const wxString& name) { // Generic + m_isWindow = TRUE; // An optimization m_windowId = 0; m_windowStyle = 0; m_windowParent = NULL; @@ -158,7 +159,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, m_autoLayout = FALSE; m_windowValidator = NULL; -#if USE_DRAG_AND_DROP +#if wxUSE_DRAG_AND_DROP m_pDropTarget = NULL; #endif @@ -185,10 +186,9 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, else m_windowId = id; - m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; + // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; + m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; m_foregroundColour = *wxBLACK; - m_defaultForegroundColour = *wxBLACK ; - m_defaultBackgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; m_windowStyle = style; @@ -250,7 +250,7 @@ wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler) return NULL; } -#if USE_DRAG_AND_DROP +#if wxUSE_DRAG_AND_DROP void wxWindow::SetDropTarget(wxDropTarget *pDropTarget) { @@ -372,7 +372,7 @@ void wxWindow::GetTextExtent(const wxString& string, int *x, int *y, // TODO } -void wxWindow::Refresh(bool eraseBack, const wxRectangle *rect) +void wxWindow::Refresh(bool eraseBack, const wxRect *rect) { // TODO } @@ -380,7 +380,7 @@ void wxWindow::Refresh(bool eraseBack, const wxRectangle *rect) // Responds to colour changes: passes event on to children. void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event) { - wxNode *node = GetChildren()->First(); + wxNode *node = GetChildren().First(); while ( node ) { // Only propagate to non-top-level windows @@ -536,7 +536,7 @@ void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible, } // Does a physical scroll -void wxWindow::ScrollWindow(int dx, int dy, const wxRectangle *rect) +void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) { // TODO return; @@ -553,6 +553,7 @@ void wxWindow::SetFont(const wxFont& font) void wxWindow::OnChar(wxKeyEvent& event) { +/* ?? if ( event.KeyCode() == WXK_TAB ) { // propagate the TABs to the parent - it's up to it to decide what // to do with it @@ -561,6 +562,18 @@ void wxWindow::OnChar(wxKeyEvent& event) return; } } +*/ + Default(); +} + +void wxWindow::OnKeyDown(wxKeyEvent& event) +{ + Default(); +} + +void wxWindow::OnKeyUp(wxKeyEvent& event) +{ + Default(); } void wxWindow::OnPaint(wxPaintEvent& event) @@ -585,7 +598,7 @@ bool wxWindow::IsEnabled() const // it's an application error (pops up a dialog) bool wxWindow::TransferDataToWindow() { - wxNode *node = GetChildren()->First(); + wxNode *node = GetChildren().First(); while ( node ) { wxWindow *child = (wxWindow *)node->Data(); @@ -605,7 +618,7 @@ bool wxWindow::TransferDataToWindow() // validation failed: don't quit bool wxWindow::TransferDataFromWindow() { - wxNode *node = GetChildren()->First(); + wxNode *node = GetChildren().First(); while ( node ) { wxWindow *child = (wxWindow *)node->Data(); @@ -621,7 +634,7 @@ bool wxWindow::TransferDataFromWindow() bool wxWindow::Validate() { - wxNode *node = GetChildren()->First(); + wxNode *node = GetChildren().First(); while ( node ) { wxWindow *child = (wxWindow *)node->Data(); @@ -644,30 +657,27 @@ wxWindow *wxWindow::FindFocus() void wxWindow::AddChild(wxWindow *child) { - GetChildren()->Append(child); + GetChildren().Append(child); child->m_windowParent = this; } void wxWindow::RemoveChild(wxWindow *child) { - if (GetChildren()) - GetChildren()->DeleteObject(child); + GetChildren().DeleteObject(child); child->m_windowParent = NULL; } void wxWindow::DestroyChildren() { - if (GetChildren()) { wxNode *node; - while ((node = GetChildren()->First()) != (wxNode *)NULL) { + while ((node = GetChildren().First()) != (wxNode *)NULL) { wxWindow *child; if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) { delete child; - if ( GetChildren()->Member(child) ) + if ( GetChildren().Member(child) ) delete node; } } /* while */ - } } void wxWindow::MakeModal(bool modal) @@ -687,6 +697,17 @@ void wxWindow::MakeModal(bool modal) } } +// If nothing defined for this, try the parent. +// E.g. we may be a button loaded from a resource, with no callback function +// defined. +void wxWindow::OnCommand(wxWindow& win, wxCommandEvent& event) +{ + if (GetEventHandler()->ProcessEvent(event) ) + return; + if (m_windowParent) + m_windowParent->GetEventHandler()->OnCommand(win, event); +} + void wxWindow::SetConstraints(wxLayoutConstraints *c) { if (m_constraints) @@ -871,7 +892,7 @@ bool wxWindow::DoPhase(int phase) { noChanges = 0; noFailures = 0; - wxNode *node = GetChildren()->First(); + wxNode *node = GetChildren().First(); while (node) { wxWindow *child = (wxWindow *)node->Data(); @@ -916,7 +937,7 @@ void wxWindow::ResetConstraints() constr->centreX.SetDone(FALSE); constr->centreY.SetDone(FALSE); } - wxNode *node = GetChildren()->First(); + wxNode *node = GetChildren().First(); while (node) { wxWindow *win = (wxWindow *)node->Data(); @@ -975,7 +996,7 @@ void wxWindow::SetConstraintSizes(bool recurse) if (recurse) { - wxNode *node = GetChildren()->First(); + wxNode *node = GetChildren().First(); while (node) { wxWindow *win = (wxWindow *)node->Data(); @@ -1104,7 +1125,10 @@ bool wxWindow::Close(bool force) { wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); event.SetEventObject(this); +#if WXWIN_COMPATIBILITY event.SetForce(force); +#endif + event.SetCanVeto(!force); return GetEventHandler()->ProcessEvent(event); } @@ -1112,9 +1136,7 @@ bool wxWindow::Close(bool force) wxObject* wxWindow::GetChild(int number) const { // Return a pointer to the Nth object in the window - if (!GetChildren()) - return(NULL) ; - wxNode *node = GetChildren()->First(); + wxNode *node = GetChildren().First(); int n = number; while (node && n--) node = node->Next() ; @@ -1145,7 +1167,7 @@ void wxWindow::Fit() { int maxX = 0; int maxY = 0; - wxNode *node = GetChildren()->First(); + wxNode *node = GetChildren().First(); while ( node ) { wxWindow *win = (wxWindow *)node->Data(); @@ -1183,7 +1205,7 @@ wxWindow *wxWindow::FindWindow(long id) if ( GetId() == id) return this; - wxNode *node = GetChildren()->First(); + wxNode *node = GetChildren().First(); while ( node ) { wxWindow *child = (wxWindow *)node->Data(); @@ -1200,7 +1222,7 @@ wxWindow *wxWindow::FindWindow(const wxString& name) if ( GetName() == name) return this; - wxNode *node = GetChildren()->First(); + wxNode *node = GetChildren().First(); while ( node ) { wxWindow *child = (wxWindow *)node->Data(); @@ -1274,6 +1296,11 @@ bool wxWindow::IsExposed(const wxRect& rect) const return (m_updateRegion.Contains(rect) != wxOutRegion); } +void wxWindow::SetToolTip(const wxString& tooltip) +{ + // TODO +} + /* * Allocates control IDs */