44 #include <sigc++/signal.h>
45 #include <sigc++/trackable.h>
47 #include <cwidget/curses++.h>
48 #include <cwidget/generic/util/ref_ptr.h>
49 #include <cwidget/style.h>
51 #include <cwidget/generic/util/eassert.h>
65 util::ref_ptr<widgets::widget> settoplevel(
const util::ref_ptr<widgets::widget> &);
68 void updatecursornow();
85 size(
int _w,
int _h):w(_w), h(_h) {}
91 point(
int _x,
int _y):x(_x), y(_y) {}
97 rect(
int _x,
int _y,
int _w,
int _h):x(_x), y(_y), w(_w), h(_h) {}
98 void set_size(
const size &s) {w=s.w; h=s.h;}
106 class widget:
virtual public sigc::trackable
117 friend void toplevel::updatecursornow();
118 friend void toplevel::handleresize();
121 struct binding_connection
127 sigc::slot0<void> slot;
129 binding_connection():bindings(NULL) {}
130 binding_connection(
const std::string &_keyname,
config::keybindings *_bindings,
const sigc::slot0<void> &_slot)
131 :
keyname(_keyname), bindings(_bindings), slot(_slot) {}
135 std::list<binding_connection> auxillary_bindings, auxillary_post_bindings;
155 mutable int refcount;
167 bool pre_display_erase:1;
174 void set_owner_window(
cwindow _win,
int x,
int y,
int w,
int h);
177 void set_isfocussed(
bool _isfocussed);
179 cwindow get_win() {
return win;}
205 eassert(refcount > 0);
212 eassert(refcount > 0);
219 static void handle_pending_deletes();
225 virtual void show_all();
227 void toggle_visible()
234 void set_visible(
bool _visible)
236 if(visible!=_visible)
249 bool dispatch_key(
const config::key & k);
253 virtual void dispatch_mouse(
short id,
int x,
int y,
int z, mmask_t bstate);
299 virtual bool focus_me();
303 bool get_isfocussed() {
return isfocussed;}
318 int timeout(
int msecs);
327 virtual bool get_cursorvisible()=0;
328 virtual point get_cursorloc()=0;
330 int get_startx() {
return geom.x;}
331 int get_starty() {
return geom.y;}
332 int get_width() {
return geom.w;}
333 int get_height() {
return geom.h;}
335 bool get_visible() {
return visible;}
338 void sync() {
if(win) {win.touch(); win.noutrefresh();}}
340 int scroll(
int n=1) {
return win?win.scroll(n):0;}
342 int addch(chtype ch) {
return win?win.addch(ch):0;}
343 int mvaddch(
int y,
int x, chtype ch) {
return win?win.mvaddch(y,x,ch):0;}
345 int add_wch(
wchar_t wch)
347 return win?win.add_wch(wch):0;
350 int add_wch(
const cchar_t *cch)
352 return win?win.add_wch(cch):0;
355 int mvadd_wch(
int y,
int x,
wchar_t wch)
357 return win?win.mvadd_wch(y, x, wch):0;
360 int mvadd_wch(
int y,
int x,
const cchar_t *cch)
362 return win?win.mvadd_wch(y, x, cch):0;
365 int addstr(
const char *str) {
return win?win.addstr(str):0;}
366 int addnstr(
const char *str,
int n) {
return win?win.addnstr(str, n):0;}
367 int mvaddstr(
int y,
int x,
const char *str) {
return win?win.mvaddstr(y, x, str):0;}
368 int mvaddnstr(
int y,
int x,
const char *str,
int n) {
return win?win.mvaddnstr(y, x, str, n):0;}
370 int addstr(
const wchar_t *str) {
return win?win.addstr(str):0;}
371 int addnstr(
const wchar_t *str,
int n) {
return win?win.addnstr(str, n):0;}
372 int mvaddstr(
int y,
int x,
const wchar_t *str) {
return win?win.mvaddstr(y, x, str):0;}
373 int mvaddnstr(
int y,
int x,
const wchar_t *str,
int n) {
return win?win.mvaddnstr(y, x, str, n):0;}
375 int addstr(
const std::wstring &str) {
return win?win.addstr(str):0;}
376 int addnstr(
const std::wstring &str,
int n) {
return win?win.addnstr(str, n):0;}
377 int mvaddstr(
int y,
int x,
const std::wstring &str) {
return win?win.mvaddstr(y, x, str):0;}
378 int mvaddnstr(
int y,
int x,
const std::wstring &str,
int n) {
return win?win.mvaddnstr(y, x, str, n):0;}
380 int addstr(
const wchstring &str) {
return win?win.addstr(str):0;}
381 int addnstr(
const wchstring &str,
int n) {
return win?win.addnstr(str, n):0;}
382 int mvaddstr(
int y,
int x,
const wchstring &str) {
return win?win.mvaddstr(y, x, str):0;}
383 int mvaddnstr(
int y,
int x,
const wchstring &str,
int n) {
return win?win.mvaddnstr(y, x, str, n):0;}
385 int addstr(
const chstring &str) {
return win?win.addstr(str):0;}
386 int addnstr(
const chstring &str,
int n) {
return win?win.addnstr(str, n):0;}
387 int mvaddstr(
int y,
int x,
const chstring &str) {
return win?win.mvaddstr(y, x, str):0;}
388 int mvaddnstr(
int y,
int x,
const chstring &str,
int n) {
return win?win.mvaddnstr(y, x, str, n):0;}
390 int attroff(
int attrs) {
return win?win.attroff(attrs):0;}
391 int attron(
int attrs) {
return win?win.attron(attrs):0;}
392 int attrset(
int attrs) {
return win?win.attrset(attrs):0;}
394 void bkgdset(
const chtype ch) {
if(win) win.bkgdset(ch);}
395 int bkgd(
const chtype ch) {
return win?win.bkgd(ch):0;}
396 chtype getbkgd() {
return win?win.getbkgd():0;}
398 int border(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
399 {
return win?win.border(ls,rs,ts,bs,tl,tr,bl,br):0;}
400 int box(chtype verch, chtype horch) {
return win?win.box(verch,horch):0;}
401 int hline(chtype ch,
int n) {
return win?win.hline(ch,n):0;}
402 int vline(chtype ch,
int n) {
return win?win.vline(ch,n):0;}
403 int mvhline(
int y,
int x, chtype ch,
int n) {
return win?win.mvhline(y, x, ch, n):0;}
404 int mvvline(
int y,
int x, chtype ch,
int n) {
return win?win.mvvline(y,x,ch,n):0;}
406 int delch() {
return win?win.delch():0;}
407 int mvdelch(
int y,
int x) {
return win?win.mvdelch(y, x):0;}
409 int deleteln() {
return win?win.deleteln():0;}
410 int insdelln(
int n) {
return win?win.insdelln(n):0;}
411 int insertln() {
return win?win.insertln():0;}
413 int echochar(chtype ch) {
return win?win.echochar(ch):0;}
415 int move(
int y,
int x) {
return win?win.move(y,x):0;}
416 void getyx(
int &y,
int &x) {
if(win) win.getyx(y,x);
else y=x=0;}
417 void getbegyx(
int &y,
int &x) {
if(win) win.getbegyx(y,x);
else y=x=0;}
418 void getmaxyx(
int &y,
int &x) {
if(win) win.getmaxyx(y,x);
else y=x=0;}
419 int getmaxy() {
return win?win.getmaxy():0;}
420 int getmaxx() {
return win?win.getmaxx():0;}
422 void show_string_as_progbar(
int x,
int y,
const std::wstring &s,
423 const style &st1,
const style &st2,
424 int size1,
int totalsize)
427 win.show_string_as_progbar(x, y, s,
433 void display_header(std::wstring s,
const style &st) {
if(win) win.display_header(s, st.get_attrs());}
434 void display_status(std::wstring s,
const style &st) {
if(win) win.display_status(s, st.get_attrs());}
436 int erase() {
return win?win.erase():0;}
437 int clear() {
return win?win.clear():0;}
438 int clrtobot() {
return win?win.clrtobot():0;}
439 int clrtoeol() {
return win?win.clrtoeol():0;}
443 int keypad(
bool bf) {
return win?win.keypad(bf):0;}
444 int meta(
bool bf) {
return win?win.meta(bf):0;}
446 bool enclose(
int y,
int x)
449 return y>=geom.y && y<geom.y+geom.h && x>=geom.x && x<geom.x+geom.w;
463 pre_display_erase=opaque;
477 typedef std::list<binding_connection>::iterator key_connection;
480 key_connection connect_key(
const std::string &
key,
482 const sigc::slot0<void> &slot);
485 key_connection connect_key_post(
const std::string &
key,
487 const sigc::slot0<void> &slot);
490 void disconnect_key(key_connection c);
492 void disconnect_key_post(key_connection c);
503 sigc::signal0<void> shown_sig;
507 sigc::signal0<void> hidden_sig;
510 sigc::signal0<void> destroyed;
514 sigc::signal0<void> do_layout;
520 sigc::signal0<void> focussed;
521 sigc::signal0<void> unfocussed;