view anagram/vaclgui/agrect.hpp @ 8:ec2b657edf13

Add explicit lint-comment-style fallthrough annotations. GCC now assumes that if you don't have these you're making a mistake, which is annoying. XXX: This changeset updates the AG output files only (by hand) and is XXX: abusive - rebuilding them will erase the change. However, I need XXX: to get things to build before I can try to get AG to issue the XXX: annotations itself, so this seems like a reasonable expedient.
author David A. Holland
date Mon, 30 May 2022 23:51:43 -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 */