libxputty 0.1
Loading...
Searching...
No Matches
xvaluedisplay.c
Go to the documentation of this file.
1/*
2 * 0BSD
3 *
4 * BSD Zero Clause License
5 *
6 * Copyright (c) 2019 Hermann Meyer
7 *
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted.
10
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
18 *
19 */
20
21
22#include "xvaluedisplay.h"
24
25
26Widget_t* add_popup_spinbox(Widget_t *parent, const char * label,
27 int x, int y, int width, int height) {
28 int x1, y1;
29 os_translate_coords(parent, parent->widget, os_get_root_window(parent->app, IS_WIDGET), 0, 0, &x1, &y1);
30 Widget_t *wid = create_window(parent->app, os_get_root_window(parent->app, IS_WIDGET), x1, y1, width +40, height+20);
32 os_set_transient_for_hint(parent, wid);
33 //wid->func.expose_callback = _draw_spinbox;
34 wid->flags |= IS_POPUP;
35 wid->scale.gravity = NONE;
36 wid->parent = parent;
37 childlist_add_child(parent->childlist, wid);
38 Widget_t *view_port = create_widget(wid->app, wid, 0 , 0, width+20, height+20);
40 Widget_t *buttons = create_widget(wid->app, wid, width+20 , 0, 20, height+20);
42 buttons->scale.gravity = NORTHWEST;
43 buttons->flags &= ~USE_TRANSPARENCY;
44 buttons->flags |= NO_AUTOREPEAT | NO_PROPAGATE;
46
47 return wid;
48}
49
50Widget_t* add_valuedisplay(Widget_t *parent, const char * label,
51 int x, int y, int width, int height) {
52
53 Widget_t *wid = create_widget(parent->app, parent, x, y, width, height);
54 add_popup_spinbox(wid, label, x, y, width, height);
55 wid->label = label;
56 wid->adj_y = add_adjustment(wid,0.0, 0.0, 0.0, 1.0, 0.01, CL_CONTINUOS);
57 wid->adj = wid->adj_y;
58 wid->scale.gravity = CENTER;
63 return wid;
64}
evfunc button_release_callback
Definition xwidget.h:101
xevfunc expose_callback
Definition xwidget.h:85
evfunc double_click_callback
Definition xwidget.h:102
xevfunc leave_callback
Definition xwidget.h:88
xevfunc enter_callback
Definition xwidget.h:87
Gravity gravity
Definition xwidget.h:347
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
Resize_t scale
Definition xwidget.h:525
Adjustment_t * adj_y
Definition xwidget.h:495
Adjustment_t * adj
Definition xwidget.h:497
void * parent
Definition xwidget.h:471
Window widget
Definition xwidget.h:469
Childlist_t * childlist
Definition xwidget.h:499
long long flags
Definition xwidget.h:461
const char * label
Definition xwidget.h:463
Func_t func
Definition xwidget.h:481
Xputty * app
Definition xwidget.h:465
Adjustment_t * add_adjustment(Widget_t *w, float std_value, float value, float min_value, float max_value, float step, CL_type type)
*add_adjustment - adding a adjustment to a Widget_t
Definition xadjustment.c:25
@ CL_CONTINUOS
Definition xadjustment.h:49
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
Widget_t * add_valuedisplay(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_valuedisplay - add a valuedisplay widget to a Widget_t
Widget_t * add_popup_spinbox(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_popup_spinbox - add a popup spinbox to a valuedisplay this is implemented in the valuedisplay via...
void _draw_buttons(void *w_, void *user_data)
_draw_buttons - draw the spinbox buttons
void _draw_spinbox(void *w_, void *user_data)
_draw_spinbox - draw a spinbox expose call
void _buttons_released(void *w_, void *button, void *user_data)
_buttons_released - set the spinbox value on button releases
void _draw_valuedisplay(void *w_, void *user_data)
_draw_valuedisplay - draw a valuedisplay on expose call
void _popup_spinbox(void *w_, void *button, void *user_data)
_popup_spinbox - show a spinbox above a valuedisplay
Window os_get_root_window(Xputty *main, int flag)
os_get_root_window - get a pointer to the root window (desktop)
void os_translate_coords(Widget_t *w, Window from_window, Window to_window, int from_x, int from_y, int *to_x, int *to_y)
os_translate_coords - get x,y related to destination Window
void os_set_transient_for_hint(Widget_t *parent, Widget_t *w)
os_set_ transient_for_hint - set a Widget_t transient to a other Widget_t only work on linux,...
void os_transparent_draw(void *w_, void *user_data)
os_transparent_draw - Draw the Widget_t to the back buffer
void os_set_window_attrb(Widget_t *w)
os_set_window_attrb - set the attribute mask to a Widget_t only work on linux, stub on Windows
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...
Definition xwidget.c:265
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....
Definition xwidget.c:163
@ CENTER
Definition xwidget.h:320
@ NONE
Definition xwidget.h:328
@ NORTHWEST
Definition xwidget.h:300
@ IS_WIDGET
Definition xwidget.h:388
@ NO_AUTOREPEAT
Definition xwidget.h:408
@ NO_PROPAGATE
Definition xwidget.h:416
@ IS_POPUP
Definition xwidget.h:392