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
27 WXLOWIN_MENU_LARGER
= WXLOWIN_MENU_FIRST
,
29 WXLOWIN_MENU_UNDERLINE_ON
,
30 WXLOWIN_MENU_UNDERLINE_OFF
,
32 WXLOWIN_MENU_BOLD_OFF
,
33 WXLOWIN_MENU_ITALICS_ON
,
34 WXLOWIN_MENU_ITALICS_OFF
,
36 WXLOWIN_MENU_TYPEWRITER
,
37 WXLOWIN_MENU_SANSSERIF
,
40 WXLOWIN_MENU_DBLCLICK
,
41 WXLOWIN_MENU_LAST
= WXLOWIN_MENU_DBLCLICK
45 This class is a rich text editing widget.
47 class wxLayoutWindow
: public wxScrolledWindow
51 @param parent parent window to display this panel in
53 wxLayoutWindow(wxWindow
*parent
);
56 virtual ~wxLayoutWindow();
58 /**@name Editing functionality */
60 /// Clears the window and sets default parameters.
61 void Clear(int family
= wxROMAN
,
66 char const *fg
="black",
67 char const *bg
="white")
69 GetLayoutList()->Clear(family
,size
,style
,weight
,underline
,fg
,bg
);
70 SetBackgroundColour(*GetLayoutList()->GetDefaults()->GetBGColour());
75 /// Enable or disable editing, i.e. processing of keystrokes.
76 void SetEditable(bool toggle
) { m_Editable
= toggle
; }
77 /// Query whether list can be edited by user.
78 bool IsEditable(void) const { return m_Editable
; }
79 /// Pastes text from clipboard.
84 void EnablePopup(bool enable
= true) { m_DoPopupMenu
= enable
; }
86 /** Sets the wrap margin.
87 @param margin set this to 0 to disable it
89 void SetWrapMargin(CoordType margin
) { m_WrapMargin
= margin
; }
91 /** Redraws the window.
92 Internally, this stores the parameter and calls a refresh on
93 wxMSW, draws directly on wxGTK.
94 @param scrollToCursor if true, scroll the window so that the
95 cursor becomes visible
97 void DoPaint(bool scrollToCursor
= false);
100 virtual long MSWGetDlgCode();
103 /// if exact == false, assume 50% extra size for the future
104 void ResizeScrollbars(bool exact
= false); // don't change this to true!
106 /// if the flag is true, we send events when user clicks on embedded objects
107 inline void SetMouseTracking(bool doIt
= true) { m_doSendEvents
= doIt
; }
109 /* Returns a pointer to the wxLayoutList object.
112 wxLayoutList
* GetLayoutList(void) { return m_llist
; }
114 /**@name Callbacks */
116 void OnPaint(wxPaintEvent
&event
);
117 void OnChar(wxKeyEvent
& event
);
118 void OnMenu(wxCommandEvent
& event
);
119 void OnLeftMouseClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_LCLICK
, event
); }
120 void OnRightMouseClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_RCLICK
, event
); }
121 void OnMouseDblClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_DBLCLICK
, event
); }
122 void OnSetFocus(wxFocusEvent
&ev
);
123 void OnKillFocus(wxFocusEvent
&ev
);
126 /// Creates a wxMenu for use as a format popup.
127 static wxMenu
* MakeFormatMenu(void);
128 /**@name Dirty flag handling for optimisations. */
131 void SetDirty(void) { m_Dirty
= true; }
132 /// Query whether window needs redrawing.
133 bool IsDirty(void) const { return m_Dirty
; }
134 /// Reset dirty flag.
135 void ResetDirty(void) { m_Dirty
= false; }
137 /// Redraws the window, used by DoPaint() or OnPaint().
138 void InternalPaint(void);
140 /// generic function for mouse events processing
141 void OnMouse(int eventId
, wxMouseEvent
& event
);
143 /// for sending events
145 /// Shall we send events?
147 /// Where does the current view start?
148 int m_ViewStartX
; int m_ViewStartY
;
149 /// Do we currently have the focus?
151 /// do we handle clicks of the right mouse button?
153 /// Should InternalPaint() scroll to cursor.
154 bool m_ScrollToCursor
;
156 wxMenu
* m_PopupMenu
;
157 /// for derived classes, set when mouse is clicked
158 wxPoint m_ClickPosition
;
159 /// for scrollbar calculations:
164 /// The layout list to be displayed.
165 wxLayoutList
*m_llist
;
167 /// Can user edit the window?
170 CoordType m_WrapMargin
;
175 wxPoint m_bitmapSize
;
177 DECLARE_EVENT_TABLE()