view anagram/guisupport/wdata.h @ 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.
 *
 * wdata.h
 */

#ifndef WDATA_H
#define WDATA_H

#include "action.h"
#include "agstring.h"
#include "agarray.h"

//#define INCLUDE_LOGGING
//#include "log.h"

class WindowConnector;
class dc;

class AgDataPanel;


class AgMenuItem {
private:
  static const AgAction nullAction;
public:
  AgString text;
  AgAction action;
  dc *displayControl;
  AgMenuItem(AgString text_, AgAction action_, dc *displayControl_) :
    text(text_),
    action(action_),
    displayControl(displayControl_)
  {
    //LOGSECTION("AgMenuItem constructor");
    //LOGV((int) (dc *) displayControl);
  }
  AgMenuItem &operator =(const AgMenuItem &m) {
    text = m.text;
    action = m.action;
    displayControl = m.displayControl;
    return *this;
  }
  AgMenuItem() :
    text(AgString())
  , action(nullAction)
  , displayControl(0)
  {}
  int operator < (const AgMenuItem  &m) const {
    return text < m.text;
  }
};

class FindTabs {
private:
  AgString text;
  char *field;
  char *nextField;

  void update() {
    if (nextField == 0) return;
    while (*nextField && *nextField != '\t') nextField++;
    if (*nextField) *nextField++ = 0;
    else nextField = 0;
  }

public:
  FindTabs(char *p) : text(p), field((char *)p), nextField((char *)p) {
    update();
  }
  char *getField() {
    char *rv = field;
    field = nextField;
    update();
    return rv;
  }
};

class WindowData {
public:
  virtual int nextChildId() = 0;
  virtual ~WindowData() {}
  virtual AgString getLine(unsigned) { return AgString(); }
  virtual AgString findHelpTopic() { return AgString(); }
  virtual unsigned nLines() { return 0; }
  virtual unsigned nColumns() { return 1; }

  virtual AgString fileName() { return AgString(); }
  virtual AgString headTitle() { return AgString(); }
  virtual AgString columnHeadTitle() { return AgString(); }
  virtual AgString footTitle() { return AgString(); }
  virtual void onEnter() {}
  virtual void close() {}
  virtual void show() {}
  virtual AgArray<AgMenuItem> auxMenu() { return AgArray<AgMenuItem>(); }

  virtual int syntaxDependent() { return 0; }
  virtual int getCursorLine(){ return 0; }
  virtual void synchCursor(unsigned) {}
};

class WindowConnector {
public:
  virtual void disconnect() {}
  virtual void setFocus() {}
  virtual int getCursorLine(){ return 0; }
  virtual WindowData *windowData() { return NULL; }
};

#endif /* WDATA_H */