diff --git a/include/wx/os2/window.h b/include/wx/os2/window.h index 457339052a..2b5dea9483 100644 --- a/include/wx/os2/window.h +++ b/include/wx/os2/window.h @@ -195,7 +195,7 @@ public: // title; for items, this is the label or button text. inline virtual wxString GetLabel() const { return GetTitle(); } - +#if wxUSE_CARET && WXWIN_COMPATIBILITY // Caret manipulation virtual void CreateCaret(int w, int h); virtual void CreateCaret(const wxBitmap *bitmap); @@ -203,7 +203,7 @@ public: virtual void ShowCaret(bool show); virtual void SetCaretPos(int x, int y); virtual void GetCaretPos(int *x, int *y) const; - +#endif // Handle a control command virtual void OnCommand(wxWindow& win, wxCommandEvent& event); @@ -267,10 +267,24 @@ protected: public: int m_returnCode; + bool m_isBeingDeleted; + bool m_isShown; + bool m_winCaptured; + bool m_mouseInWindow; + bool m_backgroundTransparent; + // handles + WXHWND m_hWnd; + WXHMENU m_hMenu; // Menu, if any + + // the size of one page for scrolling + int m_xThumbSize; + int m_yThumbSize; + long m_lDlgCode; DECLARE_EVENT_TABLE() private: void Init(); + void PMDetachWindowMenu(); }; //////////////////////////////////////////////////////////////////////// diff --git a/src/os2/window.cpp b/src/os2/window.cpp index 6970db0614..f46f05ddda 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -13,1305 +13,536 @@ #pragma implementation "window.h" #endif -#include "wx/setup.h" -#include "wx/menu.h" -#include "wx/dc.h" -#include "wx/dcclient.h" -#include "wx/utils.h" -#include "wx/app.h" -#include "wx/panel.h" -#include "wx/layout.h" -#include "wx/dialog.h" -#include "wx/listbox.h" -#include "wx/button.h" -#include "wx/settings.h" -#include "wx/msgdlg.h" -#include "wx/frame.h" +#ifndef WX_PRECOMP + #define INCL_DOS + #define INCL_PM + #include + #include "wx/window.h" + #include "wx/accel.h" + #include "wx/setup.h" + #include "wx/menu.h" + #include "wx/dc.h" + #include "wx/dcclient.h" + #include "wx/utils.h" + #include "wx/app.h" + #include "wx/panel.h" + #include "wx/layout.h" + #include "wx/dialog.h" + #include "wx/frame.h" + #include "wx/listbox.h" + #include "wx/button.h" + #include "wx/msgdlg.h" + + #include +#endif + +#if wxUSE_OWNER_DRAWN + #include "wx/ownerdrw.h" +#endif + +#if wxUSE_DRAG_AND_DROP + #include "wx/dnd.h" +#endif #include "wx/menuitem.h" #include "wx/log.h" -#if wxUSE_DRAG_AND_DROP -#include "wx/dnd.h" +#if wxUSE_TOOLTIPS + #include "wx/tooltip.h" #endif +#if wxUSE_CARET + #include "wx/caret.h" +#endif // wxUSE_CARET + +#include "wx/intl.h" +#include "wx/log.h" + + +#include "wx/textctrl.h" + #include -extern wxList wxPendingDelete; +// place compiler, OS specific includes here + + +// standard macros -- these are for OS/2 PM, but most GUI's have something similar +#ifndef GET_X_LPARAM +// SHORT1FROMMP -- LOWORD + #define GET_X_LPARAM(mp) ((unsigned short)(unsigned long)(mp)) +// SHORT2FROMMP -- HIWORD + #define GET_Y_LPARAM(mp) ((unsigned short)(unsigned long)(mp >> 16)) +#endif // GET_X_LPARAM + +// --------------------------------------------------------------------------- +// global variables +// --------------------------------------------------------------------------- + +// the last Windows message we got (MT-UNSAFE) +extern WXMSGID s_currentMsg; +extern wxList WXDLLEXPORT wxPendingDelete; +extern wxChar wxCanvasClassName[]; + +wxMenu *wxCurrentPopupMenu = NULL; +wxList *wxWinHandleList = NULL; + +// --------------------------------------------------------------------------- +// private functions +// --------------------------------------------------------------------------- +// the window proc for all our windows; most gui's have something similar +MRESULT wxWndProc( HWND hWnd + ,ULONG message + ,MPARAM mp1 + ,MPARAM mp2 + ); +void wxRemoveHandleAssociation(wxWindow *win); +void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win); +wxWindow *wxFindWinFromHandle(WXHWND hWnd); + +// --------------------------------------------------------------------------- +// event tables +// --------------------------------------------------------------------------- #if !USE_SHARED_LIBRARY -IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler) + IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) +#endif -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) +BEGIN_EVENT_TABLE(wxWindow, wxWindowBase) + EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground) + EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged) + EVT_INIT_DIALOG(wxWindow::OnInitDialog) + EVT_IDLE(wxWindow::OnIdle) END_EVENT_TABLE() -#endif +// =========================================================================== +// implementation +// =========================================================================== - -// Constructor -wxWindow::wxWindow() +void wxWindow::Init() { - // Generic - m_isWindow = TRUE; // An optimization - m_windowId = 0; - m_windowStyle = 0; - m_windowParent = NULL; - m_windowEventHandler = this; - m_windowName = ""; - m_windowCursor = *wxSTANDARD_CURSOR; - m_children = new wxList; - m_constraints = NULL; - m_constraintsInvolvedIn = NULL; - m_windowSizer = NULL; - m_sizerParent = NULL; - m_autoLayout = FALSE; - m_windowValidator = NULL; - m_defaultItem = NULL; - m_returnCode = 0; - m_caretWidth = 0; m_caretHeight = 0; - m_caretEnabled = FALSE; - m_caretShown = FALSE; - m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; - // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; - m_foregroundColour = *wxBLACK; + // generic + InitBase(); -#if wxUSE_DRAG_AND_DROP - m_pDropTarget = NULL; -#endif + // PM specific + m_winCaptured = FALSE; + m_isBeingDeleted = FALSE; + m_mouseInWindow = FALSE; + m_backgroundTransparent = FALSE; + + // wxWnd + m_hMenu = 0; + + m_hWnd = 0; + + // pass WM_GETDLGCODE to DefWindowProc() + m_lDlgCode = 0; + + m_xThumbSize = 0; + m_yThumbSize = 0; + + // as all windows are created with WS_VISIBLE style... + m_isShown = TRUE; + +} + +bool wxWindow::Create(wxWindow *parent, wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) +{ + wxCHECK_MSG( parent, FALSE, _T("can't create wxWindow without parent") ); + + if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) + return FALSE; + + // TODO: PM Specific initialization + parent->AddChild(this); + return TRUE; } // Destructor wxWindow::~wxWindow() { - // Have to delete constraints/sizer FIRST otherwise - // sizers may try to look at deleted windows as they - // delete themselves. -#if wxUSE_CONSTRAINTS - DeleteRelatedConstraints(); - if (m_constraints) - { - // This removes any dangling pointers to this window - // in other windows' constraintsInvolvedIn lists. - UnsetConstraints(m_constraints); - delete m_constraints; - m_constraints = NULL; - } - if (m_windowSizer) - { - delete m_windowSizer; - m_windowSizer = NULL; - } - // If this is a child of a sizer, remove self from parent - if (m_sizerParent) - m_sizerParent->RemoveChild((wxWindow *)this); -#endif - - if (m_windowParent) - m_windowParent->RemoveChild(this); + m_isBeingDeleted = TRUE; + PMDetachWindowMenu(); + // delete handlers? + if (m_parent) + m_parent->RemoveChild(this); DestroyChildren(); - - // TODO: destroy the window - - delete m_children; - m_children = NULL; - - // Just in case the window has been Closed, but - // we're then deleting immediately: don't leave - // dangling pointers. - wxPendingDelete.DeleteObject(this); - - if ( m_windowValidator ) - delete m_windowValidator; + if (m_hWnd) + { + if(!WinDestroyWindow(GetHwnd())) + wxLogLastError("DestroyWindow"); + // remove hWnd <-> wxWindow association + wxRemoveHandleAssociation(this); + } } -// Destroy the window (delayed, if a managed window) -bool wxWindow::Destroy() +// --------------------------------------------------------------------------- +// basic operations +// --------------------------------------------------------------------------- + +void wxWindow::Raise() { - delete this; - return TRUE; + // TODO: } -// Constructor -bool wxWindow::Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) +void wxWindow::Lower() { - // Generic - m_isWindow = TRUE; // An optimization - m_windowId = 0; - m_windowStyle = 0; - m_windowParent = NULL; - m_windowEventHandler = this; - m_windowName = ""; - m_windowCursor = *wxSTANDARD_CURSOR; - m_constraints = NULL; - m_constraintsInvolvedIn = NULL; - m_windowSizer = NULL; - m_sizerParent = NULL; - m_autoLayout = FALSE; - m_windowValidator = NULL; - -#if wxUSE_DRAG_AND_DROP - m_pDropTarget = NULL; -#endif - - m_caretWidth = 0; m_caretHeight = 0; - m_caretEnabled = FALSE; - m_caretShown = FALSE; - m_minSizeX = -1; - m_minSizeY = -1; - m_maxSizeX = -1; - m_maxSizeY = -1; - m_defaultItem = NULL; - m_windowParent = NULL; - if (!parent) - return FALSE; - - if (parent) parent->AddChild(this); - - m_returnCode = 0; - - SetName(name); - - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; - - // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; - m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; - m_foregroundColour = *wxBLACK; - - m_windowStyle = style; - - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; - - // TODO: create the window - - return TRUE; + // TODO: } void wxWindow::SetFocus() { - // TODO + // TODO: } -void wxWindow::Enable(bool enable) +void wxWindow::WarpPointer(int x_pos, int y_pos) { - // TODO + // TODO: } void wxWindow::CaptureMouse() { - // TODO + // TODO: } void wxWindow::ReleaseMouse() { - // TODO + // TODO: } -// Push/pop event handler (i.e. allow a chain of event handlers -// be searched) -void wxWindow::PushEventHandler(wxEvtHandler *handler) +void wxWindow::Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL) { - handler->SetNextHandler(GetEventHandler()); - SetEventHandler(handler); -} - -wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler) -{ - if ( GetEventHandler() ) - { - wxEvtHandler *handlerA = GetEventHandler(); - wxEvtHandler *handlerB = handlerA->GetNextHandler(); - handlerA->SetNextHandler(NULL); - SetEventHandler(handlerB); - if ( deleteHandler ) - { - delete handlerA; - return NULL; - } - else - return handlerA; - } - else - return NULL; -} - -#if wxUSE_DRAG_AND_DROP - -void wxWindow::SetDropTarget(wxDropTarget *pDropTarget) -{ - if ( m_pDropTarget != 0 ) { - delete m_pDropTarget; - } - - m_pDropTarget = pDropTarget; - if ( m_pDropTarget != 0 ) - { - // TODO - } -} - -#endif - -// Old style file-manager drag&drop -void wxWindow::DragAcceptFiles(bool accept) -{ - // TODO -} - -// Get total size -void wxWindow::GetSize(int *x, int *y) const -{ - // TODO -} - -void wxWindow::GetPosition(int *x, int *y) const -{ - // TODO -} - -void wxWindow::ScreenToClient(int *x, int *y) const -{ - // TODO -} - -void wxWindow::ClientToScreen(int *x, int *y) const -{ - // TODO -} - -void wxWindow::SetCursor(const wxCursor& cursor) -{ - m_windowCursor = cursor; - if (m_windowCursor.Ok()) - { - // TODO - } -} - - -// Get size *available for subwindows* i.e. excluding menu bar etc. -void wxWindow::GetClientSize(int *x, int *y) const -{ - // TODO -} - -void wxWindow::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO -} - -void wxWindow::SetClientSize(int width, int height) -{ - // TODO -} - -// For implementation purposes - sometimes decorations make the client area -// smaller -wxPoint wxWindow::GetClientAreaOrigin() const -{ - return wxPoint(0, 0); -} - -// Makes an adjustment to the window position (for example, a frame that has -// a toolbar that it manages itself). -void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) -{ - if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent()) - { - wxPoint pt(GetParent()->GetClientAreaOrigin()); - x += pt.x; y += pt.y; - } -} - -bool wxWindow::Show(bool show) -{ - // TODO - return FALSE; -} - -bool wxWindow::IsShown() const -{ - // TODO - return FALSE; -} - -int wxWindow::GetCharHeight() const -{ - // TODO - return 0; -} - -int wxWindow::GetCharWidth() const -{ - // TODO - return 0; -} - -void wxWindow::GetTextExtent(const wxString& string, int *x, int *y, - int *descent, int *externalLeading, const wxFont *theFont, bool) const -{ - wxFont *fontToUse = (wxFont *)theFont; - if (!fontToUse) - fontToUse = (wxFont *) & m_windowFont; - - // TODO -} - -void wxWindow::Refresh(bool eraseBack, const wxRect *rect) -{ - // TODO -} - -// Responds to colour changes: passes event on to children. -void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event) -{ - wxNode *node = GetChildren().First(); - while ( node ) - { - // Only propagate to non-top-level windows - wxWindow *win = (wxWindow *)node->Data(); - if ( win->GetParent() ) - { - wxSysColourChangedEvent event2; - event.m_eventObject = win; - win->GetEventHandler()->ProcessEvent(event2); - } - - node = node->Next(); - } -} - -// This can be called by the app (or wxWindows) to do default processing for the current -// event. Save message/event info in wxWindow so they can be used in this function. -long wxWindow::Default() -{ - // TODO - return 0; -} - -void wxWindow::InitDialog() -{ - wxInitDialogEvent event(GetId()); - event.SetEventObject( this ); - GetEventHandler()->ProcessEvent(event); -} - -// Default init dialog behaviour is to transfer data to window -void wxWindow::OnInitDialog(wxInitDialogEvent& event) -{ - TransferDataToWindow(); -} - -// Caret manipulation -void wxWindow::CreateCaret(int w, int h) -{ - m_caretWidth = w; - m_caretHeight = h; - m_caretEnabled = TRUE; -} - -void wxWindow::CreateCaret(const wxBitmap *WXUNUSED(bitmap)) -{ - // TODO -} - -void wxWindow::ShowCaret(bool show) -{ - // TODO -} - -void wxWindow::DestroyCaret() -{ - // TODO - m_caretEnabled = FALSE; -} - -void wxWindow::SetCaretPos(int x, int y) -{ - // TODO -} - -void wxWindow::GetCaretPos(int *x, int *y) const -{ - // TODO -} - -wxWindow *wxGetActiveWindow() -{ - // TODO - return NULL; -} - -void wxWindow::SetSizeHints(int minW, int minH, int maxW, int maxH, int WXUNUSED(incW), int WXUNUSED(incH)) -{ - m_minSizeX = minW; - m_minSizeY = minH; - m_maxSizeX = maxW; - m_maxSizeY = maxH; -} - -void wxWindow::Centre(int direction) -{ - int x, y, width, height, panel_width, panel_height, new_x, new_y; - - wxWindow *father = (wxWindow *)GetParent(); - if (!father) - return; - - father->GetClientSize(&panel_width, &panel_height); - GetSize(&width, &height); - GetPosition(&x, &y); - - new_x = -1; - new_y = -1; - - if (direction & wxHORIZONTAL) - new_x = (int)((panel_width - width)/2); - - if (direction & wxVERTICAL) - new_y = (int)((panel_height - height)/2); - - SetSize(new_x, new_y, -1, -1); - -} - -// Coordinates relative to the window -void wxWindow::WarpPointer (int x_pos, int y_pos) -{ - // TODO -} - -void wxWindow::OnEraseBackground(wxEraseEvent& event) -{ - // TODO - Default(); -} - -int wxWindow::GetScrollPos(int orient) const -{ - // TODO - return 0; -} - -// This now returns the whole range, not just the number -// of positions that we can scroll. -int wxWindow::GetScrollRange(int orient) const -{ - // TODO - return 0; -} - -int wxWindow::GetScrollThumb(int orient) const -{ - // TODO - return 0; -} - -void wxWindow::SetScrollPos(int orient, int pos, bool refresh) -{ - // TODO - return; -} - -// New function that will replace some of the above. -void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible, - int range, bool refresh) -{ - // TODO -} - -// Does a physical scroll -void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) -{ - // TODO - return; -} - -void wxWindow::SetFont(const wxFont& font) -{ - m_windowFont = font; - - if (!m_windowFont.Ok()) - return; - // TODO -} - -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 - if ( GetParent() ) { - if ( GetParent()->ProcessEvent(event) ) - return; - } - } -*/ - Default(); -} - -void wxWindow::OnKeyDown(wxKeyEvent& event) -{ - Default(); -} - -void wxWindow::OnKeyUp(wxKeyEvent& event) -{ - Default(); -} - -void wxWindow::OnPaint(wxPaintEvent& event) -{ - Default(); -} - -bool wxWindow::IsEnabled() const -{ - // TODO - return FALSE; -} - -// Dialog support: override these and call -// base class members to add functionality -// that can't be done using validators. -// NOTE: these functions assume that controls -// are direct children of this window, not grandchildren -// or other levels of descendant. - -// Transfer values to controls. If returns FALSE, -// it's an application error (pops up a dialog) -bool wxWindow::TransferDataToWindow() -{ - wxNode *node = GetChildren().First(); - while ( node ) - { - wxWindow *child = (wxWindow *)node->Data(); - if ( child->GetValidator() && - !child->GetValidator()->TransferToWindow() ) - { - wxMessageBox("Application Error", "Could not transfer data to window", wxOK|wxICON_EXCLAMATION); - return FALSE; - } - - node = node->Next(); - } - return TRUE; -} - -// Transfer values from controls. If returns FALSE, -// validation failed: don't quit -bool wxWindow::TransferDataFromWindow() -{ - wxNode *node = GetChildren().First(); - while ( node ) - { - wxWindow *child = (wxWindow *)node->Data(); - if ( child->GetValidator() && !child->GetValidator()->TransferFromWindow() ) - { - return FALSE; - } - - node = node->Next(); - } - return TRUE; -} - -bool wxWindow::Validate() -{ - wxNode *node = GetChildren().First(); - while ( node ) - { - wxWindow *child = (wxWindow *)node->Data(); - if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->Validate(this) ) - { - return FALSE; - } - - node = node->Next(); - } - return TRUE; -} - -// Get the window with the focus -wxWindow *wxWindow::FindFocus() -{ - // TODO - return NULL; -} - -void wxWindow::AddChild(wxWindow *child) -{ - GetChildren().Append(child); - child->m_windowParent = this; -} - -void wxWindow::RemoveChild(wxWindow *child) -{ - GetChildren().DeleteObject(child); - child->m_windowParent = NULL; -} - -void wxWindow::DestroyChildren() -{ - wxNode *node; - while ((node = GetChildren().First()) != (wxNode *)NULL) { - wxWindow *child; - if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) { - delete child; - if ( GetChildren().Member(child) ) - delete node; - } - } /* while */ -} - -void wxWindow::MakeModal(bool modal) -{ - // Disable all other windows - if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame))) - { - wxNode *node = wxTopLevelWindows.First(); - while (node) - { - wxWindow *win = (wxWindow *)node->Data(); - if (win != this) - win->Enable(!modal); - - node = node->Next(); - } - } -} - -// 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) - { - UnsetConstraints(m_constraints); - delete m_constraints; - } - m_constraints = c; - if (m_constraints) - { - // Make sure other windows know they're part of a 'meaningful relationship' - if (m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this)) - m_constraints->left.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this)) - m_constraints->top.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this)) - m_constraints->right.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this)) - m_constraints->bottom.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this)) - m_constraints->width.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this)) - m_constraints->height.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this)) - m_constraints->centreX.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this)) - m_constraints->centreY.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - } -} - -// This removes any dangling pointers to this window -// in other windows' constraintsInvolvedIn lists. -void wxWindow::UnsetConstraints(wxLayoutConstraints *c) -{ - if (c) - { - if (c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this)) - c->left.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this)) - c->top.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this)) - c->right.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this)) - c->bottom.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this)) - c->width.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this)) - c->height.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this)) - c->centreX.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this)) - c->centreY.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - } -} - -// Back-pointer to other windows we're involved with, so if we delete -// this window, we must delete any constraints we're involved with. -void wxWindow::AddConstraintReference(wxWindow *otherWin) -{ - if (!m_constraintsInvolvedIn) - m_constraintsInvolvedIn = new wxList; - if (!m_constraintsInvolvedIn->Member(otherWin)) - m_constraintsInvolvedIn->Append(otherWin); -} - -// REMOVE back-pointer to other windows we're involved with. -void wxWindow::RemoveConstraintReference(wxWindow *otherWin) -{ - if (m_constraintsInvolvedIn) - m_constraintsInvolvedIn->DeleteObject(otherWin); -} - -// Reset any constraints that mention this window -void wxWindow::DeleteRelatedConstraints() -{ - if (m_constraintsInvolvedIn) - { - wxNode *node = m_constraintsInvolvedIn->First(); - while (node) - { - wxWindow *win = (wxWindow *)node->Data(); - wxNode *next = node->Next(); - wxLayoutConstraints *constr = win->GetConstraints(); - - // Reset any constraints involving this window - if (constr) - { - constr->left.ResetIfWin((wxWindow *)this); - constr->top.ResetIfWin((wxWindow *)this); - constr->right.ResetIfWin((wxWindow *)this); - constr->bottom.ResetIfWin((wxWindow *)this); - constr->width.ResetIfWin((wxWindow *)this); - constr->height.ResetIfWin((wxWindow *)this); - constr->centreX.ResetIfWin((wxWindow *)this); - constr->centreY.ResetIfWin((wxWindow *)this); - } - delete node; - node = next; - } - delete m_constraintsInvolvedIn; - m_constraintsInvolvedIn = NULL; - } -} - -void wxWindow::SetSizer(wxSizer *sizer) -{ - m_windowSizer = sizer; - if (sizer) - sizer->SetSizerParent((wxWindow *)this); -} - -/* - * New version - */ - -bool wxWindow::Layout() -{ - if (GetConstraints()) - { - int w, h; - GetClientSize(&w, &h); - GetConstraints()->width.SetValue(w); - GetConstraints()->height.SetValue(h); - } - - // If top level (one sizer), evaluate the sizer's constraints. - if (GetSizer()) - { - int noChanges; - GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated - GetSizer()->LayoutPhase1(&noChanges); - GetSizer()->LayoutPhase2(&noChanges); - GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes - return TRUE; - } - else - { - // Otherwise, evaluate child constraints - ResetConstraints(); // Mark all constraints as unevaluated - DoPhase(1); // Just one phase need if no sizers involved - DoPhase(2); - SetConstraintSizes(); // Recursively set the real window sizes - } - return TRUE; -} - - -// Do a phase of evaluating constraints: -// the default behaviour. wxSizers may do a similar -// thing, but also impose their own 'constraints' -// and order the evaluation differently. -bool wxWindow::LayoutPhase1(int *noChanges) -{ - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - return constr->SatisfyConstraints((wxWindow *)this, noChanges); - } - else - return TRUE; -} - -bool wxWindow::LayoutPhase2(int *noChanges) -{ - *noChanges = 0; - - // Layout children - DoPhase(1); - DoPhase(2); - return TRUE; -} - -// Do a phase of evaluating child constraints -bool wxWindow::DoPhase(int phase) -{ - int noIterations = 0; - int maxIterations = 500; - int noChanges = 1; - int noFailures = 0; - wxList succeeded; - while ((noChanges > 0) && (noIterations < maxIterations)) - { - noChanges = 0; - noFailures = 0; - wxNode *node = GetChildren().First(); - while (node) - { - wxWindow *child = (wxWindow *)node->Data(); - if (!child->IsKindOf(CLASSINFO(wxFrame)) && !child->IsKindOf(CLASSINFO(wxDialog))) - { - wxLayoutConstraints *constr = child->GetConstraints(); - if (constr) - { - if (succeeded.Member(child)) - { - } - else - { - int tempNoChanges = 0; - bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ; - noChanges += tempNoChanges; - if (success) - { - succeeded.Append(child); - } - } - } - } - node = node->Next(); - } - noIterations ++; - } - return TRUE; -} - -void wxWindow::ResetConstraints() -{ - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - constr->left.SetDone(FALSE); - constr->top.SetDone(FALSE); - constr->right.SetDone(FALSE); - constr->bottom.SetDone(FALSE); - constr->width.SetDone(FALSE); - constr->height.SetDone(FALSE); - constr->centreX.SetDone(FALSE); - constr->centreY.SetDone(FALSE); - } - wxNode *node = GetChildren().First(); - while (node) - { - wxWindow *win = (wxWindow *)node->Data(); - if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog))) - win->ResetConstraints(); - node = node->Next(); - } -} - -// Need to distinguish between setting the 'fake' size for -// windows and sizers, and setting the real values. -void wxWindow::SetConstraintSizes(bool recurse) -{ - wxLayoutConstraints *constr = GetConstraints(); - if (constr && constr->left.GetDone() && constr->right.GetDone() && - constr->width.GetDone() && constr->height.GetDone()) - { - int x = constr->left.GetValue(); - int y = constr->top.GetValue(); - int w = constr->width.GetValue(); - int h = constr->height.GetValue(); - - // If we don't want to resize this window, just move it... - if ((constr->width.GetRelationship() != wxAsIs) || - (constr->height.GetRelationship() != wxAsIs)) - { - // Calls Layout() recursively. AAAGH. How can we stop that. - // Simply take Layout() out of non-top level OnSizes. - SizerSetSize(x, y, w, h); - } - else - { - SizerMove(x, y); - } - } - else if (constr) - { - char *windowClass = this->GetClassInfo()->GetClassName(); - - wxString winName; - if (GetName() == "") - winName = "unnamed"; - else - winName = GetName(); - wxDebugMsg("Constraint(s) not satisfied for window of type %s, name %s:\n", (const char *)windowClass, (const char *)winName); - if (!constr->left.GetDone()) - wxDebugMsg(" unsatisfied 'left' constraint.\n"); - if (!constr->right.GetDone()) - wxDebugMsg(" unsatisfied 'right' constraint.\n"); - if (!constr->width.GetDone()) - wxDebugMsg(" unsatisfied 'width' constraint.\n"); - if (!constr->height.GetDone()) - wxDebugMsg(" unsatisfied 'height' constraint.\n"); - wxDebugMsg("Please check constraints: try adding AsIs() constraints.\n"); - } - - if (recurse) - { - wxNode *node = GetChildren().First(); - while (node) - { - wxWindow *win = (wxWindow *)node->Data(); - if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog))) - win->SetConstraintSizes(); - node = node->Next(); - } - } -} - -// This assumes that all sizers are 'on' the same -// window, i.e. the parent of this window. -void wxWindow::TransformSizerToActual(int *x, int *y) const -{ - if (!m_sizerParent || m_sizerParent->IsKindOf(CLASSINFO(wxDialog)) || - m_sizerParent->IsKindOf(CLASSINFO(wxFrame)) ) - return; - - int xp, yp; - m_sizerParent->GetPosition(&xp, &yp); - m_sizerParent->TransformSizerToActual(&xp, &yp); - *x += xp; - *y += yp; -} - -void wxWindow::SizerSetSize(int x, int y, int w, int h) -{ - int xx = x; - int yy = y; - TransformSizerToActual(&xx, &yy); - SetSize(xx, yy, w, h); -} - -void wxWindow::SizerMove(int x, int y) -{ - int xx = x; - int yy = y; - TransformSizerToActual(&xx, &yy); - Move(xx, yy); -} - -// Only set the size/position of the constraint (if any) -void wxWindow::SetSizeConstraint(int x, int y, int w, int h) -{ - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - if (x != -1) - { - constr->left.SetValue(x); - constr->left.SetDone(TRUE); - } - if (y != -1) - { - constr->top.SetValue(y); - constr->top.SetDone(TRUE); - } - if (w != -1) - { - constr->width.SetValue(w); - constr->width.SetDone(TRUE); - } - if (h != -1) - { - constr->height.SetValue(h); - constr->height.SetDone(TRUE); - } - } -} - -void wxWindow::MoveConstraint(int x, int y) -{ - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - if (x != -1) - { - constr->left.SetValue(x); - constr->left.SetDone(TRUE); - } - if (y != -1) - { - constr->top.SetValue(y); - constr->top.SetDone(TRUE); - } - } -} - -void wxWindow::GetSizeConstraint(int *w, int *h) const -{ - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - *w = constr->width.GetValue(); - *h = constr->height.GetValue(); - } - else - GetSize(w, h); -} - -void wxWindow::GetClientSizeConstraint(int *w, int *h) const -{ - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - *w = constr->width.GetValue(); - *h = constr->height.GetValue(); - } - else - GetClientSize(w, h); -} - -void wxWindow::GetPositionConstraint(int *x, int *y) const -{ - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - *x = constr->left.GetValue(); - *y = constr->top.GetValue(); - } - else - GetPosition(x, y); -} - -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); -} - -wxObject* wxWindow::GetChild(int number) const -{ - // Return a pointer to the Nth object in the window - wxNode *node = GetChildren().First(); - int n = number; - while (node && n--) - node = node->Next() ; - if (node) - { - wxObject *obj = (wxObject *)node->Data(); - return(obj) ; - } - else - return NULL ; -} - -void wxWindow::OnDefaultAction(wxControl *initiatingItem) -{ - // Obsolete function + // TODO: } void wxWindow::Clear() { - wxClientDC dc(this); - wxBrush brush(GetBackgroundColour(), wxSOLID); - dc.SetBackground(brush); - dc.Clear(); + // TODO: +} + +bool wxWindow::SetFont(const wxFont& f) +{ + // TODO: + return(TRUE); +} + +int wxWindow::GetCharHeight() const +{ + // TODO: + return(1); +} + +int wxWindow::GetCharWidth() const +{ + // TODO: + return(1); +} + +void wxWindow::GetTextExtent( const wxString& string + ,int* x + ,int* y + ,int* descent = NULL + ,int* externalLeading = NULL + ,const wxFont* theFont = NULL + ) const +{ + // TODO: +} + +void wxWindow::SetScrollbar( int orient + ,int pos + ,int thumbVisible + ,int range + ,bool refresh = TRUE + ) +{ + // TODO: +} + +void wxWindow::SetScrollPos( int orient + ,int pos + ,bool refresh = TRUE + ) +{ + // TODO: +} + +int wxWindow::GetScrollPos(int orient) const +{ + // TODO: + return(1); +} + +int wxWindow::GetScrollRange(int orient) const +{ + // TODO: + return(1); +} + +int wxWindow::GetScrollThumb(int orient) const +{ + // TODO: + return(1); +} + +void wxWindow::ScrollWindow( int dx + ,int dy + ,const wxRect* rect = NULL + ) +{ + // TODO: +} + +#if wxUSE_DRAG_AND_DROP +void wxWindow::SetDropTarget(wxDropTarget *pDropTarget) +{ + // TODO: +} +#endif + +void wxWindow::DoClientToScreen( int *x, int *y ) const +{ + // TODO: +} + +void wxWindow::DoScreenToClient( int *x, int *y ) const +{ + // TODO: +} + +void wxWindow::DoGetPosition( int *x, int *y ) const +{ + // TODO: +} + +void wxWindow::DoGetSize( int *width, int *height ) const +{ + // TODO: +} + +void wxWindow::DoGetClientSize( int *width, int *height ) const +{ + // TODO: +} + +void wxWindow::DoSetSize(int x, int y, + int width, int height, + int sizeFlags = wxSIZE_AUTO) +{ + // TODO: +} + +void wxWindow::DoSetClientSize(int width, int height) +{ + // TODO: +} + +bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y ) +{ + // TODO: + return(TRUE); } -// Fits the panel around the items void wxWindow::Fit() { - int maxX = 0; - int maxY = 0; - wxNode *node = GetChildren().First(); - while ( node ) - { - wxWindow *win = (wxWindow *)node->Data(); - int wx, wy, ww, wh; - win->GetPosition(&wx, &wy); - win->GetSize(&ww, &wh); - if ( wx + ww > maxX ) - maxX = wx + ww; - if ( wy + wh > maxY ) - maxY = wy + wh; - - node = node->Next(); - } - SetClientSize(maxX + 5, maxY + 5); + // TODO: } -void wxWindow::SetValidator(const wxValidator& validator) +bool wxWindow::Show(bool show) // check if base implementation is OK { - if ( m_windowValidator ) - delete m_windowValidator; - m_windowValidator = validator.Clone(); - - if ( m_windowValidator ) - m_windowValidator->SetWindow(this) ; + // TODO: + return(TRUE); } -void wxWindow::SetAcceleratorTable(const wxAcceleratorTable& accel) +bool wxWindow::Enable(bool enable) // check if base implementation is OK { - m_acceleratorTable = accel; + // TODO: + return(TRUE); } -// Find a window by id or name -wxWindow *wxWindow::FindWindow(long id) +bool wxWindow::SetCursor(const wxCursor& cursor) // check if base implementation is OK { - if ( GetId() == id) - return this; - - wxNode *node = GetChildren().First(); - while ( node ) - { - wxWindow *child = (wxWindow *)node->Data(); - wxWindow *found = child->FindWindow(id); - if ( found ) - return found; - node = node->Next(); - } - return NULL; + // TODO: + return(TRUE); } -wxWindow *wxWindow::FindWindow(const wxString& name) +bool wxWindow::Validate() { - if ( GetName() == name) - return this; + // TODO: + return(TRUE); +} - wxNode *node = GetChildren().First(); - while ( node ) - { - wxWindow *child = (wxWindow *)node->Data(); - wxWindow *found = child->FindWindow(name); - if ( found ) - return found; - node = node->Next(); - } - return NULL; +wxWindow* wxWindow::FindFocus() +{ + // TODO: + return(this); +} + +void wxWindow::DragAcceptFiles(bool accept) +{ + // TODO: +} + +#if wxUSE_CARET && WXWIN_COMPATIBILITY +void wxWindow::CreateCaret(int w, int h) +{ + // TODO: +} + +void wxWindow::CreateCaret(const wxBitmap *bitmap) +{ + // TODO: +} + +void wxWindow::DestroyCaret() +{ + // TODO: +} + +void wxWindow::ShowCaret(bool show) +{ + // TODO: +} + +void wxWindow::SetCaretPos(int x, int y) +{ + // TODO: +} + +void wxWindow::GetCaretPos(int *x, int *y) const +{ + // TODO: +} + +#endif + +void wxWindow::OnCommand(wxWindow& win, wxCommandEvent& event) +{ + // TODO: +} + +void wxWindow::OnDefaultAction(wxControl *initiatingItem) +{ + // TODO: +} + +void wxWindow::OnEraseBackground(wxEraseEvent& event) +{ + // TODO: +} + +void wxWindow::OnChar(wxKeyEvent& event) +{ + // TODO: +} + +void wxWindow::OnKeyDown(wxKeyEvent& event) +{ + // TODO: +} + +void wxWindow::OnKeyUp(wxKeyEvent& event) +{ + // TODO: +} + +void wxWindow::OnPaint(wxPaintEvent& event) +{ + // TODO: } void wxWindow::OnIdle(wxIdleEvent& event) { -/* TODO: you may need to do something like this - * if your GUI doesn't generate enter/leave events + // TODO: +} - // Check if we need to send a LEAVE event - if (m_mouseInWindow) +void wxWindow::OnInitDialog(wxInitDialogEvent& event) +{ + // TODO: +} + + +wxPoint wxWindow::GetClientAreaOrigin() const +{ + // TODO: + return wxPoint(0, 0); +} + +void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) +{ + // TODO: +} + +long wxWindow::Default() +{ + // TODO: + return(1); +} + +void wxWindow::UnsetConstraints(wxLayoutConstraints *c) +{ + // TODO: +} + +wxObject* wxWindow::GetChild(int number) const +{ + // TODO: + return(this); +} + +void wxWindow::PMDetachWindowMenu() +{ + if ( m_hMenu ) { - POINT pt; - ::GetCursorPos(&pt); - if (::WindowFromPoint(pt) != (HWND) GetHWND()) + HMENU hMenu = (HMENU)m_hMenu; + + int N = ::GetMenuItemCount(hMenu); + int i; + for (i = 0; i < N; i++) { - // Generate a LEAVE event - m_mouseInWindow = FALSE; - MSWOnMouseLeave(pt.x, pt.y, 0); + wxChar buf[100]; + int chars = GetMenuString(hMenu, i, buf, 100, MF_BYPOSITION); + if ( !chars ) + { + wxLogLastError(_T("GetMenuString")); + + continue; + } + + if ( wxStrcmp(buf, _T("&Window")) == 0 ) + { + RemoveMenu(hMenu, i, MF_BYPOSITION); + + break; + } } } -*/ - - // This calls the UI-update mechanism (querying windows for - // menu/toolbar/control state information) - UpdateWindowUI(); } - -// Raise the window to the top of the Z order -void wxWindow::Raise() +void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win) { - // TODO + // adding NULL hWnd is (first) surely a result of an error and + // (secondly) breaks menu command processing + wxCHECK_RET( hWnd != (HWND)NULL, + _T("attempt to add a NULL hWnd to window list ignored") ); + + if ( !wxWinHandleList->Find((long)hWnd) ) + wxWinHandleList->Append((long)hWnd, win); } -// Lower the window to the bottom of the Z order -void wxWindow::Lower() +wxWindow *wxFindWinFromHandle(WXHWND hWnd) { - // TODO + wxNode *node = wxWinHandleList->Find((long)hWnd); + if ( !node ) + return NULL; + return (wxWindow *)node->Data(); } -bool wxWindow::AcceptsFocus() const +void wxRemoveHandleAssociation(wxWindow *win) { - return IsShown() && IsEnabled(); + wxWinHandleList->DeleteObject(win); } -// Update region access -wxRegion wxWindow::GetUpdateRegion() const -{ - return m_updateRegion; -} - -bool wxWindow::IsExposed(int x, int y, int w, int h) const -{ - return (m_updateRegion.Contains(x, y, w, h) != wxOutRegion); -} - -bool wxWindow::IsExposed(const wxPoint& pt) const -{ - return (m_updateRegion.Contains(pt) != wxOutRegion); -} - -bool wxWindow::IsExposed(const wxRect& rect) const -{ - return (m_updateRegion.Contains(rect) != wxOutRegion); -} - -void wxWindow::SetToolTip(const wxString& tooltip) -{ - // TODO -} - -/* - * Allocates control IDs - */ - -int wxWindow::NewControlId() -{ - static int s_controlId = 0; - s_controlId ++; - return s_controlId; -} - -