view anagram/vaclgui/agrect.hpp @ 14:a02e9434072e

Fix friend declaration for gcc10. XXX: did not check it against the IBM compiler, might end up needing XXX: to be conditional.
author David A. Holland
date Tue, 31 May 2022 00:59:42 -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 */