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.

121 lines
2.2 KiB

  1. //
  2. // mxToolKit (c) 1999 by Mete Ciragan
  3. //
  4. // file: mxMenuBar.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 "mxtk/mxMenuBar.h"
  15. #include <windows.h>
  16. #include <string.h>
  17. class mxMenuBar_i
  18. {
  19. public:
  20. int dummy;
  21. };
  22. mxMenuBar::mxMenuBar (mxWindow *parent)
  23. : mxWidget (0, 0, 0, 0, 0)
  24. {
  25. void *handle = (void *) CreateMenu ();
  26. setHandle (handle);
  27. setType (MX_MENUBAR);
  28. setParent (parent);
  29. if (parent)
  30. {
  31. mxWidget *w = (mxWidget *) parent;
  32. SetMenu ((HWND) w->getHandle (), (HMENU) handle);
  33. }
  34. }
  35. mxMenuBar::~mxMenuBar ()
  36. {
  37. }
  38. void
  39. mxMenuBar::addMenu (const char *item, mxMenu *menu)
  40. {
  41. AppendMenu ((HMENU) getHandle (), MF_POPUP, (UINT) ((mxWidget *) menu)->getHandle (), item);
  42. }
  43. void
  44. mxMenuBar::setEnabled (int id, bool b)
  45. {
  46. EnableMenuItem ((HMENU) getHandle (), (UINT) id, MF_BYCOMMAND | (b ? MF_ENABLED:MF_GRAYED));
  47. }
  48. void
  49. mxMenuBar::setChecked (int id, bool b)
  50. {
  51. CheckMenuItem ((HMENU) getHandle (), (UINT) id, MF_BYCOMMAND | (b ? MF_CHECKED:MF_UNCHECKED));
  52. }
  53. void
  54. mxMenuBar::modify (int id, int newId, const char *newItem)
  55. {
  56. ModifyMenu ((HMENU) getHandle (), (UINT) id, MF_BYCOMMAND | MF_STRING, (UINT) newId, (LPCTSTR) newItem);
  57. }
  58. bool
  59. mxMenuBar::isEnabled (int id) const
  60. {
  61. MENUITEMINFO mii;
  62. memset (&mii, 0, sizeof (mii));
  63. mii.cbSize = sizeof (mii);
  64. mii.fMask = MIIM_STATE;
  65. GetMenuItemInfo ((HMENU) getHandle (), (UINT) id, false, &mii);
  66. if (mii.fState & MFS_GRAYED)
  67. return true;
  68. return false;
  69. }
  70. bool
  71. mxMenuBar::isChecked (int id) const
  72. {
  73. MENUITEMINFO mii;
  74. memset (&mii, 0, sizeof (mii));
  75. mii.cbSize = sizeof (mii);
  76. mii.fMask = MIIM_STATE;
  77. GetMenuItemInfo ((HMENU) getHandle (), (UINT) id, false, &mii);
  78. if (mii.fState & MFS_CHECKED)
  79. return true;
  80. return false;
  81. }
  82. int
  83. mxMenuBar::getHeight () const
  84. {
  85. return 0;
  86. }