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_ON
,
33 WXLOWIN_MENU_UNDERLINE_OFF
,
35 WXLOWIN_MENU_BOLD_OFF
,
36 WXLOWIN_MENU_ITALICS_ON
,
37 WXLOWIN_MENU_ITALICS_OFF
,
39 WXLOWIN_MENU_TYPEWRITER
,
40 WXLOWIN_MENU_SANSSERIF
,
43 WXLOWIN_MENU_DBLCLICK
,
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
,
72 /** Sets a background image, only used on screen, not on printouts.
73 @param bitmap a pointer to a wxBitmap or NULL to remove it
75 void SetBackgroundBitmap(wxBitmap
*bitmap
= NULL
)
77 if(m_BGbitmap
) delete m_BGbitmap
;
80 /// Enable or disable editing, i.e. processing of keystrokes.
81 void SetEditable(bool toggle
) { m_Editable
= toggle
; }
82 /// Query whether list can be edited by user.
83 bool IsEditable(void) const { return m_Editable
; }
84 /** Sets cursor visibility, visible=1, invisible=0,
85 visible-on-demand=-1, to hide it until moved.
86 @param visibility -1,0 or 1
87 @return the old visibility
89 inline int SetCursorVisibility(int visibility
= -1)
90 { int v
=m_CursorVisibility
;
91 m_CursorVisibility
= visibility
; return v
;}
93 /// Pastes text from clipboard.
95 /** Copies selection to clipboard.
96 @param invalidate used internally, see wxllist.h for details
98 bool Copy(bool invalidate
= true);
99 /// Copies selection to clipboard and deletes it.
103 bool Find(const wxString
&needle
,
104 wxPoint
* fromWhere
= NULL
);
106 void EnablePopup(bool enable
= true) { m_DoPopupMenu
= enable
; }
108 /** Sets the wrap margin.
109 @param margin set this to 0 to disable it
111 void SetWrapMargin(CoordType margin
) { m_WrapMargin
= margin
; }
113 /** Redraws the window.
114 Internally, this stores the parameter and calls a refresh on
115 wxMSW, draws directly on wxGTK.
117 void DoPaint(const wxRect
*updateRect
= NULL
);
120 virtual long MSWGetDlgCode();
123 /// if exact == false, assume 50% extra size for the future
124 void ResizeScrollbars(bool exact
= false); // don't change this to true!
126 /// if the flag is true, we send events when user clicks on embedded objects
127 inline void SetMouseTracking(bool doIt
= true) { m_doSendEvents
= doIt
; }
129 /* Returns a pointer to the wxLayoutList object.
132 wxLayoutList
* GetLayoutList(void) { return m_llist
; }
134 /**@name Callbacks */
136 void OnPaint(wxPaintEvent
&event
);
137 void OnChar(wxKeyEvent
& event
);
138 void OnKeyUp(wxKeyEvent
& event
);
139 void OnMenu(wxCommandEvent
& event
);
140 void OnLeftMouseClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_LCLICK
, event
); }
141 void OnRightMouseClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_RCLICK
, event
); }
142 void OnMouseDblClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_DBLCLICK
, event
); }
143 void OnMouseMove(wxMouseEvent
&event
) { OnMouse(WXLOWIN_MENU_MOUSEMOVE
, event
) ; }
144 void OnSetFocus(wxFocusEvent
&ev
);
145 void OnKillFocus(wxFocusEvent
&ev
);
148 /// Creates a wxMenu for use as a format popup.
149 static wxMenu
* MakeFormatMenu(void);
150 /**@name Dirty flag handling for optimisations. */
153 void SetDirty(void) { m_Dirty
= true; }
154 /// Query whether window needs redrawing.
155 bool IsDirty(void) const { return m_Dirty
; }
156 /// Reset dirty flag.
157 void ResetDirty(void) { m_Dirty
= false; }
159 /// Redraws the window, used by DoPaint() or OnPaint().
160 void InternalPaint(const wxRect
*updateRect
);
162 /// Has list been modified/edited?
163 bool IsModified(void) const { return m_Modified
; }
164 /// Mark list as modified or unchanged.
165 void SetModified(bool modified
= true) { m_Modified
= modified
; }
166 /** Tell window to update a wxStatusBar with UserData labels and
168 @param bar wxStatusBar pointer
169 @param labelfield field to use in statusbar for URLs/userdata labels, or -1 to disable
170 @param cursorfield field to use for cursor position, or -1 to disable
172 inline SetStatusBar(class wxStatusBar
*bar
,
174 int cursorfield
= -1)
176 m_StatusBar
= bar
; m_StatusFieldLabel
= labelfield
;
177 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.
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:
206 /** Visibility parameter for cursor. 0/1 as expected, -1: visible
209 int m_CursorVisibility
;
211 /// The layout list to be displayed.
212 wxLayoutList
*m_llist
;
213 /// Can user edit the window?
215 /// Are we currently building a selection with the keyboard?
218 CoordType m_WrapMargin
;
219 /// Is list dirty (for redraws, internal use)?
221 /// Has list been edited?
225 wxPoint m_bitmapSize
;
226 /// A frame's statusbar to update
227 class wxStatusBar
*m_StatusBar
;
228 /// statusbar field for labels
229 int m_StatusFieldLabel
;
230 /// statusbar field for cursor positions
231 int m_StatusFieldCursor
;
232 /// a pointer to a bitmap for the background
233 wxBitmap
*m_BGbitmap
;
234 DECLARE_EVENT_TABLE()