00001 #ifndef __CTextEdit__
00002 #define __CTextEdit__
00003
00005 #ifdef WIN32
00006 #pragma warning(disable : 4311) // pointer truncation from 'Exponent::GUI::Controls::CTextEdit *const ' to 'long'
00007 #pragma warning(disable : 4312) // conversion from 'LONG' to 'Exponent::GUI::Controls::CTextEdit *' of greater size
00008 #endif
00009
00011 #include "CTextLabel.hpp"
00012 #include "../Basics/CColour.hpp"
00013 #include "../Listeners/IActionListener.hpp"
00014
00015
00016
00017 using Exponent::GUI::Basics::CColour;
00018 using Exponent::GUI::Controls::CTextLabel;
00019 using Exponent::GUI::Listeners::IActionListener;
00020
00021
00022
00023 namespace Exponent
00024 {
00025 namespace GUI
00026 {
00027 namespace Controls
00028 {
00046 class CTextEdit : public CTextLabel, public IActionListener
00047 {
00049 EXPONENT_CLASS_DECLARATION;
00052
00053
00054 public:
00055
00056
00057
00062 enum ETextEditAlignment
00063 {
00065 #ifdef WIN32
00066 e_center = ES_CENTER,
00067 e_left = ES_LEFT,
00068 e_right = ES_RIGHT,
00069 #else
00070
00071 e_center = 0,
00072 e_left,
00073 e_right
00075 #endif
00076
00077 };
00078
00079
00080
00089 CTextEdit(IControlRoot *root, const long uniqueId, const CRect &area, const CString &text, IActionListener *listener = NULL);
00090
00094 virtual ~CTextEdit();
00095
00096
00097
00102 virtual void handleLeftButtonDown(CMouseEvent &event);
00103
00108 virtual void handleDoubleClick(CMouseEvent &event);
00109
00114 virtual void handleActionEvent(const CActionEvent &event);
00115
00121 virtual void limitText(const bool limitText = false, const long textLimit = 256);
00122
00127 virtual void setAlignment(const ETextEditAlignment alignment) { m_alignment = alignment; }
00128
00134 virtual void setEditable(const bool editable = true) { m_isEditable = editable; }
00135
00140 virtual void setSingleClickEditable(const bool editable = true) { m_singleClickEdit = editable; }
00141
00146 virtual const CString &getString() const { return m_text; }
00147
00149 #ifdef WIN32
00150
00157 LRESULT setEditWindowDrawConditions(HDC drawContext);
00158
00160 #else
00161
00167 virtual TXNObject getTxnHandle() const { return m_txnHandle; }
00168
00174 virtual void cancelCall(const bool cancel) { m_cancel = cancel; }
00175
00180 virtual void drawControl(CGraphics &graphics);
00182 #endif
00183
00185
00186
00187 protected:
00188
00189
00190
00192 #ifdef WIN32
00193
00203 static LONG WINAPI windowProcTextEdit(HWND windowHandle, UINT message, WPARAM wParam, LPARAM lParam);
00205 #else
00206
00215 static pascal OSStatus windowProcTextEdit(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData);
00217 #endif
00218
00224 void launchEdit(CMouseEvent &event);
00225
00226
00227
00229 #ifdef WIN32
00230
00231 HWND m_editWindowHandle;
00232 static WNDPROC m_lastWinProc;
00233 IControl *m_previouslyLockedControl;
00234 CBrush m_brush;
00236 #else
00237
00238 TXNObject m_txnHandle;
00239 EventHandlerRef m_textEditEventHandler;
00240 bool m_cancel;
00242 #endif
00243
00245 bool m_limitText;
00246 long m_textLimit;
00247 ETextEditAlignment m_alignment;
00248 bool m_isEditable;
00249 bool m_singleClickEdit;
00250 };
00251 }
00252 }
00253 }
00254 #endif // End of CTextEdit.hpp