// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_WINDOW_H_
#define _WX_WINDOW_H_
+// ---------------------------------------------------------------------------
+// headers
+// ---------------------------------------------------------------------------
+
#ifdef __GNUG__
-#pragma interface "window.h"
+ #pragma interface "window.h"
#endif
-#include "wx/gdicmn.h"
-#include "wx/icon.h"
-#include "wx/cursor.h"
-#include "wx/pen.h"
-#include "wx/font.h"
-#include "wx/validate.h"
-#include "wx/event.h"
-#include "wx/string.h"
-#include "wx/list.h"
-#include "wx/region.h"
-#include "wx/msw/accel.h"
-#include "wx/intl.h"
-
-#define wxKEY_SHIFT 1
-#define wxKEY_CTRL 2
-
-/*
- * Base class for frame, panel, canvas, panel items, dialog box.
- *
- */
-
-/*
- * Event handler: windows have themselves as their event handlers
- * by default, but their event handlers could be set to another
- * object entirely. This separation can reduce the amount of
- * derivation required, and allow alteration of a window's functionality
- * (e.g. by a resource editor that temporarily switches event handlers).
- */
-
-class WXDLLEXPORT wxWindow;
-class WXDLLEXPORT wxEvent;
-class WXDLLEXPORT wxCommandEvent;
-class WXDLLEXPORT wxKeyEvent;
-class WXDLLEXPORT wxControl;
-class WXDLLEXPORT wxCursor;
-class WXDLLEXPORT wxColourMap;
-class WXDLLEXPORT wxFont;
-class WXDLLEXPORT wxMenu;
-class WXDLLEXPORT wxRect;
-class WXDLLEXPORT wxBitmap;
-class WXDLLEXPORT wxSizer;
-class WXDLLEXPORT wxList;
-class WXDLLEXPORT wxLayoutConstraints;
-class WXDLLEXPORT wxMouseEvent;
-class WXDLLEXPORT wxButton;
-class WXDLLEXPORT wxColour;
-class WXDLLEXPORT wxBrush;
-class WXDLLEXPORT wxPen;
-class WXDLLEXPORT wxIcon;
-class WXDLLEXPORT wxDC;
-class WXDLLEXPORT wxValidator;
-class WXDLLEXPORT wxToolTip;
-
-#if wxUSE_DRAG_AND_DROP
-class WXDLLEXPORT wxDropTarget;
+// windows.h #defines the following identifiers which are also used in wxWin
+#ifdef GetCharWidth
+ #undef GetCharWidth
#endif
-#if wxUSE_WX_RESOURCES
-class WXDLLEXPORT wxResourceTable;
-class WXDLLEXPORT wxItemResource;
+#ifdef FindWindow
+ #undef FindWindow
#endif
-WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr;
+// ---------------------------------------------------------------------------
+// forward declarations
+// ---------------------------------------------------------------------------
-WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize;
-WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition;
+class WXDLLEXPORT wxButton;
-//-----------------------------------------------------------------------------
-// wxClientData
-//-----------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+// constants
+// ---------------------------------------------------------------------------
-class wxClientData
+// FIXME does anybody use those? they're unused by wxWindows...
+enum
{
-public:
- wxClientData() { }
- virtual ~wxClientData() { }
+ wxKEY_SHIFT = 1,
+ wxKEY_CTRL = 2
};
-//-----------------------------------------------------------------------------
-// wxStringClientData
-//-----------------------------------------------------------------------------
-
-class wxStringClientData: public wxClientData
+// ---------------------------------------------------------------------------
+// wxWindow declaration for MSW
+// ---------------------------------------------------------------------------
+class WXDLLEXPORT wxWindow : public wxWindowBase
{
-public:
- wxStringClientData() { }
- wxStringClientData( wxString &data ) { m_data = data; }
- void SetData( wxString &data ) { m_data = data; }
- wxString GetData() const { return m_data; }
-
-private:
- wxString m_data;
-};
-
-// Clash with Windows headers
-#ifdef GetCharWidth
-#undef GetCharWidth
-#endif
-
-#ifdef FindWindow
-#undef FindWindow
-#endif
-
-class WXDLLEXPORT wxWindow : public wxEvtHandler
-{
- DECLARE_ABSTRACT_CLASS(wxWindow)
-
- friend class wxDC;
- friend class wxPaintDC;
+ DECLARE_DYNAMIC_CLASS(wxWindow);
public:
- wxWindow();
- wxWindow(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxPanelNameStr)
+ wxWindow() { Init(); }
+
+ wxWindow(wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = 0,
+ const wxString& name = wxPanelNameStr)
{
Init();
Create(parent, id, pos, size, style, name);
virtual ~wxWindow();
- bool Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxPanelNameStr);
-
- // Fit the window around the items
- virtual void Fit();
-
- // Show or hide the window
- virtual bool Show(bool show);
-
- // Is the window shown?
- virtual bool IsShown() const;
+ bool Create(wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = 0,
+ const wxString& name = wxPanelNameStr);
- // Raise the window to the top of the Z order
+ // implement base class pure virtuals
virtual void Raise();
-
- // Lower the window to the bottom of the Z order
virtual void Lower();
- // Is the window enabled?
- virtual bool IsEnabled() const;
-
- // For compatibility
- inline bool Enabled() const { return IsEnabled(); }
-
- // Dialog support: override these and call
- // base class members to add functionality
- // that can't be done using validators.
-
- // Transfer values to controls. If returns FALSE,
- // it's an application error (pops up a dialog)
- virtual bool TransferDataToWindow();
+ virtual bool Show( bool show = TRUE );
+ virtual bool Enable( bool enable = TRUE );
- // Transfer values from controls. If returns FALSE,
- // transfer failed: don't quit
- virtual bool TransferDataFromWindow();
+ virtual void SetFocus();
- // Validate controls. If returns FALSE,
- // validation failed: don't quit
- virtual bool Validate();
+ virtual bool Reparent( wxWindow *newParent );
- // Return code for dialogs
- inline void SetReturnCode(int retCode);
- inline int GetReturnCode();
+ virtual void WarpPointer(int x, int y);
+ virtual void CaptureMouse();
+ virtual void ReleaseMouse();
- // Set the cursor
- virtual void SetCursor(const wxCursor& cursor);
- inline virtual wxCursor& GetCursor() const { return (wxCursor& ) m_windowCursor; };
+ virtual void Refresh( bool eraseBackground = TRUE,
+ const wxRect *rect = (const wxRect *) NULL );
+ virtual void Clear();
- // Get the window with the focus
- static wxWindow *FindFocus();
+ virtual bool SetCursor( const wxCursor &cursor );
+ virtual bool SetFont( const wxFont &font );
- // Get character size
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
-
- // moving/resizing
- // ---------------
-
- // set the window size and/or position
- void SetSize( int x, int y, int width, int height,
- int sizeFlags = wxSIZE_AUTO )
- { DoSetSize(x, y, width, height, sizeFlags); }
-
- void SetSize( int width, int height )
- { DoSetSize(-1, -1, width, height, wxSIZE_USE_EXISTING); }
-
- void SetSize( const wxSize& size )
- { SetSize(size.x, size.y); }
-
- void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO)
- { DoSetSize(rect.x, rect.y, rect.width, rect.height, sizeFlags); }
-
- void Move( int x, int y )
- { DoSetSize( x, y, -1, -1, wxSIZE_USE_EXISTING ); }
-
- void Move(const wxPoint& pt)
- { Move(pt.x, pt.y); }
-
- // client size is the size of area available for subwindows
- void SetClientSize( int width, int height )
- { DoSetClientSize(width, height); }
-
- void SetClientSize( const wxSize& size )
- { DoSetClientSize(size.x, size.y); }
-
- void SetClientSize(const wxRect& rect)
- { SetClientSize( rect.width, rect.height ); }
-
- // get the window position and/or size
- virtual void GetPosition( int *x, int *y ) const;
- wxPoint GetPosition() const
- {
- int w, h;
- GetPosition(& w, & h);
-
- return wxPoint(w, h);
- }
-
- virtual void GetSize( int *width, int *height ) const;
-
- wxSize GetSize() const
- {
- int w, h;
- GetSize(& w, & h);
- return wxSize(w, h);
- }
-
- wxRect GetRect() const
- {
- int x, y, w, h;
- GetPosition(& x, & y);
- GetSize(& w, & h);
-
- return wxRect(x, y, w, h);
- }
-
- virtual void GetClientSize( int *width, int *height ) const;
- wxSize GetClientSize() const
- {
- int w, h;
- GetClientSize(& w, & h);
- return wxSize(w, h);
- }
-
- wxRect GetClientRect() const
- {
- int w, h;
- GetSize(& w, & h);
-
- return wxRect(0, 0, w, h);
- }
-
- // Convert client to screen coordinates
- virtual void ClientToScreen(int *x, int *y) const;
- wxPoint ClientToScreen(const wxPoint& pt) const
- { int x = pt.x; int y = pt.y; ClientToScreen(& x, & y); return wxPoint(x, y); }
-
- // Convert screen to client coordinates
- virtual void ScreenToClient(int *x, int *y) const;
- wxPoint ScreenToClient(const wxPoint& pt) const
- { int x = pt.x; int y = pt.y; ScreenToClient(& x, & y); return wxPoint(x, y); }
-
- // Set the focus to this window
- virtual void SetFocus();
-
- // Capture/release mouse
- virtual void CaptureMouse();
- virtual void ReleaseMouse();
-
- // Enable or disable the window
- virtual void Enable(bool enable);
+ virtual void GetTextExtent(const wxString& string,
+ int *x, int *y,
+ int *descent = (int *) NULL,
+ int *externalLeading = (int *) NULL,
+ const wxFont *theFont = (const wxFont *) NULL)
+ const;
+
+ virtual void ClientToScreen( int *x, int *y ) const;
+ virtual void ScreenToClient( int *x, int *y ) const;
+
+ virtual bool PopupMenu( wxMenu *menu, int x, int y );
+
+ virtual void SetScrollbar( int orient, int pos, int thumbVisible,
+ int range, bool refresh = TRUE );
+ virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
+ virtual int GetScrollPos( int orient ) const;
+ virtual int GetScrollThumb( int orient ) const;
+ virtual int GetScrollRange( int orient ) const;
+ virtual void ScrollWindow( int dx, int dy,
+ const wxRect* rect = (wxRect *) NULL );
#if wxUSE_DRAG_AND_DROP
- // Associate a drop target with this window (if the window already had a drop
- // target, it's deleted!) and return the current drop target (may be NULL).
- void SetDropTarget(wxDropTarget *pDropTarget);
- wxDropTarget *GetDropTarget() const { return m_pDropTarget; }
-#endif
-
-#if wxUSE_TOOLTIPS
- // tooltips
- // create a tooltip with this text
- void SetToolTip(const wxString &tip);
- // pointer may be NULL to remove the tooltip
- void SetToolTip(wxToolTip *tooltip);
- // get the current tooltip (may return NULL if none)
- wxToolTip* GetToolTip() const { return m_tooltip; }
-
-#endif // wxUSE_TOOLTIPS
+ virtual void SetDropTarget( wxDropTarget *dropTarget );
+#endif // wxUSE_DRAG_AND_DROP
// Accept files for dragging
virtual void DragAcceptFiles(bool accept);
- // Update region access
- virtual wxRegion GetUpdateRegion() const;
- virtual bool IsExposed(int x, int y, int w, int h) const;
- virtual bool IsExposed(const wxPoint& pt) const;
- virtual bool IsExposed(const wxRect& rect) const;
-
- // Set/get the window title
- virtual inline void SetTitle(const wxString& WXUNUSED(title)) {};
- inline virtual wxString GetTitle() const { return wxString(""); };
- // Most windows have the concept of a label; for frames, this is the
- // title; for items, this is the label or button text.
- inline virtual wxString GetLabel() const { return GetTitle(); }
-
- // Set/get the window name (used for resource setting in X)
- inline virtual wxString GetName() const;
- inline virtual void SetName(const wxString& name);
-
- // Centre the window
- virtual void Centre(int direction) ;
- inline void Center(int direction = wxHORIZONTAL) { Centre(direction); }
-
- // Popup a menu
- virtual bool PopupMenu(wxMenu *menu, int x, int y);
-
- // Send the window a refresh event
- virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL);
-
#if WXWIN_COMPATIBILITY
// Set/get scroll attributes
virtual void SetScrollRange(int orient, int range, bool refresh = TRUE);
virtual void SetScrollPage(int orient, int page, bool refresh = TRUE);
virtual int OldGetScrollRange(int orient) const;
virtual int GetScrollPage(int orient) const;
-#endif
-
- // New functions that will replace the above.
- virtual void SetScrollbar(int orient, int pos, int thumbVisible,
- int range, bool refresh = TRUE);
-
- virtual void SetScrollPos(int orient, int pos, bool refresh = TRUE);
- virtual int GetScrollPos(int orient) const;
- virtual int GetScrollRange(int orient) const;
- virtual int GetScrollThumb(int orient) const;
-
- virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL);
+#endif // WXWIN_COMPATIBILITY
- // Caret manipulation
+ // caret manipulation (MSW only)
virtual void CreateCaret(int w, int h);
virtual void CreateCaret(const wxBitmap *bitmap);
virtual void DestroyCaret();
virtual void SetCaretPos(int x, int y);
virtual void GetCaretPos(int *x, int *y) const;
- // Tell window how much it can be sized
- virtual void SetSizeHints(int minW = -1, int minH = -1, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1);
-
- // Set/get the window's identifier
- inline int GetId() const;
- inline void SetId(int id);
-
- // Make the window modal (all other windows unresponsive)
- virtual void MakeModal(bool modal);
-
- // Get the private handle (platform-dependent)
- inline void *GetHandle() const;
-
- // Set/get the window's relatives
- inline wxWindow *GetParent() const;
- inline void SetParent(wxWindow *p) ;
- inline wxWindow *GetGrandParent() const;
- inline wxList& GetChildren() const;
- // Set this window to be the child of 'parent'.
- // Returns FALSE it's not possible (some systems
- // won't allow it)
- virtual bool Reparent(wxWindow *parent);
-
- // Set/get the window's font
- virtual void SetFont(const wxFont& f);
- inline virtual wxFont& GetFont() const;
-
- // Set/get the window's validator
- void SetValidator(const wxValidator& validator);
- inline wxValidator *GetValidator() const;
-
- // Set/get the window's style
- inline void SetWindowStyleFlag(long flag);
- inline long GetWindowStyleFlag() const;
-
- // Set/get double-clickability
- // TODO: we probably wish to get rid of this, and
- // always allow double clicks.
- inline void SetDoubleClick(bool flag);
- inline bool GetDoubleClick() const;
- inline void AllowDoubleClick(bool value) { SetDoubleClick(value); }
-
- // Handle a control command
+ // event handlers (FIXME: shouldn't they be inside WXWIN_COMPATIBILITY?)
+ // Handle a control command
virtual void OnCommand(wxWindow& win, wxCommandEvent& event);
- // Set/get event handler
- inline void SetEventHandler(wxEvtHandler *handler);
- inline wxEvtHandler *GetEventHandler() const;
-
- // Push/pop event handler (i.e. allow a chain of event handlers
- // be searched)
- void PushEventHandler(wxEvtHandler *handler) ;
- wxEvtHandler *PopEventHandler(bool deleteHandler = FALSE) ;
-
- // Close the window by calling OnClose, posting a deletion
- virtual bool Close(bool force = FALSE);
-
- // Destroy the window (delayed, if a managed window)
- virtual bool Destroy() ;
-
- // Mode for telling default OnSize members to
- // call Layout(), if not using Sizers, just top-down constraints
- inline void SetAutoLayout(bool a);
- inline bool GetAutoLayout() const;
-
- // Set/get constraints
- inline wxLayoutConstraints *GetConstraints() const;
- void SetConstraints(wxLayoutConstraints *c);
-
- // Set/get window background colour
- inline virtual void SetBackgroundColour(const wxColour& col);
- inline virtual wxColour GetBackgroundColour() const;
-
- // Set/get window foreground colour
- inline virtual void SetForegroundColour(const wxColour& col);
- inline virtual wxColour GetForegroundColour() const;
-
- // For backward compatibility
- inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
- inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
- inline virtual wxFont& GetLabelFont() const { return GetFont(); };
- inline virtual wxFont& GetButtonFont() const { return GetFont(); };
-
- // Get the default button, if there is one
- inline virtual wxButton *GetDefaultItem() const;
- inline virtual void SetDefaultItem(wxButton *but);
-
- virtual void SetAcceleratorTable(const wxAcceleratorTable& accel);
- inline virtual wxAcceleratorTable& GetAcceleratorTable() const { return (wxAcceleratorTable&) m_acceleratorTable; }
-
- // Override to define new behaviour for default action (e.g. double clicking
- // on a listbox)
+ // Override to define new behaviour for default action (e.g. double
+ // clicking on a listbox)
virtual void OnDefaultAction(wxControl *initiatingItem);
- // Resource loading
-#if wxUSE_WX_RESOURCES
- virtual bool LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = NULL);
- virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource, const wxResourceTable *table = NULL);
-#endif
-
- // Native resource loading
+ // Native resource loading (implemented in src/msw/nativdlg.cpp)
+ // FIXME: should they really be all virtual?
virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id);
virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name);
- virtual wxWindow* GetWindowChild1(wxWindowID& id);
- virtual wxWindow* GetWindowChild(wxWindowID& id);
-
- virtual void GetTextExtent(const wxString& string, int *x, int *y,
- int *descent = NULL,
- int *externalLeading = NULL,
- const wxFont *theFont = NULL, bool use16 = FALSE) const;
-
- // Is the window retained?
- inline bool IsRetained() const;
-
- // Warp the pointer the given position
- virtual void WarpPointer(int x_pos, int y_pos) ;
+ virtual wxWindow* GetWindowChild1(wxWindowID id);
+ virtual wxWindow* GetWindowChild(wxWindowID id);
- // Clear the window
- virtual void Clear();
+ // implementation from now on
+ // --------------------------
- // Find a window by id or name
- virtual wxWindow *FindWindow(long id);
- virtual wxWindow *FindWindow(const wxString& name);
+ // simple accessors
+ // ----------------
- // Constraint operations
- bool Layout();
- void SetSizer(wxSizer *sizer); // Adds sizer child to this window
- inline wxSizer *GetSizer() const ;
- inline wxWindow *GetSizerParent() const ;
- inline void SetSizerParent(wxWindow *win);
+ WXHWND GetHWND() const { return GetHandle(); }
+ void SetHWND(WXHWND hWnd) { m_widget = hWnd; }
- // Do Update UI processing for controls
- void UpdateWindowUI();
+ bool GetUseCtl3D() const { return m_useCtl3D; }
+ bool GetTransparentBackground() const { return m_backgroundTransparent; }
+ void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; }
+ // event handlers
+ // --------------
void OnEraseBackground(wxEraseEvent& event);
void OnKeyDown(wxKeyEvent& event);
void OnKeyUp(wxKeyEvent& event);
void OnChar(wxKeyEvent& event);
void OnIdle(wxIdleEvent& event);
- // Does this window want to accept keyboard focus?
- virtual bool AcceptsFocus() const;
+ // a window may have a default button
+ // TODO move into wxPanel and/or wxFrame
+ wxButton *GetDefaultItem() const { return m_btnDefault; }
+ void SetDefaultItem(wxButton *btn) { m_btnDefault = btn; }
- virtual void PrepareDC( wxDC& WXUNUSED(dc) ) {};
public:
- ////////////////////////////////////////////////////////////////////////
- //// IMPLEMENTATION
-
// For implementation purposes - sometimes decorations make the client area
// smaller
virtual wxPoint GetClientAreaOrigin() const;
virtual wxWindow *FindItem(int id) const;
virtual wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const ;
virtual void PreDelete(WXHDC dc); // Allows system cleanup
- // TO DO: how many of these need to be virtual?
- virtual WXHWND GetHWND() const ;
- virtual void SetHWND(WXHWND hWnd);
// Make a Windows extended style from the given wxWindows window style
virtual WXDWORD MakeExtendedStyle(long style, bool eliminateBorders = TRUE);
// Determine whether 3D effects are wanted
virtual WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D);
- virtual void AddChild(wxWindow *child); // Adds reference to the child object
- virtual void RemoveChild(wxWindow *child); // Removes reference to child
- // (but doesn't delete the child object)
- virtual void DestroyChildren(); // Removes and destroys all children
-
- inline bool IsBeingDeleted();
-
// MSW only: TRUE if this control is part of the main control
virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
- // Constraint implementation
- void UnsetConstraints(wxLayoutConstraints *c);
- inline wxList *GetConstraintsInvolvedIn() const ;
- // 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 AddConstraintReference(wxWindow *otherWin);
- void RemoveConstraintReference(wxWindow *otherWin);
- void DeleteRelatedConstraints();
-
- virtual void ResetConstraints();
- virtual void SetConstraintSizes(bool recurse = TRUE);
- virtual bool LayoutPhase1(int *noChanges);
- virtual bool LayoutPhase2(int *noChanges);
- virtual bool DoPhase(int);
- // Transforms from sizer coordinate space to actual
- // parent coordinate space
- virtual void TransformSizerToActual(int *x, int *y) const ;
-
- // Set size with transformation to actual coordinates if nec.
- virtual void SizerSetSize(int x, int y, int w, int h);
- virtual void SizerMove(int x, int y);
-
- // Only set/get the size/position of the constraint (if any)
- virtual void SetSizeConstraint(int x, int y, int w, int h);
- virtual void MoveConstraint(int x, int y);
- virtual void GetSizeConstraint(int *w, int *h) const ;
- virtual void GetClientSizeConstraint(int *w, int *h) const ;
- virtual void GetPositionConstraint(int *x, int *y) const ;
-
- // Dialog units translations. Implemented in wincmn.cpp.
- wxPoint ConvertPixelsToDialog(const wxPoint& pt) ;
- wxPoint ConvertDialogToPixels(const wxPoint& pt) ;
- inline wxSize ConvertPixelsToDialog(const wxSize& sz)
- { wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); }
- inline wxSize ConvertDialogToPixels(const wxSize& sz)
- { wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); }
-
wxObject *GetChild(int number) const ;
void MSWCreate(int id, wxWindow *parent, const char *wclass, wxWindow *wx_win, const char *title,
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
- inline void SetShowing(bool show);
- inline bool IsUserEnabled() const;
- inline bool GetUseCtl3D() const ;
- inline bool GetTransparentBackground() const ;
+#if WXWIN_COMPATIBILITY
+ void SetShowing(bool show) { (void)Show(show); }
+ bool IsUserEnabled() const { return IsEnabled(); }
+#endif // WXWIN_COMPATIBILITY
// Responds to colour changes: passes event on to children.
void OnSysColourChanged(wxSysColourChangedEvent& event);
- // Transfers data to any child controls
- void OnInitDialog(wxInitDialogEvent& event);
-
- // Sends an OnInitDialog event, which in turns transfers data to
- // to the window via validators.
- virtual void InitDialog();
+ // remember the parameters of the last message
+ void PushLastMessage(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam)
+ {
+ m_lastMsg = msg;
+ m_lastWParam = wParam;
+ m_lastLParam = lParam;
+ }
- ////////////////////////////////////////////////////////////////////////
- //// PROTECTED DATA
protected:
- wxAcceleratorTable m_acceleratorTable;
- int m_windowId;
- long m_windowStyle; // Store the window's style
- wxEvtHandler * m_windowEventHandler; // Usually is 'this'
- wxLayoutConstraints * m_constraints; // Constraints for this window
- wxList * m_constraintsInvolvedIn; // List of constraints we're involved in
- wxSizer * m_windowSizer; // Window's top-level sizer (if any)
- wxWindow * m_sizerParent; // Window's parent sizer (if any)
- bool m_autoLayout; // Whether to call Layout() in OnSize
- wxWindow * m_windowParent; // Each window always knows its parent
- wxValidator * m_windowValidator;
- // Old window proc, for subclassed controls
+ // the old window proc (we subclass all windows)
WXFARPROC m_oldWndProc;
- bool m_useCtl3D; // Using CTL3D for this control
-
- bool m_inOnSize; // Protection against OnSize reentry
-#ifndef _WX_WIN32__
- // Pointer to global memory, for EDIT controls that need
- // special treatment to reduce USER area consumption.
- WXHGLOBAL m_globalHandle;
-#endif
- bool m_winEnabled;
- int m_minSizeX;
- int m_minSizeY;
- int m_maxSizeX;
- int m_maxSizeY;
+ // additional (MSW specific) flags
+ bool m_useCtl3D:1; // Using CTL3D for this control
+ bool m_inOnSize:1; // Protection against OnSize reentry
+ bool m_backgroundTransparent:1;
+ bool m_mouseInWindow:1;
+ bool m_doubleClickAllowed:1;
+ bool m_winCaptured:1;
// Caret data
+ bool m_caretEnabled:1;
+ bool m_caretShown:1;
int m_caretWidth;
int m_caretHeight;
- bool m_caretEnabled;
- bool m_caretShown;
- wxFont m_windowFont; // Window's font
- bool m_isShown;
- bool m_doubleClickAllowed ;
- wxCursor m_windowCursor; // Window's cursor
- bool m_winCaptured;
- wxString m_windowName; // Window name
-
-#if wxUSE_EXTENDED_STATICS
- wxList m_staticItems;
-#endif
-
- wxButton * m_defaultItem;
- wxColour m_backgroundColour ;
- wxColour m_foregroundColour ;
- bool m_backgroundTransparent;
+ // the size of one page for scrolling
int m_xThumbSize;
int m_yThumbSize;
- float m_lastXPos;
- float m_lastYPos;
- int m_lastEvent;
-
- bool m_mouseInWindow;
-
-#if wxUSE_DRAG_AND_DROP
- wxDropTarget *m_pDropTarget; // the current drop target or NULL
-#endif //USE_DRAG_AND_DROP
+ // the coordinates of the last mouse event and the typoe of it
+ long m_lastMouseX,
+ m_lastMouseY;
+ int m_lastMouseEvent;
-public:
- WXHWND m_hWnd; // MS Windows window handle
+ // the parameters of the last message used in Default()
WXUINT m_lastMsg;
WXWPARAM m_lastWParam;
WXLPARAM m_lastLParam;
- wxRegion m_updateRegion;
- /*
- wxRect m_updateRect; // Bounding box for screen damage area
-#ifdef __WIN32__
-WXHRGN m_updateRgn; // NT allows access to the rectangle list
-#endif
- */
-
- // WXHANDLE m_acceleratorTable;
WXHMENU m_hMenu; // Menu, if any
- wxList * m_children; // Window's children
- int m_returnCode;
- bool m_isBeingDeleted; // Fudge because can't access parent
- // when being deleted
-
- // this is the virtual function to be overriden in any derived class which
- // wants to change how SetSize() or Move() works - it is called by all
- // versions of these functions in the base class
- virtual void DoSetSize(int x, int y,
- int width, int height,
- int sizeFlags = wxSIZE_AUTO);
- // same as DoSetSize() for the client size
+ wxButton *m_btnDefault;
+
+ // implement the base class pure virtuals
+ virtual void DoGetPosition( int *x, int *y ) const;
+ virtual void DoGetSize( int *width, int *height ) const;
+ virtual void DoGetClientSize( int *width, int *height ) const;
+ virtual void DoSetSize(int x, int y,
+ int width, int height,
+ int sizeFlags = wxSIZE_AUTO);
virtual void DoSetClientSize(int width, int height);
+#if wxUSE_TOOLTIPS
+ virtual void DoSetToolTip( wxToolTip *tip );
+#endif // wxUSE_TOOLTIPS
+
private:
// common part of all ctors
void Init();
- // the associated tooltip (may be NULL if none)
-#if wxUSE_TOOLTIPS
- wxToolTip *m_tooltip;
-#endif // tooltips
-
DECLARE_EVENT_TABLE()
};
-////////////////////////////////////////////////////////////////////////
-//// INLINES
-
-inline void *wxWindow::GetHandle() const { return (void *)GetHWND(); }
-inline int wxWindow::GetId() const { return m_windowId; }
-inline void wxWindow::SetId(int id) { m_windowId = id; }
-inline wxWindow *wxWindow::GetParent() const { return m_windowParent; }
-inline void wxWindow::SetParent(wxWindow *p) { m_windowParent = p; }
-inline wxWindow *wxWindow::GetGrandParent() const { return (m_windowParent ? m_windowParent->m_windowParent : (wxWindow*) NULL); }
-inline wxList& wxWindow::GetChildren() const { return (wxList&) *m_children; }
-inline wxFont& wxWindow::GetFont() const { return (wxFont&) m_windowFont; }
-inline wxString wxWindow::GetName() const { return m_windowName; }
-inline void wxWindow::SetName(const wxString& name) { m_windowName = name; }
-inline long wxWindow::GetWindowStyleFlag() const { return m_windowStyle; }
-inline void wxWindow::SetWindowStyleFlag(long flag) { m_windowStyle = flag; }
-inline void wxWindow::SetDoubleClick(bool flag) { m_doubleClickAllowed = flag; }
-inline bool wxWindow::GetDoubleClick() const { return m_doubleClickAllowed; }
-inline void wxWindow::SetEventHandler(wxEvtHandler *handler) { m_windowEventHandler = handler; }
-inline wxEvtHandler *wxWindow::GetEventHandler() const { return m_windowEventHandler; }
-inline void wxWindow::SetAutoLayout(bool a) { m_autoLayout = a; }
-inline bool wxWindow::GetAutoLayout() const { return m_autoLayout; }
-inline wxLayoutConstraints *wxWindow::GetConstraints() const { return m_constraints; }
-inline void wxWindow::SetBackgroundColour(const wxColour& col) { m_backgroundColour = col; };
-inline wxColour wxWindow::GetBackgroundColour() const { return m_backgroundColour; };
-inline void wxWindow::SetForegroundColour(const wxColour& col) { m_foregroundColour = col; };
-inline wxColour wxWindow::GetForegroundColour() const { return m_foregroundColour; };
-
-inline wxButton *wxWindow::GetDefaultItem() const { return m_defaultItem; }
-inline void wxWindow::SetDefaultItem(wxButton *but) { m_defaultItem = but; }
-inline bool wxWindow::IsRetained() const { return ((m_windowStyle & wxRETAINED) == wxRETAINED); }
-
-inline void wxWindow::SetShowing(bool show) { m_isShown = show; }
-inline wxList *wxWindow::GetConstraintsInvolvedIn() const { return m_constraintsInvolvedIn; }
-inline wxSizer *wxWindow::GetSizer() const { return m_windowSizer; }
-inline wxWindow *wxWindow::GetSizerParent() const { return m_sizerParent; }
-inline void wxWindow::SetSizerParent(wxWindow *win) { m_sizerParent = win; }
-inline WXFARPROC wxWindow::MSWGetOldWndProc() const { return m_oldWndProc; }
-inline void wxWindow::MSWSetOldWndProc(WXFARPROC proc) { m_oldWndProc = proc; }
-inline wxValidator *wxWindow::GetValidator() const { return m_windowValidator; }
-inline bool wxWindow::IsUserEnabled() const { return m_winEnabled; }
-inline bool wxWindow::GetUseCtl3D() const { return m_useCtl3D; }
-inline bool wxWindow::GetTransparentBackground() const { return m_backgroundTransparent; }
-inline void wxWindow::SetReturnCode(int retCode) { m_returnCode = retCode; }
-inline int wxWindow::GetReturnCode() { return m_returnCode; }
-inline bool wxWindow::IsBeingDeleted() { return m_isBeingDeleted; }
-
-// Window specific (so far)
-WXDLLEXPORT wxWindow* wxGetActiveWindow();
-
-WXDLLEXPORT_DATA(extern wxWindowList) wxTopLevelWindows;
+// ---------------------------------------------------------------------------
+// global functions
+// ---------------------------------------------------------------------------
+// kbd code translation
WXDLLEXPORT int wxCharCodeMSWToWX(int keySym);
WXDLLEXPORT int wxCharCodeWXToMSW(int id, bool *IsVirtual);
-// Allocates control ids
-WXDLLEXPORT int NewControlId();
-
#endif
// _WX_WINDOW_H_
#include "wx/frame.h"
#include "wx/listbox.h"
#include "wx/button.h"
- #include "wx/settings.h"
#include "wx/msgdlg.h"
#include <stdio.h>
#include <windowsx.h>
#endif
-#if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__)
+#if ( defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__ )
#include <commctrl.h>
#endif
#endif
#endif
-// all these are defined in <windows.h>
#ifdef GetCharWidth
#undef GetCharWidth
#endif
wxWindow *wxFindWinFromHandle(WXHWND hWnd);
#if !USE_SHARED_LIBRARY
- IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler)
+ IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
#endif
-BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler)
+BEGIN_EVENT_TABLE(wxWindow, wxWindowBase)
EVT_CHAR(wxWindow::OnChar)
EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
// Find an item given the MS Windows id
wxWindow *wxWindow::FindItem(int id) const
{
-// if (!GetChildren())
+// if ( !GetChildren() )
// return NULL;
wxNode *current = GetChildren().First();
while (current)
wxWindow *childWin = (wxWindow *)current->Data();
wxWindow *wnd = childWin->FindItem(id) ;
- if (wnd)
+ if ( wnd )
return wnd ;
- if (childWin->IsKindOf(CLASSINFO(wxControl)))
+ if ( childWin->IsKindOf(CLASSINFO(wxControl)) )
{
wxControl *item = (wxControl *)childWin;
- if (item->GetId() == id)
+ if ( item->GetId() == id )
return item;
else
{
// In case it's a 'virtual' control (e.g. radiobox)
- if (item->GetSubcontrols().Member((wxObject *)id))
+ if ( item->GetSubcontrols().Member((wxObject *)id) )
return item;
}
}
// Find an item given the MS Windows handle
wxWindow *wxWindow::FindItemByHWND(WXHWND hWnd, bool controlOnly) const
{
-// if (!GetChildren())
+// if ( !GetChildren() )
// return NULL;
wxNode *current = GetChildren().First();
while (current)
// Do a recursive search.
wxWindow *parent = (wxWindow *)obj ;
wxWindow *wnd = parent->FindItemByHWND(hWnd) ;
- if (wnd)
+ if ( wnd )
return wnd ;
- if ((!controlOnly) || obj->IsKindOf(CLASSINFO(wxControl)))
+ if ( (!controlOnly) || obj->IsKindOf(CLASSINFO(wxControl)) )
{
wxWindow *item = (wxWindow *)current->Data();
- if ((HWND)(item->GetHWND()) == (HWND) hWnd)
+ if ( (HWND)(item->GetHWND()) == (HWND) hWnd )
return item;
else
{
{
}
-WXHWND wxWindow::GetHWND(void) const
-{
- return (WXHWND) m_hWnd;
-}
-
-void wxWindow::SetHWND(WXHWND hWnd)
-{
- m_hWnd = hWnd;
-}
-
// ----------------------------------------------------------------------------
// constructors and such
// ----------------------------------------------------------------------------
void wxWindow::Init()
{
- m_isWindow = TRUE;
+ // generic
+ InitBase();
- // Generic
-// m_windowCursor = * wxSTANDARD_CURSOR;
- m_windowId = 0;
- m_isShown = TRUE;
- m_windowStyle = 0;
- m_windowParent = NULL;
- m_windowEventHandler = this;
- m_children = new wxList;
+ // MSW specific
m_doubleClickAllowed = 0 ;
m_winCaptured = FALSE;
- m_constraints = NULL;
- m_constraintsInvolvedIn = NULL;
- m_windowSizer = NULL;
- m_sizerParent = NULL;
- m_autoLayout = FALSE;
- m_windowValidator = NULL;
-
- // MSW-specific
- m_hWnd = 0;
- m_winEnabled = TRUE;
- m_caretWidth = m_caretHeight = 0;
+
+ // caret stuff: initially there is no caret at all
+ m_caretWidth =
+ m_caretHeight = 0;
m_caretEnabled =
m_caretShown = FALSE;
+
m_inOnSize = FALSE;
- m_minSizeX =
- m_minSizeY =
- m_maxSizeX =
- m_maxSizeY = -1;
m_isBeingDeleted = FALSE;
m_oldWndProc = 0;
-#ifndef __WIN32__
- m_globalHandle = 0;
-#endif
m_useCtl3D = FALSE;
m_mouseInWindow = FALSE;
- m_windowParent = NULL;
- m_defaultItem = NULL;
-
- wxSystemSettings settings;
-
- m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_3DFACE) ;
- m_foregroundColour = *wxBLACK;
-
// wxWnd
m_lastMsg = 0;
m_lastWParam = 0;
m_yThumbSize = 0;
m_backgroundTransparent = FALSE;
- m_lastXPos = (float)-1.0;
- m_lastYPos = (float)-1.0;
- m_lastEvent = -1;
- m_returnCode = 0;
-
-#if wxUSE_DRAG_AND_DROP
- m_pDropTarget = NULL;
-#endif
-
-#if wxUSE_TOOLTIPS
- m_tooltip = NULL;
-#endif
-}
-
-wxWindow::wxWindow()
-{
- Init();
+ m_lastMouseX =
+ m_lastMouseY = -1;
+ m_lastMouseEvent = -1;
}
// Destructor
{
m_isBeingDeleted = TRUE;
- // first of all, delete the things on which nothing else depends
-
-#if wxUSE_TOOLTIPS
- wxDELETE(m_tooltip);
-#endif
-
- // JACS - if behaviour is odd, restore this
- // to the start of ~wxWindow. Vadim has changed
- // it to nearer the end. Unsure of side-effects
- // e.g. when deleting associated global data.
- // Restore old Window proc, if required
- // UnsubclassWin();
-
- // 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;
- }
-
- wxDELETE(m_windowSizer);
-
- // If this is a child of a sizer, remove self from parent
- if (m_sizerParent)
- m_sizerParent->RemoveChild((wxWindow *)this);
-#endif
-
- // wxWnd
MSWDetachWindowMenu();
- if (m_windowParent)
- m_windowParent->RemoveChild(this);
-
- DestroyChildren();
-
- if (m_hWnd)
+ if ( m_hWnd )
::DestroyWindow((HWND)m_hWnd);
wxRemoveHandleAssociation(this);
m_hWnd = 0;
-#ifndef __WIN32__
- if (m_globalHandle)
- {
- GlobalFree((HGLOBAL) m_globalHandle);
- m_globalHandle = 0;
- }
-#endif
-
- 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);
-
- // Just in case we've loaded a top-level window via
- // wxWindow::LoadNativeDialog but we weren't a dialog
- // class
- wxTopLevelWindows.DeleteObject(this);
-
- if ( m_windowValidator )
- delete m_windowValidator;
- // Restore old Window proc, if required
- // and remove hWnd <-> wxWindow association
+ // Restore old Window proc, if required and remove hWnd <-> wxWindow
+ // association
UnsubclassWin();
}
-// Destroy the window (delayed, if a managed window)
-bool wxWindow::Destroy()
-{
- delete this;
- return TRUE;
-}
-
extern char wxCanvasClassName[];
// real construction (Init() must have been called before!)
parent->AddChild(this);
- SetName(name);
-
- if ( id == -1 )
- m_windowId = (int)NewControlId();
- else
- m_windowId = id;
-
- int x = pos.x;
- int y = pos.y;
- int width = size.x;
- int height = size.y;
-
- // To be consistent with wxGTK
- if (width == -1)
- width = 20;
- if (height == -1)
- height = 20;
-
- wxSystemSettings settings;
-
- m_windowStyle = style;
-
DWORD msflags = 0;
- if (style & wxBORDER)
+ if ( style & wxBORDER )
msflags |= WS_BORDER;
- if (style & wxTHICK_FRAME)
+ if ( style & wxTHICK_FRAME )
msflags |= WS_THICKFRAME;
msflags |= WS_CHILD | WS_VISIBLE;
- if (style & wxCLIP_CHILDREN)
+ if ( style & wxCLIP_CHILDREN )
msflags |= WS_CLIPCHILDREN;
bool want3D;
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
- if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
+ if ( want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER ) ||
(m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
+ {
msflags |= WS_BORDER;
+ }
MSWCreate(m_windowId, parent, wxCanvasClassName, this, NULL,
- x, y, width, height, msflags, NULL, exStyle);
+ pos.x, pos.y,
+ WidthDefault(size.x), HeightDefault(size.y),
+ msflags, NULL, exStyle);
return TRUE;
}
void wxWindow::SetFocus()
{
HWND hWnd = (HWND) GetHWND();
- if (hWnd)
+ if ( hWnd )
::SetFocus(hWnd);
}
-void wxWindow::Enable(bool enable)
+bool wxWindow::Enable(bool enable)
{
- m_winEnabled = enable;
+ if ( !wxWindowBase::Enable(enable) )
+ return FALSE;
+
HWND hWnd = (HWND) GetHWND();
- if (hWnd)
+ if ( hWnd )
::EnableWindow(hWnd, (BOOL)enable);
+
+ return TRUE;
}
void wxWindow::CaptureMouse()
{
HWND hWnd = (HWND) GetHWND();
- if (hWnd && !m_winCaptured)
+ if ( hWnd && !m_winCaptured )
{
SetCapture(hWnd);
m_winCaptured = TRUE;
void wxWindow::ReleaseMouse()
{
- if (m_winCaptured)
+ if ( m_winCaptured )
{
ReleaseCapture();
m_winCaptured = FALSE;
}
}
-void wxWindow::SetAcceleratorTable(const wxAcceleratorTable& accel)
-{
- m_acceleratorTable = accel;
-}
-
-
-// Push/pop event handler (i.e. allow a chain of event handlers
-// be searched)
-void wxWindow::PushEventHandler(wxEvtHandler *handler)
-{
- 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 ) {
- m_pDropTarget->Revoke(m_hWnd);
- delete m_pDropTarget;
+ if ( m_dropTarget != 0 ) {
+ m_dropTarget->Revoke(m_hWnd);
+ delete m_dropTarget;
}
- m_pDropTarget = pDropTarget;
- if ( m_pDropTarget != 0 )
- m_pDropTarget->Register(m_hWnd);
+ m_dropTarget = pDropTarget;
+ if ( m_dropTarget != 0 )
+ m_dropTarget->Register(m_hWnd);
}
#endif // wxUSE_DRAG_AND_DROP
void wxWindow::DragAcceptFiles(bool accept)
{
HWND hWnd = (HWND) GetHWND();
- if (hWnd)
+ if ( hWnd )
::DragAcceptFiles(hWnd, (BOOL)accept);
}
#if wxUSE_TOOLTIPS
-void wxWindow::SetToolTip(const wxString &tip)
+void wxWindow::DoSetToolTip(wxToolTip *tooltip)
{
- SetToolTip(new wxToolTip(tip));
-}
+ wxWindowBase::SetToolTip(tooltip);
-void wxWindow::SetToolTip(wxToolTip *tooltip)
-{
if ( m_tooltip )
- delete m_tooltip;
-
- m_tooltip = tooltip;
- m_tooltip->SetWindow(this);
+ m_tooltip->SetWindow(this);
}
#endif // wxUSE_TOOLTIPS
// Get total size
-void wxWindow::GetSize(int *x, int *y) const
+void wxWindow::DoGetSize(int *x, int *y) const
{
HWND hWnd = (HWND) GetHWND();
RECT rect;
GetWindowRect(hWnd, &rect);
- *x = rect.right - rect.left;
- *y = rect.bottom - rect.top;
+
+ if ( x )
+ *x = rect.right - rect.left;
+ if ( y )
+ *y = rect.bottom - rect.top;
}
-void wxWindow::GetPosition(int *x, int *y) const
+void wxWindow::DoGetPosition(int *x, int *y) const
{
HWND hWnd = (HWND) GetHWND();
HWND hParentWnd = 0;
- if (GetParent())
+ if ( GetParent() )
hParentWnd = (HWND) GetParent()->GetHWND();
RECT rect;
GetWindowRect(hWnd, &rect);
- // Since we now have the absolute screen coords,
- // if there's a parent we must subtract its top left corner
+ // Since we now have the absolute screen coords, if there's a parent we
+ // must subtract its top left corner
POINT point;
point.x = rect.left;
point.y = rect.top;
- if (hParentWnd)
+ if ( hParentWnd )
{
::ScreenToClient(hParentWnd, &point);
}
- // 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).
- if (GetParent())
+ // 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).
+ if ( GetParent() )
{
wxPoint pt(GetParent()->GetClientAreaOrigin());
point.x -= pt.x;
point.y -= pt.y;
}
- *x = point.x;
- *y = point.y;
+
+ if ( x )
+ *x = point.x;
+ if ( y )
+ *y = point.y;
}
void wxWindow::ScreenToClient(int *x, int *y) const
{
- HWND hWnd = (HWND) GetHWND();
POINT pt;
- pt.x = *x;
- pt.y = *y;
+ if ( x )
+ pt.x = *x;
+ if ( y )
+ pt.y = *y;
+ HWND hWnd = (HWND) GetHWND();
::ScreenToClient(hWnd, &pt);
- *x = pt.x;
- *y = pt.y;
+ if ( x )
+ *x = pt.x;
+ if ( y )
+ *y = pt.y;
}
void wxWindow::ClientToScreen(int *x, int *y) const
{
- HWND hWnd = (HWND) GetHWND();
POINT pt;
- pt.x = *x;
- pt.y = *y;
+ if ( x )
+ pt.x = *x;
+ if ( y )
+ pt.y = *y;
+ HWND hWnd = (HWND) GetHWND();
::ClientToScreen(hWnd, &pt);
- *x = pt.x;
- *y = pt.y;
+ if ( x )
+ *x = pt.x;
+ if ( y )
+ *y = pt.y;
}
-void wxWindow::SetCursor(const wxCursor& cursor)
+bool wxWindow::SetCursor(const wxCursor& cursor)
{
- m_windowCursor = cursor;
- if (m_windowCursor.Ok())
+ if ( !wxWindowBase::SetCursor(cursor) )
{
- HWND hWnd = (HWND) GetHWND();
+ // no change
+ return FALSE;
+ }
- // Change the cursor NOW if we're within the correct window
- POINT point;
- ::GetCursorPos(&point);
+ wxASSERT_MSG( m_cursor.Ok(),
+ _T("cursor must be valid after call to the base version"));
- RECT rect;
- ::GetWindowRect(hWnd, &rect);
+ HWND hWnd = (HWND)GetHWND();
- if (::PtInRect(&rect, point) && !wxIsBusy())
- ::SetCursor((HCURSOR) m_windowCursor.GetHCURSOR());
- }
+ // Change the cursor NOW if we're within the correct window
+ POINT point;
+ ::GetCursorPos(&point);
- // This will cause big reentrancy problems if wxFlushEvents is implemented.
- // wxFlushEvents();
- // return old_cursor;
-}
+ RECT rect;
+ ::GetWindowRect(hWnd, &rect);
+
+ if ( ::PtInRect(&rect, point) && !wxIsBusy() )
+ ::SetCursor((HCURSOR)m_cursor.GetHCURSOR());
+ return TRUE;
+}
// Get size *available for subwindows* i.e. excluding menu bar etc.
-void wxWindow::GetClientSize(int *x, int *y) const
+void wxWindow::DoGetClientSize(int *x, int *y) const
{
HWND hWnd = (HWND) GetHWND();
RECT rect;
::GetClientRect(hWnd, &rect);
- *x = rect.right;
- *y = rect.bottom;
+ if ( x )
+ *x = rect.right;
+ if ( y )
+ *y = rect.bottom;
}
void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags)
int currentW,currentH;
GetSize(¤tW, ¤tH);
- if (x == currentX && y == currentY && width == currentW && height == currentH)
+ if ( x == currentX && y == currentY && width == currentW && height == currentH )
return;
int actualWidth = width;
int actualHeight = height;
int actualX = x;
int actualY = y;
- if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ if ( x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
actualX = currentX;
- if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ if ( y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
actualY = currentY;
AdjustForParentClientOrigin(actualX, actualY, sizeFlags);
- if (width == -1)
+ if ( width == -1 )
actualWidth = currentW ;
- if (height == -1)
+ if ( height == -1 )
actualHeight = currentH ;
HWND hWnd = (HWND) GetHWND();
- if (hWnd)
+ if ( hWnd )
MoveWindow(hWnd, actualX, actualY, actualWidth, actualHeight, (BOOL)TRUE);
}
wxWindow *parent = GetParent();
HWND hWnd = (HWND) GetHWND();
HWND hParentWnd = (HWND) 0;
- if (parent)
+ if ( parent )
hParentWnd = (HWND) parent->GetHWND();
RECT rect;
POINT point;
point.x = rect2.left;
point.y = rect2.top;
- if (parent)
+ if ( parent )
{
::ScreenToClient(hParentWnd, &point);
}
// a toolbar that it manages itself).
void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags)
{
- if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent())
+ if ( ((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent() )
{
wxPoint pt(GetParent()->GetClientAreaOrigin());
x += pt.x; y += pt.y;
bool wxWindow::Show(bool show)
{
- m_isShown = show;
+ if ( !wxWindowBase::Show(show) )
+ return FALSE;
+
HWND hWnd = (HWND) GetHWND();
- int cshow;
- if (show)
- cshow = SW_SHOW;
- else
- cshow = SW_HIDE;
- ShowWindow(hWnd, cshow);
- if (show)
+ int cshow = show ? SW_SHOW : SW_HIDE;
+ ::ShowWindow(hWnd, cshow);
+
+ if ( show )
{
BringWindowToTop(hWnd);
- // Next line causes a crash on NT, apparently.
- // UpdateWindow(hWnd); // Should this be here or will it cause inefficiency?
}
- return TRUE;
-}
-bool wxWindow::IsShown(void) const
-{
- // Can't rely on IsWindowVisible, since it will return FALSE
- // if the parent is not visible.
- return m_isShown;
-// int ret = ::IsWindowVisible((HWND) GetHWND()) ;
-// return (ret != 0);
+ return TRUE;
}
int wxWindow::GetCharHeight(void) const
}
void wxWindow::GetTextExtent(const wxString& string, int *x, int *y,
- int *descent, int *externalLeading, const wxFont *theFont, bool) const
+ int *descent, int *externalLeading, const wxFont *theFont) const
{
wxFont *fontToUse = (wxFont *)theFont;
- if (!fontToUse)
- fontToUse = (wxFont *) & m_windowFont;
+ if ( !fontToUse )
+ fontToUse = (wxFont *) & m_font;
HWND hWnd = (HWND) GetHWND();
HDC dc = ::GetDC(hWnd);
HFONT fnt = 0;
HFONT was = 0;
- if (fontToUse && fontToUse->Ok())
+ if ( fontToUse && fontToUse->Ok() )
{
fnt = (HFONT)fontToUse->GetResourceHandle();
if ( fnt )
GetTextExtentPoint(dc, (const char *)string, (int)string.Length(), &sizeRect);
GetTextMetrics(dc, &tm);
- if (fontToUse && fnt && was)
+ if ( fontToUse && fnt && was )
SelectObject(dc,was) ;
ReleaseDC(hWnd, dc);
*x = sizeRect.cx;
*y = sizeRect.cy;
- if (descent) *descent = tm.tmDescent;
- if (externalLeading) *externalLeading = tm.tmExternalLeading;
+ if ( descent ) *descent = tm.tmDescent;
+ if ( externalLeading ) *externalLeading = tm.tmExternalLeading;
- // if (fontToUse)
+ // if ( fontToUse )
// fontToUse->ReleaseResource();
}
void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
{
HWND hWnd = (HWND) GetHWND();
- if (hWnd)
+ if ( hWnd )
{
- if (rect)
+ if ( rect )
{
RECT mswRect;
mswRect.left = rect->x;
{
wxWindow *wnd = wxFindWinFromHandle((WXHWND) hWnd);
- if (!wnd && wxWndHook)
+ if ( !wnd && wxWndHook )
{
wxAssociateWinWithHandle(hWnd, wxWndHook);
wnd = wxWndHook;
wxWndHook = NULL;
- wnd->m_hWnd = (WXHWND) hWnd;
+ wnd->SetHWND((WXHWND)hWnd);
}
// Stop right here if we don't have a valid handle in our wxWindow object.
- if (wnd && !wnd->m_hWnd) {
- wnd->m_hWnd = (WXHWND) hWnd;
+ if ( wnd && !wnd->GetHWND() ) {
+ wnd->SetHWND((WXHWND) hWnd);
long res = wnd->MSWDefWindowProc(message, wParam, lParam );
- wnd->m_hWnd = 0;
+ wnd->SetHWND(0);
return res;
}
- if (wnd) {
- wnd->m_lastMsg = message;
- wnd->m_lastWParam = wParam;
- wnd->m_lastLParam = lParam;
+ if ( wnd ) {
+ wnd->PushLastMessage(message, wParam, lParam);
}
- if (wnd)
+ if ( wnd )
return wnd->MSWWindowProc(message, wParam, lParam);
else
return DefWindowProc( hWnd, message, wParam, lParam );
HWND hwnd = (HWND)wParam;
// return OnSetFocus(hwnd);
- if (MSWOnSetFocus((WXHWND) hwnd))
+ if ( MSWOnSetFocus((WXHWND) hwnd) )
return 0;
else return MSWDefWindowProc(message, wParam, lParam );
break;
{
HWND hwnd = (HWND)lParam;
// return OnKillFocus(hwnd);
- if (MSWOnKillFocus((WXHWND) hwnd))
+ if ( MSWOnKillFocus((WXHWND) hwnd) )
return 0;
else
return MSWDefWindowProc(message, wParam, lParam );
}
case WM_PAINT:
{
- if (MSWOnPaint())
+ if ( MSWOnPaint() )
return 0;
else return MSWDefWindowProc(message, wParam, lParam );
break;
}
case WM_DESTROY:
{
- if (MSWOnDestroy())
+ if ( MSWOnDestroy() )
return 0;
else return MSWDefWindowProc(message, wParam, lParam );
break;
HWND hwnd = (HWND)LOWORD(lParam) ;
WORD cmd = HIWORD(lParam);
#endif
- if (!MSWOnCommand(id, cmd, (WXHWND) hwnd))
+ if ( !MSWOnCommand(id, cmd, (WXHWND) hwnd) )
return MSWDefWindowProc(message, wParam, lParam );
break;
}
case WM_SYSCOLORCHANGE:
{
// Return value of 0 means, we processed it.
- if (MSWOnColorChange((WXHWND) hWnd, message, wParam, lParam) == 0)
+ if ( MSWOnColorChange((WXHWND) hWnd, message, wParam, lParam) == 0 )
return 0;
else
return MSWDefWindowProc(message, wParam, lParam );
case WM_ERASEBKGND:
{
// Prevents flicker when dragging
- if (IsIconic(hWnd)) return 1;
+ if ( IsIconic(hWnd) ) return 1;
- if (!MSWOnEraseBkgnd((WXHDC) (HDC)wParam))
+ if ( !MSWOnEraseBkgnd((WXHDC) (HDC)wParam) )
return 0; // Default(); MSWDefWindowProc(message, wParam, lParam );
else return 1;
break;
}
case WM_CLOSE:
{
- if (MSWOnClose())
+ if ( MSWOnClose() )
return 0L;
else
return 1L;
case WM_GETMINMAXINFO:
{
MINMAXINFO *info = (MINMAXINFO *)lParam;
- if (m_minSizeX != -1)
- info->ptMinTrackSize.x = (int)m_minSizeX;
- if (m_minSizeY != -1)
- info->ptMinTrackSize.y = (int)m_minSizeY;
- if (m_maxSizeX != -1)
- info->ptMaxTrackSize.x = (int)m_maxSizeX;
- if (m_maxSizeY != -1)
- info->ptMaxTrackSize.y = (int)m_maxSizeY;
+ if ( m_minWidth != -1 )
+ info->ptMinTrackSize.x = m_minWidth;
+ if ( m_minHeight != -1 )
+ info->ptMinTrackSize.y = m_minHeight;
+ if ( m_maxWidth != -1 )
+ info->ptMaxTrackSize.x = m_maxWidth;
+ if ( m_maxHeight != -1 )
+ info->ptMaxTrackSize.y = m_maxHeight;
return MSWDefWindowProc(message, wParam, lParam );
break;
}
case WM_SETCURSOR:
{
// don't set cursor for other windows, only for this one: this
- // prevents children of this window from gettign the same cursor
+ // prevents children of this window from getting the same cursor
// as the parent has (don't forget that this message is propagated
// by default up the window parent-child hierarchy)
if ( (HWND)wParam == hWnd )
{
wxCursor *cursor = NULL;
- if ( m_windowCursor.Ok() )
+ if ( m_cursor.Ok() )
{
- cursor = &m_windowCursor;
+ cursor = &m_cursor;
}
else
{
wxWindow *wxFindWinFromHandle(WXHWND hWnd)
{
wxNode *node = wxWinHandleList->Find((long)hWnd);
- if (!node)
+ if ( !node )
return NULL;
return (wxWindow *)node->Data();
}
// Find parent's size, if it exists, to set up a possible default
// panel size the size of the parent window
RECT parent_rect;
- if (parent)
+ if ( parent )
{
// Was GetWindowRect: JACS 5/5/95
::GetClientRect((HWND) parent->GetHWND(), &parent_rect);
height1 = parent_rect.bottom - parent_rect.top;
}
- if (x > -1) x1 = x;
- if (y > -1) y1 = y;
- if (width > -1) width1 = width;
- if (height > -1) height1 = height;
+ if ( x > -1 ) x1 = x;
+ if ( y > -1 ) y1 = y;
+ if ( width > -1 ) width1 = width;
+ if ( height > -1 ) height1 = height;
HWND hParent = NULL;
- if (parent)
+ if ( parent )
hParent = (HWND) parent->GetHWND();
wxWndHook = this;
- if (is_dialog)
+ if ( is_dialog )
{
// MakeProcInstance doesn't seem to be needed in C7. Is it needed for
// other compilers???
#endif
#endif
- if (m_hWnd == 0)
+ if ( m_hWnd == 0 )
MessageBox(NULL, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
"wxWindows Error", MB_ICONEXCLAMATION | MB_OK);
else MoveWindow((HWND) m_hWnd, x1, y1, width1, height1, FALSE);
else
{
int controlId = 0;
- if (style & WS_CHILD)
+ if ( style & WS_CHILD )
controlId = id;
- if (!title)
+ if ( !title )
title = "";
m_hWnd = (WXHWND)CreateWindowEx(extendedStyle, wclass,
event.SetEventObject(wxTheApp);
event.SetCanVeto(TRUE);
event.SetLoggingOff( (logOff == ENDSESSION_LOGOFF) );
- if ((this == wxTheApp->GetTopWindow()) && // Only send once
+ if ( (this == wxTheApp->GetTopWindow() ) && // Only send once
wxTheApp->ProcessEvent(event) && event.GetVeto())
{
return FALSE; // Veto!
{
// delete our drop target if we've got one
#if wxUSE_DRAG_AND_DROP
- if ( m_pDropTarget != NULL ) {
- m_pDropTarget->Revoke(m_hWnd);
+ if ( m_dropTarget != NULL ) {
+ m_dropTarget->Revoke(m_hWnd);
- delete m_pDropTarget;
- m_pDropTarget = NULL;
+ delete m_dropTarget;
+ m_dropTarget = NULL;
}
#endif
bool wxWindow::MSWOnSetFocus(WXHWND WXUNUSED(hwnd))
{
// Deal with caret
- if (m_caretEnabled && (m_caretWidth > 0) && (m_caretHeight > 0))
+ if ( m_caretEnabled && (m_caretWidth > 0) && (m_caretHeight > 0) )
{
::CreateCaret((HWND) GetHWND(), NULL, m_caretWidth, m_caretHeight);
- if (m_caretShown)
+ if ( m_caretShown )
::ShowCaret((HWND) GetHWND());
}
wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId);
event.SetEventObject(this);
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
Default();
return TRUE;
}
bool wxWindow::MSWOnKillFocus(WXHWND WXUNUSED(hwnd))
{
// Deal with caret
- if (m_caretEnabled)
+ if ( m_caretEnabled )
{
::DestroyCaret();
}
wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId);
event.SetEventObject(this);
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
Default();
return TRUE;
}
event.m_eventObject = this;
event.m_pos.x = dropPoint.x; event.m_pos.x = dropPoint.y;
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
Default();
delete[] files;
wxWindow *item = FindItem(id);
#if wxUSE_DYNAMIC_CLASSES
- if (item && item->IsKindOf(CLASSINFO(wxControl)))
+ if ( item && item->IsKindOf(CLASSINFO(wxControl)) )
{
return ((wxControl *)item)->MSWOnDraw(itemStruct);
}
wxWindow *item = FindItem(id);
#if wxUSE_DYNAMIC_CLASSES
- if (item && item->IsKindOf(CLASSINFO(wxControl)))
+ if ( item && item->IsKindOf(CLASSINFO(wxControl)) )
{
return ((wxControl *)item)->MSWOnMeasure(itemStruct);
}
WXHBRUSH wxWindow::MSWOnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
- if (nCtlColor == CTLCOLOR_DLG)
+ if ( nCtlColor == CTLCOLOR_DLG )
{
return OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
}
event.SetEventObject(this);
// Check if app handles this.
- if (GetEventHandler()->ProcessEvent(event))
+ if ( GetEventHandler()->ProcessEvent(event) )
return 0;
// We didn't process it
{
wxQueryNewPaletteEvent event(GetId());
event.SetEventObject(this);
- if (!GetEventHandler()->ProcessEvent(event) || !event.GetPaletteRealized())
+ if ( !GetEventHandler()->ProcessEvent(event) || !event.GetPaletteRealized() )
{
return (long) FALSE;
}
bool bForward = TRUE,
bWindowChange = FALSE;
- switch ( msg->wParam )
+ switch ( msg->wParam )
{
case VK_TAB:
if ( lDlgCode & DLGC_WANTTAB ) {
bool wxWindow::MSWTranslateMessage(WXMSG* pMsg)
{
- if (m_acceleratorTable.Ok() &&
+ if ( m_acceleratorTable.Ok( ) &&
::TranslateAccelerator((HWND) GetHWND(), (HACCEL) m_acceleratorTable.GetHACCEL(), (MSG *)pMsg))
return TRUE;
else
void wxWindow::MSWDetachWindowMenu()
{
- if (m_hMenu)
+ if ( m_hMenu )
{
int N = GetMenuItemCount((HMENU) m_hMenu);
int i;
{
char buf[100];
int chars = GetMenuString((HMENU) m_hMenu, i, buf, 100, MF_BYPOSITION);
- if ((chars > 0) && (strcmp(buf, "&Window") == 0))
+ if ( (chars > 0) && (strcmp(buf, "&Window") == 0) )
{
RemoveMenu((HMENU) m_hMenu, i, MF_BYPOSITION);
break;
wxPaintEvent event(m_windowId);
event.SetEventObject(this);
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
Default();
return TRUE;
}
void wxWindow::MSWOnSize(int w, int h, WXUINT WXUNUSED(flag))
{
- if (m_inOnSize)
+ if ( m_inOnSize )
return;
- if (!m_hWnd)
+ if ( !m_hWnd )
return;
m_inOnSize = TRUE;
wxSizeEvent event(wxSize(w, h), m_windowId);
event.SetEventObject(this);
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
Default();
m_inOnSize = FALSE;
// Deal with child commands from buttons etc.
bool wxWindow::MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control)
{
- if (wxCurrentPopupMenu)
+ if ( wxCurrentPopupMenu )
{
wxMenu *popupMenu = wxCurrentPopupMenu;
wxCurrentPopupMenu = NULL;
}
wxWindow *item = FindItem(id);
- if (item)
+ if ( item )
{
bool value = item->MSWCommand(cmd, id);
return value;
else
{
wxWindow *win = wxFindWinFromHandle(control);
- if (win)
+ if ( win )
return win->MSWCommand(cmd, id);
}
return FALSE;
{
wxMaximizeEvent event(m_windowId);
event.SetEventObject(this);
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
return Default();
else
return 0;
{
wxIconizeEvent event(m_windowId);
event.SetEventObject(this);
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
return Default();
else
return 0;
event.SetTimestamp(wxApp::sm_lastMessageTime);
event.m_eventObject = this;
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_LEFT_DOWN;
+ m_lastMouseX = event.m_x; m_lastMouseY = event.m_y; m_lastMouseEvent = wxEVT_LEFT_DOWN;
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
Default();
}
event.SetTimestamp(wxApp::sm_lastMessageTime);
event.m_eventObject = this;
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_LEFT_UP;
+ m_lastMouseX = event.m_x; m_lastMouseY = event.m_y; m_lastMouseEvent = wxEVT_LEFT_UP;
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
Default();
}
event.SetTimestamp(wxApp::sm_lastMessageTime);
event.m_eventObject = this;
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_LEFT_DCLICK;
+ m_lastMouseX = event.m_x; m_lastMouseY = event.m_y; m_lastMouseEvent = wxEVT_LEFT_DCLICK;
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
Default();
}
event.SetTimestamp(wxApp::sm_lastMessageTime);
event.m_eventObject = this;
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_MIDDLE_DOWN;
+ m_lastMouseX = event.m_x; m_lastMouseY = event.m_y; m_lastMouseEvent = wxEVT_MIDDLE_DOWN;
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
Default();
}
event.SetTimestamp(wxApp::sm_lastMessageTime);
event.m_eventObject = this;
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_MIDDLE_UP;
+ m_lastMouseX = event.m_x; m_lastMouseY = event.m_y; m_lastMouseEvent = wxEVT_MIDDLE_UP;
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
Default();
}
event.SetTimestamp(wxApp::sm_lastMessageTime);
event.m_eventObject = this;
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_MIDDLE_DCLICK;
+ m_lastMouseX = event.m_x; m_lastMouseY = event.m_y; m_lastMouseEvent = wxEVT_MIDDLE_DCLICK;
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
Default();
}
event.SetTimestamp(wxApp::sm_lastMessageTime);
event.m_eventObject = this;
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_RIGHT_DOWN;
+ m_lastMouseX = event.m_x; m_lastMouseY = event.m_y; m_lastMouseEvent = wxEVT_RIGHT_DOWN;
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
Default();
}
event.m_eventObject = this;
event.SetTimestamp(wxApp::sm_lastMessageTime);
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_RIGHT_UP;
+ m_lastMouseX = event.m_x; m_lastMouseY = event.m_y; m_lastMouseEvent = wxEVT_RIGHT_UP;
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
Default();
}
event.SetTimestamp(wxApp::sm_lastMessageTime);
event.m_eventObject = this;
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_RIGHT_DCLICK;
+ m_lastMouseX = event.m_x; m_lastMouseY = event.m_y; m_lastMouseEvent = wxEVT_RIGHT_DCLICK;
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
Default();
}
{
// 'normal' move event...
- if (!m_mouseInWindow)
+ if ( !m_mouseInWindow )
{
// Generate an ENTER event
m_mouseInWindow = TRUE;
// Window gets a click down message followed by a mouse move
// message even if position isn't changed! We want to discard
// the trailing move event if x and y are the same.
- if ((m_lastEvent == wxEVT_RIGHT_DOWN || m_lastEvent == wxEVT_LEFT_DOWN ||
- m_lastEvent == wxEVT_MIDDLE_DOWN) &&
- (m_lastXPos == event.m_x && m_lastYPos == event.m_y))
+ if ((m_lastMouseEvent == wxEVT_RIGHT_DOWN || m_lastMouseEvent == wxEVT_LEFT_DOWN ||
+ m_lastMouseEvent == wxEVT_MIDDLE_DOWN) &&
+ (m_lastMouseX == event.m_x && m_lastMouseY == event.m_y))
{
- m_lastXPos = event.m_x; m_lastYPos = event.m_y;
- m_lastEvent = wxEVT_MOTION;
+ m_lastMouseX = event.m_x; m_lastMouseY = event.m_y;
+ m_lastMouseEvent = wxEVT_MOTION;
return;
}
- m_lastEvent = wxEVT_MOTION;
- m_lastXPos = event.m_x; m_lastYPos = event.m_y;
+ m_lastMouseEvent = wxEVT_MOTION;
+ m_lastMouseX = event.m_x; m_lastMouseY = event.m_y;
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
Default();
}
event.SetTimestamp(wxApp::sm_lastMessageTime);
event.m_eventObject = this;
- m_lastEvent = wxEVT_ENTER_WINDOW;
- m_lastXPos = event.m_x; m_lastYPos = event.m_y;
+ m_lastMouseEvent = wxEVT_ENTER_WINDOW;
+ m_lastMouseX = event.m_x; m_lastMouseY = event.m_y;
// No message - ensure we don't try to call the default behaviour accidentally.
m_lastMsg = 0;
GetEventHandler()->ProcessEvent(event);
event.SetTimestamp(wxApp::sm_lastMessageTime);
event.m_eventObject = this;
- m_lastEvent = wxEVT_LEAVE_WINDOW;
- m_lastXPos = event.m_x; m_lastYPos = event.m_y;
+ m_lastMouseEvent = wxEVT_LEAVE_WINDOW;
+ m_lastMouseX = event.m_x; m_lastMouseY = event.m_y;
// No message - ensure we don't try to call the default behaviour accidentally.
m_lastMsg = 0;
GetEventHandler()->ProcessEvent(event);
{
int id;
bool tempControlDown = FALSE;
- if (isASCII)
+ if ( isASCII )
{
// If 1 -> 26, translate to CTRL plus a letter.
id = wParam;
- if ((id > 0) && (id < 27))
+ if ( (id > 0) && (id < 27) )
{
switch (id)
{
}
}
}
- else if ((id = wxCharCodeMSWToWX(wParam)) == 0) {
+ else if ( (id = wxCharCodeMSWToWX(wParam)) == 0 ) {
// it's ASCII and will be processed here only when called from
// WM_CHAR (i.e. when isASCII = TRUE)
id = -1;
}
- if (id != -1)
+ if ( id != -1 )
{
wxKeyEvent event(wxEVT_CHAR);
event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE);
event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE);
- if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN)
+ if ( (HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN )
event.m_altDown = TRUE;
event.m_eventObject = this;
event.m_x = pt.x; event.m_y = pt.y;
- if (GetEventHandler()->ProcessEvent(event))
+ if ( GetEventHandler()->ProcessEvent(event) )
return TRUE;
else
return FALSE;
{
int id;
- if ((id = wxCharCodeMSWToWX(wParam)) == 0) {
+ if ( (id = wxCharCodeMSWToWX(wParam)) == 0 ) {
id = wParam;
}
- if (id != -1)
+ if ( id != -1 )
{
wxKeyEvent event(wxEVT_KEY_DOWN);
event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE);
event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE);
- if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN)
+ if ( (HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN )
event.m_altDown = TRUE;
event.m_eventObject = this;
event.m_x = pt.x; event.m_y = pt.y;
- if (GetEventHandler()->ProcessEvent(event))
+ if ( GetEventHandler()->ProcessEvent(event) )
{
return TRUE;
}
{
int id;
- if ((id = wxCharCodeMSWToWX(wParam)) == 0) {
+ if ( (id = wxCharCodeMSWToWX(wParam)) == 0 ) {
id = wParam;
}
- if (id != -1)
+ if ( id != -1 )
{
wxKeyEvent event(wxEVT_KEY_UP);
event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE);
event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE);
- if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN)
+ if ( (HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN )
event.m_altDown = TRUE;
event.m_eventObject = this;
event.m_x = pt.x; event.m_y = pt.y;
- if (GetEventHandler()->ProcessEvent(event))
+ if ( GetEventHandler()->ProcessEvent(event) )
return TRUE;
else
return FALSE;
{
int buttons = 0;
int change = 0;
- if (flags & JOY_BUTTON1CHG)
+ if ( flags & JOY_BUTTON1CHG )
change = wxJOY_BUTTON1;
- if (flags & JOY_BUTTON2CHG)
+ if ( flags & JOY_BUTTON2CHG )
change = wxJOY_BUTTON2;
- if (flags & JOY_BUTTON3CHG)
+ if ( flags & JOY_BUTTON3CHG )
change = wxJOY_BUTTON3;
- if (flags & JOY_BUTTON4CHG)
+ if ( flags & JOY_BUTTON4CHG )
change = wxJOY_BUTTON4;
- if (flags & JOY_BUTTON1)
+ if ( flags & JOY_BUTTON1 )
buttons |= wxJOY_BUTTON1;
- if (flags & JOY_BUTTON2)
+ if ( flags & JOY_BUTTON2 )
buttons |= wxJOY_BUTTON2;
- if (flags & JOY_BUTTON3)
+ if ( flags & JOY_BUTTON3 )
buttons |= wxJOY_BUTTON3;
- if (flags & JOY_BUTTON4)
+ if ( flags & JOY_BUTTON4 )
buttons |= wxJOY_BUTTON4;
wxJoystickEvent event(wxEVT_JOY_BUTTON_DOWN, buttons, joystick, change);
{
int buttons = 0;
int change = 0;
- if (flags & JOY_BUTTON1CHG)
+ if ( flags & JOY_BUTTON1CHG )
change = wxJOY_BUTTON1;
- if (flags & JOY_BUTTON2CHG)
+ if ( flags & JOY_BUTTON2CHG )
change = wxJOY_BUTTON2;
- if (flags & JOY_BUTTON3CHG)
+ if ( flags & JOY_BUTTON3CHG )
change = wxJOY_BUTTON3;
- if (flags & JOY_BUTTON4CHG)
+ if ( flags & JOY_BUTTON4CHG )
change = wxJOY_BUTTON4;
- if (flags & JOY_BUTTON1)
+ if ( flags & JOY_BUTTON1 )
buttons |= wxJOY_BUTTON1;
- if (flags & JOY_BUTTON2)
+ if ( flags & JOY_BUTTON2 )
buttons |= wxJOY_BUTTON2;
- if (flags & JOY_BUTTON3)
+ if ( flags & JOY_BUTTON3 )
buttons |= wxJOY_BUTTON3;
- if (flags & JOY_BUTTON4)
+ if ( flags & JOY_BUTTON4 )
buttons |= wxJOY_BUTTON4;
wxJoystickEvent event(wxEVT_JOY_BUTTON_UP, buttons, joystick, change);
void wxWindow::MSWOnJoyMove(int joystick, int x, int y, WXUINT flags)
{
int buttons = 0;
- if (flags & JOY_BUTTON1)
+ if ( flags & JOY_BUTTON1 )
buttons |= wxJOY_BUTTON1;
- if (flags & JOY_BUTTON2)
+ if ( flags & JOY_BUTTON2 )
buttons |= wxJOY_BUTTON2;
- if (flags & JOY_BUTTON3)
+ if ( flags & JOY_BUTTON3 )
buttons |= wxJOY_BUTTON3;
- if (flags & JOY_BUTTON4)
+ if ( flags & JOY_BUTTON4 )
buttons |= wxJOY_BUTTON4;
wxJoystickEvent event(wxEVT_JOY_MOVE, buttons, joystick, 0);
void wxWindow::MSWOnJoyZMove(int joystick, int z, WXUINT flags)
{
int buttons = 0;
- if (flags & JOY_BUTTON1)
+ if ( flags & JOY_BUTTON1 )
buttons |= wxJOY_BUTTON1;
- if (flags & JOY_BUTTON2)
+ if ( flags & JOY_BUTTON2 )
buttons |= wxJOY_BUTTON2;
- if (flags & JOY_BUTTON3)
+ if ( flags & JOY_BUTTON3 )
buttons |= wxJOY_BUTTON3;
- if (flags & JOY_BUTTON4)
+ if ( flags & JOY_BUTTON4 )
buttons |= wxJOY_BUTTON4;
wxJoystickEvent event(wxEVT_JOY_ZMOVE, buttons, joystick, 0);
void wxWindow::MSWOnVScroll(WXWORD wParam, WXWORD pos, WXHWND control)
{
- if (control)
+ if ( control )
{
wxWindow *child = wxFindWinFromHandle(control);
if ( child )
break;
}
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
Default();
}
void wxWindow::MSWOnHScroll( WXWORD wParam, WXWORD pos, WXHWND control)
{
- if (control)
+ if ( control )
{
wxWindow *child = wxFindWinFromHandle(control);
if ( child ) {
return TRUE;
}
-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();
-}
-
void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font)
{
TEXTMETRIC tm;
HDC dc = ::GetDC((HWND) wnd);
HFONT fnt =0;
HFONT was = 0;
- if (the_font)
+ if ( the_font )
{
// the_font->UseResource();
// the_font->RealizeResource();
was = (HFONT) SelectObject(dc,fnt) ;
}
GetTextMetrics(dc, &tm);
- if (the_font && fnt && was)
+ if ( the_font && fnt && was )
{
SelectObject(dc,was) ;
}
*x = tm.tmAveCharWidth;
*y = tm.tmHeight + tm.tmExternalLeading;
- // if (the_font)
+ // if ( the_font )
// the_font->ReleaseResource();
}
void wxWindow::ShowCaret(bool show)
{
- if (m_caretEnabled)
+ if ( m_caretEnabled )
{
- if (show)
+ if ( show )
::ShowCaret((HWND) GetHWND());
else
::HideCaret((HWND) GetHWND());
wxWindow *wxGetActiveWindow()
{
HWND hWnd = GetActiveWindow();
- if (hWnd != 0)
+ if ( hWnd != 0 )
{
return wxFindWinFromHandle((WXHWND) hWnd);
}
void wxSetKeyboardHook(bool doIt)
{
- if (doIt)
+ if ( doIt )
{
wxTheKeyboardHookProc = MakeProcInstance((FARPROC) wxKeyboardHook, wxGetInstance());
wxTheKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) wxTheKeyboardHookProc, wxGetInstance(),
wxKeyboardHook(int nCode, WORD wParam, DWORD lParam)
{
DWORD hiWord = HIWORD(lParam);
- if (nCode != HC_NOREMOVE && ((hiWord & KF_UP) == 0))
+ if ( nCode != HC_NOREMOVE && ((hiWord & KF_UP) == 0) )
{
int id;
- if ((id = wxCharCodeMSWToWX(wParam)) != 0)
+ if ( (id = wxCharCodeMSWToWX(wParam)) != 0 )
{
wxKeyEvent event(wxEVT_CHAR_HOOK);
- if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN)
+ if ( (HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN )
event.m_altDown = TRUE;
event.m_eventObject = NULL;
event.SetTimestamp(wxApp::sm_lastMessageTime);
wxWindow *win = wxGetActiveWindow();
- if (win)
+ if ( win )
{
- if (win->GetEventHandler()->ProcessEvent(event))
+ if ( win->GetEventHandler()->ProcessEvent(event) )
return 1;
}
else
return (int)CallNextHookEx(wxTheKeyboardHook, nCode, wParam, lParam);
}
-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);
-
-}
-
void wxWindow::WarpPointer (int x_pos, int y_pos)
{
// Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
wxEraseEvent event(m_windowId, &dc);
event.m_eventObject = this;
- if (!GetEventHandler()->ProcessEvent(event))
+ if ( !GetEventHandler()->ProcessEvent(event) )
{
dc.EndDrawing();
dc.SelectOldObjects(pDC);
void wxWindow::OnEraseBackground(wxEraseEvent& event)
{
- if (!GetHWND())
+ if ( !GetHWND() )
return;
RECT rect;
SCROLLINFO info;
int dir;
- if (orient == wxHORIZONTAL) {
+ if ( orient == wxHORIZONTAL ) {
dir = SB_HORZ;
} else {
dir = SB_VERT;
info.fMask = SIF_RANGE | SIF_PAGE;
HWND hWnd = (HWND) GetHWND();
- if (hWnd)
+ if ( hWnd )
::SetScrollInfo(hWnd, dir, &info, refresh);
#else
int wOrient ;
- if (orient == wxHORIZONTAL)
+ if ( orient == wxHORIZONTAL )
wOrient = SB_HORZ;
else
wOrient = SB_VERT;
HWND hWnd = (HWND) GetHWND();
- if (hWnd)
+ if ( hWnd )
::SetScrollRange(hWnd, wOrient, 0, range, refresh);
#endif
}
SCROLLINFO info;
int dir;
- if (orient == wxHORIZONTAL) {
+ if ( orient == wxHORIZONTAL ) {
dir = SB_HORZ;
m_xThumbSize = page;
} else {
info.fMask = SIF_PAGE ;
HWND hWnd = (HWND) GetHWND();
- if (hWnd)
+ if ( hWnd )
::SetScrollInfo(hWnd, dir, &info, refresh);
#else
- if (orient == wxHORIZONTAL)
+ if ( orient == wxHORIZONTAL )
m_xThumbSize = page;
else
m_yThumbSize = page;
int wxWindow::OldGetScrollRange(int orient) const
{
int wOrient ;
- if (orient == wxHORIZONTAL)
+ if ( orient == wxHORIZONTAL )
wOrient = SB_HORZ;
else
wOrient = SB_VERT;
int minPos, maxPos;
#endif
HWND hWnd = (HWND) GetHWND();
- if (hWnd)
+ if ( hWnd )
{
::GetScrollRange(hWnd, wOrient, &minPos, &maxPos);
#if defined(__WIN95__)
int wxWindow::GetScrollPage(int orient) const
{
- if (orient == wxHORIZONTAL)
+ if ( orient == wxHORIZONTAL )
return m_xThumbSize;
else
return m_yThumbSize;
int wxWindow::GetScrollPos(int orient) const
{
int wOrient ;
- if (orient == wxHORIZONTAL)
+ if ( orient == wxHORIZONTAL )
wOrient = SB_HORZ;
else
wOrient = SB_VERT;
HWND hWnd = (HWND) GetHWND();
- if (hWnd)
+ if ( hWnd )
{
return ::GetScrollPos(hWnd, wOrient);
}
int wxWindow::GetScrollRange(int orient) const
{
int wOrient ;
- if (orient == wxHORIZONTAL)
+ if ( orient == wxHORIZONTAL )
wOrient = SB_HORZ;
else
wOrient = SB_VERT;
int minPos, maxPos;
#endif
HWND hWnd = (HWND) GetHWND();
- if (hWnd)
+ if ( hWnd )
{
::GetScrollRange(hWnd, wOrient, &minPos, &maxPos);
#if defined(__WIN95__)
int wxWindow::GetScrollThumb(int orient) const
{
- if (orient == wxHORIZONTAL)
+ if ( orient == wxHORIZONTAL )
return m_xThumbSize;
else
return m_yThumbSize;
SCROLLINFO info;
int dir;
- if (orient == wxHORIZONTAL) {
+ if ( orient == wxHORIZONTAL ) {
dir = SB_HORZ;
} else {
dir = SB_VERT;
info.fMask = SIF_POS ;
HWND hWnd = (HWND) GetHWND();
- if (hWnd)
+ if ( hWnd )
::SetScrollInfo(hWnd, dir, &info, refresh);
#else
int wOrient ;
- if (orient == wxHORIZONTAL)
+ if ( orient == wxHORIZONTAL )
wOrient = SB_HORZ;
else
wOrient = SB_VERT;
HWND hWnd = (HWND) GetHWND();
- if (hWnd)
+ if ( hWnd )
::SetScrollPos(hWnd, wOrient, pos, refresh);
#endif
}
SCROLLINFO info;
int dir;
- if (orient == wxHORIZONTAL) {
+ if ( orient == wxHORIZONTAL ) {
dir = SB_HORZ;
} else {
dir = SB_VERT;
info.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
HWND hWnd = (HWND) GetHWND();
- if (hWnd)
+ if ( hWnd )
::SetScrollInfo(hWnd, dir, &info, refresh);
#else
int wOrient ;
- if (orient == wxHORIZONTAL)
+ if ( orient == wxHORIZONTAL )
wOrient = SB_HORZ;
else
wOrient = SB_VERT;
HWND hWnd = (HWND) GetHWND();
- if (hWnd)
+ if ( hWnd )
{
::SetScrollRange(hWnd, wOrient, 0, range, FALSE);
::SetScrollPos(hWnd, wOrient, pos, refresh);
}
#endif
- if (orient == wxHORIZONTAL) {
+ if ( orient == wxHORIZONTAL ) {
m_xThumbSize = thumbVisible;
} else {
m_yThumbSize = thumbVisible;
::ScrollWindow((HWND) GetHWND(), dx, dy, NULL, NULL);
}
-void wxWindow::SetFont(const wxFont& font)
+bool wxWindow::SetFont(const wxFont& font)
{
- m_windowFont = font;
-
- if (!m_windowFont.Ok())
- return;
+ if ( !wxWindowBase::SetFont(font) )
+ {
+ // nothing to do
+ return FALSE;
+ }
HWND hWnd = (HWND) GetHWND();
- if (hWnd != 0)
+ if ( hWnd != 0 )
{
- if (m_windowFont.GetResourceHandle())
- SendMessage(hWnd, WM_SETFONT,
- (WPARAM)m_windowFont.GetResourceHandle(),TRUE);
+ WXHANDLE hFont = m_font.GetResourceHandle();
+
+ wxASSERT_MSG( hFont, _T("should have valid font") );
+
+ ::SendMessage(hWnd, WM_SETFONT, (WPARAM)hFont, TRUE);
}
+
+ return TRUE;
}
void wxWindow::SubclassWin(WXHWND hWnd)
wxRemoveHandleAssociation(this);
// Restore old Window proc
- if ((HWND) GetHWND())
+ if ( (HWND) GetHWND() )
{
FARPROC farProc = (FARPROC) GetWindowLong((HWND) GetHWND(), GWL_WNDPROC);
- if ((m_oldWndProc != 0) && (farProc != (FARPROC) m_oldWndProc))
+ if ( (m_oldWndProc != 0) && (farProc != (FARPROC) m_oldWndProc) )
{
SetWindowLong((HWND) GetHWND(), GWL_WNDPROC, (LONG) m_oldWndProc);
m_oldWndProc = 0;
// 2) If the parent is being drawn with user colours, or simple border specified,
// switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
- if (GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS) || (m_windowStyle & wxSIMPLE_BORDER))
+ if ( GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS) || (m_windowStyle & wxSIMPLE_BORDER) )
*want3D = FALSE;
// 3) Control can override this global setting by defining
// a border style, e.g. wxSUNKEN_BORDER
- if (m_windowStyle & wxSUNKEN_BORDER )
+ if ( m_windowStyle & wxSUNKEN_BORDER )
*want3D = TRUE;
// 4) If it's a special border, CTL3D can't cope so we want a native border
// apply the default border style specified.
// TODO what about non-Win95 WIN32? Does it have borders?
#if defined(__WIN95__) && !wxUSE_CTL3D
- if (defaultBorderStyle && (*want3D) && ! ((m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
+ if ( defaultBorderStyle && (*want3D) && ! ((m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER ) ||
(m_windowStyle & wxSTATIC_BORDER) || (m_windowStyle & wxSIMPLE_BORDER) ))
exStyle |= defaultBorderStyle; // WS_EX_CLIENTEDGE ;
#endif
Default();
}
-bool wxWindow::IsEnabled(void) const
-{
- return (::IsWindowEnabled((HWND) GetHWND()) != 0);
-}
-
-// 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()->Ok() && */
- !child->GetValidator()->TransferToWindow() )
- {
- wxLogError(_("Could not transfer data to window"));
- 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()->Ok() && */ !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()
+wxWindow *wxWindowBase::FindFocus()
{
HWND hWnd = ::GetFocus();
if ( hWnd )
return NULL;
}
-void wxWindow::AddChild(wxWindow *child)
-{
- GetChildren().Append(child);
- child->m_windowParent = this;
-}
-
-void wxWindow::RemoveChild(wxWindow *child)
-{
-// if (GetChildren())
- 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();
- wxLogDebug("Constraint(s) not satisfied for window of type %s, name %s:",
- (const char *)windowClass, (const char *)winName);
- if (!constr->left.GetDone())
- wxLogDebug(" unsatisfied 'left' constraint.");
- if (!constr->right.GetDone())
- wxLogDebug(" unsatisfied 'right' constraint.");
- if (!constr->width.GetDone())
- wxLogDebug(" unsatisfied 'width' constraint.");
- if (!constr->height.GetDone())
- wxLogDebug(" unsatisfied 'height' constraint.");
- wxLogDebug("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)) )
+ if ( GetEventHandler()->ProcessEvent(event) )
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) && !event.GetVeto());
+ if ( m_parent )
+ m_parent->GetEventHandler()->OnCommand(win, event);
}
wxObject* wxWindow::GetChild(int number) const
{
// Return a pointer to the Nth object in the Panel
-// if (!GetChildren())
+// if ( !GetChildren() )
// return(NULL) ;
wxNode *node = GetChildren().First();
int n = number;
while (node && n--)
node = node->Next() ;
- if (node)
+ if ( node )
{
wxObject *obj = (wxObject *)node->Data();
return(obj) ;
* we explicitly intercept the wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
* event.
- if (initiatingItem->IsKindOf(CLASSINFO(wxListBox)))
+ if ( initiatingItem->IsKindOf(CLASSINFO(wxListBox)) )
{
wxListBox *lbox = (wxListBox *)initiatingItem;
wxCommandEvent event(wxEVT_COMMAND_LEFT_DCLICK);
event.m_commandInt = -1;
- if ((lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0)
+ if ( (lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0 )
{
event.m_commandString = copystring(lbox->GetStringSelection());
event.m_commandInt = lbox->GetSelection();
lbox->ProcessCommand(event);
- if (event.m_commandString)
+ if ( event.m_commandString )
delete[] event.m_commandString;
return;
}
wxButton *but = GetDefaultItem();
- if (but)
+ if ( but )
{
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
event.SetEventObject(but);
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 = (wxValidator*)validator.Clone();
-
- if ( m_windowValidator )
- m_windowValidator->SetWindow(this) ;
-}
-
-// 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;
-}
-
/* TODO
// Default input behaviour for a scrolling canvas should be to scroll
// according to the cursor keys pressed
// Bugfix End
ViewStart(&start_x, &start_y);
// Bugfix begin
- if (vert_units)
+ if ( vert_units )
y_pages = (int)(v_height/vert_units) - y_page;
#ifdef __WXMSW__
case WXK_PRIOR:
{
// BugFix Begin
- if (y_page > 0)
+ if ( y_page > 0 )
{
- if (start_y - y_page > 0)
+ if ( start_y - y_page > 0 )
Scroll(start_x, start_y - y_page);
else
Scroll(start_x, 0);
case WXK_NEXT:
{
// Bugfix Begin
- if ((y_page > 0) && (start_y <= y_pages-y-1))
+ if ( (y_page > 0) && (start_y <= y_pages-y-1) )
{
- if (y_pages + y < start_y + y_page)
+ if ( y_pages + y < start_y + y_page )
Scroll(start_x, y_pages + y);
else
Scroll(start_x, start_y + y_page);
}
case WXK_UP:
{
- if ((y_page > 0) && (start_y >= 1))
+ if ( (y_page > 0) && (start_y >= 1) )
Scroll(start_x, start_y - 1);
break;
}
case WXK_DOWN:
{
// Bugfix Begin
- if ((y_page > 0) && (start_y <= y_pages-y-1))
+ if ( (y_page > 0) && (start_y <= y_pages-y-1) )
// Bugfix End
{
Scroll(start_x, start_y + 1);
}
case WXK_LEFT:
{
- if ((x_page > 0) && (start_x >= 1))
+ if ( (x_page > 0) && (start_x >= 1) )
Scroll(start_x - 1, start_y);
break;
}
case WXK_RIGHT:
{
- if (x_page > 0)
+ if ( x_page > 0 )
Scroll(start_x + 1, start_y);
break;
}
// Setup background and foreground colours correctly
void wxWindow::SetupColours()
{
- if (GetParent())
+ if ( GetParent() )
SetBackgroundColour(GetParent()->GetBackgroundColour());
}
void wxWindow::OnIdle(wxIdleEvent& event)
{
// Check if we need to send a LEAVE event
- if (m_mouseInWindow)
+ if ( m_mouseInWindow )
{
POINT pt;
::GetCursorPos(&pt);
- if (::WindowFromPoint(pt) != (HWND) GetHWND())
+ if ( ::WindowFromPoint(pt) != (HWND) GetHWND() )
{
// Generate a LEAVE event
m_mouseInWindow = FALSE;
int state = 0;
- if (::GetKeyState(VK_SHIFT) != 0)
+ if ( ::GetKeyState(VK_SHIFT) != 0 )
state |= MK_SHIFT;
- if (::GetKeyState(VK_CONTROL) != 0)
+ if ( ::GetKeyState(VK_CONTROL) != 0 )
state |= MK_CONTROL;
// Unfortunately the mouse button and keyboard state may have changed
return MSWDefWindowProc(WM_GETDLGCODE, 0, 0);
}
-bool wxWindow::AcceptsFocus() const
-{
- // invisible and disabled controls don't need focus
- return IsShown() && IsEnabled();
-}
-
-// 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);
-}
-
// Set this window to be the child of 'parent'.
bool wxWindow::Reparent(wxWindow *parent)
{
- if (parent == GetParent())
- return TRUE;
-
- // Unlink this window from the existing parent.
- if (GetParent())
- {
- GetParent()->RemoveChild(this);
- }
- else
- wxTopLevelWindows.DeleteObject(this);
+ if ( !wxWindowBase::Reparent(parent) )
+ return FALSE;
- HWND hWndParent = 0;
- HWND hWndChild = (HWND) GetHWND();
- if (parent != (wxWindow*) NULL)
- {
- parent->AddChild(this);
- hWndParent = (HWND) parent->GetHWND();
- }
- else
- wxTopLevelWindows.Append(this);
+ HWND hWndChild = (HWND)GetHWND();
+ HWND hWndParent = (HWND)(GetParent() ? GetParent()->GetHWND() : NULL);
::SetParent(hWndChild, hWndParent);