| 1 | ///////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: scrollbar.h |
| 3 | // Purpose: wxScrollBar class |
| 4 | // Author: David Webster |
| 5 | // Modified by: |
| 6 | // Created: 10/15/99 |
| 7 | // RCS-ID: $Id$ |
| 8 | // Copyright: (c) David Webster |
| 9 | // Licence: wxWindows licence |
| 10 | ///////////////////////////////////////////////////////////////////////////// |
| 11 | |
| 12 | #ifndef _WX_SCROLBAR_H_ |
| 13 | #define _WX_SCROLBAR_H_ |
| 14 | |
| 15 | #include "wx/control.h" |
| 16 | |
| 17 | WXDLLEXPORT_DATA(extern const char*) wxScrollBarNameStr; |
| 18 | |
| 19 | // Scrollbar item |
| 20 | class WXDLLEXPORT wxScrollBar: public wxControl |
| 21 | { |
| 22 | DECLARE_DYNAMIC_CLASS(wxScrollBar) |
| 23 | |
| 24 | public: |
| 25 | inline wxScrollBar() { m_pageSize = 0; m_viewSize = 0; m_objectSize = 0; } |
| 26 | ~wxScrollBar(); |
| 27 | |
| 28 | inline wxScrollBar(wxWindow *parent, wxWindowID id, |
| 29 | const wxPoint& pos = wxDefaultPosition, |
| 30 | const wxSize& size = wxDefaultSize, |
| 31 | long style = wxSB_HORIZONTAL, |
| 32 | #if wxUSE_VALIDATORS |
| 33 | const wxValidator& validator = wxDefaultValidator, |
| 34 | #endif |
| 35 | const wxString& name = wxScrollBarNameStr) |
| 36 | { |
| 37 | Create(parent, id, pos, size, style, validator, name); |
| 38 | } |
| 39 | bool Create(wxWindow *parent, wxWindowID id, |
| 40 | const wxPoint& pos = wxDefaultPosition, |
| 41 | const wxSize& size = wxDefaultSize, |
| 42 | long style = wxSB_HORIZONTAL, |
| 43 | #if wxUSE_VALIDATORS |
| 44 | const wxValidator& validator = wxDefaultValidator, |
| 45 | #endif |
| 46 | const wxString& name = wxScrollBarNameStr); |
| 47 | |
| 48 | int GetThumbPosition() const ; |
| 49 | inline int GetThumbSize() const { return m_pageSize; } |
| 50 | inline int GetPageSize() const { return m_viewSize; } |
| 51 | inline int GetRange() const { return m_objectSize; } |
| 52 | |
| 53 | virtual void SetThumbPosition(int viewStart); |
| 54 | virtual void SetScrollbar(int position, int thumbSize, int range, int pageSize, |
| 55 | bool refresh = TRUE); |
| 56 | |
| 57 | #if WXWIN_COMPATIBILITY |
| 58 | // Backward compatibility |
| 59 | int GetValue() const { return GetThumbPosition(); } |
| 60 | void SetValue(int viewStart) { SetThumbPosition(viewStart); } |
| 61 | void GetValues(int *viewStart, int *viewLength, int *objectLength, |
| 62 | int *pageLength) const ; |
| 63 | int GetViewLength() const { return m_viewSize; } |
| 64 | int GetObjectLength() const { return m_objectSize; } |
| 65 | |
| 66 | void SetPageSize(int pageLength); |
| 67 | void SetObjectLength(int objectLength); |
| 68 | void SetViewLength(int viewLength); |
| 69 | #endif |
| 70 | |
| 71 | void Command(wxCommandEvent& event); |
| 72 | |
| 73 | virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, |
| 74 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam); |
| 75 | virtual bool OS2OnScroll(int orientation, WXWORD wParam, |
| 76 | WXWORD pos, WXHWND control); |
| 77 | |
| 78 | #if WXWIN_COMPATIBILITY |
| 79 | // Backward compatibility: generate an old-style scroll command |
| 80 | void OnScroll(wxScrollEvent& event); |
| 81 | #endif // WXWIN_COMPATIBILITY |
| 82 | |
| 83 | protected: |
| 84 | int m_pageSize; |
| 85 | int m_viewSize; |
| 86 | int m_objectSize; |
| 87 | |
| 88 | DECLARE_EVENT_TABLE() |
| 89 | }; |
| 90 | |
| 91 | #endif |
| 92 | // _WX_SCROLBAR_H_ |