view anagram/guisupport/windowreg.h @ 15:f5acaf0c8a29

Don't cast through "volatile int". Causes a gcc warning nowadays. XXX: should put something else back here to frighten the optimizer
author David A. Holland
date Tue, 31 May 2022 01:00:55 -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 */