view anagram/vaclgui/fileview.hpp @ 21:1c9dac05d040

Add lint-style FALLTHROUGH annotations to fallthrough cases. (in the parse engine and thus the output code) Document this, because the old output causes warnings with gcc10.
author David A. Holland
date Mon, 13 Jun 2022 00:04:38 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*
 * 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 */