Team Fortress 2 Source Code as on 22/4/2020
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.

69 lines
1.7 KiB

  1. //
  2. // mxToolKit (c) 1999 by Mete Ciragan
  3. //
  4. // file: mxToggleButton.cpp
  5. // implementation: Win32 API
  6. // last modified: Apr 28 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 <mx/mxToggleButton.h>
  15. #include <windows.h>
  16. class mxToggleButton_i
  17. {
  18. public:
  19. int dummy;
  20. };
  21. mxToggleButton::mxToggleButton (mxWindow *parent, int x, int y, int w, int h, const char *label, int id)
  22. : mxWidget (parent, x, y, w, h, label)
  23. {
  24. if (!parent)
  25. return;
  26. HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();
  27. void *handle = (void *) CreateWindowEx (0, "BUTTON", label, WS_VISIBLE | WS_CHILD | BS_PUSHLIKE | BS_AUTOCHECKBOX | WS_TABSTOP,
  28. x, y, w, h, hwndParent,
  29. (HMENU) id, (HINSTANCE) GetModuleHandle (NULL), NULL);
  30. SendMessage ((HWND) handle, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0));
  31. SetWindowLong ((HWND) handle, GWL_USERDATA, (LONG) this);
  32. setHandle (handle);
  33. setType (MX_TOGGLEBUTTON);
  34. setParent (parent);
  35. setId (id);
  36. setChecked (false);
  37. }
  38. mxToggleButton::~mxToggleButton ()
  39. {
  40. }
  41. void
  42. mxToggleButton::setChecked (bool b)
  43. {
  44. SendMessage ((HWND) getHandle (), BM_SETCHECK, (WPARAM) b ? BST_CHECKED:BST_UNCHECKED, 0L);
  45. }
  46. bool
  47. mxToggleButton::isChecked () const
  48. {
  49. return (SendMessage ((HWND) getHandle (), BM_GETCHECK, 0, 0L) == BST_CHECKED);
  50. }