combobox.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #ifndef __COMBOBOX_H
  2. #define __COMBOBOX_H
  3. #include <api/skin/widgets/dropdownlist.h>
  4. #include <api/script/objects/c_script/h_edit.h>
  5. #include <api/script/objects/c_script/c_edit.h>
  6. #define COMBOBOX_PARENT DropDownList
  7. class XmlObject;
  8. class HEBKeysCallback;
  9. class ComboBox : public COMBOBOX_PARENT {
  10. public:
  11. ComboBox();
  12. virtual ~ComboBox();
  13. virtual int wantTrapButton() { return 1; }
  14. virtual int wantTrapText() { return 0; }
  15. virtual int wantTrapEdit() { return 1; }
  16. virtual void abstract_onNewContent();
  17. virtual void trapControls();
  18. virtual const wchar_t *dropdownlist_getMainGroupId() { return L"wasabi.combobox.main.group"; }
  19. virtual const wchar_t *dropdownlist_getListGroupId() { return L"wasabi.combobox.list.group"; }
  20. virtual const wchar_t *dropdownlist_getButtonId() { return L"combobox.button"; }
  21. virtual const wchar_t *dropdownlist_getListId() { return L"combobox.list"; }
  22. virtual const wchar_t *combobox_getEditId() { return L"combobox.edit"; }
  23. virtual const wchar_t *embeddedxui_getEmbeddedObjectId() { return combobox_getEditId(); }
  24. virtual void dropdownlist_onCloseList();
  25. virtual void dropdownlist_onOpenList();
  26. virtual void setText(const wchar_t *text, int hover=0); // use this to set the content of the edit box
  27. virtual const wchar_t *getText(int fromcontrol=0); // use this one to ask for the currently displayed entry
  28. virtual const wchar_t *getCustomText() { return NULL; }
  29. virtual void dropdownlist_onConfigureList(GuiObject *o);
  30. virtual void onSelect(int id, int hover);
  31. virtual void enter();
  32. void selectEditor();
  33. virtual int onAction(const wchar_t *action, const wchar_t *param=NULL, int x=-1, int y=-1, intptr_t p1=0, intptr_t p2=0, void *data=NULL, size_t datalen=0, ifc_window *source=NULL);
  34. virtual void onEditKeyDown(int vk);
  35. virtual void onEditKeyUp(int vk);
  36. virtual void onEditEnter(const wchar_t *txt);
  37. virtual void onEditChar(int c);
  38. virtual int wantTransferDownToList() { return 1; }
  39. virtual int wantTransferUpToList() { return 1; }
  40. virtual int wantTransferHomeToList() { return 1; }
  41. virtual int wantTransferEndToList() { return 1; }
  42. virtual int wantTransferPgUpToList() { return 1; }
  43. virtual int wantTransferPgDnToList() { return 1; }
  44. virtual int wantTransferEnterToList() { return 1; }
  45. virtual int wantDownOpenList() { return 1; }
  46. virtual int wantCloseListOnChar() { return 1; }
  47. virtual int wantEnterOnSelect() { return 1; }
  48. virtual void listDown();
  49. virtual void listUp();
  50. virtual void listHome();
  51. virtual void listEnd();
  52. virtual void listPageDown();
  53. virtual void listPageUp();
  54. virtual void listSelect();
  55. virtual void onPreCloseList();
  56. private:
  57. virtual void updateTextInControl(const wchar_t *text);
  58. HEBKeysCallback *keys_edit;
  59. GuiObject *lastlist;
  60. StringW curtxt;
  61. int savedidle, savedautoenter;
  62. int disable_getselection;
  63. };
  64. class HEBKeysCallback : public H_Edit {
  65. public:
  66. HEBKeysCallback(ScriptObject *trap, ComboBox *_callback) :
  67. callback(_callback), H_Edit(trap), o(trap) {
  68. }
  69. virtual void hook_onKeyDown(int vk) {
  70. callback->onEditKeyDown(vk);
  71. }
  72. virtual void hook_onKeyUp(int vk) {
  73. callback->onEditKeyUp(vk);
  74. }
  75. virtual void hook_onEnter()
  76. {
  77. C_Edit e(o);
  78. callback->onEditEnter(e.getText());
  79. }
  80. virtual void hook_onChar(wchar_t c) {
  81. callback->onEditChar(c);
  82. }
  83. private:
  84. ComboBox *callback;
  85. ScriptObject *o;
  86. };
  87. #endif