wxWindow class work

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4584 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster 1999-11-15 23:16:19 +00:00
parent 329e50732b
commit 776d87d504
3 changed files with 476 additions and 303 deletions

View File

@ -48,6 +48,11 @@ class WXDLLEXPORT wxToolBar: public wxToolBarBase
wxToolBarTool *AddTool(int toolIndex, const wxBitmap& bitmap, const wxBitmap& pushedBitmap = wxNullBitmap, wxToolBarTool *AddTool(int toolIndex, const wxBitmap& bitmap, const wxBitmap& pushedBitmap = wxNullBitmap,
bool toggle = FALSE, long xPos = -1, long yPos = -1, wxObject *clientData = NULL, bool toggle = FALSE, long xPos = -1, long yPos = -1, wxObject *clientData = NULL,
const wxString& helpString1 = "", const wxString& helpString2 = ""); const wxString& helpString1 = "", const wxString& helpString2 = "");
//Virtual function hiding suppression
inline wxToolBarTool *AddTool(int toolIndex, const wxBitmap& bitmap, const wxBitmap& pushedBitmap = wxNullBitmap,
bool toggle = FALSE, wxCoord xPos = -1, wxCoord yPos = -1, wxObject *clientData = NULL,
const wxString& helpString1 = "", const wxString& helpString2 = "")
{ return(AddTool(toolIndex, bitmap, pushedBitmap, toggle, (long)xPos, (long)yPos, clientData, helpString1, helpString2)); }
// Set default bitmap size // Set default bitmap size
void SetToolBitmapSize(const wxSize& size); void SetToolBitmapSize(const wxSize& size);
@ -81,12 +86,6 @@ protected:
WXHBITMAP m_hBitmap; WXHBITMAP m_hBitmap;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
private:
//Virtual function hiding suppression
inline wxToolBarTool *AddTool(int toolIndex, const wxBitmap& bitmap, const wxBitmap& pushedBitmap = wxNullBitmap,
bool toggle = FALSE, wxCoord xPos = -1, wxCoord yPos = -1, wxObject *clientData = NULL,
const wxString& helpString1 = "", const wxString& helpString2 = "")
{ return(AddTool(toolIndex, bitmap, pushedBitmap, toggle, (long)xPos, (long)yPos, clientData, helpString1, helpString2)); }
}; };
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR

View File

@ -51,111 +51,144 @@ class WXDLLEXPORT wxWindow : public wxWindowBase
public: public:
wxWindow() { Init(); } wxWindow() { Init(); }
wxWindow(wxWindow *parent, wxWindow( wxWindow* pParent
wxWindowID id, ,wxWindowID vId
const wxPoint& pos = wxDefaultPosition, ,const wxPoint& rPos = wxDefaultPosition
const wxSize& size = wxDefaultSize, ,const wxSize& rSize = wxDefaultSize
long style = 0, ,long lStyle = 0
const wxString& name = wxPanelNameStr) ,const wxString& rName = wxPanelNameStr
)
{ {
Init(); Init();
Create(parent, id, pos, size, style, name); Create( pParent
,vId
,rPos
,rSize
,lStyle
,rName
);
} }
virtual ~wxWindow(); virtual ~wxWindow();
bool Create(wxWindow *parent, bool Create( wxWindow* pParent
wxWindowID id, ,wxWindowID vId
const wxPoint& pos = wxDefaultPosition, ,const wxPoint& rPos = wxDefaultPosition
const wxSize& size = wxDefaultSize, ,const wxSize& rSize = wxDefaultSize
long style = 0, ,long lStyle = 0
const wxString& name = wxPanelNameStr); ,const wxString& rName = wxPanelNameStr
);
// implement base class pure virtuals // implement base class pure virtuals
virtual void SetTitle( const wxString& title); virtual void SetTitle(const wxString& rTitle);
virtual wxString GetTitle() const; virtual wxString GetTitle(void) const;
virtual void Raise(void);
virtual void Lower(void);
virtual bool Show(bool bShow = TRUE);
virtual bool Enable(bool bEnable = TRUE);
virtual void SetFocus(void);
virtual bool Reparent(wxWindow* pNewParent);
virtual void WarpPointer( int x
,int y
);
virtual void CaptureMouse(void);
virtual void ReleaseMouse(void);
virtual void Refresh( bool bEraseBackground = TRUE
,const wxRect* pRect = (const wxRect *)NULL
);
virtual void Clear(void);
virtual bool SetCursor(const wxCursor& rCursor);
virtual bool SetFont(const wxFont& rFont);
virtual int GetCharHeight(void) const;
virtual int GetCharWidth(void) const;
virtual void GetTextExtent( const wxString& rString
,int* pX
,int* pY
,int* pDescent = (int *)NULL
,int* pExternalLeading = (int *)NULL
,const wxFont* pTheFont = (const wxFont *)NULL
) const;
virtual bool DoPopupMenu( wxMenu* pMenu
,int nX
,int nY
);
virtual void Raise(); virtual void SetScrollbar( int nOrient
virtual void Lower(); ,int nPos
,int nThumbVisible
virtual bool Show( bool show = TRUE ); ,int nRange
virtual bool Enable( bool enable = TRUE ); ,bool bRefresh = TRUE
);
virtual void SetFocus(); virtual void SetScrollPos( int nOrient
,int nPos
virtual bool Reparent( wxWindow *newParent ); ,bool bRefresh = TRUE
);
virtual void WarpPointer(int x, int y); virtual int GetScrollPos(int nOrient) const;
virtual void CaptureMouse(); virtual int GetScrollThumb(int nOrient) const;
virtual void ReleaseMouse(); virtual int GetScrollRange(int nOrient) const;
virtual void ScrollWindow( int nDx
virtual void Refresh( bool eraseBackground = TRUE, ,int nDy
const wxRect *rect = (const wxRect *) NULL ); ,const wxRect* pRect = (wxRect *)NULL
virtual void Clear(); );
virtual bool SetCursor( const wxCursor &cursor );
virtual bool SetFont( const wxFont &font );
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
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 bool DoPopupMenu( 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 #if wxUSE_DRAG_AND_DROP
virtual void SetDropTarget( wxDropTarget *dropTarget ); virtual void SetDropTarget(wxDropTarget* pDropTarget);
#endif // wxUSE_DRAG_AND_DROP #endif // wxUSE_DRAG_AND_DROP
// Accept files for dragging // Accept files for dragging
virtual void DragAcceptFiles(bool accept); virtual void DragAcceptFiles(bool bAccept);
#if WXWIN_COMPATIBILITY #if WXWIN_COMPATIBILITY
// Set/get scroll attributes // Set/get scroll attributes
virtual void SetScrollRange(int orient, int range, bool refresh = TRUE); virtual void SetScrollRange( int nOrient
virtual void SetScrollPage(int orient, int page, bool refresh = TRUE); ,int nRange
virtual int OldGetScrollRange(int orient) const; ,bool bRefresh = TRUE
virtual int GetScrollPage(int orient) const; );
virtual void SetScrollPage( int nOrient
,int nPage
,bool bRefresh = TRUE
);
virtual int OldGetScrollRange(int nOrient) const;
virtual int GetScrollPage(int nOrient) const;
//
// event handlers // event handlers
//
// Handle a control command // Handle a control command
virtual void OnCommand(wxWindow& win, wxCommandEvent& event); virtual void OnCommand( wxWindow& rWin
,wxCommandEvent& rEvent
);
// Override to define new behaviour for default action (e.g. double // Override to define new behaviour for default action (e.g. double
// clicking on a listbox) // clicking on a listbox)
virtual void OnDefaultAction(wxControl * WXUNUSED(initiatingItem)) { } virtual void OnDefaultAction(wxControl* WXUNUSED(pInitiatingItem)) { }
#endif // WXWIN_COMPATIBILITY #endif // WXWIN_COMPATIBILITY
#if wxUSE_CARET && WXWIN_COMPATIBILITY #if wxUSE_CARET && WXWIN_COMPATIBILITY
// caret manipulation (old MSW only functions, see wxCaret class for the void CreateCaret( int nWidth
// new API) ,int nHeight
void CreateCaret(int w, int h); );
void CreateCaret(const wxBitmap *bitmap); void CreateCaret(const wxBitmap* pBitmap);
void DestroyCaret(); void DestroyCaret(void);
void ShowCaret(bool show); void ShowCaret(bool bShow);
void SetCaretPos(int x, int y); void SetCaretPos( int nX
void GetCaretPos(int *x, int *y) const; ,int nY
);
void GetCaretPos( int* pX
,int* pY
) const;
#endif // wxUSE_CARET #endif // wxUSE_CARET
// Native resource loading (implemented in src/msw/nativdlg.cpp) // Native resource loading (implemented in src/os2/nativdlg.cpp)
// FIXME: should they really be all virtual? // FIXME: should they really be all virtual?
virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id); virtual bool LoadNativeDialog( wxWindow* pParent
virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name); ,wxWindowID& vId
wxWindow* GetWindowChild1(wxWindowID id); );
wxWindow* GetWindowChild(wxWindowID id); virtual bool LoadNativeDialog( wxWindow* pParent
,const wxString& rName
);
wxWindow* GetWindowChild1(wxWindowID vId);
wxWindow* GetWindowChild(wxWindowID vId);
// implementation from now on // implementation from now on
// -------------------------- // --------------------------
@ -163,72 +196,89 @@ public:
// simple accessors // simple accessors
// ---------------- // ----------------
WXHWND GetHWND() const { return m_hWnd; } WXHWND GetHWND(void) const { return m_hWnd; }
void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; } void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
virtual WXWidget GetHandle() const { return GetHWND(); } virtual WXWidget GetHandle(void) const { return GetHWND(); }
bool GetUseCtl3D(void) const { return m_bUseCtl3D; }
bool GetUseCtl3D() const { return m_useCtl3D; } bool GetTransparentBackground(void) const { return m_bBackgroundTransparent; }
bool GetTransparentBackground() const { return m_backgroundTransparent; } void SetTransparent(bool bT = TRUE) { m_bBackgroundTransparent = bT; }
void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; }
// event handlers // event handlers
// -------------- // --------------
void OnEraseBackground(wxEraseEvent& event); void OnEraseBackground(wxEraseEvent& rEvent);
void OnIdle(wxIdleEvent& event); void OnIdle(wxIdleEvent& rEvent);
public: public:
// For implementation purposes - sometimes decorations make the client area // For implementation purposes - sometimes decorations make the client area
// smaller // smaller
virtual wxPoint GetClientAreaOrigin() const; virtual wxPoint GetClientAreaOrigin(void) const;
// Makes an adjustment to the window position (for example, a frame that has // Makes an adjustment to the window position (for example, a frame that has
// a toolbar that it manages itself). // a toolbar that it manages itself).
virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags); virtual void AdjustForParentClientOrigin( int& rX
,int& rY
,int nSizeFlags
);
// Windows subclassing // Windows subclassing
void SubclassWin(WXHWND hWnd); void SubclassWin(WXHWND hWnd);
void UnsubclassWin(); void UnsubclassWin(void);
WXFARPROC OS2GetOldWndProc() const { return m_oldWndProc; } WXFARPROC OS2GetOldWndProc(void) const { return m_fnOldWndProc; }
void OS2SetOldWndProc(WXFARPROC proc) { m_oldWndProc = proc; } void OS2SetOldWndProc(WXFARPROC fnProc) { m_fnOldWndProc = fnProc; }
wxWindow *FindItem(long id) const; wxWindow* FindItem(long lId) const;
wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const; wxWindow* FindItemByHWND( WXHWND hWnd
,bool bControlOnly = FALSE
) const;
// Make a Windows extended style from the given wxWindows window style // Make a Windows extended style from the given wxWindows window style ?? applicable to OS/2??
static WXDWORD MakeExtendedStyle(long style, static WXDWORD MakeExtendedStyle( long lStyle
bool eliminateBorders = TRUE); ,bool bEliminateBorders = TRUE
);
// Determine whether 3D effects are wanted // Determine whether 3D effects are wanted
WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const; WXDWORD Determine3DEffects( WXDWORD dwDefaultBorderStyle
,bool* pbWant3D
) const;
// MSW only: TRUE if this control is part of the main control // PM only: TRUE if this control is part of the main control
virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; }; virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
// returns TRUE if the window has been created // returns TRUE if the window has been created
bool OS2Create(int id, bool OS2Create( int nId
wxWindow *parent, ,wxWindow* pParent
const wxChar *wclass, ,const wxChar* zWclass
wxWindow *wx_win, ,wxWindow* pWxWin
const wxChar *title, ,const wxChar* zTitle
int x, int y, int width, int height, ,int nX
WXDWORD style, ,int nY
const wxChar *dialog_template = NULL, ,int nWidth
WXDWORD exendedStyle = 0); ,int nHeight
virtual bool OS2Command(WXUINT param, WXWORD id); ,WXDWORD dwStyle
,const wxChar* zDialogTemplate = NULL
,WXDWORD dwExendedStyle = 0
);
virtual bool OS2Command( WXUINT uParam
,WXWORD nId
);
#if WXWIN_COMPATIBILITY #if WXWIN_COMPATIBILITY
wxObject *GetChild(int number) const; wxObject* GetChild(int nNumber) const;
virtual void OS2DeviceToLogical(float *x, float *y) const; virtual void OS2DeviceToLogical( float* pfX
,float* pfY
) const;
#endif // WXWIN_COMPATIBILITY #endif // WXWIN_COMPATIBILITY
// Create an appropriate wxWindow from a HWND // Create an appropriate wxWindow from a HWND
virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd); virtual wxWindow* CreateWindowFromHWND( wxWindow* pParent
,WXHWND hWnd
);
// Make sure the window style reflects the HWND style (roughly) // Make sure the window style reflects the HWND style (roughly)
virtual void AdoptAttributesFromHWND(); virtual void AdoptAttributesFromHWND(void);
// Setup background and foreground colours correctly // Setup background and foreground colours correctly
virtual void SetupColours(); virtual void SetupColours(void);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// helpers for message handlers: these perform the same function as the // helpers for message handlers: these perform the same function as the
@ -236,191 +286,286 @@ public:
// the correct parameters // the correct parameters
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
void UnpackCommand(WXWPARAM wParam, WXLPARAM lParam, void UnpackCommand( WXWPARAM wParam
WXWORD *id, WXHWND *hwnd, WXWORD *cmd); ,WXLPARAM lParam,
void UnpackActivate(WXWPARAM wParam, WXLPARAM lParam, WXWORD* pId
WXWORD *state, WXWORD *minimized, WXHWND *hwnd); ,WXHWND* pHwnd
void UnpackScroll(WXWPARAM wParam, WXLPARAM lParam, ,WXWORD* pCmd
WXWORD *code, WXWORD *pos, WXHWND *hwnd); );
void UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam, void UnpackActivate( WXWPARAM wParam
WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd); ,WXLPARAM lParam
void UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam, ,WXWORD* pState
WXWORD *item, WXWORD *flags, WXHMENU *hmenu); ,WXWORD* pMinimized
,WXHWND* pHwnd
);
void UnpackScroll( WXWPARAM wParam
,WXLPARAM lParam
,WXWORD* pCode
,WXWORD* pPos
,WXHWND* pHwnd
);
void UnpackCtlColor( WXWPARAM wParam
,WXLPARAM lParam
,WXWORD* pCtlColor
,WXHDC* pHdc
,WXHWND* pHwnd
);
void UnpackMenuSelect( WXWPARAM wParam
,WXLPARAM lParam
,WXWORD* pTtem
,WXWORD* pFlags
,WXHMENU* pHmenu
);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// internal handlers for MSW messages: all handlers return a boolen value: // internal handlers for OS2 messages: all handlers return a boolen value:
// TRUE means that the handler processed the event and FALSE that it didn't // TRUE means that the handler processed the event and FALSE that it didn't
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// there are several cases where we have virtual functions for Windows // there are several cases where we have virtual functions for PM
// message processing: this is because these messages often require to be // message processing: this is because these messages often require to be
// processed in a different manner in the derived classes. For all other // processed in a different manner in the derived classes. For all other
// messages, however, we do *not* have corresponding MSWOnXXX() function // messages, however, we do *not* have corresponding OS2OnXXX() function
// and if the derived class wants to process them, it should override // and if the derived class wants to process them, it should override
// MSWWindowProc() directly. // OS2WindowProc() directly.
// scroll event (both horizontal and vertical) // scroll event (both horizontal and vertical)
virtual bool OS2OnScroll(int orientation, WXWORD nSBCode, virtual bool OS2OnScroll( int nOrientation
WXWORD pos, WXHWND control); ,WXWORD nSBCode
,WXWORD pos
,WXHWND control
);
virtual bool OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); virtual bool OS2OnNotify( int nIdCtrl
,WXLPARAM lParam
,WXLPARAM* pResult
);
// owner-drawn controls need to process these messages // owner-drawn controls need to process these messages
virtual bool OS2OnDrawItem(int id, WXDRAWITEMSTRUCT *item); virtual bool OS2OnDrawItem( int nId
virtual bool OS2OnMeasureItem(int id, WXMEASUREITEMSTRUCT *item); ,WXDRAWITEMSTRUCT* pItem
);
virtual bool OS2OnMeasureItem( int nId
,WXMEASUREITEMSTRUCT* pItem
);
// the rest are not virtual // the rest are not virtual
bool HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate); bool HandleCreate( WXLPCREATESTRUCT vCs
,bool* pMayCreate
);
bool HandleInitDialog(WXHWND hWndFocus); bool HandleInitDialog(WXHWND hWndFocus);
bool HandleDestroy(); bool HandleDestroy(void);
bool HandlePaint(void);
bool HandlePaint(); bool HandleEraseBkgnd(WXHDC vDC);
bool HandleEraseBkgnd(WXHDC pDC); bool HandleMinimize(void);
bool HandleMaximize(void);
bool HandleMinimize(); bool HandleSize( int nX
bool HandleMaximize(); ,int nY
bool HandleSize(int x, int y, WXUINT flag); ,WXUINT uFlag
bool HandleGetMinMaxInfo(void *mmInfo); );
bool HandleGetMinMaxInfo(void* pMmInfo);
bool HandleShow(bool show, int status); bool HandleShow( bool bShow
bool HandleActivate(int flag, bool minimized, WXHWND activate); ,int nStatus
);
bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); bool HandleActivate( int nFlag
bool HandleSysCommand(WXWPARAM wParam, WXLPARAM lParam); ,bool bMinimized
,WXHWND hActivate
bool HandleCtlColor(WXHBRUSH *hBrush, );
WXHDC hdc, bool HandleCommand( WXWORD nId
WXHWND hWnd, ,WXWORD nCmd
WXUINT nCtlColor, ,WXHWND hControl
WXUINT message, );
WXWPARAM wParam, bool HandleSysCommand( WXWPARAM wParam
WXLPARAM lParam); ,WXLPARAM lParam
);
bool HandleCtlColor( WXHBRUSH* phBrush
,WXHDC hDc
,WXHWND hWnd
,WXUINT uCtlColor
,WXUINT uMessage
,WXWPARAM wParam
,WXLPARAM lParam
);
bool HandlePaletteChanged(WXHWND hWndPalChange); bool HandlePaletteChanged(WXHWND hWndPalChange);
bool HandleQueryNewPalette(); bool HandleQueryNewPalette(void);
bool HandleSysColorChange(); bool HandleSysColorChange(void);
bool HandleQueryEndSession( long lLogOff
bool HandleQueryEndSession(long logOff, bool *mayEnd); ,bool* pbMayEnd
bool HandleEndSession(bool endSession, long logOff); );
bool HandleEndSession( bool bEndSession
bool HandleSetFocus(WXHWND wnd); ,long lLogOff
bool HandleKillFocus(WXHWND wnd); );
bool HandleSetFocus(WXHWND hWnd);
bool HandleKillFocus(WXHWND hWnd);
bool HandleDropFiles(WXWPARAM wParam); bool HandleDropFiles(WXWPARAM wParam);
bool HandleMouseEvent( WXUINT uMsg
bool HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags); ,int nX
bool HandleMouseMove(int x, int y, WXUINT flags); ,int nY
,WXUINT uFlags
bool HandleChar(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE); );
bool HandleKeyDown(WXWORD wParam, WXLPARAM lParam); bool HandleMouseMove( int nX
bool HandleKeyUp(WXWORD wParam, WXLPARAM lParam); ,int nY
,WXUINT uFlags
bool HandleQueryDragIcon(WXHICON *hIcon); );
bool HandleChar( WXWORD wParam
bool HandleSetCursor(WXHWND hWnd, short nHitTest, int mouseMsg); ,WXLPARAM lParam
,bool bIsASCII = FALSE
);
bool HandleKeyDown( WXWORD wParam
,WXLPARAM lParam
);
bool HandleKeyUp( WXWORD wParam
,WXLPARAM lParam
);
bool HandleQueryDragIcon(WXHICON* phIcon);
bool HandleSetCursor( WXHWND hWnd
,short nHitTest
,int nMouseMsg
);
// Window procedure // Window procedure
virtual MRESULT OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); virtual MRESULT OS2WindowProc( HWND hwnd
,WXUINT uMsg
,WXWPARAM wParam
,WXLPARAM lParam
);
// Calls an appropriate default window procedure // Calls an appropriate default window procedure
virtual MRESULT OS2DefWindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); virtual MRESULT OS2DefWindowProc( HWND hwnd
virtual bool OS2ProcessMessage(WXMSG* pMsg); ,WXUINT uMsg
virtual bool OS2TranslateMessage(WXMSG* pMsg); ,WXWPARAM wParam
virtual void OS2DestroyWindow(); ,WXLPARAM lParam
);
virtual bool OS2ProcessMessage(WXMSG* pMsg);
virtual bool OS2TranslateMessage(WXMSG* pMsg);
virtual void OS2DestroyWindow(void);
// Detach "Window" menu from menu bar so it doesn't get deleted // Detach "Window" menu from menu bar so it doesn't get deleted
void OS2DetachWindowMenu(); void OS2DetachWindowMenu(void);
// this function should return the brush to paint the window background // this function should return the brush to paint the window background
// with or 0 for the default brush // with or 0 for the default brush
virtual WXHBRUSH OnCtlColor(WXHDC hDC, virtual WXHBRUSH OnCtlColor( WXHDC hDC
WXHWND hWnd, ,WXHWND hWnd
WXUINT nCtlColor, ,WXUINT uCtlColor
WXUINT message, ,WXUINT uMessage
WXWPARAM wParam, ,WXWPARAM wParam
WXLPARAM lParam); ,WXLPARAM lParam
);
#if WXWIN_COMPATIBILITY #if WXWIN_COMPATIBILITY
void SetShowing(bool show) { (void)Show(show); } void SetShowing(bool bShow) { (void)Show(show); }
bool IsUserEnabled() const { return IsEnabled(); } bool IsUserEnabled(void) const { return IsEnabled(); }
#endif // WXWIN_COMPATIBILITY #endif // WXWIN_COMPATIBILITY
// Responds to colour changes: passes event on to children. // Responds to colour changes: passes event on to children.
void OnSysColourChanged(wxSysColourChangedEvent& event); void OnSysColourChanged(wxSysColourChangedEvent& rEvent);
// initialize various fields of wxMouseEvent (common part of MSWOnMouseXXX) // initialize various fields of wxMouseEvent (common part of OS2OnMouseXXX)
void InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags); void InitMouseEvent( wxMouseEvent& rEvent
,int nX
,int nY
,WXUINT uFlags
);
protected: protected:
// the window handle // the window handle
WXHWND m_hWnd; WXHWND m_hWnd;
// the old window proc (we subclass all windows) // the old window proc (we subclass all windows)
WXFARPROC m_oldWndProc; WXFARPROC m_fnOldWndProc;
// additional (MSW specific) flags // additional (MSW specific) flags
bool m_useCtl3D:1; // Using CTL3D for this control bool m_bUseCtl3D:1; // Using CTL3D for this control
bool m_backgroundTransparent:1; bool m_bBackgroundTransparent:1;
bool m_mouseInWindow:1; bool m_bMouseInWindow:1;
bool m_doubleClickAllowed:1; bool m_bDoubleClickAllowed:1;
bool m_winCaptured:1; bool m_bWinCaptured:1;
// the size of one page for scrolling // the size of one page for scrolling
int m_xThumbSize; int m_nXThumbSize;
int m_yThumbSize; int m_nYThumbSize;
#if wxUSE_MOUSEEVENT_HACK #if wxUSE_MOUSEEVENT_HACK
// the coordinates of the last mouse event and the type of it // the coordinates of the last mouse event and the type of it
long m_lastMouseX, long m_lLastMouseX,
m_lastMouseY; long m_lLastMouseY;
int m_lastMouseEvent; int m_nLastMouseEvent;
#endif // wxUSE_MOUSEEVENT_HACK #endif // wxUSE_MOUSEEVENT_HACK
WXHMENU m_hMenu; // Menu, if any WXHMENU m_hMenu; // Menu, if any
// the return value of WM_GETDLGCODE handler // the return value of WM_GETDLGCODE handler
long m_lDlgCode; long m_lDlgCode;
// implement the base class pure virtuals // implement the base class pure virtuals
virtual void DoClientToScreen( int *x, int *y ) const; virtual void DoClientToScreen( int* pX
virtual void DoScreenToClient( int *x, int *y ) const; ,int* pY
virtual void DoGetPosition( int *x, int *y ) const; ) const;
virtual void DoGetSize( int *width, int *height ) const; virtual void DoScreenToClient( int* pX
virtual void DoGetClientSize( int *width, int *height ) const; ,int* pY
virtual void DoSetSize(int x, int y, ) const;
int width, int height, virtual void DoGetPosition( int* pX
int sizeFlags = wxSIZE_AUTO); ,int* pY
virtual void DoSetClientSize(int width, int height); ) const;
virtual void DoGetSize( int* pWidth
,int* pHeight
) const;
virtual void DoGetClientSize( int* pWidth
,int* pHeight
) const;
virtual void DoSetSize( int nX
,int nY
,int nWidth
,int nHeight
,int nSizeFlags = wxSIZE_AUTO
);
virtual void DoSetClientSize( int nWidth
,int nHeight
);
// get the size which best suits the window: e.g., for a static text it // get the size which best suits the window: e.g., for a static text it
// will be the width and height of the text // will be the width and height of the text
virtual wxSize DoGetBestSize(); virtual wxSize DoGetBestSize(void);
// move the window to the specified location and resize it: this is called // move the window to the specified location and resize it: this is called
// from both DoSetSize() and DoSetClientSize() and would usually just call // from both DoSetSize() and DoSetClientSize() and would usually just call
// ::MoveWindow() except for composite controls which will want to arrange // ::MoveWindow() except for composite controls which will want to arrange
// themselves inside the given rectangle // themselves inside the given rectangle
virtual void DoMoveWindow(int x, int y, int width, int height); virtual void DoMoveWindow( int nX
,int nY
,int nWidth
,int nHeight
);
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
virtual void DoSetToolTip( wxToolTip *tip ); virtual void DoSetToolTip(wxToolTip* pTip);
#endif // wxUSE_TOOLTIPS #endif // wxUSE_TOOLTIPS
private: private:
// common part of all ctors // common part of all ctors
void Init(); void Init(void);
// the (non-virtual) handlers for the events // the (non-virtual) handlers for the events
bool HandleMove(int x, int y); bool HandleMove( int nX
bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags); ,int nY
);
bool HandleJoystickEvent( WXUINT uMsg
,int pX
,int pY
,WXUINT uFlags
);
bool HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); bool HandleNotify( int nIdCtrl
,WXLPARAM lParam
,WXLPARAM* pResult
);
DECLARE_NO_COPY_CLASS(wxWindow); DECLARE_NO_COPY_CLASS(wxWindow);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
private: private:
// Virtual function hiding supression // Virtual function hiding supression
inline virtual bool Reparent( wxWindowBase *newParent ) inline virtual bool Reparent(wxWindowBase* pNewParent)
{ return(wxWindowBase::Reparent(newParent));}; { return(wxWindowBase::Reparent(pNewParent));};
}; };
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -428,7 +573,9 @@ private:
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// kbd code translation // kbd code translation
WXDLLEXPORT int wxCharCodeOS2ToWX(int keySym); WXDLLEXPORT int wxCharCodeOS2ToWX(int nKeySym);
WXDLLEXPORT int wxCharCodeWXToOS2(int id, bool *IsVirtual); WXDLLEXPORT int wxCharCodeWXToOS2( int nId
,bool* pbIsVirtual
);
#endif #endif
// _WX_WINDOW_H_ // _WX_WINDOW_H_

View File

@ -124,71 +124,81 @@ END_EVENT_TABLE()
// implementation // implementation
// =========================================================================== // ===========================================================================
// Find an item given the MS Windows id // Find an item given the PM Window id
wxWindow *wxWindow::FindItem(long id) const wxWindow* wxWindow::FindItem(
long ulId
) const
{ {
wxWindowList::Node *current = GetChildren().GetFirst(); wxWindowList::Node* pCurrent = GetChildren().GetFirst();
while (current)
while (pCurrent)
{ {
wxWindow *childWin = current->GetData(); wxWindow* pChildWin = pCurrent->GetData();
wxWindow* pWnd = pChildWin->FindItem(ulId);
wxWindow *wnd = childWin->FindItem(id); if (pWnd)
if ( wnd ) return pWnd;
return wnd;
if ( childWin->IsKindOf(CLASSINFO(wxControl)) ) if (pChildWin->IsKindOf(CLASSINFO(wxControl)))
{ {
wxControl *item = (wxControl *)childWin; wxControl* pItem = (wxControl *)pChildWin;
if ( item->GetId() == id )
return item; if (pItem->GetId() == ulId)
return(pItem);
else else
{ {
// In case it's a 'virtual' control (e.g. radiobox) // In case it's a 'virtual' control (e.g. radiobox)
if ( item->GetSubcontrols().Member((wxObject *)id) ) if (pItem->GetSubcontrols().Member((wxObject *)ulId))
return item; return(pItem);
} }
} }
pCurrent = pCurrent->GetNext();
current = current->GetNext();
} }
return(NULL);
return NULL;
} }
// Find an item given the MS Windows handle // Find an item given the PM Window handle
wxWindow *wxWindow::FindItemByHWND(WXHWND hWnd, bool controlOnly) const wxWindow* wxWindow::FindItemByHWND(
WXHWND hWnd
, bool bControlOnly
) const
{ {
wxWindowList::Node *current = GetChildren().GetFirst(); wxWindowList::Node* pCurrent = GetChildren().GetFirst();
while (current)
while (pCurrent)
{ {
wxWindow *parent = current->GetData(); wxWindow* pParent = pCurrent->GetData();
// Do a recursive search. // Do a recursive search.
wxWindow *wnd = parent->FindItemByHWND(hWnd); wxWindow* pWnd = pParent->FindItemByHWND(hWnd);
if ( wnd )
return wnd;
if ( !controlOnly || parent->IsKindOf(CLASSINFO(wxControl)) ) if (pWnd)
return(pWnd);
if (!bControlOnly || pParent->IsKindOf(CLASSINFO(wxControl)))
{ {
wxWindow *item = current->GetData(); wxWindow* pItem = pCurrent->GetData();
if ( item->GetHWND() == hWnd )
return item; if (pItem->GetHWND() == hWnd)
return(pItem);
else else
{ {
if ( item->ContainsHWND(hWnd) ) if (pItem->ContainsHWND(hWnd))
return item; return(pItem);
} }
} }
pCurrent = pCurrent->GetNext();
current = current->GetNext();
} }
return NULL; return(NULL);
} }
// Default command handler // Default command handler
bool wxWindow::OS2Command(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id)) bool wxWindow::OS2Command(
WXUINT WXUNUSED(uParam)
, WXWORD WXUNUSED(uId)
)
{ {
return FALSE; return(FALSE);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -201,13 +211,13 @@ void wxWindow::Init()
InitBase(); InitBase();
// PM specific // PM specific
m_doubleClickAllowed = 0; m_bDoubleClickAllowed = 0;
m_winCaptured = FALSE; m_bWinCaptured = FALSE;
m_isBeingDeleted = FALSE; m_isBeingDeleted = FALSE;
m_oldWndProc = 0; m_fnOldWndProc = 0;
m_useCtl3D = FALSE; m_bUseCtl3D = FALSE;
m_mouseInWindow = FALSE; m_bMouseInWindow = FALSE;
// wxWnd // wxWnd
m_hMenu = 0; m_hMenu = 0;
@ -217,17 +227,17 @@ void wxWindow::Init()
// pass WM_GETDLGCODE to DefWindowProc() // pass WM_GETDLGCODE to DefWindowProc()
m_lDlgCode = 0; m_lDlgCode = 0;
m_xThumbSize = 0; m_nXThumbSize = 0;
m_yThumbSize = 0; m_nYThumbSize = 0;
m_backgroundTransparent = FALSE; m_bBackgroundTransparent = FALSE;
// as all windows are created with WS_VISIBLE style... // as all windows are created with WS_VISIBLE style...
m_isShown = TRUE; m_isShown = TRUE;
#if wxUSE_MOUSEEVENT_HACK #if wxUSE_MOUSEEVENT_HACK
m_lastMouseX = m_lLastMouseX =
m_lastMouseY = -1; m_lLastMouseY = -1;
m_lastMouseEvent = -1; m_nLastMouseEvent = -1;
#endif // wxUSE_MOUSEEVENT_HACK #endif // wxUSE_MOUSEEVENT_HACK
} }
@ -250,30 +260,47 @@ wxWindow::~wxWindow()
} }
} }
bool wxWindow::Create(wxWindow *parent, wxWindowID id, bool wxWindow::Create(
const wxPoint& pos, wxWindow* pParent
const wxSize& size, , wxWindowID vId
long style, , const wxPoint& rPos
const wxString& name) , const wxSize& rSize
, long lStyle
, const wxString& rName
)
{ {
wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindow without parent") ); wxCHECK_MSG(pParent, FALSE, wxT("can't create wxWindow without parent"));
if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) if ( !CreateBase( pParent
return FALSE; ,vId
,rPos
,rSize
,lStyle
,wxDefaultValidator
,rName
))
return(FALSE);
parent->AddChild(this); pParent->AddChild(this);
bool want3D; bool bWant3D;
WXDWORD exStyle = 0; // TODO: Determine3DEffects(WS_EX_CLIENTEDGE, &want3D); WXDWORD dwExStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &bWant3D);
DWORD msflags = 0; DWORD ulFlags = 0L;
OS2Create( m_windowId
// TODO: PM Specific initialization ,pParent
OS2Create(m_windowId, parent, wxCanvasClassName, this, NULL, ,wxCanvasClassName
pos.x, pos.y, ,this
WidthDefault(size.x), HeightDefault(size.y), ,NULL
msflags, NULL, exStyle); ,rPos.x
return TRUE; ,rPos.y
,WidthDefault(rSize.x)
,HeightDefault(rSize.y)
,ulFlags
,NULL
,dwExStyle
);
return(TRUE);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -435,7 +462,7 @@ void wxWindow::ScrollWindow( int dx
void wxWindow::SubclassWin(WXHWND hWnd) void wxWindow::SubclassWin(WXHWND hWnd)
{ {
wxASSERT_MSG( !m_oldWndProc, wxT("subclassing window twice?") ); wxASSERT_MSG( !m_fnOldWndProc, wxT("subclassing window twice?") );
HWND hwnd = (HWND)hWnd; HWND hwnd = (HWND)hWnd;
/* /*
@ -2071,10 +2098,10 @@ bool wxWindow::HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags)
bool wxWindow::HandleMouseMove(int x, int y, WXUINT flags) bool wxWindow::HandleMouseMove(int x, int y, WXUINT flags)
{ {
if ( !m_mouseInWindow ) if ( !m_bMouseInWindow )
{ {
// Generate an ENTER event // Generate an ENTER event
m_mouseInWindow = TRUE; m_bMouseInWindow = TRUE;
wxMouseEvent event(wxEVT_ENTER_WINDOW); wxMouseEvent event(wxEVT_ENTER_WINDOW);
InitMouseEvent(event, x, y, flags); InitMouseEvent(event, x, y, flags);