libxputty 0.1
Loading...
Searching...
No Matches
xtabbox.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 "xtabbox.h"
23#include "xtabbox_private.h"
24
25
26Widget_t* tabbox_add_tab(Widget_t *tabbox, const char * label) {
27 Metrics_t metrics;
28 os_get_window_metrics(tabbox, &metrics);
29 int width = metrics.width;
30 int height = metrics.height;
31 Widget_t *wid = create_widget(tabbox->app,tabbox, 4, 20, width-8, height-24);
32 wid->scale.gravity = NORTHWEST;
33 wid->label = label;
35 //wid->func.map_notify_callback = _tab_mapped_callback;
36 float max_value = tabbox->adj->max_value+1.0;
37 set_adjustment(tabbox->adj,0.0, max_value, 0.0, max_value,1.0, CL_NONE);
38 adj_set_value(tabbox->adj,0.0);
39 return wid;
40}
41
42Widget_t* add_tabbox(Widget_t *parent, const char * label,
43 int x, int y, int width, int height) {
44
45 Widget_t *wid = create_widget(parent->app, parent, x, y, width, height);
46 wid->label = label;
47 wid->scale.gravity = CENTER;
48 wid->adj_y = add_adjustment(wid,0.0, 0.0, 0.0, -1.0,1.0, CL_NONE);
49 wid->adj = wid->adj_y;
51 //wid->func.button_press_callback = _tab_button_pressed;
53 //wid->func.map_notify_callback = _tabbox_mapped_callback;
54 return wid;
55}
56
57void tabbox_remove_tab(Widget_t *tabbox, int tab) {
58 int elem = tabbox->childlist->elem;
59 if (tab > elem) return;
60 Widget_t *wid = tabbox->childlist->childs[tab];
61 destroy_widget(wid, tabbox->app);
62 float max_value = tabbox->adj->max_value-1.0;
63 set_adjustment(tabbox->adj,0.0, max_value, 0.0, max_value,1.0, CL_NONE);
64}
float max_value
Definition xadjustment.h:92
Widget_t ** childs
Definition xchildlist.h:51
evfunc button_release_callback
Definition xwidget.h:101
xevfunc expose_callback
Definition xwidget.h:85
Metrics_t - struct to receive window size, position & visibility Pass this struct to os_get_window_...
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
Childlist_t * childlist
Definition xwidget.h:499
const char * label
Definition xwidget.h:463
Func_t func
Definition xwidget.h:481
Xputty * app
Definition xwidget.h:465
void adj_set_value(Adjustment_t *adj, float value)
adj_set_value - set the current value to the Adjustment_t
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
void set_adjustment(Adjustment_t *adj, float std_value, float value, float min_value, float max_value, float step, CL_type type)
*set_adjustment - set a new range to a existing Adjustment_t or create if it not exists yet
Definition xadjustment.c:80
@ CL_NONE
Definition xadjustment.h:47
void tabbox_remove_tab(Widget_t *tabbox, int tab)
tabbox_remove_tab - remove a tab from a tabbox Widget_t
Definition xtabbox.c:57
Widget_t * tabbox_add_tab(Widget_t *tabbox, const char *label)
tabbox_add_tab - add a tab to a tabbox Widget_t
Definition xtabbox.c:26
Widget_t * add_tabbox(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_tabbox - add a tabbox to a Widget_t
Definition xtabbox.c:42
void _draw_tabbox(void *w_, void *user_data)
_draw_tabbox - draw the tabbox on expose call
void _draw_tab(void *w_, void *user_data)
_draw_tab - draw a single tab on expose call
void _tab_button_released(void *w_, void *button_, void *user_data)
_tab_button_released - select the tab to show (hide all other)
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
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
@ CENTER
Definition xwidget.h:320
@ NORTHWEST
Definition xwidget.h:300
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