138 lines
3.0 KiB
C++
138 lines
3.0 KiB
C++
//## begin module.cm preserve=no
|
|
|
|
// %X% %Q% %Z% %W%
|
|
|
|
//## end module.cm
|
|
|
|
|
|
|
|
//## begin module.cp preserve=no
|
|
|
|
//## end module.cp
|
|
|
|
|
|
|
|
//## Module: Desktop; Pseudo Package body
|
|
|
|
//## Subsystem: lab7
|
|
|
|
//## Source file: H:\kurs\avC++\lab7\Desktop.cpp
|
|
|
|
|
|
|
|
//## begin module.additionalIncludes preserve=no
|
|
|
|
//## end module.additionalIncludes
|
|
|
|
|
|
|
|
//## begin module.includes preserve=yes
|
|
|
|
#include <iostream.h>
|
|
|
|
//## end module.includes
|
|
|
|
|
|
|
|
// Desktop
|
|
|
|
#include "Desktop.h"
|
|
|
|
//## begin module.additionalDeclarations preserve=yes
|
|
|
|
//## end module.additionalDeclarations
|
|
|
|
|
|
|
|
|
|
|
|
// Class Desktop
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Desktop::Desktop()
|
|
|
|
//## begin Desktop::Desktop%.hasinit preserve=no
|
|
|
|
//## end Desktop::Desktop%.hasinit
|
|
|
|
//## begin Desktop::Desktop%.initialization preserve=yes
|
|
|
|
//## end Desktop::Desktop%.initialization
|
|
|
|
{
|
|
|
|
//## begin Desktop::Desktop%.body preserve=yes
|
|
|
|
//## end Desktop::Desktop%.body
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Desktop::~Desktop()
|
|
|
|
{
|
|
|
|
//## begin Desktop::~Desktop%.body preserve=yes
|
|
|
|
//## end Desktop::~Desktop%.body
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//## Other Operations (implementation)
|
|
|
|
void Desktop::handleMouseEvent (Event e)
|
|
|
|
{
|
|
|
|
//## begin Desktop::handleMouseEvent%940854123.body preserve=yes
|
|
|
|
Window *wTmp;
|
|
|
|
|
|
|
|
if(active->isHit(e.getxpos(),e.getypos()))
|
|
|
|
active->handleMouseEvent(e);
|
|
|
|
else if(!wList.isEmpty()){
|
|
|
|
wTmp = wList.getFirst();
|
|
|
|
if(wTmp->isHit(e.getxpos(),e.getypos())){
|
|
|
|
active = wTmp;
|
|
|
|
wTmp->handleMouseEvent(e);
|
|
|
|
}
|
|
|
|
while(!wList.isLast()){
|
|
|
|
wTmp = wList.getNext();
|
|
|
|
if(wTmp->isHit(e.getxpos(),e.getypos())){
|
|
|
|
active = wTmp;
|
|
|
|
wTmp->handleMouseEvent(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//## end Desktop::handleMouseEvent%940854123.body
|
|
|
|
}
|
|
|
|
|
|
|
|
void Desktop::draw (Graphics& gd)
|
|
|
|
{
|
|
|
|
//## begin Desktop::draw%940929795.body preserve=yes
|
|
|
|
Window *wTmp;
|
|
|
|
|
|
|
|
if(!wList.isEmpty()){
|
|
|
|
wTmp = wList.getFirst();
|
|
|
|
wTmp->draw(gd);
|
|
|
|
|
|
|
|
while(!wList.isLast()){
|
|
|
|
wTmp = wList.getNext();
|
|
|
|
wTmp->draw(gd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
active->draw(gd);
|
|
|
|
//## end Desktop::draw%940929795.body
|
|
|
|
}
|
|
|
|
|
|
|
|
void Desktop::add (Window* w)
|
|
|
|
{
|
|
|
|
//## begin Desktop::add%940945814.body preserve=yes
|
|
|
|
wList.addElement(w);
|
|
|
|
active = w;
|
|
|
|
//## end Desktop::add%940945814.body
|
|
|
|
}
|
|
|
|
|
|
|
|
void Desktop::run (EventReader& er, Graphics& gd)
|
|
|
|
{
|
|
|
|
//## begin Desktop::run%940945815.body preserve=yes
|
|
|
|
Event ev;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while(1){
|
|
|
|
ev = er.getEvent();
|
|
|
|
switch(ev.getEventType()){
|
|
|
|
case MOUSE_E: handleMouseEvent(ev);
|
|
|
|
draw(gd);
|
|
|
|
break;
|
|
|
|
case KEY_E: handleKeyEvent(ev);
|
|
|
|
draw(gd);
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
//## end Desktop::run%940945815.body
|
|
|
|
}
|
|
|
|
|
|
|
|
void Desktop::handleKeyEvent (Event e)
|
|
|
|
{
|
|
|
|
//## begin Desktop::handleKeyEvent%941013987.body preserve=yes
|
|
|
|
//## end Desktop::handleKeyEvent%941013987.body
|
|
|
|
}
|
|
|
|
|
|
|
|
// Additional Declarations
|
|
|
|
//## begin Desktop.declarations preserve=yes
|
|
|
|
//## end Desktop.declarations
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//## begin module.epilog preserve=yes
|
|
|
|
//## end module.epilog
|
|
|