Mercurial > ~dholland > hg > ag > index.cgi
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/anagram/vaclgui/fileview.hpp Sat Dec 22 17:52:45 2007 -0500 @@ -0,0 +1,94 @@ +/* + * AnaGram, A System for Syntax Directed Programming + * Copyright 1997-2002 Parsifal Software. All Rights Reserved. + * See the file COPYING for license and usage terms. + * + * fileview.hpp + */ + +#ifndef FILEVIEW_HPP +#define FILEVIEW_HPP + +#include "agview.hpp" +#include "textfile.h" + +//#define INCLUDE_LOGGING +//#include "log.h" + + +class FileView : public AgView { +protected: + text_file file; + +public: + FileView(IWindow *owner, text_file &file_); + ~FileView(); + + virtual void reload() { file.read_file(); } + virtual unsigned nLines() { return file.lx.size(); } + virtual AgString getLine(unsigned ln); + virtual AgString headTitle() { return file.name; } + AgNotificationAction<FileView> dataColorChange; + void onColorChange() { refresh(); } + AgNotificationAction<FileView> fontChange; + void onFontChange(); + virtual Boolean findNext(AgString); + virtual Boolean findPrev(AgString); +}; + + +class FileWindow : public AgFrame { +private: + FileView fileView; + int windowId; + + void init(text_file &file, IRectangle r); + +public: +/* + FileWindow(text_file &file) + : AgFrame() + , fileView(this, file) + { + init(file); + } +*/ + FileWindow(int id, text_file &file, IRectangle r) + : AgFrame(id) + , fileView(this, file) + { + //LOGSECTION("File Window constructor"); + init(file, r); + } + + ~FileWindow() { + //LOGSECTION("File Window destructor"); + } + + FileWindow &setFocus() { + //LOGSECTION("FileWindow::setFocus"); + fileView.setFocus(); + return *this; + } + FileWindow &enableCursor(int flag = true) { + fileView.enableCursor(flag); + return *this; + } + FileWindow &enableCursorBar(int flag = true) { + //fileView.cursorLineHighlight = flag; + fileView.enableCursorBar(flag); + return *this; + } + cint getCursorLocation() { + return fileView.getCursorLocation(); + } + FileWindow &setCursorLocation(cint x) { + fileView.setCursorLocation(x); + return *this; + } + virtual Boolean findNext(AgString s) { return fileView.findNext(s); } + virtual Boolean findPrev(AgString s) { return fileView.findPrev(s); } +}; + + +#endif /* FILEVIEW_HPP */