Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/vaclgui/fileview.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 * fileview.hpp | |
7 */ | |
8 | |
9 #ifndef FILEVIEW_HPP | |
10 #define FILEVIEW_HPP | |
11 | |
12 #include "agview.hpp" | |
13 #include "textfile.h" | |
14 | |
15 //#define INCLUDE_LOGGING | |
16 //#include "log.h" | |
17 | |
18 | |
19 class FileView : public AgView { | |
20 protected: | |
21 text_file file; | |
22 | |
23 public: | |
24 FileView(IWindow *owner, text_file &file_); | |
25 ~FileView(); | |
26 | |
27 virtual void reload() { file.read_file(); } | |
28 virtual unsigned nLines() { return file.lx.size(); } | |
29 virtual AgString getLine(unsigned ln); | |
30 virtual AgString headTitle() { return file.name; } | |
31 AgNotificationAction<FileView> dataColorChange; | |
32 void onColorChange() { refresh(); } | |
33 AgNotificationAction<FileView> fontChange; | |
34 void onFontChange(); | |
35 virtual Boolean findNext(AgString); | |
36 virtual Boolean findPrev(AgString); | |
37 }; | |
38 | |
39 | |
40 class FileWindow : public AgFrame { | |
41 private: | |
42 FileView fileView; | |
43 int windowId; | |
44 | |
45 void init(text_file &file, IRectangle r); | |
46 | |
47 public: | |
48 /* | |
49 FileWindow(text_file &file) | |
50 : AgFrame() | |
51 , fileView(this, file) | |
52 { | |
53 init(file); | |
54 } | |
55 */ | |
56 FileWindow(int id, text_file &file, IRectangle r) | |
57 : AgFrame(id) | |
58 , fileView(this, file) | |
59 { | |
60 //LOGSECTION("File Window constructor"); | |
61 init(file, r); | |
62 } | |
63 | |
64 ~FileWindow() { | |
65 //LOGSECTION("File Window destructor"); | |
66 } | |
67 | |
68 FileWindow &setFocus() { | |
69 //LOGSECTION("FileWindow::setFocus"); | |
70 fileView.setFocus(); | |
71 return *this; | |
72 } | |
73 FileWindow &enableCursor(int flag = true) { | |
74 fileView.enableCursor(flag); | |
75 return *this; | |
76 } | |
77 FileWindow &enableCursorBar(int flag = true) { | |
78 //fileView.cursorLineHighlight = flag; | |
79 fileView.enableCursorBar(flag); | |
80 return *this; | |
81 } | |
82 cint getCursorLocation() { | |
83 return fileView.getCursorLocation(); | |
84 } | |
85 FileWindow &setCursorLocation(cint x) { | |
86 fileView.setCursorLocation(x); | |
87 return *this; | |
88 } | |
89 virtual Boolean findNext(AgString s) { return fileView.findNext(s); } | |
90 virtual Boolean findPrev(AgString s) { return fileView.findPrev(s); } | |
91 }; | |
92 | |
93 | |
94 #endif /* FILEVIEW_HPP */ |