diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/mxtk/mxscrollbar.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'utils/mxtk/mxscrollbar.cpp')
| -rw-r--r-- | utils/mxtk/mxscrollbar.cpp | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/utils/mxtk/mxscrollbar.cpp b/utils/mxtk/mxscrollbar.cpp new file mode 100644 index 0000000..ae10bc2 --- /dev/null +++ b/utils/mxtk/mxscrollbar.cpp @@ -0,0 +1,134 @@ +// +// mxToolKit (c) 1999 by Mete Ciragan +// +// file: mxScrollbar.cpp +// implementation: Win32 API +// last modified: Mar 18 1999, Mete Ciragan +// copyright: The programs and associated files contained in this +// distribution were developed by Mete Ciragan. The programs +// are not in the public domain, but they are freely +// distributable without licensing fees. These programs are +// provided without guarantee or warrantee expressed or +// implied. +// +#include "mxtk/mxScrollbar.h" +#include <windows.h> +#include <commctrl.h> + + + +class mxScrollbar_i +{ +public: + int dummy; +}; + + + +mxScrollbar::mxScrollbar (mxWindow *parent, int x, int y, int w, int h, int id, int style) +: mxWidget (parent, x, y, w, h) +{ + if (!parent) + return; + + DWORD dwStyle = WS_CHILD | WS_VISIBLE; + HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle (); + + if (style == Horizontal) + dwStyle = WS_CHILD | WS_VISIBLE | SBS_HORZ | SBS_RIGHTALIGN; + else if (style == Vertical) + dwStyle = WS_CHILD | WS_VISIBLE | SBS_VERT | SBS_RIGHTALIGN; // WS_VSCROLL; + + void *handle = (void *) CreateWindowEx (0, "SCROLLBAR", "", dwStyle, + x, y, w, h, hwndParent, + (HMENU) id, (HINSTANCE) GetModuleHandle (NULL), NULL); + + SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0)); + SetWindowLong ((HWND) handle, GWL_USERDATA, (LONG) this); + + setHandle (handle); + setType (MX_SCROLLBAR); + setParent (parent); + setId (id); +} + + + +mxScrollbar::~mxScrollbar () +{ +} + + + +void +mxScrollbar::setValue (int ivalue) +{ + SetScrollPos( (HWND) getHandle (), SB_CTL, ivalue, FALSE ); +} + + + +void +mxScrollbar::setRange (int min, int max ) +{ + SCROLLINFO si = { sizeof( SCROLLINFO ), SIF_RANGE, min, max, 0, 0, 0 }; + + SetScrollInfo( (HWND) getHandle (), SB_CTL, &si, TRUE ); +} + + + +void +mxScrollbar::setPagesize (int size) +{ + SCROLLINFO si = { sizeof( SCROLLINFO ), SIF_PAGE, 0, 0, (UINT)size, 0, 0 }; + + SetScrollInfo( (HWND) getHandle (), SB_CTL, &si, TRUE ); +} + + + +int +mxScrollbar::getValue () const +{ + // SCROLLINFO si = { sizeof( SCROLLINFO ), SIF_POS | SIF_TRACKPOS, 0, 0, 0, 0, 0 }; + // GetScrollInfo( (HWND) getHandle (), SB_CTL, &si ); + // return si.nPos; + return GetScrollPos( (HWND) getHandle (), SB_CTL ); +} + + + +int +mxScrollbar::getMinValue () const +{ + SCROLLINFO si = { sizeof( SCROLLINFO ), SIF_RANGE, 0, 0, 0, 0, 0 }; + + GetScrollInfo( (HWND) getHandle (), SB_CTL, &si ); + + return si.nMin; +} + + + +int +mxScrollbar::getMaxValue () const +{ + SCROLLINFO si = { sizeof( SCROLLINFO ), SIF_RANGE, 0, 0, 0, 0, 0 }; + + GetScrollInfo( (HWND) getHandle (), SB_CTL, &si ); + + return si.nMax; +} + + + +int +mxScrollbar::getPagesize () const +{ + SCROLLINFO si = { sizeof( SCROLLINFO ), SIF_PAGE, 0, 0, 0, 0, 0 }; + + GetScrollInfo( (HWND) getHandle (), SB_CTL, &si ); + + return si.nPage; +} |