]> git.saurik.com Git - wxWidgets.git/blob - user/wxLayout/wxlwindow.h
two more bug notes
[wxWidgets.git] / user / wxLayout / wxlwindow.h
1 /*-*- c++ -*-********************************************************
2 * wxLwindow.h : a scrolled Window for displaying/entering rich text*
3 * *
4 * (C) 1998,1999 by Karsten Ballüder (Ballueder@usa.net) *
5 * *
6 * $Id$
7 *******************************************************************/
8 #ifndef WXLWINDOW_H
9 #define WXLWINDOW_H
10
11 #ifdef __GNUG__
12 # pragma interface "wxlwindow.h"
13 #endif
14
15 #ifndef USE_PCH
16 # include <wx/wx.h>
17 #endif
18
19 #include "wxllist.h"
20
21 #ifndef WXLOWIN_MENU_FIRST
22 # define WXLOWIN_MENU_FIRST 12000
23 #endif
24
25 enum
26 {
27 WXLOWIN_MENU_LARGER = WXLOWIN_MENU_FIRST,
28 WXLOWIN_MENU_SMALLER,
29 WXLOWIN_MENU_UNDERLINE_ON,
30 WXLOWIN_MENU_UNDERLINE_OFF,
31 WXLOWIN_MENU_BOLD_ON,
32 WXLOWIN_MENU_BOLD_OFF,
33 WXLOWIN_MENU_ITALICS_ON,
34 WXLOWIN_MENU_ITALICS_OFF,
35 WXLOWIN_MENU_ROMAN,
36 WXLOWIN_MENU_TYPEWRITER,
37 WXLOWIN_MENU_SANSSERIF,
38 WXLOWIN_MENU_RCLICK,
39 WXLOWIN_MENU_LCLICK,
40 WXLOWIN_MENU_DBLCLICK,
41 WXLOWIN_MENU_MOUSEMOVE,
42 WXLOWIN_MENU_LAST = WXLOWIN_MENU_MOUSEMOVE
43 };
44
45 /**
46 This class is a rich text editing widget.
47 */
48 class wxLayoutWindow : public wxScrolledWindow
49 {
50 public:
51 /** Constructor.
52 @param parent parent window to display this panel in
53 */
54 wxLayoutWindow(wxWindow *parent);
55
56 /// Destructor.
57 virtual ~wxLayoutWindow();
58
59 /**@name Editing functionality */
60 //@{
61 /// Clears the window and sets default parameters.
62 void Clear(int family = wxROMAN,
63 int size=12,
64 int style=wxNORMAL,
65 int weight=wxNORMAL,
66 int underline=0,
67 wxColour *fg=NULL,
68 wxColour *bg=NULL);
69 /** Sets a background image, only used on screen, not on printouts.
70 @param bitmap a pointer to a wxBitmap or NULL to remove it
71 */
72 void SetBackgroundBitmap(wxBitmap *bitmap = NULL)
73 {
74 if(m_BGbitmap) delete m_BGbitmap;
75 m_BGbitmap = bitmap;
76 }
77 /// Enable or disable editing, i.e. processing of keystrokes.
78 void SetEditable(bool toggle) { m_Editable = toggle; }
79 /// Query whether list can be edited by user.
80 bool IsEditable(void) const { return m_Editable; }
81 /// Pastes text from clipboard.
82 void Paste(void);
83 /// Copies selection to clipboard.
84 bool Copy(void);
85 /// Copies selection to clipboard and deletes it.
86 bool Cut(void);
87 //@}
88
89 bool Find(const wxString &needle,
90 wxPoint * fromWhere = NULL);
91
92 void EnablePopup(bool enable = true) { m_DoPopupMenu = enable; }
93
94 /** Sets the wrap margin.
95 @param margin set this to 0 to disable it
96 */
97 void SetWrapMargin(CoordType margin) { m_WrapMargin = margin; }
98
99 /** Redraws the window.
100 Internally, this stores the parameter and calls a refresh on
101 wxMSW, draws directly on wxGTK.
102 */
103 void DoPaint(const wxRect *updateRect);
104
105 #ifdef __WXMSW__
106 virtual long MSWGetDlgCode();
107 #endif //MSW
108
109 /// if exact == false, assume 50% extra size for the future
110 void ResizeScrollbars(bool exact = false); // don't change this to true!
111
112 /// if the flag is true, we send events when user clicks on embedded objects
113 inline void SetMouseTracking(bool doIt = true) { m_doSendEvents = doIt; }
114
115 /* Returns a pointer to the wxLayoutList object.
116 @return the list
117 */
118 wxLayoutList * GetLayoutList(void) { return m_llist; }
119
120 /**@name Callbacks */
121 //@{
122 void OnPaint(wxPaintEvent &event);
123 void OnChar(wxKeyEvent& event);
124 void OnKeyUp(wxKeyEvent& event);
125 void OnMenu(wxCommandEvent& event);
126 void OnLeftMouseClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_LCLICK, event); }
127 void OnRightMouseClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_RCLICK, event); }
128 void OnMouseDblClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_DBLCLICK, event); }
129 void OnMouseMove(wxMouseEvent &event) { OnMouse(WXLOWIN_MENU_MOUSEMOVE, event) ; }
130 void OnSetFocus(wxFocusEvent &ev);
131 void OnKillFocus(wxFocusEvent &ev);
132 //@}
133
134 /// Creates a wxMenu for use as a format popup.
135 static wxMenu * MakeFormatMenu(void);
136 /**@name Dirty flag handling for optimisations. */
137 //@{
138 /// Set dirty flag.
139 void SetDirty(void) { m_Dirty = true; }
140 /// Query whether window needs redrawing.
141 bool IsDirty(void) const { return m_Dirty; }
142 /// Reset dirty flag.
143 void ResetDirty(void) { m_Dirty = false; }
144 //@}
145 /// Redraws the window, used by DoPaint() or OnPaint().
146 void InternalPaint(const wxRect *updateRect);
147
148 /// Has list been modified/edited?
149 bool IsModified(void) const { return m_Modified; }
150 /// Mark list as modified or unchanged.
151 void SetModified(bool modified = true) { m_Modified = modified; }
152
153 protected:
154 /// generic function for mouse events processing
155 void OnMouse(int eventId, wxMouseEvent& event);
156 /// as the name says
157 void ScrollToCursor(void);
158 /// for sending events
159 wxWindow *m_Parent;
160 /// Shall we send events?
161 bool m_doSendEvents;
162 /// Where does the current view start?
163 int m_ViewStartX; int m_ViewStartY;
164 /// Do we currently have the focus?
165 bool m_HaveFocus;
166 /// do we handle clicks of the right mouse button?
167 bool m_DoPopupMenu;
168 /// Should InternalPaint() scroll to cursor.
169 bool m_ScrollToCursor;
170 /// Do we currently have a non-standard cursor?
171 bool m_HandCursor;
172 /// the menu
173 wxMenu * m_PopupMenu;
174 /// for derived classes, set when mouse is clicked
175 wxPoint m_ClickPosition;
176 /// for scrollbar calculations:
177 int m_maxx;
178 int m_maxy;
179 int m_lineHeight;
180 private:
181 /// The layout list to be displayed.
182 wxLayoutList *m_llist;
183 /// Can user edit the window?
184 bool m_Editable;
185 /// Are we currently building a selection with the keyboard?
186 bool m_Selecting;
187 /// wrap margin
188 CoordType m_WrapMargin;
189 /// Is list dirty (for redraws, internal use)?
190 bool m_Dirty;
191 /// Has list been edited?
192 bool m_Modified;
193 wxMemoryDC *m_memDC;
194 wxBitmap *m_bitmap;
195 wxPoint m_bitmapSize;
196 /// a pointer to a bitmap for the background
197 wxBitmap *m_BGbitmap;
198 DECLARE_EVENT_TABLE()
199 };
200
201 #endif