Category : Recently Uploaded Files
Archive   : DOSUIT07.ZIP
Filename : POPWIN.CPP

 
Output of file : POPWIN.CPP contained in archive : DOSUIT07.ZIP

#ifdef ALL
#define POPWINA
#define POPWINB
#endif
#ifndef POPWINA
#define LIBRARY_MODULE
#endif

#include "popwin.hpp"
#include "screen.hpp"
#include "event.hpp"


#ifdef POPWINA
SubWindow::SubWindow(VObject *v,const ColorSet &c,AlignFlag a,const char *n)
: Window(v,a,c,n)
{
}

void SubWindow::popin(coord x,coord y)
{
coord h = minheight();

if(y + h > screen->height())
y = screen->height() - h;
h = maxheight();
if(y + h > screen->height())
h = screen->height() - y;
if(h != height())
setheight(h);

coord w = minwidth();

if(x + w > screen->width())
x = screen->width() - w;
w = maxwidth();
if(x + w > screen->width())
w = screen->width() - x;
if(w != width())
setwidth(w);

position(x,y);
placeInside(screen->rectangle());
show();
}

void SubWindow::popin(VObject *v)
{
Point p = { v->left(), v->bottom() + 1 };

v->getwindow()->screenCoords(p);
popin(p);
}

void SubWindow::contentsSet(VObject* o,ControlFlag f)
{
if((f & CFfocus) && !testcFlag(CFfocus))
show();
Window::contentsSet(o,f);
}

void SubWindow::setwidth(const coord w)
{
Window::setwidth(w);
if(count() == 1)
objects.first()->setwidth(w);
}

void SubWindow::setheight(const coord h)
{
Window::setheight(h);
if(count() == 1)
objects.first()->setheight(h);
}
#endif

#ifdef POPWINB
PopWindow::PopWindow(VObject *v,const ColorSet &c,AlignFlag a,const char *n)
: SubWindow(v,c,a,n), inspectct(0)
{
}

void PopWindow::resetfocus()
{
if(testcFlag(CFfocus))
{
SubWindow::resetfocus();
if(!inspecting())
popout();
}

}

#ifdef NINSPECT
char *PopWindow::inspectinfo(char *buf,const char *s) const
{
return "";
}
#else
int PopWindow::inspectclick(MouseEvent &e)
{
int r;

if(this->encloses(e.at()))
{
inspectct++;
r = SubWindow::inspectclick(e);
inspectct--;
}
else
r = SubWindow::inspectclick(e);
return r;
}
#endif

int PopWindow::rightclick(MouseEvent &)
{
popout();
return 1;
}

int PopWindow::kbdevent(KeyboardEvent &e)
{
if(e.value() == Kesc)
{
popout();
return 1;
}
return SubWindow::kbdevent(e);
}
#endif