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.

113 lines
2.2 KiB

  1. //
  2. // mxToolKit (c) 1999 by Mete Ciragan
  3. //
  4. // file: mxWindow.cpp
  5. // implementation: Win32 API
  6. // last modified: Apr 12 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/mxWindow.h"
  15. #include <windows.h>
  16. extern mxWindow *g_mainWindow;
  17. class mxWindow_i
  18. {
  19. public:
  20. UINT d_uTimer;
  21. };
  22. mxWindow::mxWindow (mxWindow *parent, int x, int y, int w, int h, const char *label, int style)
  23. : mxWidget (parent, x, y, w, h, label)
  24. {
  25. d_this = new mxWindow_i;
  26. d_this->d_uTimer = 0;
  27. DWORD dwStyle = 0;
  28. if (style == Normal)
  29. dwStyle = WS_OVERLAPPEDWINDOW;
  30. else if (style == Popup)
  31. dwStyle = WS_POPUP;
  32. else if (style == Dialog || style == ModalDialog)
  33. dwStyle = WS_CAPTION | WS_SYSMENU;
  34. void *parentHandle = 0;
  35. if (parent)
  36. {
  37. parentHandle = parent->getHandle ();
  38. dwStyle = WS_CHILD | WS_VISIBLE;
  39. }
  40. void *handle = (void *) CreateWindowEx (0, "mx_class", label, dwStyle,
  41. x, y, w, h, (HWND) parentHandle,
  42. (HMENU) NULL, (HINSTANCE) GetModuleHandle (NULL), NULL);
  43. SetWindowLong ((HWND) handle, GWL_USERDATA, reinterpret_cast< LONG >( this ) );
  44. setHandle (handle);
  45. setType (MX_WINDOW);
  46. setParent (parent);
  47. //setLabel (label);
  48. //setBounds (x, y, w, h);
  49. if (!parent && !g_mainWindow)
  50. g_mainWindow = this;
  51. }
  52. mxWindow::~mxWindow ()
  53. {
  54. SetWindowLong ((HWND) (HWND) getHandle(), GWL_USERDATA, (LONG) 0 );
  55. delete d_this;
  56. }
  57. int
  58. mxWindow::handleEvent (mxEvent * /*event*/ )
  59. {
  60. return 0;
  61. }
  62. void
  63. mxWindow::redraw ()
  64. {
  65. }
  66. void
  67. mxWindow::setTimer (int milliSeconds)
  68. {
  69. if (d_this->d_uTimer)
  70. {
  71. KillTimer ((HWND) getHandle (), d_this->d_uTimer);
  72. d_this->d_uTimer = 0;
  73. }
  74. if (milliSeconds > 0)
  75. {
  76. d_this->d_uTimer = 21001;
  77. d_this->d_uTimer = (UINT)SetTimer ((HWND) getHandle (), d_this->d_uTimer, milliSeconds, NULL);
  78. }
  79. }
  80. void
  81. mxWindow::setMenuBar (mxMenuBar *menuBar)
  82. {
  83. SetMenu ((HWND) getHandle (), (HMENU) ((mxWidget *) menuBar)->getHandle ());
  84. }