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_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
,
70 GetLayoutList()->Clear(family
,size
,style
,weight
,underline
,fg
,bg
);
71 SetBackgroundColour(GetLayoutList()->GetDefaults()->GetBGColour());
72 ResizeScrollbars(true);
77 r
.x
= r
.y
= 0; GetSize(&w
,&h
);
82 /** Sets a background image, only used on screen, not on printouts.
83 @param bitmap a pointer to a wxBitmap or NULL to remove it
85 void SetBackgroundBitmap(wxBitmap
*bitmap
= NULL
)
87 if(m_BGbitmap
) delete m_BGbitmap
;
90 /// Enable or disable editing, i.e. processing of keystrokes.
91 void SetEditable(bool toggle
) { m_Editable
= toggle
; }
92 /// Query whether list can be edited by user.
93 bool IsEditable(void) const { return m_Editable
; }
94 /// Pastes text from clipboard.
99 void EnablePopup(bool enable
= true) { m_DoPopupMenu
= enable
; }
101 /** Sets the wrap margin.
102 @param margin set this to 0 to disable it
104 void SetWrapMargin(CoordType margin
) { m_WrapMargin
= margin
; }
106 /** Redraws the window.
107 Internally, this stores the parameter and calls a refresh on
108 wxMSW, draws directly on wxGTK.
110 void DoPaint(const wxRect
*updateRect
);
113 virtual long MSWGetDlgCode();
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 OnMenu(wxCommandEvent
& event
);
132 void OnLeftMouseClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_LCLICK
, event
); }
133 void OnRightMouseClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_RCLICK
, event
); }
134 void OnMouseDblClick(wxMouseEvent
& event
) { OnMouse(WXLOWIN_MENU_DBLCLICK
, event
); }
135 void OnMouseMove(wxMouseEvent
&event
) { OnMouse(WXLOWIN_MENU_MOUSEMOVE
, event
) ; }
136 void OnSetFocus(wxFocusEvent
&ev
);
137 void OnKillFocus(wxFocusEvent
&ev
);
140 /// Creates a wxMenu for use as a format popup.
141 static wxMenu
* MakeFormatMenu(void);
142 /**@name Dirty flag handling for optimisations. */
145 void SetDirty(void) { m_Dirty
= true; }
146 /// Query whether window needs redrawing.
147 bool IsDirty(void) const { return m_Dirty
; }
148 /// Reset dirty flag.
149 void ResetDirty(void) { m_Dirty
= false; }
151 /// Redraws the window, used by DoPaint() or OnPaint().
152 void InternalPaint(const wxRect
*updateRect
);
154 /// Has list been modified/edited?
155 bool IsModified(void) const { return m_Modified
; }
156 /// Mark list as modified or unchanged.
157 void SetModified(bool modified
= true) { m_Modified
= modified
; }
160 /// generic function for mouse events processing
161 void OnMouse(int eventId
, wxMouseEvent
& event
);
163 /// for sending events
165 /// Shall we send events?
167 /// Where does the current view start?
168 int m_ViewStartX
; int m_ViewStartY
;
169 /// Do we currently have the focus?
171 /// do we handle clicks of the right mouse button?
173 /// Should InternalPaint() scroll to cursor.
174 bool m_ScrollToCursor
;
175 /// Do we currently have a non-standard cursor?
178 wxMenu
* m_PopupMenu
;
179 /// for derived classes, set when mouse is clicked
180 wxPoint m_ClickPosition
;
181 /// for scrollbar calculations:
186 /// The layout list to be displayed.
187 wxLayoutList
*m_llist
;
188 /// Can user edit the window?
190 /// Are we currently building a selection with the keyboard?
193 CoordType m_WrapMargin
;
194 /// Is list dirty (for redraws, internal use)?
196 /// Has list been edited?
200 wxPoint m_bitmapSize
;
201 /// a pointer to a bitmap for the background
202 wxBitmap
*m_BGbitmap
;
203 DECLARE_EVENT_TABLE()