view anagram/vaclgui/ctrlpanel.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.
 *
 * ctrlpanel.hpp
 */

#ifndef CTRLPANEL_HPP
#define CTRLPANEL_HPP

#include <time.h>
#include "port.h"

//#include <icanvas.hpp>
#include <icmdhdr.hpp>
#include <icombobx.hpp>
//#include <ifiledlg.hpp>
#include <iflyhhdr.hpp>
#include <iflytext.hpp>
#include <ifocshdr.hpp>
#include <ifont.hpp>
#include <iframe.hpp>
#include <igraphbt.hpp>
#include <imenubar.hpp>
#include <imenuhdr.hpp>
#include <imousevt.hpp>
#include <imoushdr.hpp>
//#include <imphdr.hpp>
#include <ipainevt.hpp>
#include <ipainhdr.hpp>
#include <iselhdr.hpp>
#include <isetcv.hpp>
#include <islhdr.hpp>
#include <istattxt.hpp>
//#include <istring.hpp>
#include <isubmenu.hpp>
#include <isysmenu.hpp>
#include <ithread.hpp>
#include <itimer.hpp>
#include <ititle.hpp>

#include "action.h"
#include "agstring.h"
#include "frame.hpp"
#include "openfile.hpp"
#include "statwin.hpp"


class ControlPanel
  : public IFrameWindow
  , public ICommandHandler
  , public IMenuHandler
  , public AgHelpHandler
  , public IFrameHandler
  , public IMouseHandler
//  , public IMousePointer
  , public IPaintHandler
  , public IFocusHandler
  , public IKeyboardHandler
//  , public IResizeHandler
{

  // Declare friendship with the AnalyzeGrammarFn class which encapsulates
  // a thread function that executes a member function of this class
  //-------
  friend class AnalyzeGrammarFn;
  friend class BuildParserFn;
  friend class TimerFn;

  //Boolean         busyFlag;
  //int             errorCount;
  //int             minimized;
  //ISize             minimumSize;

public:

  Boolean         autobuildFlag;
  Boolean         showSyntaxFlag;
  Boolean         showStatsFlag;
  Boolean         stayOnTopFlag;

  // Constructor and destructor

  ControlPanel(unsigned long windowId);
  ~ControlPanel();
  static void makeControlPanel();
  void openCommandLineFile();
  //Boolean busy() { return busyFlag; }
  void idSyntaxFile(AgString);
  void loadSyntaxFile();
  char *removeTilde(char *);
  AgThread         analyzeThread;

  //int maxDataPanelWidth;

  AgUserHandler *userHandler;
  static AgString selectedMenuText;
  //void checkTopmost();
  //AgClassAction<ControlPanel> topmostAction;
  void setStatus();


  // Command event handler function

  Boolean command(ICommandEvent&);
  Boolean activated(IFrameEvent &);
  Boolean deactivated(IFrameEvent &);
  Boolean gotFocus(IControlEvent &);
  //Boolean lostFocus(IControlEvent &);
  Boolean virtualKeyPress(IKeyboardEvent &);
  //Boolean mousePointerChange(IMousePointerEvent &event);
  ControlPanel &makeTopmost();
  //ControlPanel &makeNotTopmost();
  //Boolean dispatchHandlerEvent(IEvent &event);
  Boolean systemCommand(ICommandEvent&);
  Boolean menuShowing(IMenuEvent &event, ISubmenu &submenu);
  Boolean menuEnded(IMenuEvent &event);
  Boolean menuSelected(IMenuEvent &event);
  Boolean mouseClicked(IMouseClickEvent &event);
  Boolean paintWindow(IPaintEvent &event);
  //Boolean windowResize(IResizeEvent &event);
  void showErrors();
  void closeWindows();
  void hideWindows();
  void restoreWindows();
  void closeSyntaxWindows();
  virtual Boolean showHelp(IEvent &event);
  virtual ControlPanel &close();
  void gatherProfile();
  void rememberFile(AgString);
  void selectMenuItem(long);
  void restoreDirectory();

  class TimerFn : public ITimerFn {
  private:
    ITimer &timer;
    //StatusControl &window;
    StatisticsWindow &window;
    IThread &thread;
    void timerExpired(unsigned long timerId);

  public:
    TimerFn(ITimer &timer_, StatisticsWindow &window_, IThread &thread_)
      : timer(timer_)
      , window(window_)
      , thread(thread_)
    {}
  };

  class ComboBox
    : public IComboBox
    , public IShowListHandler
    , public ISelectHandler
  {
  private:
    int listShowing;

  public:
    AgAction enterAction;
    AgAction selectAction;
    ComboBox(long id, IWindow *owner, char *text)
      : IComboBox(id, owner, owner, IRectangle(),
        autoScroll |
        dropDownType | horizontalScroll | tabStop)
      , listShowing(0)
    {
      //LOGSECTION("ControlPanel::ComboBox::ComboBox");
      IFont f = font();
      ISize minimum(f.textWidth(text),f.maxCharHeight() );
      //LOGV(minimum.asString());
      setMinimumSize(minimum).show();
      addAsLast("");
      ISelectHandler::handleEventsFor(this);
      IShowListHandler::handleEventsFor(this);
    }
    ~ComboBox() {
      ISelectHandler::stopHandlingEventsFor(this);
      IShowListHandler::stopHandlingEventsFor(this);
    }

    Boolean listShown(IControlEvent &event);
    Boolean enter(IControlEvent &event);
  };

  void findNext();
  void findPrev();

  void monitor(IThread &thread);

  ITimer timer;

  AgAction quitAction;
  void quit();

  AgNotificationAction<ControlPanel> textColorChange;
  AgNotificationAction<ControlPanel> linkColorChange;
  AgNotificationAction<ControlPanel> traversedColorChange;
  void onTextColorChange();
  void onLinkColorChange();
  void onTraversedColorChange();


//private:

  // Shows product information dialog
  //virtual void productInfo();

  AgString         openFileName;
  time_t           openFileTimestamp;
  AgString         sourceText;

  IMenuBar        menuBar;
  ISystemMenu     systemMenu;
  IFont           systemMenuFont;

  ISetCanvas             canvas;
    ISetCanvas             buttonCanvas;
      IGraphicPushButton     agButton;
      IGraphicPushButton     bpButton;
      IGraphicPushButton     ftButton;
      IGraphicPushButton     gtButton;
      IGraphicPushButton     warnButton;
      IGraphicPushButton     confButton;
      IGraphicPushButton     helpButton;
      IStaticText            statusControl;
    ISetCanvas             searchCanvas;
      ComboBox               searchKeyBox;
      IGraphicPushButton     findNextButton;
      IGraphicPushButton     findPrevButton;

  IFlyText            flyText;
  IFlyOverHelpHandler flyOver;
  IAccelerator accelerator;

public:
  ITitle          windowTitle;

  AgStack<AgString> recentFiles;

  int topmostFlag;

  //void showHelpTopic();
  int helpRequested;

  HelpDemon statusControlHelp;
  HelpDemon searchKeyHelp;

  IRectangle closeRect;

  static IPointerHandle  helpCursor;
  static IPointerHandle  activeCursor;
  static ISystemPointerHandle waitCursor;
  static int             helpCursorSet;
  static void resetCursor();
};

extern ControlPanel  *controlPanel;
extern IPoint         controlPanelLocation;

extern int            syntaxFileId;
extern IRectangle     syntaxFileRect;


#endif /* CTRLPANEL_HPP */