editwnd.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. //NONPORTABLE
  2. #ifndef _EDITWND_H
  3. #define _EDITWND_H
  4. #include <api/wnd/wndclass/guiobjwnd.h>
  5. #include <tataki/color/skinclr.h>
  6. #include <api/wnd/usermsg.h>
  7. #include <bfc/common.h>
  8. #define EDITWND_PARENT GuiObjectWnd
  9. class EditWnd : public EDITWND_PARENT {
  10. public:
  11. EditWnd(wchar_t *buffer=NULL, int buflen=0);
  12. virtual ~EditWnd();
  13. virtual int onInit();
  14. virtual int onPaint(Canvas *canvas);
  15. virtual int onResize();
  16. #ifdef WIN32
  17. virtual LRESULT wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  18. #endif
  19. // mig: Made these virtual to allow to be accessed by
  20. // EditWndString object in editwndstring.h
  21. virtual void setBuffer(wchar_t *buffer, int len);
  22. virtual void getBuffer(wchar_t *outbuf, int len);
  23. virtual const wchar_t *getBufferPtr() { return outbuf; }
  24. virtual int getBufferLength() { return maxlen; }
  25. virtual void setBackgroundColor(ARGB32 c);
  26. virtual void setTextColor(ARGB32 c);
  27. void setModal(int modal); //if modal, deletes self on enter
  28. void setAutoEnter(int a); //fake an onEnter event when lose focus
  29. int getAutoEnter() { return autoenter; }
  30. void setAutoSelect(int a); //true==grab the focus on init
  31. void setIdleTimerLen(int ms); // how many ms keys are idle before send msg
  32. virtual void onSetVisible(int show);
  33. virtual int onGetFocus();
  34. virtual int wantFocus();
  35. virtual void setWantFocus(int w) { wantfocus = w; }
  36. virtual void selectAll();
  37. virtual void enter();
  38. virtual void setIdleEnabled(int i) { idleenabled = i; }
  39. virtual int getIdleEnabled() { return idleenabled; }
  40. void setBorder(int border);
  41. int getTextLength();
  42. HWND getEditWnd();
  43. virtual int handleRatio() { return 0; }
  44. virtual int getAutoSelect() { return autoselect; }
  45. void setMultiline(int ml);
  46. void setReadOnly(int ro);
  47. void setPassword(int pw);
  48. void setAutoHScroll(int hs);
  49. void setAutoVScroll(int vs);
  50. void setVScroll(int vs);
  51. int isEditorKey(int vk);
  52. virtual void invalidate();
  53. virtual int gotFocus();
  54. // the wndproc for the edit box
  55. virtual LRESULT editWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  56. protected:
  57. virtual void timerCallback(int id);
  58. // call down on these if you override them
  59. virtual void onEditUpdate();
  60. virtual void onIdleEditUpdate();
  61. virtual int onEnter(); // user hit enter.. return 1 to close window
  62. virtual int onAbort(); // user hit escape.. return 1 to close window
  63. virtual int onLoseFocus(); // different from onKillFocus() from BaseWnd!
  64. void setStyle(LONG style, int set);
  65. #ifdef LINUX
  66. virtual int onLeftButtonDown( int x, int y );
  67. virtual int onLeftButtonUp( int x, int y );
  68. virtual int onMouseMove( int x, int y );
  69. virtual int onKeyDown(int key);
  70. #endif
  71. private:
  72. #ifdef LINUX
  73. int textposFromCoord( int x, int y );
  74. #endif
  75. HWND editWnd;
  76. WNDPROC prevWndProc;
  77. int maxlen;
  78. int retcode;
  79. int idletimelen;
  80. int modal;
  81. int bordered;
  82. int autoenter;
  83. int beforefirstresize;
  84. int autoselect;
  85. int multiline;
  86. int readonly;
  87. int password;
  88. int idleenabled;
  89. int autohscroll,autovscroll,vscroll;
  90. int nextenterfaked;
  91. SkinColor backgroundcolor, textcolor, selectioncolor;
  92. #ifdef LINUX
  93. int selstart, selend;
  94. int cursorpos;
  95. int selectmode;
  96. int viewstart;
  97. #endif
  98. #ifdef WIN32
  99. HBRUSH oldbrush;
  100. #endif
  101. // Basically, we're redoing the functionality of EditWndString
  102. // (the bigger version), so we'll probably erase EditWndString
  103. // completely as an object.
  104. MemBlock<wchar_t> buffer8;
  105. wchar_t *outbuf;
  106. int wantfocus;
  107. #ifdef LINUX
  108. StringW inbuf;
  109. #endif
  110. };
  111. #define EDITWND_RETURN_NOTHING 0 // user didn't do nothing
  112. #define EDITWND_RETURN_OK 1 // user hit return
  113. #define EDITWND_RETURN_CANCEL 2 // user hit escape or something
  114. #endif