home *** CD-ROM | disk | FTP | other *** search
- #include "xw.h"
-
- /*-----
- */
-
- #include "xk.h"
- #include "xo.h"
- #include "xx.h"
-
- /*-----
- XWinMgr::ok
- affiche une boite de dialogue standard : Ok
- */
-
- class OkWin : public XWin
- {
- protected :
- virtual void on_call (XObj *obj);
- virtual void on_char (int key);
-
- public :
- OkWin (int wdt, int hgh, const char *hdr, const char *msg);
- };
-
- OkWin::OkWin (int wdt, int hgh, const char *hdr, const char *msg)
-
- : XWin(wdt + 8, hgh + 8)
-
- {
- XText * obj;
-
- 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, (wdt - 2) >> 1, 8, "&Ok", xk_aO));
-
- obj->defs(0, msg);
- }
-
- void OkWin::on_call (XObj *obj)
- {
-
- if (obj->type() == xo_PUSH)
- {
- xo(obj, XPush)->push(1);
- hide();
- }
-
- }
-
- void OkWin::on_char (int key)
- {
-
- if ((key == xk_ESC) || (key == xk_RET))
- hide();
-
- }
-
- void XWinMgr::ok (const char *hdr, const char *msg)
- {
- int wdt, hgh;
- OkWin * 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 OkWin(wdt, hgh, hdr, msg);
- xw.exec(win);
- delete win;
- }
-
-