Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
1.8 KiB

  1. //
  2. // mxToolKit (c) 1999 by Mete Ciragan
  3. //
  4. // file: mxProgressBar.cpp
  5. // implementation: Win32 API
  6. // last modified: Mar 18 1999, Mete Ciragan
  7. // copyright: The programs and associated files contained in this
  8. // distribution were developed by Mete Ciragan. The programs
  9. // are not in the public domain, but they are freely
  10. // distributable without licensing fees. These programs are
  11. // provided without guarantee or warrantee expressed or
  12. // implied.
  13. //
  14. #include "mxtk/mxProgressBar.h"
  15. #include <windows.h>
  16. #include <commctrl.h>
  17. class mxProgressBar_i
  18. {
  19. public:
  20. int d_value;
  21. int d_steps;
  22. };
  23. mxProgressBar::mxProgressBar (mxWindow *parent, int x, int y, int w, int h, int style)
  24. : mxWidget (parent, x, y, w, h)
  25. {
  26. d_this = new mxProgressBar_i;
  27. DWORD dwStyle = WS_VISIBLE | WS_CHILD;
  28. HWND hwndParent = parent ? (HWND) ((mxWidget *) parent)->getHandle () : NULL;
  29. if (style == Smooth)
  30. dwStyle |= PBS_SMOOTH;
  31. void *handle = (void *) CreateWindowEx (0, PROGRESS_CLASS, "", dwStyle,
  32. x, y, w, h, hwndParent,
  33. (HMENU) NULL, (HINSTANCE) GetModuleHandle (NULL), NULL);
  34. SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
  35. setHandle (handle);
  36. setType (MX_PROGRESSBAR);
  37. setParent (parent);
  38. }
  39. mxProgressBar::~mxProgressBar ()
  40. {
  41. delete d_this;
  42. }
  43. void
  44. mxProgressBar::setValue (int value)
  45. {
  46. d_this->d_value = value;
  47. SendMessage ((HWND) getHandle (), PBM_SETPOS, (WPARAM) value, 0L);
  48. }
  49. void
  50. mxProgressBar::setTotalSteps (int steps)
  51. {
  52. d_this->d_steps = steps;
  53. SendMessage ((HWND) getHandle (), PBM_SETRANGE, 0, MAKELPARAM (0, steps));
  54. }
  55. int
  56. mxProgressBar::getValue () const
  57. {
  58. return d_this->d_value;
  59. }
  60. int
  61. mxProgressBar::getTotalSteps () const
  62. {
  63. return d_this->d_steps;
  64. }