Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/vaclgui/dview.hpp @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 /* | |
2 * AnaGram, A System for Syntax Directed Programming | |
3 * Copyright 1997-2002 Parsifal Software. All Rights Reserved. | |
4 * See the file COPYING for license and usage terms. | |
5 * | |
6 * dview.hpp | |
7 */ | |
8 | |
9 #ifndef DVIEW_HPP | |
10 #define DVIEW_HPP | |
11 | |
12 #include <icanvas.hpp> | |
13 #include <iclipbrd.hpp> | |
14 #include <icmdevt.hpp> | |
15 #include <icmdhdr.hpp> | |
16 //#include <icoordsy.hpp> | |
17 //#include <iexcbase.hpp> | |
18 //#include <ifont.hpp> | |
19 #include <ikeyevt.hpp> | |
20 #include <ikeyhdr.hpp> | |
21 #include <imenuevt.hpp> | |
22 #include <imenuhdr.hpp> | |
23 #include <imoushdr.hpp> | |
24 #include <imousevt.hpp> | |
25 #include <ipainevt.hpp> | |
26 #include <ipainhdr.hpp> | |
27 #include <ipopmenu.hpp> | |
28 //#include <irefcnt.hpp> | |
29 #include <iscroll.hpp> | |
30 #include <iscrlevt.hpp> | |
31 #include <iscrlhdr.hpp> | |
32 //#include <isizeevt.hpp> | |
33 #include <isizehdr.hpp> | |
34 //#include <istattxt.hpp> | |
35 #include <itimer.hpp> | |
36 //#include <ititle.hpp> | |
37 | |
38 class AgFrame; // from frame.hpp | |
39 #include "agstring.h" | |
40 #include "agview.hpp" | |
41 #include "search.h" | |
42 | |
43 | |
44 class AgDataView | |
45 : public ICanvas | |
46 , public ICommandHandler | |
47 , public IKeyboardHandler | |
48 , public IMenuHandler | |
49 , public IMouseHandler | |
50 , public IPaintHandler | |
51 , public IResizeHandler | |
52 , public IScrollHandler | |
53 , public AgHelpHandler | |
54 , public AgFocusHandler | |
55 { | |
56 public: | |
57 | |
58 static const int defaultWindowHeight; | |
59 | |
60 class MouseDragTimer : public ITimerFn { | |
61 private: | |
62 AgDataView *window; | |
63 int mouseLine; | |
64 int topLine; | |
65 public: | |
66 MouseDragTimer(AgDataView *, int, int); | |
67 void timerExpired(unsigned long timerId); | |
68 }; | |
69 | |
70 // Constructor | |
71 AgDataView(IWindow *, WindowData *); | |
72 AgDataView(IWindow *ownerWindow_); | |
73 AgDataView &init(WindowData *); | |
74 AgDataView &reset(); | |
75 | |
76 // Destructor | |
77 ~AgDataView(); | |
78 | |
79 void disconnect(); | |
80 | |
81 AgAction enterAction; | |
82 AgDataView &setEnterAction(AgAction action) { | |
83 enterAction = action; | |
84 return *this; | |
85 } | |
86 //virtual void onEnter() { | |
87 // enterAction.performDeferred(); | |
88 //} | |
89 | |
90 AgAction selectAction; | |
91 AgDataView &setSelectAction(AgAction action) { | |
92 selectAction = action; | |
93 return *this; | |
94 } | |
95 //virtual void onSelect() { | |
96 // selectAction.performDeferred(); | |
97 //} | |
98 | |
99 int getCursorLine(); | |
100 AgDataView &setCursorLine(int); | |
101 AgDataView &synchCursor(int); | |
102 void mouseDragTimerInterrupt(int &topLine, int mouseLine); | |
103 | |
104 ISize suggestSize(); | |
105 | |
106 AgDataView &setLayoutDistorted(unsigned long, unsigned long); | |
107 | |
108 AgDataView &layout(); | |
109 int tableWidth; | |
110 int columnHeadWidth; | |
111 AgDataView &adjustMaxWidth(AgString); | |
112 AgDataView &setColumnTitles(AgString title); | |
113 AgColumnHead columnHeadTitle; | |
114 AgStaticText dataArea; | |
115 | |
116 int lineHeight() const { | |
117 return font().externalLeading() + font().maxSize().height(); | |
118 } | |
119 int charWidth() const { return font().maxSize().width(); } | |
120 int avgCharWidth() const { return font().avgCharWidth(); } | |
121 int maxDescender() const { return font().maxDescender(); } | |
122 | |
123 AgDataView &repaintLine(int); | |
124 | |
125 SearchProcess searchProcess; | |
126 Boolean findNext(AgString); | |
127 Boolean findPrev(AgString); | |
128 AgDataView ©To(IClipboard &c); | |
129 virtual void showHelp(); | |
130 | |
131 protected: | |
132 | |
133 // Layout functions | |
134 AgDataView &doLayout(); | |
135 Boolean windowResize(IResizeEvent &); | |
136 ISize calcMinimumSize() const; | |
137 AgDataView &repositionWindow(); | |
138 int findMaxWidth(void); | |
139 | |
140 | |
141 // Handler functions | |
142 | |
143 // Command Handler | |
144 Boolean command(ICommandEvent &event); | |
145 | |
146 // Keyboard handler | |
147 Boolean virtualKeyPress(IKeyboardEvent &); | |
148 Boolean key(IKeyboardEvent &); | |
149 | |
150 // Menu handler | |
151 Boolean makePopUpMenu(IMenuEvent &event); | |
152 | |
153 IPopUpMenu popUpMenu; | |
154 AgArray<AgMenuItem> auxMenu; | |
155 Boolean menuEnded(IMenuEvent &); | |
156 AgDataView &initPopUp(); | |
157 AgDataView &validatePopUp(); | |
158 | |
159 virtual Boolean showHelp(IEvent &event); | |
160 | |
161 virtual ColorSpec *getLineColor(int); | |
162 | |
163 // Mouse handler | |
164 Boolean mouseClicked(IMouseClickEvent &event); | |
165 Boolean mouseMoved(IMouseEvent &event); | |
166 void dragMouse(int topLine, int mouseLine); | |
167 | |
168 Boolean gotFocus(IEvent &); | |
169 Boolean lostFocus(IEvent &); | |
170 | |
171 Boolean mouseDown; | |
172 int mouseDownCursorLine; | |
173 ITimer mouseTimer; | |
174 | |
175 | |
176 // Paint handler | |
177 Boolean paintWindow(IPaintEvent &); | |
178 | |
179 // Scroll handler | |
180 Boolean lineDown(IScrollEvent &); | |
181 Boolean lineLeft(IScrollEvent &); | |
182 Boolean lineRight(IScrollEvent &); | |
183 Boolean lineUp(IScrollEvent &); | |
184 Boolean pageDown(IScrollEvent &); | |
185 Boolean pageLeft(IScrollEvent &); | |
186 Boolean pageRight(IScrollEvent &); | |
187 Boolean pageUp(IScrollEvent &); | |
188 Boolean scrollBoxTrack(IScrollEvent &); | |
189 Boolean scrollBoxTrackEnd(IScrollEvent &event); | |
190 /* | |
191 virtual Boolean scrollBoxTrackEnd(IScrollEvent &event) { | |
192 return scrollBoxTrack(event); | |
193 } | |
194 */ | |
195 | |
196 public: | |
197 // child windows | |
198 IScrollBar horizontalScrollBar; | |
199 IScrollBar verticalScrollBar; | |
200 | |
201 AgDataView &setFrame(AgFrame *f) {frameWindow = f; return *this;} | |
202 | |
203 // window parameters | |
204 AgString copyTitle; | |
205 int windowId; | |
206 IWindow *ownerWindow; | |
207 AgFrame *frameWindow; | |
208 WindowData *windowData; | |
209 ColorSpec *color; | |
210 ColorSpec *cursorColor; | |
211 AgNotificationAction<AgDataView> dataColorChange; | |
212 AgNotificationAction<AgDataView> fontChange; | |
213 void onColorChange() { refresh(); } | |
214 void onFontChange(); | |
215 | |
216 int *tabArray; | |
217 int popUpInitialized; | |
218 char *helpTopic; | |
219 | |
220 // layout state | |
221 Boolean vsbShowing; | |
222 Boolean hsbShowing; | |
223 int columnHeadsPresent; | |
224 int tableHeight; | |
225 int verticalLineCount; | |
226 | |
227 // window state | |
228 int cursorLine; | |
229 int prevHorizontal; | |
230 int prevVertical; | |
231 int rightButtonDown; | |
232 | |
233 enum ButtonState { buttonIdle, buttonDown, waitingForClick }; | |
234 ButtonState rightButtonState; | |
235 | |
236 private: | |
237 int layoutActive; | |
238 int layoutComplete; | |
239 }; | |
240 | |
241 inline int AgDataView::getCursorLine() { return cursorLine; } | |
242 | |
243 void logFont(IFont activeFont); | |
244 void logFont(IFont activeFont, char *p); | |
245 | |
246 | |
247 #endif /* DVIEW_HPP */ |