libxputty 0.1
Loading...
Searching...
No Matches
Functions
xwidget.c File Reference

Go to the source code of this file.

Functions

void create_cairo_context_and_buffer (Widget_t *w)
 
const char * widget_type_name (Widget_t *w)
 widget_type_name - textual representation of (Widget_t*)->widget_type
 
int key_mapping (Display *dpy, XKeyEvent *xkey)
 _key_mapping - modifier key's mapped to a integer value
 
void destroy_widget (Widget_t *w, Xputty *main)
 destroy_widget - destroy a widget
When a Widget_t receive a destroy_widget() call, it will propagate that to all childs in it's Childlist_t. So all childs get destroyed before the Widget_t itself close.
 
void configure_event (void *w_, void *user_data)
 
void resize_childs (Widget_t *w)
 resize_childs - intern check if child widgets needs resizing
 
void widget_reset_scale (Widget_t *w)
 widget_reset_scale - used to reset scaling mode after a image surface is drawn to the Widget_t surface with widget_set_scale()
 
void widget_set_scale (Widget_t *w)
 widget_set_scale - set scaling mode to scale a image surface to the size of the Widget_t surface
 
Widget_tcreate_window (Xputty *app, Window win, int x, int y, int width, int height)
 *create_window - create a Window
You need to create as least minimun one Window to get started.
The first created Window is the top_level_widget()
A Window could be created on the DefaultRootWindow() or embeded into a other XWindow
 
Widget_tcreate_widget (Xputty *app, Widget_t *parent, int x, int y, int width, int height)
 *create_widget - create a widget
A Widget_t could only be created as child of a other Widget_t
To create a Widget_t you need to create a Widget_t with create_window() before.
 
void connect_func (void(**event)(), void(*handler)())
 connect_func - connect a event with a handler without type check. For supported events see: Func_t
 
void widget_set_title (Widget_t *w, const char *title)
 widget_set_title - set window title for a Widget_t
 
void widget_show (Widget_t *w)
 widget_show - map/show widget
 
void widget_hide (Widget_t *w)
 widget_hide - unmap/hide a Widget_t
 
void widget_hide_all (Widget_t *w)
 widget_hide_all - unmap/hide all Widget_t from app
 
void widget_show_all (Widget_t *w)
 widget_show_all - map/show Widget_t with all childs
 
void pop_widget_show_all (Widget_t *w)
 pop_widget_show_all - map/show popup widget with all it's childs
 
void submenu_widget_show_all (Widget_t *w)
 submenu_widget_show_all - map/show submenu Widget_t with all childs
 
void show_tooltip (Widget_t *wid)
 show_tooltip - check if a Widget_t have a tooltip, and show it, if a tooltip is available.
 
void hide_tooltip (Widget_t *wid)
 hide_tooltip - check if a Widget_t have a tooltip, and hide it, if a tooltip is mapped.
 
Widget_tget_toplevel_widget (Xputty *main)
 *get_toplevel_widget - get pointer to the top level Widget_t
 
void expose_widget (Widget_t *w)
 expose_widgets - send a expose event (EXPOSE) to a Widget_t
 
void transparent_draw (void *w_, void *user_data)
 transparent_draw - copy parent surface to child surface
you usaualy didn't need to call this, it's used automaticaly when a Widget_t have set the flag USE_TRANSPARENCY
this is the default setting for Widget_t
 
void widget_draw (void *w_, void *user_data)
 widget_draw - redraw only the widget,not the child widgets
 
void widget_event_loop (void *w_, void *event, Xputty *main, void *user_data)
 widget_event_loop - the internal widget event loop
 
void send_configure_event (Widget_t *w, int x, int y, int width, int height)
 send_configure_event - send a ConfigureNotify to Widget_t
used to resize a Widget_t
 
void send_button_press_event (Widget_t *w)
 send_button_press_event - send ButtonPress event to Widget_t
simulate a BUTTON_PRESS Event
 
void send_button_release_event (Widget_t *w)
 send_button_release_event - send ButtonRelease event to Widget_t
simulate a BUTTON_RELEASE Event
 
void send_systray_message (Widget_t *w)
 send_systray_message - request a systray icon for Widget_t
currently not working
 
void quit (Widget_t *w)
 quit - exit the main loop
 
void quit_widget (Widget_t *w)
 quit_widget - remove a widget from the processing loop
 

Function Documentation

◆ configure_event()

void configure_event ( void *  w_,
void *  user_data 
)

Definition at line 128 of file xwidget.c.

128 {
129 Widget_t *wid = (Widget_t*)w_;
130 Metrics_t metrics;
131 os_get_window_metrics(wid, &metrics);
132 if (wid->width != metrics.width || wid->height != metrics.height) {
133 wid->scale.scale_x = (float)wid->scale.init_width - metrics.width;
134 wid->scale.scale_y = (float)wid->scale.init_height - metrics.height;
135 wid->scale.cscale_x = (float)((float)wid->scale.init_width/(float)metrics.width);
136 wid->scale.cscale_y = (float)((float)wid->scale.init_height/(float)metrics.height);
137 wid->scale.rcscale_x = (float)((float)metrics.width/(float)wid->scale.init_width);
138 wid->scale.rcscale_y = (float)((float)metrics.height/(float)wid->scale.init_height);
139 wid->scale.ascale = wid->scale.cscale_x < wid->scale.cscale_y ?
140 wid->scale.cscale_y : wid->scale.cscale_x;
141
142 _resize_surface(wid, metrics.width, metrics.height);
143
144 debug_print("Widget_t configure callback width %i height %i\n", metrics.width, metrics.height);
145
146 _resize_childs(wid);
147 }
148 wid->func.configure_notify_callback(wid,NULL);
149}
xevfunc configure_notify_callback
Definition xwidget.h:93
Metrics_t - struct to receive window size, position & visibility Pass this struct to os_get_window_...
int init_height
Definition xwidget.h:355
float scale_y
Definition xwidget.h:359
float ascale
Definition xwidget.h:369
float cscale_y
Definition xwidget.h:363
float rcscale_x
Definition xwidget.h:365
float cscale_x
Definition xwidget.h:361
int init_width
Definition xwidget.h:353
float rcscale_y
Definition xwidget.h:367
float scale_x
Definition xwidget.h:357
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
Resize_t scale
Definition xwidget.h:525
int width
Definition xwidget.h:521
int height
Definition xwidget.h:523
Func_t func
Definition xwidget.h:481
void os_get_window_metrics(Widget_t *w, Metrics_t *metrics)
os_get_window_metrics - Get the Merics_t struct related to a Widget_t
void _resize_surface(Widget_t *wid, int width, int height)
_resize_surface - intern check if a Widget_t surfaces needs resizing
void _resize_childs(Widget_t *wid)
_resize_childs - intern check if child widgets needs resizing

References _resize_childs(), _resize_surface(), Resize_t::ascale, Func_t::configure_notify_callback, Resize_t::cscale_x, Resize_t::cscale_y, Widget_t::func, Metrics_t::height, Widget_t::height, Resize_t::init_height, Resize_t::init_width, os_get_window_metrics(), Resize_t::rcscale_x, Resize_t::rcscale_y, Widget_t::scale, Resize_t::scale_x, Resize_t::scale_y, Metrics_t::width, and Widget_t::width.

Referenced by create_widget(), and create_window().

◆ connect_func()

void connect_func ( void(**)()  event,
void(*)()  handler 
)

connect_func - connect a event with a handler without type check. For supported events see: Func_t

Parameters
**event- the event to connect
*handler- the handler to handle the event

Definition at line 352 of file xwidget.c.

352 {
353 debug_print("address of a is: %p\n", (void*)event);
354 debug_print("address of b is: %p\n", (void*)handler);
355 *event = handler;
356 debug_print("address of a is: %p\n", (void*)(*event));
357}

◆ create_cairo_context_and_buffer()

void create_cairo_context_and_buffer ( Widget_t w)

Definition at line 249 of file xwidget.c.

249 {
250 int width = w->scale.init_width;
251 int height = w->scale.init_height;
252 assert(cairo_surface_status(w->surface) == CAIRO_STATUS_SUCCESS);
253 w->cr = cairo_create(w->surface);
254 cairo_select_font_face (w->cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
255 CAIRO_FONT_WEIGHT_NORMAL);
256
257 w->buffer = cairo_surface_create_similar (w->surface,
258 CAIRO_CONTENT_COLOR_ALPHA, width, height);
259 assert(cairo_surface_status(w->buffer) == CAIRO_STATUS_SUCCESS);
260 w->crb = cairo_create (w->buffer);
261 cairo_select_font_face (w->crb, "Sans", CAIRO_FONT_SLANT_NORMAL,
262 CAIRO_FONT_WEIGHT_NORMAL);
263}
cairo_surface_t * surface
Definition xwidget.h:483
cairo_surface_t * buffer
Definition xwidget.h:487
cairo_t * crb
Definition xwidget.h:489
cairo_t * cr
Definition xwidget.h:485

References Widget_t::buffer, Widget_t::cr, Widget_t::crb, Resize_t::init_height, Resize_t::init_width, Widget_t::scale, and Widget_t::surface.

Referenced by create_widget(), and create_window().

◆ create_widget()

Widget_t * create_widget ( Xputty app,
Widget_t win,
int  x,
int  y,
int  width,
int  height 
)

*create_widget - create a widget
A Widget_t could only be created as child of a other Widget_t
To create a Widget_t you need to create a Widget_t with create_window() before.

Parameters
*app- pointer to the Xputty *main struct to use
*win- pointer to the Parrent Widget_t
x,y,width,height- the position/geometry to create the widget
Returns
Widget_t* - pointer to the Widget_t struct

Definition at line 265 of file xwidget.c.

266 {
267
268 Widget_t *w = (Widget_t*)malloc(sizeof(Widget_t));
269 assert(w != NULL);
270 debug_print("assert(w)\n");
271 memset(w, 0, sizeof(Widget_t));
272 w->image = NULL;
273
275 w->flags &= ~NO_AUTOREPEAT;
276 w->flags &= ~FAST_REDRAW;
277 w->flags &= ~HIDE_ON_DELETE;
278 w->flags &= ~REUSE_IMAGE;
279 w->flags &= ~NO_PROPAGATE;
280 w->flags &= ~IS_SUBMENU;
281 w->flags &= ~DONT_PROPAGATE;
282 w->app = app;
283 w->parent = parent;
284 w->parent_struct = NULL;
285 w->private_struct = NULL;
286 w->label = NULL;
287 memset(w->input_label, 0, 32 * (sizeof w->input_label[0]));
288 w->state = 0;
289#ifdef __linux__
290 w->double_click = 0;
291#endif
292 w->data = 0;
293 w->x = x;
294 w->y = y;
295 w->width = width;
296 w->height = height;
297 w->scale.gravity = CENTER;
298 w->scale.init_width = width;
299 w->scale.init_height = height;
300 w->scale.init_x = x;
301 w->scale.init_y = y;
302 w->scale.scale_x = 0.0;
303 w->scale.scale_y = 0.0;
304 w->scale.cscale_x = 1.0;
305 w->scale.cscale_y = 1.0;
306 w->scale.rcscale_x = 1.0;
307 w->scale.rcscale_y = 1.0;
308 w->scale.ascale = 1.0;
309 w->adj_x = NULL;
310 w->adj_y = NULL;
311 w->adj = NULL;
312 w->color_scheme = (XColor_t*)malloc(sizeof(XColor_t));
313 memcpy(w->color_scheme, app->color_scheme, sizeof (struct XColor_t));
314 w->childlist = (Childlist_t*)malloc(sizeof(Childlist_t));
315 assert(w->childlist != NULL);
317 childlist_add_child(parent->childlist, w);
340
341 //XMapWindow(app->dpy, w->widget);
342 //debug_print("size of Widget_t = %lld\n", sizeof(struct Widget_t));
343
344 os_create_widget_window_and_surface(w, app, parent, x, y, width, height);
346#ifdef __linux__ // childlist already set up
348#endif
349 return w;
350}
Childlist_t - struct to hold a Widget_t child list Xputty main holds a list of any Widget_t created...
Definition xchildlist.h:49
evfunc button_release_callback
Definition xwidget.h:101
xevfunc configure_callback
Definition xwidget.h:86
xevfunc map_notify_callback
Definition xwidget.h:94
xevfunc unmap_notify_callback
Definition xwidget.h:95
xevfunc expose_callback
Definition xwidget.h:85
evfunc key_release_callback
Definition xwidget.h:105
evfunc key_press_callback
Definition xwidget.h:104
xevfunc visibiliy_change_callback
Definition xwidget.h:98
evfunc double_click_callback
Definition xwidget.h:102
xevfunc leave_callback
Definition xwidget.h:88
xevfunc adj_callback
Definition xwidget.h:89
xevfunc value_changed_callback
Definition xwidget.h:90
xevfunc dnd_notify_callback
Definition xwidget.h:97
xevfunc user_callback
Definition xwidget.h:91
xevfunc mem_free_callback
Definition xwidget.h:92
evfunc motion_callback
Definition xwidget.h:103
xevfunc enter_callback
Definition xwidget.h:87
evfunc button_press_callback
Definition xwidget.h:100
xevfunc dialog_callback
Definition xwidget.h:96
Gravity gravity
Definition xwidget.h:347
int init_y
Definition xwidget.h:351
int init_x
Definition xwidget.h:349
int y
Definition xwidget.h:519
Adjustment_t * adj_y
Definition xwidget.h:495
vfunc event_callback
Definition xwidget.h:479
Adjustment_t * adj_x
Definition xwidget.h:493
XColor_t * color_scheme
Definition xwidget.h:467
cairo_surface_t * image
Definition xwidget.h:491
Adjustment_t * adj
Definition xwidget.h:497
void * parent
Definition xwidget.h:471
int x
Definition xwidget.h:517
int state
Definition xwidget.h:511
Childlist_t * childlist
Definition xwidget.h:499
int data
Definition xwidget.h:509
xevfunc xpaste_callback
Definition xwidget.h:533
long long flags
Definition xwidget.h:461
char input_label[32]
Definition xwidget.h:459
void * private_struct
Definition xwidget.h:475
const char * label
Definition xwidget.h:463
Time double_click
Definition xwidget.h:506
void * parent_struct
Definition xwidget.h:473
Xputty * app
Definition xwidget.h:465
XColor_t - the Widget_t Color struct XColor_t could be used for theming you Widget_t set.
Definition xcolor.h:105
XColor_t * color_scheme
Definition xputty.h:234
Childlist_t * childlist
Definition xputty.h:230
void childlist_add_child(Childlist_t *childlist, Widget_t *child)
childlist_add_child - internal use to add a child to the Childlist_t You usually didn't need to cal...
Definition xchildlist.c:42
void childlist_init(Childlist_t *childlist)
childlist_init - internal use to allocate the array to min size You usually didn't need to call thi...
Definition xchildlist.c:25
void os_widget_event_loop(void *w_, void *event, Xputty *main, void *user_data)
os_widget_event_loop - the Widget_t event loop on windows all messges goes into WndProc,...
void os_transparent_draw(void *w_, void *user_data)
os_transparent_draw - Draw the Widget_t to the back buffer
void os_create_widget_window_and_surface(Widget_t *w, Xputty *app, Widget_t *parent, int x, int y, int width, int height)
os_create_main_widget_and_surface - create a Widget_t with a acairo surface this function is used mai...
void os_adjustment_callback(void *w_, void *user_data)
os_adjustment_callback - called when a adjustment value have changed used internal for redraw the Wid...
void create_cairo_context_and_buffer(Widget_t *w)
Definition xwidget.c:249
void configure_event(void *w_, void *user_data)
Definition xwidget.c:128
@ CENTER
Definition xwidget.h:320
@ IS_WIDGET
Definition xwidget.h:388
@ USE_TRANSPARENCY
Definition xwidget.h:398
void _dummy_callback(void *w_, void *user_data)
_dummy1_callback - default debuging callback for xevfunc's
void _dummy1_callback(void *w_, void *_data, void *user_data)
_dummy1_callback - default debuging callback for evfunc's

References _dummy1_callback(), _dummy_callback(), Widget_t::adj, Func_t::adj_callback, Widget_t::adj_x, Widget_t::adj_y, Widget_t::app, Resize_t::ascale, Func_t::button_press_callback, Func_t::button_release_callback, CENTER, Xputty::childlist, Widget_t::childlist, childlist_add_child(), childlist_init(), Xputty::color_scheme, Widget_t::color_scheme, Func_t::configure_callback, configure_event(), Func_t::configure_notify_callback, create_cairo_context_and_buffer(), Resize_t::cscale_x, Resize_t::cscale_y, Widget_t::data, Func_t::dialog_callback, Func_t::dnd_notify_callback, Widget_t::double_click, Func_t::double_click_callback, Func_t::enter_callback, Widget_t::event_callback, Func_t::expose_callback, Widget_t::flags, Widget_t::func, Resize_t::gravity, Widget_t::height, Widget_t::image, Resize_t::init_height, Resize_t::init_width, Resize_t::init_x, Resize_t::init_y, Widget_t::input_label, IS_WIDGET, Func_t::key_press_callback, Func_t::key_release_callback, Widget_t::label, Func_t::leave_callback, Func_t::map_notify_callback, Func_t::mem_free_callback, Func_t::motion_callback, os_adjustment_callback(), os_create_widget_window_and_surface(), os_transparent_draw(), os_widget_event_loop(), Widget_t::parent, Widget_t::parent_struct, Widget_t::private_struct, Resize_t::rcscale_x, Resize_t::rcscale_y, Widget_t::scale, Resize_t::scale_x, Resize_t::scale_y, Widget_t::state, Func_t::unmap_notify_callback, USE_TRANSPARENCY, Func_t::user_callback, Func_t::value_changed_callback, Func_t::visibiliy_change_callback, Widget_t::width, Widget_t::x, Widget_t::xpaste_callback, and Widget_t::y.

Referenced by add_button(), add_check_box(), add_check_button(), add_combobox(), add_frame(), add_hmeter(), add_hslider(), add_image(), add_image_button(), add_image_knob(), add_image_toggle_button(), add_knob(), add_label(), add_listbox(), add_listview(), add_menu(), add_menubar(), add_midi_keyboard(), add_multi_listview(), add_on_off_button(), add_playhead(), add_popup_spinbox(), add_switch_image_button(), add_tabbox(), add_toggle_button(), add_tuner(), add_valuedisplay(), add_vmeter(), add_vslider(), add_waveview(), cmenu_add_submenu(), create_combobox_viewport(), create_hyperlink(), create_listbox_viewport(), create_listview_viewport(), create_multi_listview_viewport(), create_viewport(), listbox_add_entry(), menu_add_item(), menu_add_numeric_items(), menu_add_submenu(), menu_add_value_entry(), save_file_dialog(), and tabbox_add_tab().

◆ create_window()

Widget_t * create_window ( Xputty app,
Window  win,
int  x,
int  y,
int  width,
int  height 
)

*create_window - create a Window
You need to create as least minimun one Window to get started.
The first created Window is the top_level_widget()
A Window could be created on the DefaultRootWindow() or embeded into a other XWindow

Parameters
*app- pointer to the Xputty *main struct to use
win- pointer to the Parrent Window (may be Root)
x,y,width,height- the position/geometry to create the window
Returns
Widget_t * - pointer to the Widget_t struct

Definition at line 163 of file xwidget.c.

164 {
165
166 Widget_t *w = (Widget_t*)malloc(sizeof(Widget_t));
167 assert(w != NULL);
168 debug_print("assert(w)\n");
169 memset(w, 0, sizeof(Widget_t));
170 w->image = NULL;
171
172 w->flags = IS_WINDOW;
173 w->flags &= ~NO_AUTOREPEAT;
174 w->flags &= ~FAST_REDRAW;
175 w->flags &= ~HIDE_ON_DELETE;
176 w->flags &= ~REUSE_IMAGE;
177 w->flags &= ~NO_PROPAGATE;
178 w->flags &= ~IS_SUBMENU;
179 w->flags &= ~DONT_PROPAGATE;
180 w->app = app;
181 w->parent = &win;
182 w->parent_struct = NULL;
183 w->private_struct = NULL;
184 w->label = NULL;
185 memset(w->input_label, 0, 32 * (sizeof w->input_label[0]));
186 w->state = 0;
187#ifdef __linux__
188 w->double_click = 0;
189#endif
190 w->data = 0;
191 w->x = x;
192 w->y = y;
193 w->width = width;
194 w->height = height;
195 w->scale.init_x = x;
196 w->scale.init_y = y;
197 w->scale.init_width = width;
198 w->scale.init_height = height;
199 w->scale.scale_x = 0.0;
200 w->scale.scale_y = 0.0;
201 w->scale.cscale_x = 1.0;
202 w->scale.cscale_y = 1.0;
203 w->scale.rcscale_x = 1.0;
204 w->scale.rcscale_y = 1.0;
205 w->scale.ascale = 1.0;
206 w->scale.gravity = CENTER;
207 w->adj_x = NULL;
208 w->adj_y = NULL;
209 w->adj = NULL;
210 w->color_scheme = (XColor_t*)malloc(sizeof(XColor_t));
211 memcpy(w->color_scheme, app->color_scheme, sizeof (struct XColor_t));
212 w->childlist = (Childlist_t*)malloc(sizeof(Childlist_t));
213 assert(w->childlist != NULL);
237
238 //XMapWindow(app->dpy, w->widget);
239 //debug_print("size of Func_t = %llu\n", sizeof(w->func)/sizeof(void*));
240
241 os_create_main_window_and_surface(w, app, win, x, y, width, height);
243#ifdef __linux__ // childlist already set up
245#endif
246 return w;
247}
void os_create_main_window_and_surface(Widget_t *w, Xputty *app, Window win, int x, int y, int width, int height)
os_create_main_window_and_surface - create a Widget_t with a acairo surface this function is used mai...
void widget_event_loop(void *w_, void *event, Xputty *main, void *user_data)
widget_event_loop - the internal widget event loop
Definition xwidget.c:506
@ IS_WINDOW
Definition xwidget.h:390

References _dummy1_callback(), _dummy_callback(), Widget_t::adj, Func_t::adj_callback, Widget_t::adj_x, Widget_t::adj_y, Widget_t::app, Resize_t::ascale, Func_t::button_press_callback, Func_t::button_release_callback, CENTER, Xputty::childlist, Widget_t::childlist, childlist_add_child(), childlist_init(), Xputty::color_scheme, Widget_t::color_scheme, Func_t::configure_callback, configure_event(), Func_t::configure_notify_callback, create_cairo_context_and_buffer(), Resize_t::cscale_x, Resize_t::cscale_y, Widget_t::data, Func_t::dialog_callback, Func_t::dnd_notify_callback, Widget_t::double_click, Func_t::double_click_callback, Func_t::enter_callback, Widget_t::event_callback, Func_t::expose_callback, Widget_t::flags, Widget_t::func, Resize_t::gravity, Widget_t::height, Widget_t::image, Resize_t::init_height, Resize_t::init_width, Resize_t::init_x, Resize_t::init_y, Widget_t::input_label, IS_WINDOW, Func_t::key_press_callback, Func_t::key_release_callback, Widget_t::label, Func_t::leave_callback, Func_t::map_notify_callback, Func_t::mem_free_callback, Func_t::motion_callback, os_adjustment_callback(), os_create_main_window_and_surface(), Widget_t::parent, Widget_t::parent_struct, Widget_t::private_struct, Resize_t::rcscale_x, Resize_t::rcscale_y, Widget_t::scale, Resize_t::scale_x, Resize_t::scale_y, Widget_t::state, Func_t::unmap_notify_callback, Func_t::user_callback, Func_t::value_changed_callback, Func_t::visibiliy_change_callback, widget_event_loop(), Widget_t::width, Widget_t::x, Widget_t::xpaste_callback, and Widget_t::y.

Referenced by add_popup_spinbox(), create_combobox_menu(), create_menu(), create_tooltip(), mk_open_midi_keyboard(), open_directory_dialog(), open_file_dialog(), open_message_dialog(), open_midi_keyboard(), and save_file_dialog().

◆ destroy_widget()

void destroy_widget ( Widget_t w,
Xputty main 
)

destroy_widget - destroy a widget
When a Widget_t receive a destroy_widget() call, it will propagate that to all childs in it's Childlist_t. So all childs get destroyed before the Widget_t itself close.

Parameters
*w- pointer to the Widget_t sending the request
*main- pointer to main struct

Definition at line 86 of file xwidget.c.

86 {
87 int count = childlist_find_child(main->childlist, w);
88 if (count == 0 && main->run == true) {
89 quit(w);
90 } else if(childlist_find_child(main->childlist, w)>=0) {
91 if(w->flags & REUSE_IMAGE) {
92 w->image = NULL;
93 }
94 if(w->flags & HAS_MEM) {
95 w->func.mem_free_callback(w, NULL);
96 }
98 int ch = childlist_has_child(w->childlist);
99 if (ch) {
100 int i = ch;
101 for(;i>0;i--) {
102 destroy_widget(w->childlist->childs[i-1],main);
103
104 }
105 destroy_widget(w,main);
106 }
107 if(w->flags & IS_WIDGET) {
108 Widget_t *p = (Widget_t *) w->parent;
109 childlist_remove_child(p->childlist, w);
110 }
114 cairo_surface_destroy(w->image);
115 cairo_destroy(w->crb);
116 cairo_surface_destroy(w->buffer);
117 cairo_destroy(w->cr);
118 cairo_surface_destroy(w->surface);
119
121 free(w->color_scheme);
122 free(w->childlist);
123 free(w);
124 w = NULL;
125 }
126}
Widget_t ** childs
Definition xchildlist.h:51
bool run
Definition xputty.h:256
void * delete_adjustment(Adjustment_t *adj)
delete_adjustment - freeing the memory of the Adjustment_t You usually don't need to call this,...
int childlist_find_child(Childlist_t *childlist, Widget_t *child)
childlist_find_child - find a child in a the Childlist_t this could be sued to check if a Widget_t is...
Definition xchildlist.c:69
void childlist_destroy(Childlist_t *childlist)
childlist_destroy - internal use to free the Childlist_t You usually didn't need to call this
Definition xchildlist.c:38
void childlist_remove_child(Childlist_t *childlist, Widget_t *child)
childlist_remove_child - internal use to remove a child from the childlist You usually didn't need ...
Definition xchildlist.c:55
int childlist_has_child(Childlist_t *childlist)
childlist_has_child - check if a Widget_t Childlist_t contain a child
Definition xchildlist.c:89
void os_destroy_window(Widget_t *w)
os_destroy_window - destroy a widget (close and remove from processing)
void quit(Widget_t *w)
quit - exit the main loop
Definition xwidget.c:526
void destroy_widget(Widget_t *w, Xputty *main)
destroy_widget - destroy a widget When a Widget_t receive a destroy_widget() call,...
Definition xwidget.c:86
@ HAS_MEM
Definition xwidget.h:406
@ REUSE_IMAGE
Definition xwidget.h:414

References Widget_t::adj_x, Widget_t::adj_y, Widget_t::buffer, Xputty::childlist, Widget_t::childlist, childlist_destroy(), childlist_find_child(), childlist_has_child(), childlist_remove_child(), Childlist_t::childs, Widget_t::color_scheme, Widget_t::cr, Widget_t::crb, delete_adjustment(), destroy_widget(), Widget_t::flags, Widget_t::func, HAS_MEM, Widget_t::image, IS_WIDGET, Func_t::mem_free_callback, os_destroy_window(), Widget_t::parent, quit(), REUSE_IMAGE, Xputty::run, and Widget_t::surface.

Referenced by destroy_widget(), main_quit(), menu_remove_item(), os_main_run(), os_run_embedded(), os_widget_event_loop(), tabbox_remove_tab(), and WndProc().

◆ expose_widget()

void expose_widget ( Widget_t w)

◆ get_toplevel_widget()

Widget_t * get_toplevel_widget ( Xputty main)

*get_toplevel_widget - get pointer to the top level Widget_t

Parameters
*main- pointer to the main Xputty struct

Definition at line 441 of file xwidget.c.

441 {
442 return main->childlist->childs[0];
443}

References Xputty::childlist, and Childlist_t::childs.

Referenced by os_quit().

◆ hide_tooltip()

void hide_tooltip ( Widget_t wid)

hide_tooltip - check if a Widget_t have a tooltip, and hide it, if a tooltip is mapped.

Parameters
*wid- pointer to the Widget_t receiving the event

Definition at line 430 of file xwidget.c.

430 {
431 int i = 0;
432 for(;i<wid->childlist->elem;i++) {
433 Widget_t *w = wid->childlist->childs[i];
434 if (w->flags & IS_TOOLTIP) {
435 widget_hide(w);
436 break;
437 }
438 }
439}
void widget_hide(Widget_t *w)
widget_hide - unmap/hide a Widget_t
Definition xwidget.c:368
@ IS_TOOLTIP
Definition xwidget.h:396

References Widget_t::childlist, Childlist_t::childs, Childlist_t::elem, Widget_t::flags, IS_TOOLTIP, and widget_hide().

Referenced by _draw_combobox_entrys(), _draw_list(), _draw_multi_list(), _list_motion(), _multi_list_motion(), _update_list_view(), _update_view(), os_widget_event_loop(), and WndProc().

◆ key_mapping()

int key_mapping ( Display dpy,
XKeyEvent xkey 
)

_key_mapping - modifier key's mapped to a integer value

Parameters
*dpy- pointer to the Display in use
*xkey- the key to map
Returns
int - value (1-10) or 0 when not mapped

Definition at line 37 of file xwidget.c.

37 {
38 if (xkey->keycode == XKeysymToKeycode(dpy,XK_Tab))
39 return (xkey->state & ShiftMask) ? 1 : 2;
40 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_Up))
41 return 3;
42 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_Right))
43 return 4;
44 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_Down))
45 return 5;
46 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_Left))
47 return 6;
48 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_Home))
49 return 7;
50 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_Insert))
51 return 8;
52 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_End))
53 return 9;
54 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_Return))
55 return 10;
56 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_BackSpace))
57 return 11;
58 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_Delete))
59 return 12;
60 // keypad
61 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_KP_Subtract))
62 return 1;
63 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_KP_Add))
64 return 2;
65 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_KP_Up))
66 return 3;
67 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_KP_Right))
68 return 4;
69 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_KP_Down))
70 return 5;
71 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_KP_Left))
72 return 6;
73 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_KP_Home))
74 return 7;
75 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_KP_Insert))
76 return 8;
77 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_KP_End))
78 return 9;
79 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_KP_Enter))
80 return 10;
81 else if (xkey->keycode == XKeysymToKeycode(dpy,XK_KP_Delete))
82 return 12;
83 else return 0;
84}
unsigned int state
int keycode

References XEvent::keycode, and XEvent::state.

Referenced by _check_keymap(), _combobox_key_pressed(), _list_key_pressed(), and _multi_list_key_pressed().

◆ pop_widget_show_all()

void pop_widget_show_all ( Widget_t w)

pop_widget_show_all - map/show popup widget with all it's childs

Parameters
*w- pointer to the Widget_t to map

Definition at line 400 of file xwidget.c.

400 {
401 if (w->flags & IS_SUBMENU) return;
402 w->func.map_notify_callback(w, NULL);
404 int i=0;
405 for(;i<w->childlist->elem;i++) {
407 }
408}
void os_widget_show(Widget_t *w)
os_widget_show - Show a Widget_t
void pop_widget_show_all(Widget_t *w)
pop_widget_show_all - map/show popup widget with all it's childs
Definition xwidget.c:400
@ IS_SUBMENU
Definition xwidget.h:418

References Widget_t::childlist, Childlist_t::childs, Childlist_t::elem, Widget_t::flags, Widget_t::func, IS_SUBMENU, Func_t::map_notify_callback, os_widget_show(), and pop_widget_show_all().

Referenced by _popup_spinbox(), pop_combobox_menu_show(), pop_menu_show(), and pop_widget_show_all().

◆ quit()

void quit ( Widget_t w)

quit - exit the main loop

Parameters
*w- pointer to the Widget_t sending the request

Definition at line 526 of file xwidget.c.

526 {
527 os_quit(w);
528}
void os_quit(Widget_t *w)
os_quit - quit the main loop and free all used memory

References os_quit().

Referenced by destroy_widget().

◆ quit_widget()

void quit_widget ( Widget_t w)

quit_widget - remove a widget from the processing loop

Parameters
*w- pointer to the Widget_t sending the request

Definition at line 530 of file xwidget.c.

530 {
531 os_quit(w);
532}

References os_quit().

Referenced by os_widget_event_loop(), and WndProc().

◆ resize_childs()

void resize_childs ( Widget_t wid)

resize_childs - intern check if child widgets needs resizing

Parameters
*wid- pointer to the Widget_t receive the event

Definition at line 151 of file xwidget.c.

151 {
153}

References _resize_childs().

◆ send_button_press_event()

void send_button_press_event ( Widget_t w)

send_button_press_event - send ButtonPress event to Widget_t
simulate a BUTTON_PRESS Event

Parameters
*w- pointer to the Widget_t to send the notify

Definition at line 514 of file xwidget.c.

514 {
516}
void os_send_button_press_event(Widget_t *w)
os_send_button_press_event - Send a button press event to a Widget_t see XButtonEvent

References os_send_button_press_event().

Referenced by _check_keymap().

◆ send_button_release_event()

void send_button_release_event ( Widget_t w)

send_button_release_event - send ButtonRelease event to Widget_t
simulate a BUTTON_RELEASE Event

Parameters
*w- pointer to the Widget_t to send the notify

Definition at line 518 of file xwidget.c.

518 {
520}
void os_send_button_release_event(Widget_t *w)
os_send_button_release_event - Send a button release event to a Widget_t see XButtonEvent

References os_send_button_release_event().

Referenced by _check_keymap().

◆ send_configure_event()

void send_configure_event ( Widget_t w,
int  x,
int  y,
int  width,
int  height 
)

send_configure_event - send a ConfigureNotify to Widget_t
used to resize a Widget_t

Parameters
*w- pointer to the Widget_t to send the notify
x,y- the new Widget_t position
width,height- the new Widget_t size

Definition at line 510 of file xwidget.c.

510 {
511 os_send_configure_event(w, x, y, width, height);
512}
void os_send_configure_event(Widget_t *w, int x, int y, int width, int height)
os_send_configure_event - Send a configure event to a Widget_t

References os_send_configure_event().

◆ send_systray_message()

void send_systray_message ( Widget_t w)

send_systray_message - request a systray icon for Widget_t
currently not working

Parameters
*w- pointer to the Widget_t to send the notify

Definition at line 522 of file xwidget.c.

522 {
524}
void os_send_systray_message(Widget_t *w)
os_send_send_systray_message - Send a systray event to a Widget_t only working on Linux for now

References os_send_systray_message().

◆ show_tooltip()

void show_tooltip ( Widget_t wid)

show_tooltip - check if a Widget_t have a tooltip, and show it, if a tooltip is available.

Parameters
*wid- pointer to the Widget_t receiving the event

Definition at line 419 of file xwidget.c.

419 {
420 int i = 0;
421 for(;i<wid->childlist->elem;i++) {
422 Widget_t *w = wid->childlist->childs[i];
423 if (w->flags & IS_TOOLTIP) {
424 os_show_tooltip(wid, w);
425 break;
426 }
427 }
428}
void os_show_tooltip(Widget_t *wid, Widget_t *w)
os_show_tooltip - Show a tooltip of a Widget_t

References Widget_t::childlist, Childlist_t::childs, Childlist_t::elem, Widget_t::flags, IS_TOOLTIP, and os_show_tooltip().

Referenced by _draw_combobox_entrys(), _draw_list(), _draw_multi_list(), _update_list_view(), _update_view(), os_widget_event_loop(), and WndProc().

◆ submenu_widget_show_all()

void submenu_widget_show_all ( Widget_t w)

submenu_widget_show_all - map/show submenu Widget_t with all childs

Parameters
*w- pointer to the Widget_t to map

Definition at line 410 of file xwidget.c.

410 {
411 w->func.map_notify_callback(w, NULL);
413 int i=0;
414 for(;i<w->childlist->elem;i++) {
416 }
417}
void submenu_widget_show_all(Widget_t *w)
submenu_widget_show_all - map/show submenu Widget_t with all childs
Definition xwidget.c:410

References Widget_t::childlist, Childlist_t::childs, Childlist_t::elem, Widget_t::func, Func_t::map_notify_callback, os_widget_show(), and submenu_widget_show_all().

Referenced by pop_submenu_show(), and submenu_widget_show_all().

◆ transparent_draw()

void transparent_draw ( void *  wid,
void *  user_data 
)

transparent_draw - copy parent surface to child surface
you usaualy didn't need to call this, it's used automaticaly when a Widget_t have set the flag USE_TRANSPARENCY
this is the default setting for Widget_t

Parameters
*wid- pointer to the Widget_t receiving the event
*user_data- void pointer to attached user_data

Definition at line 449 of file xwidget.c.

449 {
450 Widget_t *wid = (Widget_t*)w_;
451 Metrics_t m;
452 os_get_window_metrics(wid, &m);
453 if (!m.visible) return;
454
455 cairo_push_group (wid->cr);
456
457 if (wid->flags & USE_TRANSPARENCY) {
458 Widget_t *parent = (Widget_t*)wid->parent;
459
460 debug_print("Widget_t _transparency \n");
461 cairo_set_source_surface (wid->crb, parent->buffer, -m.x, -m.y);
462 cairo_paint (wid->crb);
463 }
464
465 cairo_push_group (wid->crb);
466 wid->func.expose_callback(wid, user_data);
467 cairo_pop_group_to_source (wid->crb);
468 cairo_paint (wid->crb);
469
470 cairo_set_source_surface (wid->cr, wid->buffer,0,0);
471 cairo_paint (wid->cr);
472
473 cairo_pop_group_to_source (wid->cr);
474 cairo_paint (wid->cr);
475 if ( wid->flags & DONT_PROPAGATE) return;
477}
@ DONT_PROPAGATE
Definition xwidget.h:420
void _propagate_child_expose(Widget_t *wid)
_propagate_child_expose - send expose to any child Widget_t

References _propagate_child_expose(), Widget_t::buffer, Widget_t::cr, Widget_t::crb, DONT_PROPAGATE, Func_t::expose_callback, Widget_t::flags, Widget_t::func, os_get_window_metrics(), Widget_t::parent, USE_TRANSPARENCY, Metrics_t::visible, Metrics_t::x, and Metrics_t::y.

Referenced by _propagate_child_expose(), create_hyperlink(), onPaint(), os_adjustment_callback(), os_transparent_draw(), and os_widget_event_loop().

◆ widget_draw()

void widget_draw ( void *  w_,
void *  user_data 
)

widget_draw - redraw only the widget,not the child widgets

Parameters
*w_- pointer to the Widget_t receiving the event
*user_data- void pointer to attached user_data

Definition at line 479 of file xwidget.c.

479 {
480 Widget_t *wid = (Widget_t*)w_;
481
482 cairo_push_group (wid->cr);
483
484 if (wid->flags & USE_TRANSPARENCY) {
485 Widget_t *parent = (Widget_t*)wid->parent;
486 Metrics_t m;
487 os_get_window_metrics(wid, &m);
488
489 debug_print("Widget_t draw widget \n");
490 cairo_set_source_surface (wid->crb, parent->buffer, -m.x, -m.y);
491 cairo_paint (wid->crb);
492 }
493
494 cairo_push_group (wid->crb);
495 wid->func.expose_callback(wid, user_data);
496 cairo_pop_group_to_source (wid->crb);
497 cairo_paint (wid->crb);
498
499 cairo_set_source_surface (wid->cr, wid->buffer,0,0);
500 cairo_paint (wid->cr);
501
502 cairo_pop_group_to_source (wid->cr);
503 cairo_paint (wid->cr);
504}

References Widget_t::buffer, Widget_t::cr, Widget_t::crb, Func_t::expose_callback, Widget_t::flags, Widget_t::func, os_get_window_metrics(), Widget_t::parent, USE_TRANSPARENCY, Metrics_t::x, and Metrics_t::y.

◆ widget_event_loop()

void widget_event_loop ( void *  w_,
void *  event,
Xputty main,
void *  user_data 
)

widget_event_loop - the internal widget event loop

Parameters
*w_- void pointer to the Widget_t receiving the event
*event- void pointer to the XEvent
*main- void pointer to the Xputty *main struct running the event loop
*user_data- void pointer to attached user_data

Definition at line 506 of file xwidget.c.

506 {
507 os_widget_event_loop(w_, event, main, user_data);
508}

References os_widget_event_loop().

Referenced by create_window().

◆ widget_hide()

void widget_hide ( Widget_t w)

widget_hide - unmap/hide a Widget_t

Parameters
*w- pointer to the Widget_t to unmap

Definition at line 368 of file xwidget.c.

368 {
369 int i=0;
370 for(;i<w->childlist->elem;i++) {
372 }
373 w->func.unmap_notify_callback(w, NULL);
375}
void os_widget_hide(Widget_t *w)
os_widget_hide - Hide a Widget_t

References Widget_t::childlist, Childlist_t::childs, Childlist_t::elem, Widget_t::func, os_widget_hide(), Func_t::unmap_notify_callback, and widget_hide().

Referenced by _check_grab(), _check_menu_state(), _check_submenu(), _draw_tabbox(), _enter_submenu(), _hide_all_tooltips(), _leave_submenu(), hide_tooltip(), os_main_run(), os_run_embedded(), pop_menu_show(), widget_hide(), widget_hide_all(), and WndProc().

◆ widget_hide_all()

void widget_hide_all ( Widget_t w)

widget_hide_all - unmap/hide all Widget_t from app

Parameters
*w- pointer to the Widget_t which send the unmap request

Definition at line 377 of file xwidget.c.

377 {
378 int i=0;
379 for(;i<w->app->childlist->elem;i++) {
381 }
382 w->func.unmap_notify_callback(w, NULL);
384}

References Widget_t::app, Xputty::childlist, Childlist_t::childs, Childlist_t::elem, Widget_t::func, os_widget_hide(), Func_t::unmap_notify_callback, and widget_hide().

◆ widget_reset_scale()

void widget_reset_scale ( Widget_t w)

widget_reset_scale - used to reset scaling mode after a image surface is drawn to the Widget_t surface with widget_set_scale()

Parameters
*w- pointer to the Widget_t sending the request

Definition at line 155 of file xwidget.c.

155 {
156 cairo_scale(w->crb, w->scale.cscale_x,w->scale.cscale_y);
157}

References Widget_t::crb, Resize_t::cscale_x, Resize_t::cscale_y, and Widget_t::scale.

Referenced by _draw_playhead().

◆ widget_set_scale()

void widget_set_scale ( Widget_t w)

widget_set_scale - set scaling mode to scale a image surface to the size of the Widget_t surface

Parameters
*w- pointer to the Widget_t sending the request

Definition at line 159 of file xwidget.c.

159 {
160 cairo_scale(w->crb, w->scale.rcscale_x,w->scale.rcscale_y);
161}

References Widget_t::crb, Resize_t::rcscale_x, Resize_t::rcscale_y, and Widget_t::scale.

Referenced by _draw_playhead().

◆ widget_set_title()

void widget_set_title ( Widget_t w,
const char *  title 
)

widget_set_title - set window title for a Widget_t

Parameters
*w- pointer to the Widget_t to set the title
*title- the title to store

Definition at line 359 of file xwidget.c.

359 {
360 os_set_title(w, title);
361}
void os_set_title(Widget_t *w, const char *title)
os_set_title - Set the title of a Widget_t

References os_set_title().

Referenced by mk_open_midi_keyboard(), open_directory_dialog(), open_file_dialog(), open_message_dialog(), and save_file_dialog().

◆ widget_show()

void widget_show ( Widget_t w)

widget_show - map/show widget

Parameters
*w- pointer to the Widget_t to map

Definition at line 363 of file xwidget.c.

363 {
364 w->func.map_notify_callback(w, NULL);
366}

References Widget_t::func, Func_t::map_notify_callback, and os_widget_show().

◆ widget_show_all()

void widget_show_all ( Widget_t w)

widget_show_all - map/show Widget_t with all childs

Parameters
*w- pointer to the Widget_t to map

Definition at line 386 of file xwidget.c.

386 {
387 if (w->flags & IS_POPUP || w->flags & IS_TOOLTIP ||
388 w->flags & IS_SUBMENU) {
389 return;
390 } else {
391 w->func.map_notify_callback(w, NULL);
393 int i=0;
394 for(;i<w->childlist->elem;i++) {
396 }
397 }
398}
void widget_show_all(Widget_t *w)
widget_show_all - map/show Widget_t with all childs
Definition xwidget.c:386
@ IS_POPUP
Definition xwidget.h:392

References Widget_t::childlist, Childlist_t::childs, Childlist_t::elem, Widget_t::flags, Widget_t::func, IS_POPUP, IS_SUBMENU, IS_TOOLTIP, Func_t::map_notify_callback, os_widget_show(), and widget_show_all().

Referenced by _draw_tabbox(), open_directory_dialog(), open_file_dialog(), open_message_dialog(), save_file_dialog(), and widget_show_all().

◆ widget_type_name()

const char * widget_type_name ( Widget_t w)

widget_type_name - textual representation of (Widget_t*)->widget_type

Parameters
w- the Widget_t* to query (NULL is allowed)
Returns
const char* - zero terminated string; must not be free()d

Definition at line 27 of file xwidget.c.

27 {
28 if (!w)
29 return widget_type_names[0]; // "WT_NONE"
30 else if (w->widget_type >= XPUTTY_WIDGET_NAME_COUNT)
31 return widget_type_names[XPUTTY_WIDGET_NAME_COUNT]; // "UNKNOWN"
32 else
33 return widget_type_names[w->widget_type];
34}
WidgetType widget_type
Definition xwidget.h:477

References Widget_t::widget_type.