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.

74 lines
1.7 KiB

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