]> git.decadent.org.uk Git - ion3.git/blob - mod_tiling/panehandle.c
[svn-upgrade] Integrating new upstream version, ion3 (20070506)
[ion3.git] / mod_tiling / panehandle.c
1 /*
2  * ion/mod_tiling/panehandle.c
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2007. 
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     ((WRegion*)pwin)->flags|=REGION_SKIP_FOCUS;
53     
54     panehandle_getbrush(pwin);
55     
56     if(pwin->brush==NULL){
57         GrBorderWidths bdw=GR_BORDER_WIDTHS_INIT;
58         memcpy(&(pwin->bdw), &bdw, sizeof(bdw));
59     }
60
61     window_select_input(&(pwin->wwin), IONCORE_EVENTMASK_NORMAL);
62     
63     return TRUE;
64 }
65
66
67 WPaneHandle *create_panehandle(WWindow *parent, const WFitParams *fp)
68 {
69     CREATEOBJ_IMPL(WPaneHandle, panehandle, (p, parent, fp));
70 }
71
72
73 void panehandle_deinit(WPaneHandle *pwin)
74 {
75     assert(pwin->splitfloat==NULL);
76     
77     if(pwin->brush!=NULL){
78         grbrush_release(pwin->brush);
79         pwin->brush=NULL;
80     }
81     
82     window_deinit(&(pwin->wwin));
83 }
84
85
86 /*}}}*/
87
88
89 /*{{{ Drawing */
90
91
92 static void panehandle_updategr(WPaneHandle *pwin)
93 {
94     panehandle_getbrush(pwin);
95     region_updategr_default((WRegion*)pwin);
96 }
97
98
99 static void panehandle_draw(WPaneHandle *pwin, bool complete)
100 {
101     WRectangle g;
102     
103     if(pwin->brush==NULL)
104         return;
105     
106     g.x=0;
107     g.y=0;
108     g.w=REGION_GEOM(pwin).w;
109     g.h=REGION_GEOM(pwin).h;
110     
111     grbrush_begin(pwin->brush, &g, (complete ? 0 : GRBRUSH_NO_CLEAR_OK));
112     
113     grbrush_draw_borderline(pwin->brush, &g, pwin->bline);
114     
115     grbrush_end(pwin->brush);
116 }
117
118
119 /*}}}*/
120
121
122 /*{{{ The class */
123
124
125 static DynFunTab panehandle_dynfuntab[]={
126     {region_updategr, panehandle_updategr},
127     {window_draw, panehandle_draw},
128     END_DYNFUNTAB,
129 };
130
131
132 IMPLCLASS(WPaneHandle, WWindow, panehandle_deinit, panehandle_dynfuntab);
133
134
135 /*}}}*/
136