view anagram/vaclgui/about.cpp @ 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.
 *
 * about.cpp
 */

#include <ifont.hpp>

#include "about.hpp"
#include "build.h"
#include "vaclgui.hpp"
#include "version.h"

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


AboutBox::AboutBox()
  : AgFrame(  IFrameWindow::border
            | dialogBackground
            | IFrameWindow::systemMenu)
  , canvas(nextChildId(), this, this, IRectangle(),
	     IMultiCellCanvas::classDefaultStyle
	   | IWindow::clipChildren)
  , anaGramIcon(nextChildId(), &canvas, &canvas, iconHandle,IRectangle(),
		  IIconControl::classDefaultStyle
		| IIconControl::fillBackground)
  , textBlock(nextChildId(), &canvas, &canvas, IRectangle(),
	        ISetCanvas::verticalDecks
	      | ISetCanvas::packTight
	      | ISetCanvas::centerAlign
	      | IWindow::clipChildren
	      | IWindow::visible)
  , titleLines(&textBlock)
  , copyrightNotice(&textBlock)
  //, licenseBox(nextChildId(), &textBlock, &textBlock)
  //, licensee(&textBlock, IRectangle(),
  //             IStaticText::classDefaultStyle
  //           | IStaticText::border3D),
  , address(&textBlock)
  , buildInfo(&textBlock)
{
  LOGSECTION("AboutBox::AboutBox");
  IPaintHandler::handleEventsFor(&canvas);
  IPaintHandler::handleEventsFor(&textBlock);
  IFont headFont("Arial", 12);
  IFont textFont("Arial", 8);
  windowTitle.setText("About AnaGram");

  LOGV(headFont.name()) LCV(headFont.pointSize());
  LOGV(textFont.name()) LCV(textFont.pointSize());

  titleLines.setFont(headFont);
  buildInfo.setFont(textFont);
  copyrightNotice.setFont(textFont);
  //licensee.setFont(textFont);
  //licenseBox.setFont(textFont);
  address.setFont(textFont);

  anaGramIcon.sizeTo(anaGramIcon.minimumSize());

  int leading = textFont.maxSize().height() + textFont.externalLeading();

  titleLines.setMargin(leading/2, leading/2);
  titleLines.setVTab(leading/2);
  titleLines.setText(
    "AnaGram LALR Parser Generator\n" VERSIONSTRING
    );
  LOGV(titleLines.minimumSize());
  textBlock.setDeckCount(1);

  copyrightNotice.setMargin(leading/2, leading/2);
  copyrightNotice.setVTab(leading/2);
  copyrightNotice.setText(
    "Copyright 1993-2002 Parsifal Software. "
    "All rights reserved.\n"
    "Copyright 2006, 2007 David A. Holland. "
    "All rights reserved.\n"
    "\n"
    "This version of AnaGram is free software.\n"
    "There is NO WARRANTY.\n"
    "See \"license\" in the help system for details.\n"
    );

  //licenseBox.setText("This copy of AnaGram is registered to:");
  //licensee.setText(licenseeText().pointer());
  //licensee.setMargin(leading, leading);
  //licensee.setVTab(leading/2);

  //ISize minSize = licenseBox.minimumSize();
  //ISize licenseeSize = licensee.minimumSize();
  //if (licenseeSize.width() < minSize.width()) {
  //  licenseeSize.setWidth(minSize.width());
  //}
  //licensee.setMinimumSize(licenseeSize);

  //LOGV(licensee.minimumSize());

  address.setMargin(leading/2, leading/2);
  address.setVTab(leading/2);
  address.setText("\n\vThe AnaGram web site is\n"
                  "http://www.parsifalsoft.com/");

  AgString bi1 = "\n\vBuilt ";
  AgString bi2 = build_date;
  AgString bi3 = "\non ";
  AgString bi4 = build_os;
  AgString bi = bi1.concat(bi2).concat(bi3).concat(bi4);
  buildInfo.setMargin(leading/2, leading/2);
  buildInfo.setVTab(leading/2);
  buildInfo.setText(bi.pointer());

  canvas.setColumnWidth(1, 16);
  canvas.setColumnWidth(5, 16);
  canvas.setRowHeight(1, 16);
  canvas.setRowHeight(5, 16);
  canvas.setColumnWidth(2, 32);
  canvas.setColumnWidth(3, 0, true);
  canvas.setColumnWidth(4, 32);
  LOGV(canvas.rowHeight(5));
  canvas.setRowHeight(2, 32);
  canvas.setRowHeight(3, 0, true);
  LOGV(canvas.rowHeight(2));
  canvas.addToCell(&anaGramIcon, 2, 2, 1, 1);
  LOGV(canvas.rowHeight(2));
  canvas.addToCell(&textBlock, 3, 2, 1, 3);
  ISize canvasSize = canvas.minimumSize();
  LOGV(canvasSize.asString());
  ISize frameSize = frameRectFor(IRectangle(canvasSize)).size();
  setClient(&canvas);
  sizeTo(frameSize);
  registerTitle("About AnaGram");
  LOGV(canvas.rowHeight(2));
}

AboutBox::~AboutBox() {
  IPaintHandler::stopHandlingEventsFor(&canvas);
  IPaintHandler::stopHandlingEventsFor(&textBlock);
}

Boolean AboutBox::paintWindow(IPaintEvent &event) {
  LOGSECTION("AboutBox::paintWindow");
  LOGV(event.rect().asString());
  LOGV((int) event.controlWindow());
  LOGV((int) event.dispatchingWindow());
  LOGV(position().asString());
  event.clearBackground(IGUIColor::dialogBgnd);
  return false;
}