]>
git.saurik.com Git - wxWidgets.git/blob - samples/richedit/wxlwindow.h
e0ddabd6276a1ea5d491f5a219b2cdb5b4456350
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 OnSize(wxSizeEvent
&event
);
131 void OnPaint(wxPaintEvent
&event
);
132 void OnChar(wxKeyEvent
& event
);
133 void OnKeyUp(wxKeyEvent
& event
);
134 void OnUpdateMenuUnderline(wxUpdateUIEvent
& event
);
135 void OnUpdateMenuBold(wxUpdateUIEvent
& event
);
136 void OnUpdateMenuItalic(wxUpdateUIEvent
& event
);
137 void OnMenu(wxCommandEvent
& event
);
138 void OnLeftMouseDown(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_LDOWN
, event
); }
139 void OnLeftMouseUp(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_LUP
, event
); }
140 void OnRightMouseClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_RCLICK
, event
); }
141 void OnMouseDblClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_DBLCLICK
, event
); }
142 void OnMouseMove(wxMouseEvent
&event
) { OnMouse(WXLOWIN_MENU_MOUSEMOVE
, event
) ; }
143 void OnSetFocus(wxFocusEvent
&ev
);
144 void OnKillFocus(wxFocusEvent
&ev
);
147 /// Creates a wxMenu for use as a format popup.
148 static wxMenu
* MakeFormatMenu(void);
149 /**@name Dirty flag handling for optimisations. */
152 void SetDirty(void) { m_Dirty
= true; }
153 /// Query whether window needs redrawing.
154 bool IsDirty(void) const { return m_Dirty
; }
155 /// Reset dirty flag.
156 void ResetDirty(void) { m_Dirty
= false; }
158 /// Redraws the window, used by DoPaint() or OnPaint().
159 void InternalPaint(const wxRect
*updateRect
);
161 /// Has list been modified/edited?
162 bool IsModified(void) const { return m_Modified
; }
163 /// Mark list as modified or unchanged.
164 void SetModified(bool modified
= true) { m_Modified
= modified
; }
165 /** Tell window to update a wxStatusBar with UserData labels and
167 @param bar wxStatusBar pointer
168 @param labelfield field to use in statusbar for URLs/userdata labels, or -1 to disable
169 @param cursorfield field to use for cursor position, or -1 to disable
171 void SetStatusBar(class wxStatusBar
*bar
,
173 int cursorfield
= -1)
175 m_StatusBar
= bar
; m_StatusFieldLabel
= labelfield
;
176 m_StatusFieldCursor
= cursorfield
;
180 /// generic function for mouse events processing
181 void OnMouse(int eventId
, wxMouseEvent
& event
);
183 void ScrollToCursor(void);
184 /// for sending events
186 /// Shall we send events?
188 /// Where does the current view start?
189 int m_ViewStartX
; int m_ViewStartY
;
190 /// Do we currently have the focus?
192 /// do we handle clicks of the right mouse button?
194 /// Should InternalPaint() scroll to cursor (VZ: seems unused any more)
195 bool m_ScrollToCursor
;
196 /// Do we currently have a non-standard cursor?
199 wxMenu
* m_PopupMenu
;
200 /// for derived classes, set when mouse is clicked
201 wxPoint m_ClickPosition
;
202 /// for scrollbar calculations:
207 /// do we have the corresponding scrollbar?
208 bool m_hasHScrollbar
,
211 /** Visibility parameter for cursor. 0/1 as expected, -1: visible
214 int m_CursorVisibility
;
216 /// The layout list to be displayed.
217 wxLayoutList
*m_llist
;
218 /// Can user edit the window?
220 /// Are we currently building a selection with the keyboard?
223 CoordType m_WrapMargin
;
224 /// Is list dirty (for redraws, internal use)?
226 /// Has list been edited?
230 wxPoint m_bitmapSize
;
231 /// A frame's statusbar to update
232 class wxStatusBar
*m_StatusBar
;
233 /// statusbar field for labels
234 int m_StatusFieldLabel
;
235 /// statusbar field for cursor positions
236 int m_StatusFieldCursor
;
237 /// a pointer to a bitmap for the background
238 wxBitmap
*m_BGbitmap
;
239 DECLARE_EVENT_TABLE()