#include "Punkt.h" #include "Fenster.h" using namespace Framework; // Inhalt der Punkt Klasse aus Punkt.h // Konstroktor Punkt::Punkt() { x = 0; y = 0; ref = 1; } Punkt::Punkt( int x, int y ) { this->x = x; this->y = y; ref = 1; } // Destruktor Punkt::~Punkt() { } // nicht constant void Punkt::setP( int x, int y ) // setzt x und y { this->x = x; this->y = y; } void Punkt::setX( int x ) // setzt x { this->x = x; } void Punkt::setY( int y ) // setzt y { this->y = y; } // constant int Punkt::getX() const // gibt x zurück { return x; } int Punkt::getY() const // gibt y zurück { return y; } // Reference Counting Punkt *Punkt::getThis() { ref++; return this; } Punkt *Punkt::release() { ref--; if( ref == 0 ) delete this; return 0; } // andere Funktionen Punkt *Framework::BildschirmGröße() // Gibt die Größe des Bildschirms zurück { RECT r; GetWindowRect( GetDesktopWindow(), &r ); return new Punkt( r.right, r.bottom ); } Punkt *Framework::Bildschirmmitte() // Giebt die Mitte des Bildschirms zurück { RECT r; GetWindowRect( GetDesktopWindow(), &r ); // Bildschirmgröße herausfinden return new Punkt( r.right / 2, r.bottom / 2 ); } Punkt *Framework::Bildschirmmitte( WFenster *f ) // Giebt die Mitte des Bildschirms zurück { Punkt *p = Bildschirmmitte(); Punkt *p2 = f->getGröße(); Punkt *ret = new Punkt( p->getX() - p2->getX() / 2, p->getY() - p2->getY() / 2 ); f = f->release(); p->release(); p2->release(); return ret; } bool Framework::operator >( Punkt &a, Punkt &b ) // Gibt an, ob a > als b ist { return a.getX() > b.getX() && a.getY() > b.getY(); } bool Framework::operator <( Punkt &a, Punkt &b ) // Gibt an, ob a < als b ist { return a.getX() < b.getX() && a.getY() < b.getY(); } bool Framework::operator <=( Punkt &a, Punkt &b ) // Gibt an, ob a <= als b ist { return a.getX() <= b.getX() && a.getY() <= b.getY(); } bool Framework::operator >=( Punkt &a, Punkt &b ) // Gibt an, ob a >= als b ist { return a.getX() >= b.getX() && a.getY() >= b.getY(); }