]>
git.saurik.com Git - wxWidgets.git/blob - samples/richedit/wxlwindow.h
1 /*-*- c++ -*-********************************************************
2 * wxLwindow.h : a scrolled Window for displaying/entering rich text*
4 * (C) 1998,1999 by Karsten Ballüder (Ballueder@usa.net) *
7 *******************************************************************/
12 # pragma interface "wxlwindow.h"
21 #ifndef WXLOWIN_MENU_FIRST
22 # define WXLOWIN_MENU_FIRST 12000
26 #define wxUSE_PRIVATE_CLIPBOARD_FORMAT 1
30 WXLOWIN_MENU_LARGER
= WXLOWIN_MENU_FIRST
,
32 WXLOWIN_MENU_UNDERLINE
,
36 WXLOWIN_MENU_TYPEWRITER
,
37 WXLOWIN_MENU_SANSSERIF
,
39 WXLOWIN_MENU_DBLCLICK
,
43 WXLOWIN_MENU_MOUSEMOVE
,
44 WXLOWIN_MENU_LAST
= WXLOWIN_MENU_MOUSEMOVE
48 This class is a rich text editing widget.
50 class wxLayoutWindow
: public wxScrolledWindow
54 @param parent parent window to display this panel in
56 wxLayoutWindow(wxWindow
*parent
);
59 virtual ~wxLayoutWindow();
61 /**@name Editing functionality */
63 /// Clears the window and sets default parameters.
64 void Clear(int family
= wxROMAN
,
71 /** Sets a background image, only used on screen, not on printouts.
72 @param bitmap a pointer to a wxBitmap or NULL to remove it
74 void SetBackgroundBitmap(wxBitmap
*bitmap
= NULL
)
76 if(m_BGbitmap
) delete m_BGbitmap
;
79 /// Enable or disable editing, i.e. processing of keystrokes.
80 void SetEditable(bool toggle
) { m_Editable
= toggle
; }
81 /// Query whether list can be edited by user.
82 bool IsEditable(void) const { return m_Editable
; }
83 /** Sets cursor visibility, visible=1, invisible=0,
84 visible-on-demand=-1, to hide it until moved.
85 @param visibility -1,0 or 1
86 @return the old visibility
88 inline int SetCursorVisibility(int visibility
= -1)
89 { int v
=m_CursorVisibility
;
90 m_CursorVisibility
= visibility
; return v
;}
92 /// Pastes text from clipboard.
93 void Paste(bool usePrimarySelection
= FALSE
);
94 /** Copies selection to clipboard.
95 @param invalidate used internally, see wxllist.h for details
97 bool Copy(bool invalidate
= true);
98 /// Copies selection to clipboard and deletes it.
102 bool Find(const wxString
&needle
,
103 wxPoint
* fromWhere
= NULL
);
105 void EnablePopup(bool enable
= true) { m_DoPopupMenu
= enable
; }
107 /** Sets the wrap margin.
108 @param margin set this to 0 to disable it
110 void SetWrapMargin(CoordType margin
) { m_WrapMargin
= margin
; }
112 /** Redraws the window.
113 Internally, this stores the parameter and calls a refresh on
114 wxMSW, draws directly on wxGTK.
116 void DoPaint(const wxRect
*updateRect
= NULL
);
118 /// if exact == false, assume 50% extra size for the future
119 void ResizeScrollbars(bool exact
= false); // don't change this to true!
121 /// if the flag is true, we send events when user clicks on embedded objects
122 inline void SetMouseTracking(bool doIt
= true) { m_doSendEvents
= doIt
; }
124 /* Returns a pointer to the wxLayoutList object.
127 wxLayoutList
* GetLayoutList(void) { return m_llist
; }
129 /**@name Callbacks */
131 void OnSize(wxSizeEvent
&event
);
132 void OnPaint(wxPaintEvent
&event
);
133 void OnChar(wxKeyEvent
& event
);
134 void OnKeyUp(wxKeyEvent
& event
);
135 void OnUpdateMenuUnderline(wxUpdateUIEvent
& event
);
136 void OnUpdateMenuBold(wxUpdateUIEvent
& event
);
137 void OnUpdateMenuItalic(wxUpdateUIEvent
& event
);
138 void OnMenu(wxCommandEvent
& event
);
139 void OnLeftMouseDown(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_LDOWN
, event
); }
140 void OnLeftMouseUp(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_LUP
, event
); }
141 void OnRightMouseClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_RCLICK
, event
); }
142 void OnMiddleMouseDown(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_MDOWN
, event
); }
143 void OnMouseDblClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_DBLCLICK
, event
); }
144 void OnMouseMove(wxMouseEvent
&event
) { OnMouse(WXLOWIN_MENU_MOUSEMOVE
, event
) ; }
145 void OnSetFocus(wxFocusEvent
&ev
);
146 void OnKillFocus(wxFocusEvent
&ev
);
149 /// Creates a wxMenu for use as a format popup.
150 static wxMenu
* MakeFormatMenu(void);
151 /**@name Dirty flag handling for optimisations. */
154 void SetDirty(void) { m_Dirty
= true; }
155 /// Query whether window needs redrawing.
156 bool IsDirty(void) const { return m_Dirty
; }
157 /// Reset dirty flag.
158 void ResetDirty(void) { m_Dirty
= false; }
160 /// Redraws the window, used by DoPaint() or OnPaint().
161 void InternalPaint(const wxRect
*updateRect
);
163 /// Has list been modified/edited?
164 bool IsModified(void) const { return m_Modified
; }
165 /// Mark list as modified or unchanged.
166 void SetModified(bool modified
= true) { m_Modified
= modified
; }
167 /** Tell window to update a wxStatusBar with UserData labels and
169 @param bar wxStatusBar pointer
170 @param labelfield field to use in statusbar for URLs/userdata labels, or -1 to disable
171 @param cursorfield field to use for cursor position, or -1 to disable
173 void SetStatusBar(class wxStatusBar
*bar
,
175 int cursorfield
= -1)
177 m_StatusBar
= bar
; m_StatusFieldLabel
= labelfield
;
178 m_StatusFieldCursor
= cursorfield
;
182 /// generic function for mouse events processing
183 void OnMouse(int eventId
, wxMouseEvent
& event
);
185 void ScrollToCursor(void);
186 /// for sending events
188 /// Shall we send events?
190 /// Where does the current view start?
191 int m_ViewStartX
; int m_ViewStartY
;
192 /// Do we currently have the focus?
194 /// do we handle clicks of the right mouse button?
196 /// Should InternalPaint() scroll to cursor (VZ: seems unused any more)
197 bool m_ScrollToCursor
;
198 /// Do we currently have a non-standard cursor?
201 wxMenu
* m_PopupMenu
;
202 /// for derived classes, set when mouse is clicked
203 wxPoint m_ClickPosition
;
204 /// for scrollbar calculations:
209 /// do we have the corresponding scrollbar?
210 bool m_hasHScrollbar
,
213 /** Visibility parameter for cursor. 0/1 as expected, -1: visible
216 int m_CursorVisibility
;
218 /// The layout list to be displayed.
219 wxLayoutList
*m_llist
;
220 /// Can user edit the window?
222 /// Are we currently building a selection with the keyboard?
225 CoordType m_WrapMargin
;
226 /// Is list dirty (for redraws, internal use)?
228 /// Has list been edited?
232 wxPoint m_bitmapSize
;
233 /// A frame's statusbar to update
234 class wxStatusBar
*m_StatusBar
;
235 /// statusbar field for labels
236 int m_StatusFieldLabel
;
237 /// statusbar field for cursor positions
238 int m_StatusFieldCursor
;
239 /// a pointer to a bitmap for the background
240 wxBitmap
*m_BGbitmap
;
241 DECLARE_EVENT_TABLE()