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.

101 lines
2.0 KiB

  1. //
  2. // mxToolKit (c) 1999 by Mete Ciragan
  3. //
  4. // file: mxChoice.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/mxChoice.h"
  15. #include <windows.h>
  16. class mxChoice_i
  17. {
  18. public:
  19. int dummy;
  20. };
  21. mxChoice::mxChoice (mxWindow *parent, int x, int y, int w, int h, int id)
  22. : mxWidget (parent, x, y, w, h)
  23. {
  24. if (!parent)
  25. return;
  26. HWND hwndParent = (HWND) ((mxWidget *) parent)->getHandle ();
  27. void *handle = (void *) CreateWindowEx (0, "COMBOBOX", "", WS_VISIBLE | WS_CHILD | WS_VSCROLL | CBS_DROPDOWNLIST,
  28. x, y, w, h + 500, 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_CHOICE);
  34. setParent (parent);
  35. setId (id);
  36. }
  37. mxChoice::~mxChoice ()
  38. {
  39. removeAll ();
  40. }
  41. void
  42. mxChoice::add (const char *item)
  43. {
  44. SendMessage ((HWND) getHandle (), CB_ADDSTRING, 0, (LPARAM) (LPCTSTR) item);
  45. }
  46. void
  47. mxChoice::select (int index)
  48. {
  49. SendMessage ((HWND) getHandle (), CB_SETCURSEL, (WPARAM) index, 0L);
  50. }
  51. void
  52. mxChoice::remove (int index)
  53. {
  54. SendMessage ((HWND) getHandle (), CB_DELETESTRING, (WPARAM) index, 0L);
  55. }
  56. void
  57. mxChoice::removeAll ()
  58. {
  59. SendMessage ((HWND) getHandle (), CB_RESETCONTENT, 0, 0L);
  60. }
  61. int
  62. mxChoice::getItemCount () const
  63. {
  64. return (int) SendMessage ((HWND) getHandle (), CB_GETCOUNT, 0, 0L);
  65. }
  66. int
  67. mxChoice::getSelectedIndex () const
  68. {
  69. return (int) SendMessage ((HWND) getHandle (), CB_GETCURSEL, 0, 0L);
  70. }