2 * ion/mod_query/input.c
4 * Copyright (c) Tuomo Valkonen 1999-2005.
6 * Ion is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
12 #include <libmainloop/defer.h>
13 #include <ioncore/common.h>
14 #include <ioncore/window.h>
15 #include <ioncore/global.h>
16 #include <ioncore/regbind.h>
17 #include <ioncore/event.h>
25 * Scroll input \var{input} text contents up.
28 void input_scrollup(WInput
*input
)
30 CALL_DYN(input_scrollup
, input
, (input
));
35 * Scroll input \var{input} text contents down.
38 void input_scrolldown(WInput
*input
)
40 CALL_DYN(input_scrolldown
, input
, (input
));
44 void input_calc_size(WInput
*input
, WRectangle
*geom
)
46 *geom
=input
->last_fp
.g
;
48 CALL_DYN(input_calc_size
, input
, (input
, geom
));
53 const char *input_style(WInput
*input
)
55 const char *ret
="input";
56 CALL_DYN_RET(ret
, const char*, input_style
, input
, (input
));
64 /*{{{ Resize and draw config update */
67 static void input_do_refit(WInput
*input
, WWindow
*par
)
70 input_calc_size(input
, &g
);
71 window_do_fitrep(&input
->win
, par
, &g
);
75 void input_refit(WInput
*input
)
77 input_do_refit(input
, NULL
);
81 void input_fitrep(WInput
*input
, WWindow
*par
, const WFitParams
*fp
)
84 input_do_refit(input
, par
);
88 void input_updategr(WInput
*input
)
92 brush
=gr_get_brush(region_rootwin_of((WRegion
*)input
),
99 if(input
->brush
!=NULL
)
100 grbrush_release(input
->brush
, input
->win
.win
);
104 region_updategr_default((WRegion
*)input
);
106 window_draw((WWindow
*)input
, TRUE
);
116 bool input_init(WInput
*input
, WWindow
*par
, const WFitParams
*fp
)
122 if(!window_init((WWindow
*)input
, par
, fp
))
127 input
->brush
=gr_get_brush(region_rootwin_of((WRegion
*)par
),
128 win
, input_style(input
));
130 if(input
->brush
==NULL
)
134 window_select_input(&(input
->win
), IONCORE_EVENTMASK_NORMAL
);
136 region_add_bindmap((WRegion
*)input
, mod_query_input_bindmap
);
141 window_deinit((WWindow
*)input
);
146 void input_deinit(WInput
*input
)
148 if(input
->brush
!=NULL
)
149 grbrush_release(input
->brush
, input
->win
.win
);
151 window_deinit((WWindow
*)input
);
156 * Close input not calling any possible finish handlers.
159 void input_cancel(WInput
*input
)
161 mainloop_defer_destroy((Obj
*)input
);
165 bool input_rqclose(WInput
*input
)
178 static void input_inactivated(WInput
*input
)
180 window_draw((WWindow
*)input
, FALSE
);
184 static void input_activated(WInput
*input
)
186 window_draw((WWindow
*)input
, FALSE
);
193 /*{{{ Dynamic function table and class implementation */
196 static DynFunTab input_dynfuntab
[]={
197 {(DynFun
*)region_fitrep
, (DynFun
*)input_fitrep
},
198 {region_updategr
, input_updategr
},
199 {(DynFun
*)region_rqclose
, (DynFun
*)input_rqclose
},
200 {region_activated
, input_activated
},
201 {region_inactivated
, input_inactivated
},
206 IMPLCLASS(WInput
, WWindow
, input_deinit
, input_dynfuntab
);