]>
git.saurik.com Git - wxWidgets.git/blob - samples/richedit/wxlwindow.h
3bbaf90d4369c16981166a781b27b65668549af6
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
,
42 WXLOWIN_MENU_MOUSEMOVE
,
43 WXLOWIN_MENU_LAST
= WXLOWIN_MENU_MOUSEMOVE
47 This class is a rich text editing widget.
49 class wxLayoutWindow
: public wxScrolledWindow
53 @param parent parent window to display this panel in
55 wxLayoutWindow(wxWindow
*parent
);
58 virtual ~wxLayoutWindow();
60 /**@name Editing functionality */
62 /// Clears the window and sets default parameters.
63 void Clear(int family
= wxROMAN
,
70 /** Sets a background image, only used on screen, not on printouts.
71 @param bitmap a pointer to a wxBitmap or NULL to remove it
73 void SetBackgroundBitmap(wxBitmap
*bitmap
= NULL
)
75 if(m_BGbitmap
) delete m_BGbitmap
;
78 /// Enable or disable editing, i.e. processing of keystrokes.
79 void SetEditable(bool toggle
) { m_Editable
= toggle
; }
80 /// Query whether list can be edited by user.
81 bool IsEditable(void) const { return m_Editable
; }
82 /** Sets cursor visibility, visible=1, invisible=0,
83 visible-on-demand=-1, to hide it until moved.
84 @param visibility -1,0 or 1
85 @return the old visibility
87 inline int SetCursorVisibility(int visibility
= -1)
88 { int v
=m_CursorVisibility
;
89 m_CursorVisibility
= visibility
; return v
;}
91 /// Pastes text from clipboard.
93 /** Copies selection to clipboard.
94 @param invalidate used internally, see wxllist.h for details
96 bool Copy(bool invalidate
= true);
97 /// Copies selection to clipboard and deletes it.
101 bool Find(const wxString
&needle
,
102 wxPoint
* fromWhere
= NULL
);
104 void EnablePopup(bool enable
= true) { m_DoPopupMenu
= enable
; }
106 /** Sets the wrap margin.
107 @param margin set this to 0 to disable it
109 void SetWrapMargin(CoordType margin
) { m_WrapMargin
= margin
; }
111 /** Redraws the window.
112 Internally, this stores the parameter and calls a refresh on
113 wxMSW, draws directly on wxGTK.
115 void DoPaint(const wxRect
*updateRect
= NULL
);
117 /// if exact == false, assume 50% extra size for the future
118 void ResizeScrollbars(bool exact
= false); // don't change this to true!
120 /// if the flag is true, we send events when user clicks on embedded objects
121 inline void SetMouseTracking(bool doIt
= true) { m_doSendEvents
= doIt
; }
123 /* Returns a pointer to the wxLayoutList object.
126 wxLayoutList
* GetLayoutList(void) { return m_llist
; }
128 /**@name Callbacks */
130 void OnPaint(wxPaintEvent
&event
);
131 void OnChar(wxKeyEvent
& event
);
132 void OnKeyUp(wxKeyEvent
& event
);
133 void OnUpdateMenuUnderline(wxUpdateUIEvent
& event
);
134 void OnUpdateMenuBold(wxUpdateUIEvent
& event
);
135 void OnUpdateMenuItalic(wxUpdateUIEvent
& event
);
136 void OnMenu(wxCommandEvent
& event
);
137 void OnLeftMouseDown(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_LDOWN
, event
); }
138 void OnLeftMouseUp(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_LUP
, event
); }
139 void OnRightMouseClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_RCLICK
, event
); }
140 void OnMouseDblClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_DBLCLICK
, event
); }
141 void OnMouseMove(wxMouseEvent
&event
) { OnMouse(WXLOWIN_MENU_MOUSEMOVE
, event
) ; }
142 void OnSetFocus(wxFocusEvent
&ev
);
143 void OnKillFocus(wxFocusEvent
&ev
);
146 /// Creates a wxMenu for use as a format popup.
147 static wxMenu
* MakeFormatMenu(void);
148 /**@name Dirty flag handling for optimisations. */
151 void SetDirty(void) { m_Dirty
= true; }
152 /// Query whether window needs redrawing.
153 bool IsDirty(void) const { return m_Dirty
; }
154 /// Reset dirty flag.
155 void ResetDirty(void) { m_Dirty
= false; }
157 /// Redraws the window, used by DoPaint() or OnPaint().
158 void InternalPaint(const wxRect
*updateRect
);
160 /// Has list been modified/edited?
161 bool IsModified(void) const { return m_Modified
; }
162 /// Mark list as modified or unchanged.
163 void SetModified(bool modified
= true) { m_Modified
= modified
; }
164 /** Tell window to update a wxStatusBar with UserData labels and
166 @param bar wxStatusBar pointer
167 @param labelfield field to use in statusbar for URLs/userdata labels, or -1 to disable
168 @param cursorfield field to use for cursor position, or -1 to disable
170 void SetStatusBar(class wxStatusBar
*bar
,
172 int cursorfield
= -1)
174 m_StatusBar
= bar
; m_StatusFieldLabel
= labelfield
;
175 m_StatusFieldCursor
= cursorfield
;
179 /// generic function for mouse events processing
180 void OnMouse(int eventId
, wxMouseEvent
& event
);
182 void ScrollToCursor(void);
183 /// for sending events
185 /// Shall we send events?
187 /// Where does the current view start?
188 int m_ViewStartX
; int m_ViewStartY
;
189 /// Do we currently have the focus?
191 /// do we handle clicks of the right mouse button?
193 /// Should InternalPaint() scroll to cursor (VZ: seems unused any more)
194 bool m_ScrollToCursor
;
195 /// Do we currently have a non-standard cursor?
198 wxMenu
* m_PopupMenu
;
199 /// for derived classes, set when mouse is clicked
200 wxPoint m_ClickPosition
;
201 /// for scrollbar calculations:
205 /** Visibility parameter for cursor. 0/1 as expected, -1: visible
208 int m_CursorVisibility
;
210 /// The layout list to be displayed.
211 wxLayoutList
*m_llist
;
212 /// Can user edit the window?
214 /// Are we currently building a selection with the keyboard?
217 CoordType m_WrapMargin
;
218 /// Is list dirty (for redraws, internal use)?
220 /// Has list been edited?
224 wxPoint m_bitmapSize
;
225 /// A frame's statusbar to update
226 class wxStatusBar
*m_StatusBar
;
227 /// statusbar field for labels
228 int m_StatusFieldLabel
;
229 /// statusbar field for cursor positions
230 int m_StatusFieldCursor
;
231 /// a pointer to a bitmap for the background
232 wxBitmap
*m_BGbitmap
;
233 DECLARE_EVENT_TABLE()