2 * ion/mod_query/input.c
4 * Copyright (c) Tuomo Valkonen 1999-2009.
6 * See the included file LICENSE for details.
9 #include <libmainloop/defer.h>
10 #include <ioncore/common.h>
11 #include <ioncore/window.h>
12 #include <ioncore/global.h>
13 #include <ioncore/regbind.h>
14 #include <ioncore/event.h>
15 #include <ioncore/names.h>
23 * Scroll input \var{input} text contents up.
26 void input_scrollup(WInput
*input
)
28 CALL_DYN(input_scrollup
, input
, (input
));
33 * Scroll input \var{input} text contents down.
36 void input_scrolldown(WInput
*input
)
38 CALL_DYN(input_scrolldown
, input
, (input
));
42 void input_calc_size(WInput
*input
, WRectangle
*geom
)
44 *geom
=input
->last_fp
.g
;
46 CALL_DYN(input_calc_size
, input
, (input
, geom
));
51 const char *input_style(WInput
*input
)
53 const char *ret
="input";
54 CALL_DYN_RET(ret
, const char*, input_style
, input
, (input
));
62 /*{{{ Resize and draw config update */
65 static void input_do_refit(WInput
*input
, WWindow
*par
)
68 input_calc_size(input
, &g
);
69 window_do_fitrep(&input
->win
, par
, &g
);
73 void input_refit(WInput
*input
)
75 input_do_refit(input
, NULL
);
79 bool input_fitrep(WInput
*input
, WWindow
*par
, const WFitParams
*fp
)
81 if(par
!=NULL
&& !region_same_rootwin((WRegion
*)input
, (WRegion
*)par
))
84 input_do_refit(input
, par
);
90 void input_updategr(WInput
*input
)
94 brush
=gr_get_brush(input
->win
.win
,
95 region_rootwin_of((WRegion
*)input
),
101 if(input
->brush
!=NULL
)
102 grbrush_release(input
->brush
);
106 region_updategr_default((WRegion
*)input
);
108 window_draw((WWindow
*)input
, TRUE
);
118 bool input_init(WInput
*input
, WWindow
*par
, const WFitParams
*fp
)
124 if(!window_init((WWindow
*)input
, par
, fp
, "WInput"))
129 input
->brush
=gr_get_brush(win
, region_rootwin_of((WRegion
*)par
),
132 if(input
->brush
==NULL
)
136 window_select_input(&(input
->win
), IONCORE_EVENTMASK_NORMAL
);
138 region_add_bindmap((WRegion
*)input
, mod_query_input_bindmap
);
140 region_register((WRegion
*)input
);
145 window_deinit((WWindow
*)input
);
150 void input_deinit(WInput
*input
)
152 if(input
->brush
!=NULL
)
153 grbrush_release(input
->brush
);
155 window_deinit((WWindow
*)input
);
160 * Close input not calling any possible finish handlers.
163 void input_cancel(WInput
*input
)
165 region_defer_rqdispose((WRegion
*)input
);
175 static void input_inactivated(WInput
*input
)
177 window_draw((WWindow
*)input
, FALSE
);
181 static void input_activated(WInput
*input
)
183 window_draw((WWindow
*)input
, FALSE
);
193 void mod_query_get_minimum_extents(GrBrush
*brush
, bool with_spacing
,
200 grbrush_get_border_widths(brush
, &bdw
);
201 grbrush_get_font_extents(brush
, &fnte
);
203 spc
=(with_spacing
? bdw
.spacing
: 0);
205 *h
=(fnte
.max_height
+bdw
.top
+bdw
.bottom
+spc
);
206 *w
=(bdw
.left
+bdw
.right
+spc
);
213 /*{{{ Dynamic function table and class implementation */
216 static DynFunTab input_dynfuntab
[]={
217 {(DynFun
*)region_fitrep
, (DynFun
*)input_fitrep
},
218 {region_updategr
, input_updategr
},
219 {region_activated
, input_activated
},
220 {region_inactivated
, input_inactivated
},
226 IMPLCLASS(WInput
, WWindow
, input_deinit
, input_dynfuntab
);