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

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

#ifdef ALL
#define ALERTA
#define ALERTB
#define ALERTC
#define ALERTD
#define ALERTE
#endif
#ifndef ALERTA
#define LIBRARY_MODULE
#endif

#include
#include "alert.hpp"
#include "dialog.hpp"
#include "cluster.hpp"
#include "button.hpp"
#include "text.hpp"
#include "layout.hpp"
#include "screen.hpp"


#ifdef ALERTA
void alert(const char *text,const ColorSet &c)
{
ModalDialog *d = new ModalDialog(
new HCluster(ObjectCollection(3)
+ new MultiLineText(text)
+ new Space
+ new CloseButton("O.K.",Kesc)
),
"");

d->setcolors(c);
d->enter();
}
#endif

#ifdef ALERTB
int confirm(const char *text,
const char *yestext,const char *notext,
const ColorSet &c)
{
ModalDialog *d = new ModalDialog(
new HCluster(ObjectCollection(3)
+ new MultiLineText(text)
+ new Space
+ new ButtonVCluster(OCollection(Button)(2)
+ new CloseButton(yestext,Knone)
+ new CancelButton(notext,Kesc)
)
),
"");

d->setcolors(c);
return !d->enter();
}
#endif

#ifdef ALERTC
void select(const char *text,Command *cmd,const char *option,...)
{
ButtonVCluster *v = new ButtonVCluster;

v->add(new CloseButton(option,Knone,cmd));

va_list args;

va_start(args,option);
while((option = va_arg(args,const char *)) != 0
&& (cmd = va_arg(args,Command *)) != 0)
v->add(new CloseButton(option,Knone,cmd));

v->add(new CancelButton);

Dialog *d = new Dialog(
new HCluster(ObjectCollection(3)
+ new MultiLineText(text)
+ new Space
+ v
),
"");
d->enter();
}
#endif

#ifdef ALERTD
Message::Message(const char *text,int width,AlignFlag alignment,
BorderFlag border,const ColorSet &c)
{
w = new Window(
new VCluster(
ObjectCollection(1) + new Text(text,width),
"",AFexpand,border),
alignment,c);
w->show();
w->update();
}

Message::~Message()
{
if(w)
{
VALIDATE(w);
delete w;
}
}
#endif

#ifdef ALERTE
long ProgressBox::calculateScale() const
{
return (total <= 0 || width() < 2) ? 0 : total / width();
}

ProgressBox::ProgressBox(long max, const char *name)
: VObject(name), total(max), done(0)
{
}

void ProgressBox::refresh(long howmuch)
{
long scale = calculateScale();

if(howmuch < 0)
howmuch = 0;
if(scale && window && howmuch / scale != done / scale)
{
dirty();
window->update();
}
done = howmuch;
}

coord ProgressBox::maxwidth() const
{
return (total > screen->width()) ? screen->width() : total;
}

coord ProgressBox::minwidth() const
{
return (total > 20) ? 20 : total;
}

void ProgressBox::paint(Rectangle r)
{
long scale = calculateScale();

r &= *this;
VObject::paint(r);
if(scale && done / scale)
{
Rectangle paintedBit(*this);
paintedBit.setwidth(done / scale);
paintedBit &= r;
window->fillrect(paintedBit,219);
}
}
#endif