]> git.decadent.org.uk Git - ion3.git/blob - mod_tiling/panehandle.c
[svn-upgrade] Integrating new upstream version, ion3 (20081002)
[ion3.git] / mod_tiling / panehandle.c
1 /*
2  * ion/mod_tiling/panehandle.c
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2008. 
5  *
6  * See the included file LICENSE for details.
7  */
8
9 #include <string.h>
10
11 #include <libtu/objp.h>
12 #include <libtu/minmax.h>
13 #include <ioncore/common.h>
14 #include <ioncore/global.h>
15 #include <ioncore/event.h>
16 #include <ioncore/gr.h>
17 #include <ioncore/regbind.h>
18 #include "panehandle.h"
19 #include "main.h"
20
21
22 /*{{{ Init/deinit */
23
24
25 static void panehandle_getbrush(WPaneHandle *pwin)
26 {
27     GrBrush *brush=gr_get_brush(pwin->wwin.win, 
28                                 region_rootwin_of((WRegion*)pwin), 
29                                 "pane");
30
31     if(brush!=NULL){
32         if(pwin->brush!=NULL)
33             grbrush_release(pwin->brush);
34         
35         pwin->brush=brush;
36         
37         grbrush_get_border_widths(brush, &(pwin->bdw));
38         grbrush_enable_transparency(brush, GR_TRANSPARENCY_YES);
39     }
40 }
41
42
43 bool panehandle_init(WPaneHandle *pwin, WWindow *parent, const WFitParams *fp)
44 {
45     pwin->brush=NULL;
46     pwin->bline=GR_BORDERLINE_NONE;
47     pwin->splitfloat=NULL;
48     
49     if(!window_init(&(pwin->wwin), parent, fp))
50         return FALSE;
51     
52     panehandle_getbrush(pwin);
53     
54     if(pwin->brush==NULL){
55         GrBorderWidths bdw=GR_BORDER_WIDTHS_INIT;
56         memcpy(&(pwin->bdw), &bdw, sizeof(bdw));
57     }
58
59     window_select_input(&(pwin->wwin), IONCORE_EVENTMASK_NORMAL);
60     
61     return TRUE;
62 }
63
64
65 WPaneHandle *create_panehandle(WWindow *parent, const WFitParams *fp)
66 {
67     CREATEOBJ_IMPL(WPaneHandle, panehandle, (p, parent, fp));
68 }
69
70
71 void panehandle_deinit(WPaneHandle *pwin)
72 {
73     assert(pwin->splitfloat==NULL);
74     
75     if(pwin->brush!=NULL){
76         grbrush_release(pwin->brush);
77         pwin->brush=NULL;
78     }
79     
80     window_deinit(&(pwin->wwin));
81 }
82
83
84 /*}}}*/
85
86
87 /*{{{ Drawing */
88
89
90 static void panehandle_updategr(WPaneHandle *pwin)
91 {
92     panehandle_getbrush(pwin);
93     region_updategr_default((WRegion*)pwin);
94 }
95
96
97 static void panehandle_draw(WPaneHandle *pwin, bool complete)
98 {
99     WRectangle g;
100     
101     if(pwin->brush==NULL)
102         return;
103     
104     g.x=0;
105     g.y=0;
106     g.w=REGION_GEOM(pwin).w;
107     g.h=REGION_GEOM(pwin).h;
108     
109     grbrush_begin(pwin->brush, &g, (complete ? 0 : GRBRUSH_NO_CLEAR_OK));
110     
111     grbrush_draw_borderline(pwin->brush, &g, pwin->bline);
112     
113     grbrush_end(pwin->brush);
114 }
115
116
117 /*}}}*/
118
119
120 /*{{{ The class */
121
122
123 static DynFunTab panehandle_dynfuntab[]={
124     {region_updategr, panehandle_updategr},
125     {window_draw, panehandle_draw},
126     END_DYNFUNTAB,
127 };
128
129
130 IMPLCLASS(WPaneHandle, WWindow, panehandle_deinit, panehandle_dynfuntab);
131
132
133 /*}}}*/
134