home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 18
/
CD_ASCQ_18_111294_W.iso
/
dos
/
prg
/
c
/
x_lib10
/
xw_yes.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1994-10-20
|
2KB
|
93 lines
#include "xw.h"
/*-----
*/
#include "xk.h"
#include "xo.h"
#include "xx.h"
/*-----
XWinMgr::yes
affiche une boîte de dialogue standard : Oui/Non
*/
class YesWin : public XWin
{
protected :
virtual void on_call (XObj *obj);
virtual void on_char (int key);
public :
YesWin (int wdt, int hgh, const char *hdr, const char *msg);
};
YesWin::YesWin (int wdt, int hgh, const char *hdr, const char *msg)
: XWin(wdt + 8, hgh + 8)
{
int tmp;
XText * obj;
tmp = (wdt - 11) >> 1;
if (hdr == 0)
defw(xw_STDWIN & ~xw_HEADER);
else
head(hdr);
link(new XBox(1, 1, 1, wdt + 4, hgh + 2, 0, 1));
obj = (XText *)link(new XText(2, 2, 3, wdt, hgh, 0, 0));
link(new XPush(3, hgh + 4, tmp, 7, "&Oui", xk_aO));
link(new XPush(4, hgh + 4, tmp + 11, 7, "&Non", xk_aN));
obj->defs(0, msg);
}
void YesWin::on_call (XObj *obj)
{
if (obj->type() == xo_PUSH)
{
xo(obj, XPush)->push(1);
hide();
retn(obj->id() == 3);
}
}
void YesWin::on_char (int key)
{
if ((key == xk_ESC) || (key == xk_RET))
{
hide();
retn(key == xk_RET);
}
}
int XWinMgr::yes (const char *hdr, const char *msg)
{
int wdt, hgh, ret;
YesWin * win;
if ((wdt = _smax(msg, '\n') + 2) > 70)
wdt = 70;
else if (wdt < 26)
wdt = 26;
if ((hgh = _scnt(msg, '\n') + 2) > 20)
hgh = 20;
else if (hgh < 3)
hgh = 3;
win = new YesWin(wdt, hgh, hdr, msg);
ret = xw.exec(win);
delete win;
return (ret);
}