]>
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 0
30 WXLOWIN_MENU_LARGER
= WXLOWIN_MENU_FIRST
,
32 WXLOWIN_MENU_UNDERLINE
,
36 WXLOWIN_MENU_TYPEWRITER
,
37 WXLOWIN_MENU_SANSSERIF
,
39 WXLOWIN_MENU_DBLCLICK
,
42 WXLOWIN_MENU_LCLICK
= WXLOWIN_MENU_LDOWN
,
44 WXLOWIN_MENU_MOUSEMOVE
,
45 WXLOWIN_MENU_LAST
= WXLOWIN_MENU_MOUSEMOVE
49 This class is a rich text editing widget.
51 class wxLayoutWindow
: public wxScrolledWindow
55 @param parent parent window to display this panel in
57 wxLayoutWindow(wxWindow
*parent
);
60 virtual ~wxLayoutWindow();
62 /**@name Editing functionality */
64 /// Clears the window and sets default parameters.
65 void Clear(int family
= wxROMAN
,
73 /// override base class virtual to also refresh the scrollbar position
74 virtual void Refresh(bool eraseBackground
= TRUE
,
75 const wxRect
*rect
= (const wxRect
*)NULL
);
77 /** Sets a background image, only used on screen, not on printouts.
78 @param bitmap a pointer to a wxBitmap or NULL to remove it
80 void SetBackgroundBitmap(wxBitmap
*bitmap
= NULL
)
82 if(m_BGbitmap
) delete m_BGbitmap
;
85 /// Enable or disable editing, i.e. processing of keystrokes.
86 void SetEditable(bool toggle
)
87 { m_Editable
= toggle
; SetCursorVisibility(toggle
); }
88 /// Query whether list can be edited by user.
89 bool IsEditable(void) const { return m_Editable
; }
90 /** Sets cursor visibility, visible=1, invisible=0,
91 visible-on-demand=-1, to hide it until moved.
92 @param visibility -1,0 or 1
93 @return the old visibility
95 inline int SetCursorVisibility(int visibility
= -1)
96 { int v
=m_CursorVisibility
;
97 m_CursorVisibility
= visibility
; return v
;}
99 /// Pastes text from clipboard.
100 void Paste(bool usePrimarySelection
= FALSE
);
101 /** Copies selection to clipboard.
102 @param invalidate used internally, see wxllist.h for details
104 bool Copy(bool invalidate
= true);
105 /// Copies selection to clipboard and deletes it.
109 bool Find(const wxString
&needle
,
110 wxPoint
* fromWhere
= NULL
);
112 void EnablePopup(bool enable
= true) { m_DoPopupMenu
= enable
; }
114 /** Sets the wrap margin.
115 @param margin set this to 0 to disable it
117 void SetWrapMargin(CoordType margin
) { m_WrapMargin
= margin
; }
119 /** Redraws the window.
120 Internally, this stores the parameter and calls a refresh on
121 wxMSW, draws directly on wxGTK.
123 void DoPaint(const wxRect
*updateRect
= NULL
);
125 /// if exact == false, assume 50% extra size for the future
126 void ResizeScrollbars(bool exact
= false); // don't change this to true!
128 /// if the flag is true, we send events when user clicks on embedded objects
129 inline void SetMouseTracking(bool doIt
= true) { m_doSendEvents
= doIt
; }
131 /* Returns a pointer to the wxLayoutList object.
134 wxLayoutList
* GetLayoutList(void) { return m_llist
; }
136 /**@name Callbacks */
138 void OnSize(wxSizeEvent
&event
);
139 void OnPaint(wxPaintEvent
&event
);
140 void OnChar(wxKeyEvent
& event
);
141 void OnKeyUp(wxKeyEvent
& event
);
142 void OnUpdateMenuUnderline(wxUpdateUIEvent
& event
);
143 void OnUpdateMenuBold(wxUpdateUIEvent
& event
);
144 void OnUpdateMenuItalic(wxUpdateUIEvent
& event
);
145 void OnMenu(wxCommandEvent
& event
);
146 void OnLeftMouseDown(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_LDOWN
, event
); }
147 void OnLeftMouseUp(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_LUP
, event
); }
148 void OnRightMouseClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_RCLICK
, event
); }
149 void OnMiddleMouseDown(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_MDOWN
, event
); }
150 void OnMouseDblClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_DBLCLICK
, event
); }
151 void OnMouseMove(wxMouseEvent
&event
) { OnMouse(WXLOWIN_MENU_MOUSEMOVE
, event
) ; }
152 void OnSetFocus(wxFocusEvent
&ev
);
153 void OnKillFocus(wxFocusEvent
&ev
);
156 /// Creates a wxMenu for use as a format popup.
157 static wxMenu
* MakeFormatMenu(void);
158 /**@name Dirty flag handling for optimisations. */
161 void SetDirty(void) { m_Dirty
= true; }
162 /// Query whether window needs redrawing.
163 bool IsDirty(void) const { return m_Dirty
; }
164 /// Reset dirty flag.
165 void ResetDirty(void) { m_Dirty
= false; }
167 /// Redraws the window, used by DoPaint() or OnPaint().
168 void InternalPaint(const wxRect
*updateRect
);
170 /// Has list been modified/edited?
171 bool IsModified(void) const { return m_Modified
; }
172 /// Mark list as modified or unchanged.
173 void SetModified(bool modified
= true) { m_Modified
= modified
; }
174 /** Tell window to update a wxStatusBar with UserData labels and
176 @param bar wxStatusBar pointer
177 @param labelfield field to use in statusbar for URLs/userdata labels, or -1 to disable
178 @param cursorfield field to use for cursor position, or -1 to disable
180 void SetStatusBar(class wxStatusBar
*bar
,
182 int cursorfield
= -1)
184 m_StatusBar
= bar
; m_StatusFieldLabel
= labelfield
;
185 m_StatusFieldCursor
= cursorfield
;
189 /// generic function for mouse events processing
190 void OnMouse(int eventId
, wxMouseEvent
& event
);
192 void ScrollToCursor(void);
193 /// for sending events
195 /// Shall we send events?
197 /// Where does the current view start?
198 int m_ViewStartX
; int m_ViewStartY
;
199 /// Do we currently have the focus?
201 /// do we handle clicks of the right mouse button?
203 /// Should InternalPaint() scroll to cursor (VZ: seems unused any more)
204 bool m_ScrollToCursor
;
205 /// Do we currently have a non-standard cursor?
208 wxMenu
* m_PopupMenu
;
209 /// for derived classes, set when mouse is clicked
210 wxPoint m_ClickPosition
;
211 /// for scrollbar calculations:
216 /// do we have the corresponding scrollbar?
217 bool m_hasHScrollbar
,
220 /** Visibility parameter for cursor. 0/1 as expected, -1: visible
223 int m_CursorVisibility
;
225 bool SetAutoDeleteSelection(bool enable
= TRUE
)
227 bool old
= m_AutoDeleteSelection
;
228 m_AutoDeleteSelection
= enable
;
232 /// The layout list to be displayed.
233 wxLayoutList
*m_llist
;
234 /// Can user edit the window?
236 /// Are we currently building a selection with the keyboard?
239 CoordType m_WrapMargin
;
240 /// Is list dirty (for redraws, internal use)?
242 /// Has list been edited?
246 wxPoint m_bitmapSize
;
247 /// A frame's statusbar to update
248 class wxStatusBar
*m_StatusBar
;
249 /// statusbar field for labels
250 int m_StatusFieldLabel
;
251 /// statusbar field for cursor positions
252 int m_StatusFieldCursor
;
253 /// a pointer to a bitmap for the background
254 wxBitmap
*m_BGbitmap
;
255 /**@name Some configuration options */
257 /// Do we want to auto-replace the selection with new text?
258 bool m_AutoDeleteSelection
;
260 DECLARE_EVENT_TABLE()