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

#ifndef WINDOWREG_H
#define WINDOWREG_H

//#include <icmdevt.hpp>
//#include <ievent.hpp>
//#include <iframe.hpp>

#include "action.h"
#include "agstack.h"
#include "agstring.h"

class AgFrame;


struct WindowRecord {
  int id;
  AgString title;
  AgAction action;
  AgFrame *window;
  int isShowing;
  int isActive;
  WindowRecord()
    : id(0), title(), action(), window(0), isShowing(0), isActive(0)
  {}
  WindowRecord(int i, const AgString t, const AgAction a, AgFrame *w)
    : id(i), title(t), action(a), window(w), isShowing(1), isActive(1)
  {}
  int operator < (const WindowRecord &w) const { return title < w.title; }
};

class WindowRegistry {
private:
  AgStack<WindowRecord> registry;

public:
  int cascadeFlag;

  WindowRegistry()
    : cascadeFlag(0)
  {}

  void registerId(AgFrame *window, AgString title, AgAction action);
  void refresh(AgString title);

  void remove(int id);
  AgFrame *find(AgString title);
  AgFrame *find(int id);
  AgString getTitle(int id);

  //void bubbleUp(int id);
  void markActive(int id);
  void clearActive();
  int action(int id);
  int action(AgString title);
  int size() { return registry.size();}

  WindowRecord &operator [] (int k) {
    return registry[k];
  }
};


#endif /* WINDOWREG_H */