00001
00029 #ifndef INC_MGUI_WYSIWYG_H
00030 #define INC_MGUI_WYSIWYG_H
00031
00032 #ifndef INC_MGUI_CTRL_H
00033 #include <mgui/ctrl.h>
00034 #endif
00035
00036 #ifndef INC_MI32_MISTRING_H
00037 #include <mi32/mistring.h>
00038 #endif
00039
00040
00041 #ifndef GENERATING_DOXYGEN_OUTPUT
00042 struct TEXTSTYLE;
00043 #endif
00044
00045
00046 namespace MGUI {
00047
00048
00050 class CTRL_EDIT_TEXT_WYSIWYG : public MGUI::CTRL {
00051 public:
00052
00053 enum FLAGS {
00054 FLAG_Default = 0x0000,
00055 FLAG_ReadOnly = 0x0001,
00056 };
00057
00059 CTRL_EDIT_TEXT_WYSIWYG (
00060 );
00061
00063 virtual ~CTRL_EDIT_TEXT_WYSIWYG (
00064 );
00065
00067 bool CanUndo (
00068 ) const;
00069 ;
00070
00072 void ClearValue (
00073 bool notify = true
00074 );
00075
00077 void ClearSelection (
00078 );
00079
00081 void CutSelection (
00082 );
00083
00085 void CopySelection (
00086 );
00087
00089 void Create (
00090 MGUI::LAYOUT_PANE_BASE& ParentPane,
00091 int width = 0,
00092 int height = 0,
00093 FLAGS flags = FLAG_Default,
00094 MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedHeight
00095 );
00096
00098 INT32 GetCursorPos (
00099 ) const;
00100
00104 int GetFirstVisibleLine (
00105 ) const;
00106
00108 int GetLineCount (
00109 ) const;
00110
00115 int GetLineFromChar (
00116 int nIndex = -1
00117 ) const;
00118
00122 int GetLineIndex (
00123 int nLine = -1
00124 );
00125
00132 int GetLineLength (
00133 int nLine = -1
00134 );
00135
00138 bool GetModify (
00139 ) const;
00140 ;
00141
00144 void GetSelection (
00145 int& nStartChar,
00146 int& nEndChar
00147 ) const;
00148
00151 void GetStyle (
00152 TEXTSTYLE& style,
00153 int offset = -1
00154 ) const;
00155
00157 const MISTRING& GetValue (
00158 ) const { return (m_value); }
00159
00161 bool GetWYSIWYG (
00162 ) const;
00163
00165 void HideCursor (
00166 );
00167
00169 void LineScroll (
00170 int nLines,
00171 int nChars = 0
00172 );
00173
00175 void Paste ();
00176
00178 void SetCursorPos (
00179 int nCharIndex,
00180 bool bScroll = true
00181 );
00182
00184 void SetCursorPos (
00185 int line,
00186 int col,
00187 bool bScroll = true
00188 );
00189
00190 void SetDelegateOnChangeValue (
00191 DELEGATE_VOID_NOPARMS Delegate
00192 ) { m_DelegateOnChangeValue = Delegate; }
00193
00197 void SetDelegateOnCursorMotion (
00198 DELEGATE_BOOL_INT32 Delegate
00199 ) { m_DelegateOnCursorMotion = Delegate; }
00200
00201 void SetDelegateOnFocus (
00202 DELEGATE_VOID_NOPARMS Delegate
00203 ) { m_DelegateOnFocus = Delegate; }
00204
00205 void SetDelegateOnLosingFocus (
00206 DELEGATE_VOID_NOPARMS Delegate
00207 ) { m_DelegateOnLosingFocus = Delegate; }
00208
00209 void SetDelegateOnToggleWYSIWYG (
00210 DELEGATE_VOID_BOOL Delegate
00211 ) { m_DelegateOnToggleWYSIWYG = Delegate; }
00212
00213 void SetDelegateOnUserEdit (
00214 DELEGATE_VOID_NOPARMS Delegate
00215 ) { m_DelegateOnUserEdit = Delegate; }
00216
00218 void SetModify (
00219 bool modified = true
00220 );
00221
00223 void SetReadOnly (
00224 bool ReadOnly = true
00225 );
00226
00228 void SetSelection (
00229 int start,
00230 int end
00231 );
00232
00236 void SetStyle (
00237 const TEXTSTYLE& style
00238 );
00239
00242 void SetStyle (
00243 const TEXTSTYLE& style,
00244 int start,
00245 int end
00246 );
00247
00251 void SetValue (
00252 const MIUNICODE* string,
00253 bool notify = true
00254 );
00255
00256 void SetWordWrap (
00257 bool bWordWrap = true
00258 );
00259
00261 void SetWYSIWYG (
00262 bool bvalue
00263 );
00264
00266 void ShowCursor (
00267 );
00268
00270 void Undo ();
00271
00272 protected:
00273
00274 virtual void v_OnActivate ();
00275
00279 virtual void v_OnChangeValue ();
00280
00284 virtual void v_OnUserEdit ();
00285
00286 private:
00287 #ifndef GENERATING_DOXYGEN_OUTPUT
00288
00289 bool m_UserEdited;
00290 Widget m_TraversalWidget;
00291 int m_TraversalDir;
00292 bool m_InternalModify;
00293 bool m_HasValue;
00294 MISTRING m_value;
00295 DELEGATE_VOID_NOPARMS m_DelegateOnChangeValue;
00296 DELEGATE_BOOL_INT32 m_DelegateOnCursorMotion;
00297 DELEGATE_VOID_NOPARMS m_DelegateOnFocus;
00298 DELEGATE_VOID_NOPARMS m_DelegateOnLosingFocus;
00299 DELEGATE_VOID_NOPARMS m_DelegateOnUserEdit;
00300 DELEGATE_VOID_BOOL m_DelegateOnToggleWYSIWYG;
00301
00302 virtual void v_SetFocus() const;
00303
00304 bool GetEditStr (MISTRING& str) const;
00305 void UpdateCtrl (const MISTRING& string);
00306
00308 virtual void UpdateValue (bool notify = true);
00309
00310 static void CB_Activate (Widget, CTRL_EDIT_TEXT_WYSIWYG*, void*);
00311 static void CB_Focus (Widget, CTRL_EDIT_TEXT_WYSIWYG*, void*);
00312 static void CB_LosingFocus (Widget, CTRL_EDIT_TEXT_WYSIWYG*, void*);
00313 static void CB_ModifyVerify (Widget, CTRL_EDIT_TEXT_WYSIWYG*, void*);
00314 static void CB_ValueChanged (Widget, CTRL_EDIT_TEXT_WYSIWYG*, void*);
00315 static void CB_MotionVerify (Widget, CTRL_EDIT_TEXT_WYSIWYG*, void*);
00316 static void CB_ToggleWYSIWYG (Widget, CTRL_EDIT_TEXT_WYSIWYG*, void*);
00317
00318
00319 CTRL_EDIT_TEXT_WYSIWYG (const CTRL_EDIT_TEXT_WYSIWYG&);
00320 CTRL_EDIT_TEXT_WYSIWYG& operator= (const CTRL_EDIT_TEXT_WYSIWYG&);
00321
00322 #endif // GENERATING_DOXYGEN_OUTPUT
00323 };
00324
00325 #ifndef GENERATING_DOXYGEN_OUTPUT
00326 DEFINE_ENUM_OP_BITWISE(MGUI::CTRL_EDIT_TEXT_WYSIWYG::FLAGS)
00327 #endif
00328
00329
00330
00331
00332 }
00333
00334 #endif // INC_MGUI_CTRL_H