view anagram/guisupport/windowreg.h @ 4:bebb2ba69e1d

maybe help with getting tex to fail properly on error
author David A. Holland
date Sat, 18 Apr 2020 17:12:17 -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 */