00001
00036 #ifndef INC_MGUI_EDITBASE_H
00037 #define INC_MGUI_EDITBASE_H
00038
00039 #ifndef INC_MGUI_CTRL_H
00040 #include <mgui/ctrl.h>
00041 #endif
00042
00043 #ifndef INC_MI32_MISTRING_H
00044 #include <mi32/mistring.h>
00045 #endif
00046
00047 namespace MGUI {
00048
00049
00051 class CTRL_EDIT_BASE : public MGUI::CTRL {
00052 public:
00053
00055 enum CREATEFLAGS {
00056 CREATEFLAG_None = 0x00000000,
00057 CREATEFLAG_ReadOnly = 0x00010000,
00058 CREATEFLAG_RightAlign = 0x00020000,
00059 CREATEFLAG_Opaque = 0x00040000,
00060 CREATEFLAG_UseFixedWidthFont = 0x00080000,
00061 CREATEFLAG_WordWrap = 0x00100000,
00062 CREATEFLAG_WidthInPixels = 0x00200000,
00063 CREATEFLAG_HeightInPixels = 0x00400000,
00064 CREATEFLAG_SizeInPixels = (CREATEFLAG_WidthInPixels|CREATEFLAG_HeightInPixels),
00065 CREATEFLAG_MASK = 0xFFFF0000
00066 };
00067
00069 CTRL_EDIT_BASE (
00070 );
00071
00073 ~CTRL_EDIT_BASE (
00074 );
00075
00077 void ClearSelection (
00078 );
00079
00081 void CopySelection (
00082 );
00083
00085 void CutSelection (
00086 );
00087
00089 INT32 GetCursorPos (
00090 ) const;
00091
00094 const bool GetModify (
00095 ) const { return (m_UserEdited); }
00096
00099 void GetSelection (
00100 int& nStartChar,
00101 int& nEndChar
00102 ) const;
00103
00105 void Insert (
00106 const MISTRING& text
00107 );
00108
00110 bool HasValue (
00111 ) const;
00112
00114 void Paste (
00115 );
00116
00121 void ReplaceSelection (
00122 const MISTRING& NewText
00123 );
00124
00140 void SetANSIColor (
00141 INT32 indx,
00142 const COLOR& color
00143 );
00144
00146 void SetDelegateOnActivate (
00147 DELEGATE_VOID_NOPARMS delegate
00148 ) { m_DelegateOnActivate = delegate; }
00149
00152 void SetDelegateOnChangeValue (
00153 DELEGATE_VOID_NOPARMS delegate
00154 ) { m_DelegateOnChangeValue = delegate; }
00155
00157 void SetDelegateOnGainFocus (
00158 DELEGATE_VOID_NOPARMS delegate
00159 ) { m_DelegateOnGainFocus = delegate; }
00160
00162 void SetDelegateOnLoseFocus (
00163 DELEGATE_VOID_NOPARMS delegate
00164 ) { m_DelegateOnLoseFocus = delegate; }
00165
00168 void SetDelegateOnSelection (
00169 DELEGATE_VOID_NOPARMS delegate
00170 ) { m_DelegateOnSelection = delegate; }
00171
00174 void SetDelegateOnUserEdit (
00175 DELEGATE_VOID_NOPARMS delegate
00176 ) { m_DelegateOnUserEdit = delegate; }
00177
00180 void SetDisplayNoValue (
00181 const MISTRING& string
00182 );
00183
00185 void SetMaxLength (
00186 int length
00187 );
00188
00190 void SetModify (
00191 bool modified = true
00192 ) { m_UserEdited = modified; }
00193
00195 void SetReadOnly (
00196 bool ReadOnly = true
00197 );
00198
00201 void SetSelection (
00202 int StartChar = 0,
00203 int EndChar = -1,
00204 bool NoScroll = true
00205 );
00206
00209 void SetValidChars (
00210 const MIUNICODE* string,
00211 bool invert = false
00212 );
00213
00214 protected:
00215
00216 bool m_UserEdited;
00217 bool m_HasValue;
00218
00221 bool CheckValidChars (
00222 MISTRING& string
00223 ) const;
00224
00225 void CreateCtrl (
00226 LAYOUT_PANE_BASE& ParentPane,
00227 int width,
00228 int height,
00229 CREATEFLAGS flags,
00230 LAYOUT_SIZEALIGN sizealign
00231 );
00232
00233 bool GetEditStr (
00234 MISTRING& str
00235 ) const;
00236
00237
00238 void NotifyChanged (
00239 ) { OnChangeValue(); }
00240
00242 void UpdateCtrl (
00243 const MISTRING& string
00244 );
00245
00247 void UpdateValue (bool notify);
00248
00249 private:
00250 #ifndef GENERATING_DOXYGEN_OUTPUT
00251
00252 DELEGATE_VOID_NOPARMS m_DelegateOnActivate;
00253 DELEGATE_VOID_NOPARMS m_DelegateOnChangeValue;
00254 DELEGATE_VOID_NOPARMS m_DelegateOnUserEdit;
00255 DELEGATE_VOID_NOPARMS m_DelegateOnSelection;
00256 DELEGATE_VOID_NOPARMS m_DelegateOnGainFocus;
00257 DELEGATE_VOID_NOPARMS m_DelegateOnLoseFocus;
00258
00259 Widget m_TraversalWidget;
00260 int m_TraversalDir;
00261 int m_MaxLength;
00262
00263 bool m_InternalModify;
00264 bool m_ValidInvert;
00265 MISTRING m_ValidChars;
00266 MISTRING m_EmptyDisplay;
00267
00268 static void CB_Activate (Widget, CTRL_EDIT_BASE*, void*);
00269 static void CB_Focus (Widget, CTRL_EDIT_BASE*, void*);
00270 static void CB_LosingFocus (Widget, CTRL_EDIT_BASE*, void*);
00271 static void CB_ModifyVerify (Widget, CTRL_EDIT_BASE*, void*);
00272 static void CB_ValueChanged (Widget, CTRL_EDIT_BASE*, void*);
00273 static void CB_Selection (Widget, CTRL_EDIT_BASE*, void*);
00274
00275 void OnUserEdit ();
00276
00277 CTRL_EDIT_BASE (const CTRL_EDIT_BASE&);
00278 CTRL_EDIT_BASE& operator= (const CTRL_EDIT_BASE&);
00279 #endif // GENERATING_DOXYGEN_OUTPUT
00280
00281
00282
00285 virtual void OnActivate ();
00286
00290 virtual void OnChangeValue ();
00291
00294 virtual void v_OnUserEdit ();
00295
00298 virtual void v_UpdateValue (
00299 MISTRING& newvalue
00300 );
00301
00302 };
00303 #ifndef GENERATING_DOXYGEN_OUTPUT
00304 DEFINE_ENUM_OP_BITWISE(CTRL_EDIT_BASE::CREATEFLAGS)
00305 #endif
00306
00307
00308
00309 }
00310
00311 #endif // INC_MGUI_EDITBASE_H