libxputty 0.1
Loading...
Searching...
No Matches
Functions
xtabbox_private.h File Reference

Go to the source code of this file.

Functions

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)
 

Function Documentation

◆ _draw_tab()

void _draw_tab ( void *  w_,
void *  user_data 
)

_draw_tab - draw a single tab on expose call

Parameters
*w_- the tab to draw
*user_data- attached user_data

Definition at line 92 of file xtabbox_private.c.

92 {
93 Widget_t *w = (Widget_t*)w_;
94 Widget_t *p = (Widget_t*)w->parent;
95 _draw_tabbox(p, NULL);
96}
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
void * parent
Definition xwidget.h:471
void _draw_tabbox(void *w_, void *user_data)
_draw_tabbox - draw the tabbox on expose call

References _draw_tabbox(), and Widget_t::parent.

Referenced by tabbox_add_tab().

◆ _draw_tabbox()

void _draw_tabbox ( void *  w_,
void *  user_data 
)

_draw_tabbox - draw the tabbox on expose call

Parameters
*w_- the tabbox to draw
*user_data- attached user_data

Definition at line 39 of file xtabbox_private.c.

39 {
40 Widget_t *w = (Widget_t*)w_;
41 Metrics_t metrics;
42 os_get_window_metrics(w, &metrics);
43 int width_t = metrics.width;
44 int height_t = metrics.height;
45 if (!metrics.visible) return;
46
47 int tabsize = 1;
48 int elem = w->childlist->elem;
49 if (elem) tabsize = width_t/elem;
50 int v = (int)adj_get_value(w->adj);
51
52 cairo_new_path (w->crb);
53 cairo_set_line_width(w->crb,1);
55 _rounded_box(w->crb, 1, 21, width_t-2, height_t-22, (v+1)*tabsize);
56 cairo_stroke(w->crb);
57
58 cairo_text_extents_t extents;
60 cairo_set_font_size (w->crb, w->app->normal_font/w->scale.ascale);
61 int i = 0;
62 int t = 0;
63 for(;i<elem;i++) {
64 Widget_t *wi = w->childlist->childs[i];
65 if(v == i) {
66 cairo_move_to (w->crb, t+1, 21);
67 cairo_line_to(w->crb, t+1, 1);
68 cairo_line_to(w->crb, t+tabsize-1, 1);
69 cairo_line_to(w->crb, t+tabsize-1, 21);
71 cairo_stroke(w->crb);
74 } else {
76 cairo_rectangle(w->crb, t+2, 1, tabsize-4, 20);
77 cairo_fill_preserve(w->crb);
79 cairo_stroke(w->crb);
81 widget_hide(wi);
82 }
83
84 cairo_text_extents(w->crb,"Äy" , &extents);
85 cairo_move_to (w->crb, 5+t, 2+extents.height);
86 cairo_show_text(w->crb, wi->label);
87 cairo_new_path (w->crb);
88 t += tabsize;
89 }
90}
Widget_t ** childs
Definition xchildlist.h:51
Metrics_t - struct to receive window size, position & visibility Pass this struct to os_get_window_...
float ascale
Definition xwidget.h:369
Resize_t scale
Definition xwidget.h:525
Adjustment_t * adj
Definition xwidget.h:497
cairo_t * crb
Definition xwidget.h:489
Childlist_t * childlist
Definition xwidget.h:499
const char * label
Definition xwidget.h:463
Xputty * app
Definition xwidget.h:465
int normal_font
Definition xputty.h:248
float adj_get_value(Adjustment_t *adj)
adj_get_value - get the current value of the Adjustment_t
void use_frame_color_scheme(Widget_t *w, Color_state st)
use_frame_color_scheme - use frame Colors to paint on Widget_t
Definition xcolor.c:280
Color_state get_color_state(Widget_t *wid)
get_color_state - get the Color_state to use in relation to the Widget_t state
Definition xcolor.c:222
void use_text_color_scheme(Widget_t *w, Color_state st)
use_text_color_scheme - use text Colors to paint on Widget_t
Definition xcolor.c:266
void use_bg_color_scheme(Widget_t *w, Color_state st)
use_bg_color_scheme - use background Colors to paint on Widget_t
Definition xcolor.c:252
@ NORMAL_
Definition xcolor.h:44
@ INSENSITIVE_
Definition xcolor.h:48
@ ACTIVE_
Definition xcolor.h:47
void _rounded_box(cairo_t *cr, float x, float y, float w, float h, float lsize)
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 widget_show_all(Widget_t *w)
widget_show_all - map/show Widget_t with all childs
Definition xwidget.c:386
void widget_hide(Widget_t *w)
widget_hide - unmap/hide a Widget_t
Definition xwidget.c:368

References _rounded_box(), ACTIVE_, Widget_t::adj, adj_get_value(), Widget_t::app, Resize_t::ascale, Widget_t::childlist, Childlist_t::childs, Widget_t::crb, Childlist_t::elem, get_color_state(), Metrics_t::height, INSENSITIVE_, Widget_t::label, NORMAL_, Xputty::normal_font, os_get_window_metrics(), Widget_t::scale, use_bg_color_scheme(), use_frame_color_scheme(), use_text_color_scheme(), Metrics_t::visible, widget_hide(), widget_show_all(), and Metrics_t::width.

Referenced by _draw_tab(), and add_tabbox().

◆ _tab_button_released()

void _tab_button_released ( void *  w_,
void *  button_,
void *  user_data 
)

_tab_button_released - select the tab to show (hide all other)

Parameters
*w_- the Widget_t which is released
*button_- the xbutton event
*user_data- attached user_data

Definition at line 98 of file xtabbox_private.c.

98 {
99 Widget_t *w = (Widget_t*)w_;
100 Metrics_t metrics;
101 os_get_window_metrics(w, &metrics);
102 int width_t = metrics.width;
103 if (w->flags & HAS_POINTER) {
104 XButtonEvent *xbutton = (XButtonEvent*)button_;
105 if (xbutton->y < 20) {
106 int tabsize = width_t;
107 int elem = w->childlist->elem;
108 if (elem) tabsize = width_t/elem;
109 adj_set_value(w->adj,(float)(xbutton->x/tabsize));
110 expose_widget(w);
111 }
112 }
113
114}
long long flags
Definition xwidget.h:461
void adj_set_value(Adjustment_t *adj, float value)
adj_set_value - set the current value to the Adjustment_t
void expose_widget(Widget_t *w)
expose_widgets - send a expose event (EXPOSE) to a Widget_t
Definition xwidget.c:445
@ HAS_POINTER
Definition xwidget.h:402

References Widget_t::adj, adj_set_value(), Widget_t::childlist, Childlist_t::elem, expose_widget(), Widget_t::flags, HAS_POINTER, os_get_window_metrics(), Metrics_t::width, XEvent::x, and XEvent::y.

Referenced by add_tabbox().