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,
bool toggle = FALSE, long xPos = -1, long yPos = -1, wxObject *clientData = NULL,
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
void SetToolBitmapSize(const wxSize& size);
@ -81,12 +86,6 @@ protected:
WXHBITMAP m_hBitmap;
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

View File

@ -51,111 +51,144 @@ class WXDLLEXPORT wxWindow : public wxWindowBase
public:
wxWindow() { Init(); }
wxWindow(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr)
wxWindow( wxWindow* pParent
,wxWindowID vId
,const wxPoint& rPos = wxDefaultPosition
,const wxSize& rSize = wxDefaultSize
,long lStyle = 0
,const wxString& rName = wxPanelNameStr
)
{
Init();
Create(parent, id, pos, size, style, name);
Create( pParent
,vId
,rPos
,rSize
,lStyle
,rName
);
}
virtual ~wxWindow();
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr);
bool Create( wxWindow* pParent
,wxWindowID vId
,const wxPoint& rPos = wxDefaultPosition
,const wxSize& rSize = wxDefaultSize
,long lStyle = 0
,const wxString& rName = wxPanelNameStr
);
// implement base class pure virtuals
virtual void SetTitle( const wxString& title);
virtual wxString GetTitle() const;
virtual void SetTitle(const wxString& rTitle);
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 Lower();
virtual bool Show( bool show = TRUE );
virtual bool Enable( bool enable = TRUE );
virtual void SetFocus();
virtual bool Reparent( wxWindow *newParent );
virtual void WarpPointer(int x, int y);
virtual void CaptureMouse();
virtual void ReleaseMouse();
virtual void Refresh( bool eraseBackground = TRUE,
const wxRect *rect = (const 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 );
virtual void SetScrollbar( int nOrient
,int nPos
,int nThumbVisible
,int nRange
,bool bRefresh = TRUE
);
virtual void SetScrollPos( int nOrient
,int nPos
,bool bRefresh = TRUE
);
virtual int GetScrollPos(int nOrient) const;
virtual int GetScrollThumb(int nOrient) const;
virtual int GetScrollRange(int nOrient) const;
virtual void ScrollWindow( int nDx
,int nDy
,const wxRect* pRect = (wxRect *)NULL
);
#if wxUSE_DRAG_AND_DROP
virtual void SetDropTarget( wxDropTarget *dropTarget );
virtual void SetDropTarget(wxDropTarget* pDropTarget);
#endif // wxUSE_DRAG_AND_DROP
// Accept files for dragging
virtual void DragAcceptFiles(bool accept);
virtual void DragAcceptFiles(bool bAccept);
#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;
virtual void SetScrollRange( int nOrient
,int nRange
,bool bRefresh = TRUE
);
virtual void SetScrollPage( int nOrient
,int nPage
,bool bRefresh = TRUE
);
virtual int OldGetScrollRange(int nOrient) const;
virtual int GetScrollPage(int nOrient) const;
//
// event handlers
//
// 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
// clicking on a listbox)
virtual void OnDefaultAction(wxControl * WXUNUSED(initiatingItem)) { }
virtual void OnDefaultAction(wxControl* WXUNUSED(pInitiatingItem)) { }
#endif // WXWIN_COMPATIBILITY
#if wxUSE_CARET && WXWIN_COMPATIBILITY
// caret manipulation (old MSW only functions, see wxCaret class for the
// new API)
void CreateCaret(int w, int h);
void CreateCaret(const wxBitmap *bitmap);
void DestroyCaret();
void ShowCaret(bool show);
void SetCaretPos(int x, int y);
void GetCaretPos(int *x, int *y) const;
void CreateCaret( int nWidth
,int nHeight
);
void CreateCaret(const wxBitmap* pBitmap);
void DestroyCaret(void);
void ShowCaret(bool bShow);
void SetCaretPos( int nX
,int nY
);
void GetCaretPos( int* pX
,int* pY
) const;
#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?
virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id);
virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name);
wxWindow* GetWindowChild1(wxWindowID id);
wxWindow* GetWindowChild(wxWindowID id);
virtual bool LoadNativeDialog( wxWindow* pParent
,wxWindowID& vId
);
virtual bool LoadNativeDialog( wxWindow* pParent
,const wxString& rName
);
wxWindow* GetWindowChild1(wxWindowID vId);
wxWindow* GetWindowChild(wxWindowID vId);
// implementation from now on
// --------------------------
@ -163,72 +196,89 @@ public:
// simple accessors
// ----------------
WXHWND GetHWND() const { return m_hWnd; }
WXHWND GetHWND(void) const { return m_hWnd; }
void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
virtual WXWidget GetHandle() const { return GetHWND(); }
bool GetUseCtl3D() const { return m_useCtl3D; }
bool GetTransparentBackground() const { return m_backgroundTransparent; }
void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; }
virtual WXWidget GetHandle(void) const { return GetHWND(); }
bool GetUseCtl3D(void) const { return m_bUseCtl3D; }
bool GetTransparentBackground(void) const { return m_bBackgroundTransparent; }
void SetTransparent(bool bT = TRUE) { m_bBackgroundTransparent = bT; }
// event handlers
// --------------
void OnEraseBackground(wxEraseEvent& event);
void OnIdle(wxIdleEvent& event);
void OnEraseBackground(wxEraseEvent& rEvent);
void OnIdle(wxIdleEvent& rEvent);
public:
// For implementation purposes - sometimes decorations make the client area
// smaller
virtual wxPoint GetClientAreaOrigin() const;
virtual wxPoint GetClientAreaOrigin(void) const;
// Makes an adjustment to the window position (for example, a frame that has
// 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
void SubclassWin(WXHWND hWnd);
void UnsubclassWin();
void UnsubclassWin(void);
WXFARPROC OS2GetOldWndProc() const { return m_oldWndProc; }
void OS2SetOldWndProc(WXFARPROC proc) { m_oldWndProc = proc; }
WXFARPROC OS2GetOldWndProc(void) const { return m_fnOldWndProc; }
void OS2SetOldWndProc(WXFARPROC fnProc) { m_fnOldWndProc = fnProc; }
wxWindow *FindItem(long id) const;
wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const;
wxWindow* FindItem(long lId) const;
wxWindow* FindItemByHWND( WXHWND hWnd
,bool bControlOnly = FALSE
) const;
// Make a Windows extended style from the given wxWindows window style
static WXDWORD MakeExtendedStyle(long style,
bool eliminateBorders = TRUE);
// Make a Windows extended style from the given wxWindows window style ?? applicable to OS/2??
static WXDWORD MakeExtendedStyle( long lStyle
,bool bEliminateBorders = TRUE
);
// 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; };
// returns TRUE if the window has been created
bool OS2Create(int id,
wxWindow *parent,
const wxChar *wclass,
wxWindow *wx_win,
const wxChar *title,
int x, int y, int width, int height,
WXDWORD style,
const wxChar *dialog_template = NULL,
WXDWORD exendedStyle = 0);
virtual bool OS2Command(WXUINT param, WXWORD id);
bool OS2Create( int nId
,wxWindow* pParent
,const wxChar* zWclass
,wxWindow* pWxWin
,const wxChar* zTitle
,int nX
,int nY
,int nWidth
,int nHeight
,WXDWORD dwStyle
,const wxChar* zDialogTemplate = NULL
,WXDWORD dwExendedStyle = 0
);
virtual bool OS2Command( WXUINT uParam
,WXWORD nId
);
#if WXWIN_COMPATIBILITY
wxObject *GetChild(int number) const;
virtual void OS2DeviceToLogical(float *x, float *y) const;
wxObject* GetChild(int nNumber) const;
virtual void OS2DeviceToLogical( float* pfX
,float* pfY
) const;
#endif // WXWIN_COMPATIBILITY
// 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)
virtual void AdoptAttributesFromHWND();
virtual void AdoptAttributesFromHWND(void);
// Setup background and foreground colours correctly
virtual void SetupColours();
virtual void SetupColours(void);
// ------------------------------------------------------------------------
// helpers for message handlers: these perform the same function as the
@ -236,144 +286,211 @@ public:
// the correct parameters
// ------------------------------------------------------------------------
void UnpackCommand(WXWPARAM wParam, WXLPARAM lParam,
WXWORD *id, WXHWND *hwnd, WXWORD *cmd);
void UnpackActivate(WXWPARAM wParam, WXLPARAM lParam,
WXWORD *state, WXWORD *minimized, WXHWND *hwnd);
void UnpackScroll(WXWPARAM wParam, WXLPARAM lParam,
WXWORD *code, WXWORD *pos, WXHWND *hwnd);
void UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd);
void UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
WXWORD *item, WXWORD *flags, WXHMENU *hmenu);
void UnpackCommand( WXWPARAM wParam
,WXLPARAM lParam,
WXWORD* pId
,WXHWND* pHwnd
,WXWORD* pCmd
);
void UnpackActivate( WXWPARAM wParam
,WXLPARAM lParam
,WXWORD* pState
,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
// ------------------------------------------------------------------------
// 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
// 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
// MSWWindowProc() directly.
// OS2WindowProc() directly.
// scroll event (both horizontal and vertical)
virtual bool OS2OnScroll(int orientation, WXWORD nSBCode,
WXWORD pos, WXHWND control);
virtual bool OS2OnScroll( int nOrientation
,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
virtual bool OS2OnDrawItem(int id, WXDRAWITEMSTRUCT *item);
virtual bool OS2OnMeasureItem(int id, WXMEASUREITEMSTRUCT *item);
virtual bool OS2OnDrawItem( int nId
,WXDRAWITEMSTRUCT* pItem
);
virtual bool OS2OnMeasureItem( int nId
,WXMEASUREITEMSTRUCT* pItem
);
// the rest are not virtual
bool HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate);
bool HandleCreate( WXLPCREATESTRUCT vCs
,bool* pMayCreate
);
bool HandleInitDialog(WXHWND hWndFocus);
bool HandleDestroy();
bool HandlePaint();
bool HandleEraseBkgnd(WXHDC pDC);
bool HandleMinimize();
bool HandleMaximize();
bool HandleSize(int x, int y, WXUINT flag);
bool HandleGetMinMaxInfo(void *mmInfo);
bool HandleShow(bool show, int status);
bool HandleActivate(int flag, bool minimized, WXHWND activate);
bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
bool HandleSysCommand(WXWPARAM wParam, WXLPARAM lParam);
bool HandleCtlColor(WXHBRUSH *hBrush,
WXHDC hdc,
WXHWND hWnd,
WXUINT nCtlColor,
WXUINT message,
WXWPARAM wParam,
WXLPARAM lParam);
bool HandleDestroy(void);
bool HandlePaint(void);
bool HandleEraseBkgnd(WXHDC vDC);
bool HandleMinimize(void);
bool HandleMaximize(void);
bool HandleSize( int nX
,int nY
,WXUINT uFlag
);
bool HandleGetMinMaxInfo(void* pMmInfo);
bool HandleShow( bool bShow
,int nStatus
);
bool HandleActivate( int nFlag
,bool bMinimized
,WXHWND hActivate
);
bool HandleCommand( WXWORD nId
,WXWORD nCmd
,WXHWND hControl
);
bool HandleSysCommand( WXWPARAM wParam
,WXLPARAM lParam
);
bool HandleCtlColor( WXHBRUSH* phBrush
,WXHDC hDc
,WXHWND hWnd
,WXUINT uCtlColor
,WXUINT uMessage
,WXWPARAM wParam
,WXLPARAM lParam
);
bool HandlePaletteChanged(WXHWND hWndPalChange);
bool HandleQueryNewPalette();
bool HandleSysColorChange();
bool HandleQueryEndSession(long logOff, bool *mayEnd);
bool HandleEndSession(bool endSession, long logOff);
bool HandleSetFocus(WXHWND wnd);
bool HandleKillFocus(WXHWND wnd);
bool HandleQueryNewPalette(void);
bool HandleSysColorChange(void);
bool HandleQueryEndSession( long lLogOff
,bool* pbMayEnd
);
bool HandleEndSession( bool bEndSession
,long lLogOff
);
bool HandleSetFocus(WXHWND hWnd);
bool HandleKillFocus(WXHWND hWnd);
bool HandleDropFiles(WXWPARAM wParam);
bool HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags);
bool HandleMouseMove(int x, int y, WXUINT flags);
bool HandleChar(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE);
bool HandleKeyDown(WXWORD wParam, WXLPARAM lParam);
bool HandleKeyUp(WXWORD wParam, WXLPARAM lParam);
bool HandleQueryDragIcon(WXHICON *hIcon);
bool HandleSetCursor(WXHWND hWnd, short nHitTest, int mouseMsg);
bool HandleMouseEvent( WXUINT uMsg
,int nX
,int nY
,WXUINT uFlags
);
bool HandleMouseMove( int nX
,int nY
,WXUINT uFlags
);
bool HandleChar( WXWORD wParam
,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
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
virtual MRESULT OS2DefWindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
virtual MRESULT OS2DefWindowProc( HWND hwnd
,WXUINT uMsg
,WXWPARAM wParam
,WXLPARAM lParam
);
virtual bool OS2ProcessMessage(WXMSG* pMsg);
virtual bool OS2TranslateMessage(WXMSG* pMsg);
virtual void OS2DestroyWindow();
virtual void OS2DestroyWindow(void);
// 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
// with or 0 for the default brush
virtual WXHBRUSH OnCtlColor(WXHDC hDC,
WXHWND hWnd,
WXUINT nCtlColor,
WXUINT message,
WXWPARAM wParam,
WXLPARAM lParam);
virtual WXHBRUSH OnCtlColor( WXHDC hDC
,WXHWND hWnd
,WXUINT uCtlColor
,WXUINT uMessage
,WXWPARAM wParam
,WXLPARAM lParam
);
#if WXWIN_COMPATIBILITY
void SetShowing(bool show) { (void)Show(show); }
bool IsUserEnabled() const { return IsEnabled(); }
void SetShowing(bool bShow) { (void)Show(show); }
bool IsUserEnabled(void) const { return IsEnabled(); }
#endif // WXWIN_COMPATIBILITY
// 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)
void InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags);
// initialize various fields of wxMouseEvent (common part of OS2OnMouseXXX)
void InitMouseEvent( wxMouseEvent& rEvent
,int nX
,int nY
,WXUINT uFlags
);
protected:
// the window handle
WXHWND m_hWnd;
// the old window proc (we subclass all windows)
WXFARPROC m_oldWndProc;
WXFARPROC m_fnOldWndProc;
// additional (MSW specific) flags
bool m_useCtl3D:1; // Using CTL3D for this control
bool m_backgroundTransparent:1;
bool m_mouseInWindow:1;
bool m_doubleClickAllowed:1;
bool m_winCaptured:1;
bool m_bUseCtl3D:1; // Using CTL3D for this control
bool m_bBackgroundTransparent:1;
bool m_bMouseInWindow:1;
bool m_bDoubleClickAllowed:1;
bool m_bWinCaptured:1;
// the size of one page for scrolling
int m_xThumbSize;
int m_yThumbSize;
int m_nXThumbSize;
int m_nYThumbSize;
#if wxUSE_MOUSEEVENT_HACK
// the coordinates of the last mouse event and the type of it
long m_lastMouseX,
m_lastMouseY;
int m_lastMouseEvent;
long m_lLastMouseX,
long m_lLastMouseY;
int m_nLastMouseEvent;
#endif // wxUSE_MOUSEEVENT_HACK
WXHMENU m_hMenu; // Menu, if any
@ -382,45 +499,73 @@ protected:
long m_lDlgCode;
// implement the base class pure virtuals
virtual void DoClientToScreen( int *x, int *y ) const;
virtual void DoScreenToClient( int *x, int *y ) const;
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);
virtual void DoClientToScreen( int* pX
,int* pY
) const;
virtual void DoScreenToClient( int* pX
,int* pY
) const;
virtual void DoGetPosition( int* pX
,int* pY
) 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
// 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
// from both DoSetSize() and DoSetClientSize() and would usually just call
// ::MoveWindow() except for composite controls which will want to arrange
// 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
virtual void DoSetToolTip( wxToolTip *tip );
virtual void DoSetToolTip(wxToolTip* pTip);
#endif // wxUSE_TOOLTIPS
private:
// common part of all ctors
void Init();
void Init(void);
// the (non-virtual) handlers for the events
bool HandleMove(int x, int y);
bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags);
bool HandleMove( int nX
,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_EVENT_TABLE()
private:
// Virtual function hiding supression
inline virtual bool Reparent( wxWindowBase *newParent )
{ return(wxWindowBase::Reparent(newParent));};
inline virtual bool Reparent(wxWindowBase* pNewParent)
{ return(wxWindowBase::Reparent(pNewParent));};
};
// ---------------------------------------------------------------------------
@ -428,7 +573,9 @@ private:
// ---------------------------------------------------------------------------
// kbd code translation
WXDLLEXPORT int wxCharCodeOS2ToWX(int keySym);
WXDLLEXPORT int wxCharCodeWXToOS2(int id, bool *IsVirtual);
WXDLLEXPORT int wxCharCodeOS2ToWX(int nKeySym);
WXDLLEXPORT int wxCharCodeWXToOS2( int nId
,bool* pbIsVirtual
);
#endif
// _WX_WINDOW_H_

View File

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