]>
git.saurik.com Git - wxWidgets.git/blob - samples/richedit/wxlwindow.h
6344296e965d7f9daf3ba6d9a0f3feeab89f2b6e
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
,
40 WXLOWIN_MENU_DBLCLICK
,
41 WXLOWIN_MENU_MOUSEMOVE
,
42 WXLOWIN_MENU_LAST
= WXLOWIN_MENU_MOUSEMOVE
46 This class is a rich text editing widget.
48 class wxLayoutWindow
: public wxScrolledWindow
52 @param parent parent window to display this panel in
54 wxLayoutWindow(wxWindow
*parent
);
57 virtual ~wxLayoutWindow();
59 /**@name Editing functionality */
61 /// Clears the window and sets default parameters.
62 void Clear(int family
= wxROMAN
,
69 /** Sets a background image, only used on screen, not on printouts.
70 @param bitmap a pointer to a wxBitmap or NULL to remove it
72 void SetBackgroundBitmap(wxBitmap
*bitmap
= NULL
)
74 if(m_BGbitmap
) delete m_BGbitmap
;
77 /// Enable or disable editing, i.e. processing of keystrokes.
78 void SetEditable(bool toggle
) { m_Editable
= toggle
; }
79 /// Query whether list can be edited by user.
80 bool IsEditable(void) const { return m_Editable
; }
81 /** Sets cursor visibility, visible=1, invisible=0,
82 visible-on-demand=-1, to hide it until moved.
83 @param visibility -1,0 or 1
84 @return the old visibility
86 inline int SetCursorVisibility(int visibility
= -1)
87 { int v
=m_CursorVisibility
;
88 m_CursorVisibility
= visibility
; return v
;}
90 /// Pastes text from clipboard.
92 /** Copies selection to clipboard.
93 @param invalidate used internally, see wxllist.h for details
95 bool Copy(bool invalidate
= true);
96 /// Copies selection to clipboard and deletes it.
100 bool Find(const wxString
&needle
,
101 wxPoint
* fromWhere
= NULL
);
103 void EnablePopup(bool enable
= true) { m_DoPopupMenu
= enable
; }
105 /** Sets the wrap margin.
106 @param margin set this to 0 to disable it
108 void SetWrapMargin(CoordType margin
) { m_WrapMargin
= margin
; }
110 /** Redraws the window.
111 Internally, this stores the parameter and calls a refresh on
112 wxMSW, draws directly on wxGTK.
114 void DoPaint(const wxRect
*updateRect
= NULL
);
116 /// if exact == false, assume 50% extra size for the future
117 void ResizeScrollbars(bool exact
= false); // don't change this to true!
119 /// if the flag is true, we send events when user clicks on embedded objects
120 inline void SetMouseTracking(bool doIt
= true) { m_doSendEvents
= doIt
; }
122 /* Returns a pointer to the wxLayoutList object.
125 wxLayoutList
* GetLayoutList(void) { return m_llist
; }
127 /**@name Callbacks */
129 void OnPaint(wxPaintEvent
&event
);
130 void OnChar(wxKeyEvent
& event
);
131 void OnKeyUp(wxKeyEvent
& event
);
132 void OnUpdateMenuUnderline(wxUpdateUIEvent
& event
);
133 void OnUpdateMenuBold(wxUpdateUIEvent
& event
);
134 void OnUpdateMenuItalic(wxUpdateUIEvent
& event
);
135 void OnMenu(wxCommandEvent
& event
);
136 void OnLeftMouseClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_LCLICK
, event
); }
137 void OnRightMouseClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_RCLICK
, event
); }
138 void OnMouseDblClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_DBLCLICK
, event
); }
139 void OnMouseMove(wxMouseEvent
&event
) { OnMouse(WXLOWIN_MENU_MOUSEMOVE
, event
) ; }
140 void OnSetFocus(wxFocusEvent
&ev
);
141 void OnKillFocus(wxFocusEvent
&ev
);
144 /// Creates a wxMenu for use as a format popup.
145 static wxMenu
* MakeFormatMenu(void);
146 /**@name Dirty flag handling for optimisations. */
149 void SetDirty(void) { m_Dirty
= true; }
150 /// Query whether window needs redrawing.
151 bool IsDirty(void) const { return m_Dirty
; }
152 /// Reset dirty flag.
153 void ResetDirty(void) { m_Dirty
= false; }
155 /// Redraws the window, used by DoPaint() or OnPaint().
156 void InternalPaint(const wxRect
*updateRect
);
158 /// Has list been modified/edited?
159 bool IsModified(void) const { return m_Modified
; }
160 /// Mark list as modified or unchanged.
161 void SetModified(bool modified
= true) { m_Modified
= modified
; }
162 /** Tell window to update a wxStatusBar with UserData labels and
164 @param bar wxStatusBar pointer
165 @param labelfield field to use in statusbar for URLs/userdata labels, or -1 to disable
166 @param cursorfield field to use for cursor position, or -1 to disable
168 void SetStatusBar(class wxStatusBar
*bar
,
170 int cursorfield
= -1)
172 m_StatusBar
= bar
; m_StatusFieldLabel
= labelfield
;
173 m_StatusFieldCursor
= cursorfield
;
177 /// generic function for mouse events processing
178 void OnMouse(int eventId
, wxMouseEvent
& event
);
180 void ScrollToCursor(void);
181 /// for sending events
183 /// Shall we send events?
185 /// Where does the current view start?
186 int m_ViewStartX
; int m_ViewStartY
;
187 /// Do we currently have the focus?
189 /// do we handle clicks of the right mouse button?
191 /// Should InternalPaint() scroll to cursor (VZ: seems unused any more)
192 bool m_ScrollToCursor
;
193 /// Do we currently have a non-standard cursor?
196 wxMenu
* m_PopupMenu
;
197 /// for derived classes, set when mouse is clicked
198 wxPoint m_ClickPosition
;
199 /// for scrollbar calculations:
203 /** Visibility parameter for cursor. 0/1 as expected, -1: visible
206 int m_CursorVisibility
;
208 /// The layout list to be displayed.
209 wxLayoutList
*m_llist
;
210 /// Can user edit the window?
212 /// Are we currently building a selection with the keyboard?
215 CoordType m_WrapMargin
;
216 /// Is list dirty (for redraws, internal use)?
218 /// Has list been edited?
222 wxPoint m_bitmapSize
;
223 /// A frame's statusbar to update
224 class wxStatusBar
*m_StatusBar
;
225 /// statusbar field for labels
226 int m_StatusFieldLabel
;
227 /// statusbar field for cursor positions
228 int m_StatusFieldCursor
;
229 /// a pointer to a bitmap for the background
230 wxBitmap
*m_BGbitmap
;
231 DECLARE_EVENT_TABLE()