#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 <os2.h>
+ #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 <stdio.h>
+#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 <string.h>
-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)
-
-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()
-
+ IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
#endif
+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()
-// Constructor
-wxWindow::wxWindow()
-{
- // 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;
-
-#if wxUSE_DRAG_AND_DROP
- m_pDropTarget = NULL;
-#endif
-}
+// ===========================================================================
+// implementation
+// ===========================================================================
-// Destructor
-wxWindow::~wxWindow()
+void wxWindow::Init()
{
- // 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
+ // generic
+ InitBase();
- if (m_windowParent)
- m_windowParent->RemoveChild(this);
+ // PM specific
+ m_winCaptured = FALSE;
+ m_isBeingDeleted = FALSE;
+ m_mouseInWindow = FALSE;
+ m_backgroundTransparent = FALSE;
- DestroyChildren();
+ // wxWnd
+ m_hMenu = 0;
- // TODO: destroy the window
+ m_hWnd = 0;
- delete m_children;
- m_children = NULL;
+ // pass WM_GETDLGCODE to DefWindowProc()
+ m_lDlgCode = 0;
- // Just in case the window has been Closed, but
- // we're then deleting immediately: don't leave
- // dangling pointers.
- wxPendingDelete.DeleteObject(this);
+ m_xThumbSize = 0;
+ m_yThumbSize = 0;
- if ( m_windowValidator )
- delete m_windowValidator;
-}
+ // as all windows are created with WS_VISIBLE style...
+ m_isShown = TRUE;
-// Destroy the window (delayed, if a managed window)
-bool wxWindow::Destroy()
-{
- delete this;
- return TRUE;
}
-// Constructor
bool wxWindow::Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
{
- // 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;
+ wxCHECK_MSG( parent, FALSE, _T("can't create wxWindow without parent") );
-#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)
+ if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
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
-
+ // TODO: PM Specific initialization
+ parent->AddChild(this);
return TRUE;
}
-void wxWindow::SetFocus()
+// Destructor
+wxWindow::~wxWindow()
{
- // TODO
-}
+ m_isBeingDeleted = TRUE;
-void wxWindow::Enable(bool enable)
-{
- // TODO
+ PMDetachWindowMenu();
+ // delete handlers?
+ if (m_parent)
+ m_parent->RemoveChild(this);
+ DestroyChildren();
+ if (m_hWnd)
+ {
+ if(!WinDestroyWindow(GetHwnd()))
+ wxLogLastError("DestroyWindow");
+ // remove hWnd <-> wxWindow association
+ wxRemoveHandleAssociation(this);
+ }
}
-void wxWindow::CaptureMouse()
-{
- // TODO
-}
+// ---------------------------------------------------------------------------
+// basic operations
+// ---------------------------------------------------------------------------
-void wxWindow::ReleaseMouse()
+void wxWindow::Raise()
{
- // TODO
+ // TODO:
}
-// Push/pop event handler (i.e. allow a chain of event handlers
-// be searched)
-void wxWindow::PushEventHandler(wxEvtHandler *handler)
+void wxWindow::Lower()
{
- handler->SetNextHandler(GetEventHandler());
- SetEventHandler(handler);
+ // TODO:
}
-wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler)
+void wxWindow::SetFocus()
{
- 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;
+ // TODO:
}
-#if wxUSE_DRAG_AND_DROP
-
-void wxWindow::SetDropTarget(wxDropTarget *pDropTarget)
+void wxWindow::WarpPointer(int x_pos, int y_pos)
{
- if ( m_pDropTarget != 0 ) {
- delete m_pDropTarget;
- }
-
- m_pDropTarget = pDropTarget;
- if ( m_pDropTarget != 0 )
- {
- // TODO
- }
+ // TODO:
}
-#endif
-
-// Old style file-manager drag&drop
-void wxWindow::DragAcceptFiles(bool accept)
+void wxWindow::CaptureMouse()
{
- // TODO
+ // TODO:
}
-// Get total size
-void wxWindow::GetSize(int *x, int *y) const
+void wxWindow::ReleaseMouse()
{
- // TODO
+ // TODO:
}
-void wxWindow::GetPosition(int *x, int *y) const
+void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
{
- // TODO
+ // TODO:
}
-void wxWindow::ScreenToClient(int *x, int *y) const
+void wxWindow::Clear()
{
- // TODO
+ // TODO:
}
-void wxWindow::ClientToScreen(int *x, int *y) const
+bool wxWindow::SetFont(const wxFont& f)
{
- // TODO
+ // TODO:
+ return(TRUE);
}
-void wxWindow::SetCursor(const wxCursor& cursor)
+int wxWindow::GetCharHeight() const
{
- m_windowCursor = cursor;
- if (m_windowCursor.Ok())
- {
- // TODO
- }
+ // TODO:
+ return(1);
}
-
-// Get size *available for subwindows* i.e. excluding menu bar etc.
-void wxWindow::GetClientSize(int *x, int *y) const
+int wxWindow::GetCharWidth() const
{
- // TODO
+ // TODO:
+ return(1);
}
-void wxWindow::SetSize(int x, int y, int width, int height, int sizeFlags)
+void wxWindow::GetTextExtent( const wxString& string
+ ,int* x
+ ,int* y
+ ,int* descent
+ ,int* externalLeading
+ ,const wxFont* theFont
+ ) const
{
- // TODO
+ // TODO:
}
-void wxWindow::SetClientSize(int width, int height)
+void wxWindow::SetScrollbar( int orient
+ ,int pos
+ ,int thumbVisible
+ ,int range
+ ,bool refresh
+ )
{
- // TODO
+ // TODO:
}
-// For implementation purposes - sometimes decorations make the client area
-// smaller
-wxPoint wxWindow::GetClientAreaOrigin() const
+void wxWindow::SetScrollPos( int orient
+ ,int pos
+ ,bool refresh
+ )
{
- return wxPoint(0, 0);
+ // TODO:
}
-// 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)
+int wxWindow::GetScrollPos(int orient) const
{
- if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent())
- {
- wxPoint pt(GetParent()->GetClientAreaOrigin());
- x += pt.x; y += pt.y;
- }
+ // TODO:
+ return(1);
}
-bool wxWindow::Show(bool show)
+int wxWindow::GetScrollRange(int orient) const
{
- // TODO
- return FALSE;
+ // TODO:
+ return(1);
}
-bool wxWindow::IsShown() const
+int wxWindow::GetScrollThumb(int orient) const
{
- // TODO
- return FALSE;
+ // TODO:
+ return(1);
}
-int wxWindow::GetCharHeight() const
+void wxWindow::ScrollWindow( int dx
+ ,int dy
+ ,const wxRect* rect
+ )
{
- // TODO
- return 0;
+ // TODO:
}
-int wxWindow::GetCharWidth() const
+#if wxUSE_DRAG_AND_DROP
+void wxWindow::SetDropTarget(wxDropTarget *pDropTarget)
{
- // TODO
- return 0;
+ // TODO:
}
+#endif
-void wxWindow::GetTextExtent(const wxString& string, int *x, int *y,
- int *descent, int *externalLeading, const wxFont *theFont, bool) const
+void wxWindow::DoClientToScreen( int *x, int *y ) const
{
- wxFont *fontToUse = (wxFont *)theFont;
- if (!fontToUse)
- fontToUse = (wxFont *) & m_windowFont;
-
- // TODO
+ // TODO:
}
-void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
+void wxWindow::DoScreenToClient( int *x, int *y ) const
{
- // TODO
+ // TODO:
}
-// Responds to colour changes: passes event on to children.
-void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event)
+void wxWindow::DoGetPosition( int *x, int *y ) const
{
- 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();
- }
+ // TODO:
}
-// 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()
+void wxWindow::DoGetSize( int *width, int *height ) const
{
- // TODO
- return 0;
+ // TODO:
}
-void wxWindow::InitDialog()
+void wxWindow::DoGetClientSize( int *width, int *height ) const
{
- wxInitDialogEvent event(GetId());
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent(event);
+ // TODO:
}
-// Default init dialog behaviour is to transfer data to window
-void wxWindow::OnInitDialog(wxInitDialogEvent& event)
+void wxWindow::DoSetSize(int x, int y,
+ int width, int height,
+ int sizeFlags)
{
- TransferDataToWindow();
+ // TODO:
}
-// Caret manipulation
-void wxWindow::CreateCaret(int w, int h)
+void wxWindow::DoSetClientSize(int width, int height)
{
- m_caretWidth = w;
- m_caretHeight = h;
- m_caretEnabled = TRUE;
+ // TODO:
}
-void wxWindow::CreateCaret(const wxBitmap *WXUNUSED(bitmap))
+bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y )
{
- // TODO
+ // TODO:
+ return(TRUE);
}
-void wxWindow::ShowCaret(bool show)
+void wxWindow::Fit()
{
- // TODO
+ // TODO:
}
-void wxWindow::DestroyCaret()
+bool wxWindow::Show(bool show) // check if base implementation is OK
{
- // TODO
- m_caretEnabled = FALSE;
+ // TODO:
+ return(TRUE);
}
-void wxWindow::SetCaretPos(int x, int y)
+bool wxWindow::Enable(bool enable) // check if base implementation is OK
{
- // TODO
+ // TODO:
+ return(TRUE);
}
-void wxWindow::GetCaretPos(int *x, int *y) const
+bool wxWindow::SetCursor(const wxCursor& cursor) // check if base implementation is OK
{
- // TODO
+ // TODO:
+ return(TRUE);
}
-wxWindow *wxGetActiveWindow()
+bool wxWindow::Validate()
{
- // TODO
- return NULL;
+ // TODO:
+ return(TRUE);
}
-void wxWindow::SetSizeHints(int minW, int minH, int maxW, int maxH, int WXUNUSED(incW), int WXUNUSED(incH))
+wxWindow* wxWindow::FindFocus()
{
- m_minSizeX = minW;
- m_minSizeY = minH;
- m_maxSizeX = maxW;
- m_maxSizeY = maxH;
+ wxWindow* window = NULL;
+ // TODO:
+ return(window);
}
-void wxWindow::Centre(int direction)
+void wxWindow::DragAcceptFiles(bool accept)
{
- 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);
-
+ // TODO:
}
-// Coordinates relative to the window
-void wxWindow::WarpPointer (int x_pos, int y_pos)
+#if wxUSE_CARET && WXWIN_COMPATIBILITY
+void wxWindow::CreateCaret(int w, int h)
{
- // TODO
+ // TODO:
}
-void wxWindow::OnEraseBackground(wxEraseEvent& event)
+void wxWindow::CreateCaret(const wxBitmap *bitmap)
{
- // TODO
- Default();
+ // TODO:
}
-int wxWindow::GetScrollPos(int orient) const
+void wxWindow::DestroyCaret()
{
- // TODO
- return 0;
+ // TODO:
}
-// This now returns the whole range, not just the number
-// of positions that we can scroll.
-int wxWindow::GetScrollRange(int orient) const
+void wxWindow::ShowCaret(bool show)
{
- // TODO
- return 0;
+ // TODO:
}
-int wxWindow::GetScrollThumb(int orient) const
+void wxWindow::SetCaretPos(int x, int y)
{
- // TODO
- return 0;
+ // TODO:
}
-void wxWindow::SetScrollPos(int orient, int pos, bool refresh)
+void wxWindow::GetCaretPos(int *x, int *y) const
{
- // TODO
- return;
+ // TODO:
}
-// New function that will replace some of the above.
-void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible,
- int range, bool refresh)
+#endif
+
+void wxWindow::OnCommand(wxWindow& win, wxCommandEvent& event)
{
- // TODO
+ // TODO:
}
-// Does a physical scroll
-void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
+void wxWindow::OnDefaultAction(wxControl *initiatingItem)
{
- // TODO
- return;
+ // TODO:
}
-void wxWindow::SetFont(const wxFont& font)
+void wxWindow::OnEraseBackground(wxEraseEvent& event)
{
- m_windowFont = font;
-
- if (!m_windowFont.Ok())
- return;
- // TODO
+ // 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();
+ // TODO:
}
void wxWindow::OnKeyDown(wxKeyEvent& event)
{
- Default();
+ // TODO:
}
void wxWindow::OnKeyUp(wxKeyEvent& event)
{
- Default();
+ // TODO:
}
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;
+ // TODO:
}
-// Get the window with the focus
-wxWindow *wxWindow::FindFocus()
+void wxWindow::OnIdle(wxIdleEvent& event)
{
- // TODO
- return NULL;
+ // TODO:
}
-void wxWindow::AddChild(wxWindow *child)
+void wxWindow::OnInitDialog(wxInitDialogEvent& event)
{
- GetChildren().Append(child);
- child->m_windowParent = this;
+ // TODO:
}
-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)
+wxPoint wxWindow::GetClientAreaOrigin() const
{
- // 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();
- }
- }
+ // TODO:
+ return wxPoint(0, 0);
}
-// 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)
+void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags)
{
- if (GetEventHandler()->ProcessEvent(event) )
- return;
- if (m_windowParent)
- m_windowParent->GetEventHandler()->OnCommand(win, event);
+ // TODO:
}
-void wxWindow::SetConstraints(wxLayoutConstraints *c)
+long wxWindow::Default()
{
- 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);
- }
+ // TODO:
+ return(1);
}
-// 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);
- }
+ // TODO:
}
-// 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)
+wxObject* wxWindow::GetChild(int number) const
{
- if (!m_constraintsInvolvedIn)
- m_constraintsInvolvedIn = new wxList;
- if (!m_constraintsInvolvedIn->Member(otherWin))
- m_constraintsInvolvedIn->Append(otherWin);
+ // TODO:
+ return((wxObject*)this);
}
-// REMOVE back-pointer to other windows we're involved with.
-void wxWindow::RemoveConstraintReference(wxWindow *otherWin)
+WXWidget wxWindow::GetHandle() const
{
- if (m_constraintsInvolvedIn)
- m_constraintsInvolvedIn->DeleteObject(otherWin);
+ // TODO:
+ return((WXWidget)m_hWnd);
}
-// Reset any constraints that mention this window
-void wxWindow::DeleteRelatedConstraints()
+void wxWindow::PMDetachWindowMenu()
{
- if (m_constraintsInvolvedIn)
- {
- wxNode *node = m_constraintsInvolvedIn->First();
- while (node)
+ if ( m_hMenu )
{
- 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;
-}
+ HMENU hMenu = (HMENU)m_hMenu;
-
-// 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)
+ int N = (int)WinSendMsg(hMenu, MM_QUERYITEMCOUNT, 0, 0);
+ int i;
+ for (i = 0; i < N; i++)
{
- if (succeeded.Member(child))
- {
- }
- else
- {
- int tempNoChanges = 0;
- bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ;
- noChanges += tempNoChanges;
- if (success)
+ wxChar buf[100];
+ int chars = (int)WinSendMsg(hMenu, MM_QUERYITEMTEXT, MPFROM2SHORT(i, N), buf);
+ if ( !chars )
{
- succeeded.Append(child);
- }
- }
- }
- }
- node = node->Next();
- }
- noIterations ++;
- }
- return TRUE;
-}
+ wxLogLastError(_T("GetMenuString"));
-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
-}
-
-void wxWindow::Clear()
-{
- wxClientDC dc(this);
- wxBrush brush(GetBackgroundColour(), wxSOLID);
- dc.SetBackground(brush);
- dc.Clear();
-}
-
-// 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);
-}
-
-void wxWindow::SetValidator(const wxValidator& validator)
-{
- if ( m_windowValidator )
- delete m_windowValidator;
- m_windowValidator = validator.Clone();
-
- if ( m_windowValidator )
- m_windowValidator->SetWindow(this) ;
-}
-
-void wxWindow::SetAcceleratorTable(const wxAcceleratorTable& accel)
-{
- m_acceleratorTable = accel;
-}
-
-// Find a window by id or name
-wxWindow *wxWindow::FindWindow(long id)
-{
- 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;
-}
-
-wxWindow *wxWindow::FindWindow(const wxString& name)
-{
- if ( GetName() == name)
- return this;
-
- 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;
-}
-
-void wxWindow::OnIdle(wxIdleEvent& event)
-{
-/* TODO: you may need to do something like this
- * if your GUI doesn't generate enter/leave events
+ continue;
+ }
- // Check if we need to send a LEAVE event
- if (m_mouseInWindow)
- {
- POINT pt;
- ::GetCursorPos(&pt);
- if (::WindowFromPoint(pt) != (HWND) GetHWND())
- {
- // Generate a LEAVE event
- m_mouseInWindow = FALSE;
- MSWOnMouseLeave(pt.x, pt.y, 0);
+ if ( wxStrcmp(buf, _T("&Window")) == 0 )
+ {
+ WinSendMsg(hMenu, MM_DELETEITEM, MPFROM2SHORT(i, TRUE), 0);
+ 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()
-{
- // TODO
}
-// Lower the window to the bottom of the Z order
-void wxWindow::Lower()
+void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win)
{
- // TODO
-}
-
-bool wxWindow::AcceptsFocus() const
-{
- return IsShown() && IsEnabled();
-}
+ // 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") );
-// 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);
+ if ( !wxWinHandleList->Find((long)hWnd) )
+ wxWinHandleList->Append((long)hWnd, win);
}
-bool wxWindow::IsExposed(const wxPoint& pt) const
+wxWindow *wxFindWinFromHandle(WXHWND hWnd)
{
- return (m_updateRegion.Contains(pt) != wxOutRegion);
+ wxNode *node = wxWinHandleList->Find((long)hWnd);
+ if ( !node )
+ return NULL;
+ return (wxWindow *)node->Data();
}
-bool wxWindow::IsExposed(const wxRect& rect) const
+void wxRemoveHandleAssociation(wxWindow *win)
{
- return (m_updateRegion.Contains(rect) != wxOutRegion);
+ wxWinHandleList->DeleteObject(win);
}
-void wxWindow::SetToolTip(const wxString& tooltip)
-{
- // TODO
-}
-
-/*
- * Allocates control IDs
- */
-
-int wxWindow::NewControlId()
-{
- static int s_controlId = 0;
- s_controlId ++;
- return s_controlId;
-}
-
-