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

#ifndef AGRECT_HPP
#define AGRECT_HPP

#include <iwindow.hpp>
//#include <irect.hpp>
#include <windows.h>

#include "agstack.h"
#include "cint.h"


enum AgQuadrant {
  upperLeft, lowerLeft, upperRight, lowerRight
};

enum AgAlignment {
  topLeft, topCenter, topRight,
  centerLeft, centerCenter, centerRight,
  bottomLeft, bottomCenter, bottomRight
};

class AgRectangle {
private:
  cint pos;
  cint sz;
  AgQuadrant anchor;

public:
  AgRectangle() : anchor(upperLeft) {}
  AgRectangle(RECT r);
  AgRectangle(IWindow *w);
  AgRectangle(cint size_);
  AgRectangle(cint loc, cint size_, AgQuadrant whichQuadrant = lowerRight);
  cint position(AgQuadrant whichCorner = upperLeft);
  AgRectangle &setSize(cint s);
  cint size() { return sz; }
  int area() { return sz.x*sz.y; }
  AgRectangle intersection(AgRectangle &r);
  AgRectangle &limit(cint size);
  static AgRectangle desktop();
  int operator < (const AgRectangle &r) const;
};

struct LayoutRef {
  cint corner[4];
  AgStack<AgRectangle> stack;

  LayoutRef(AgRectangle &r);
  cint position(AgQuadrant c) {
    return corner[c%4];
  }
  int overlap(AgRectangle &r);
  void merge(AgRectangle &r);
};


AgQuadrant opposite(AgQuadrant corner);


#endif /* AGRECT_HPP */