X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c0ed460c2e7802793d591c84f3cfdbff159c5549..f855e630cc1f05707835d796f5338de1fe68bd2f:/include/wx/msw/window.h diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index c0b172bb2f..27d739947d 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -81,6 +81,42 @@ WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr; WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize; WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition; +//----------------------------------------------------------------------------- +// wxClientData +//----------------------------------------------------------------------------- + +class wxClientData +{ +public: + wxClientData() { } + virtual ~wxClientData() { } +}; + +//----------------------------------------------------------------------------- +// wxStringClientData +//----------------------------------------------------------------------------- + +class wxStringClientData: public wxClientData +{ +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) @@ -162,39 +198,50 @@ public: // Get overall window size virtual void GetSize(int *width, int *height) const; - virtual wxSize GetSize() const { int w, h; GetSize(& w, & h); return wxSize(w, h); } - virtual wxRect GetRect() const { int w, h; int x, y; GetPosition(& x, & y); GetSize(& w, & h); return wxRect(x, y, w, h); } + wxSize GetSize() const { int w, h; GetSize(& w, & h); return wxSize(w, h); } // Get window position, relative to parent (or screen if no parent) virtual void GetPosition(int *x, int *y) const; - virtual wxPoint GetPosition() const { int x, y; GetPosition(&x, &y); return wxPoint(x, y); } + wxPoint GetPosition() const + { int x, y; GetPosition(&x, &y); return wxPoint(x, y); } + + // Get size and position + wxRect GetRect() const + { int x, y, w, h; GetPosition(& x, & y); GetSize(& w, & h); return wxRect(x, y, w, h); } // Get client (application-useable) size virtual void GetClientSize(int *width, int *height) const; - virtual wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); } + wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); } // Set overall size and position + // generic function, may be overriden in derived classes virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); - virtual void SetSize(int width, int height) { SetSize(-1, -1, width, height, wxSIZE_USE_EXISTING); } - virtual void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO) + + void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO) { SetSize(rect.x, rect.y, rect.width, rect.height, sizeFlags); } - virtual void SetSize(const wxSize& size) { SetSize(-1, -1, size.x, size.y, wxSIZE_USE_EXISTING); } + // set size only + void SetSize(int width, int height) + { SetSize(-1, -1, width, height, wxSIZE_USE_EXISTING); } + void SetSize(const wxSize& size) + { SetSize(-1, -1, size.x, size.y, wxSIZE_USE_EXISTING); } + + // set position only virtual void Move(int x, int y) { SetSize(x, y, -1, -1, wxSIZE_USE_EXISTING); } - virtual void Move(const wxPoint& pt) { SetSize(pt.x, pt.y, -1, -1, wxSIZE_USE_EXISTING); } + void Move(const wxPoint& pt) { SetSize(pt.x, pt.y, -1, -1, wxSIZE_USE_EXISTING); } // Set client size virtual void SetClientSize(int width, int height); - virtual void SetClientSize(const wxSize& sz) { SetClientSize(sz.x, sz.y); } + void SetClientSize(const wxSize& sz) { SetClientSize(sz.x, sz.y); } // Convert client to screen coordinates virtual void ClientToScreen(int *x, int *y) const; - virtual wxPoint ClientToScreen(const wxPoint& pt) 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; - virtual wxPoint ScreenToClient(const wxPoint& pt) 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 @@ -407,13 +454,15 @@ public: void OnEraseBackground(wxEraseEvent& event); void OnChar(wxKeyEvent& event); + void OnKeyDown(wxKeyEvent& event); + void OnKeyUp(wxKeyEvent& event); void OnPaint(wxPaintEvent& event); void OnIdle(wxIdleEvent& event); // Does this window want to accept keyboard focus? virtual bool AcceptsFocus() const; - virtual void PrepareDC( wxDC &dc ) {}; + virtual void PrepareDC( wxDC& WXUNUSED(dc) ) {}; public: //////////////////////////////////////////////////////////////////////// //// IMPLEMENTATION @@ -565,6 +614,8 @@ public: virtual void MSWOnMouseLeave(int x, int y, WXUINT flags); virtual void MSWOnChar(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE); + virtual void MSWOnKeyDown(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE); + virtual void MSWOnKeyUp(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE); virtual bool MSWOnActivate(int flag, bool minimized, WXHWND activate); virtual long MSWOnMDIActivate(long flag, WXHWND activate, WXHWND deactivate); @@ -714,7 +765,7 @@ 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 : NULL); } +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; }