2 * ion/mod_tiling/panehandle.c
4 * Copyright (c) Tuomo Valkonen 1999-2007.
6 * Ion is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
14 #include <libtu/objp.h>
15 #include <libtu/minmax.h>
16 #include <ioncore/common.h>
17 #include <ioncore/global.h>
18 #include <ioncore/event.h>
19 #include <ioncore/gr.h>
20 #include <ioncore/regbind.h>
21 #include "panehandle.h"
28 static void panehandle_getbrush(WPaneHandle *pwin)
30 GrBrush *brush=gr_get_brush(pwin->wwin.win,
31 region_rootwin_of((WRegion*)pwin),
36 grbrush_release(pwin->brush);
40 grbrush_get_border_widths(brush, &(pwin->bdw));
41 grbrush_enable_transparency(brush, GR_TRANSPARENCY_YES);
46 bool panehandle_init(WPaneHandle *pwin, WWindow *parent, const WFitParams *fp)
49 pwin->bline=GR_BORDERLINE_NONE;
50 pwin->splitfloat=NULL;
52 if(!window_init(&(pwin->wwin), parent, fp))
55 ((WRegion*)pwin)->flags|=REGION_SKIP_FOCUS;
57 panehandle_getbrush(pwin);
59 if(pwin->brush==NULL){
60 GrBorderWidths bdw=GR_BORDER_WIDTHS_INIT;
61 memcpy(&(pwin->bdw), &bdw, sizeof(bdw));
64 window_select_input(&(pwin->wwin), IONCORE_EVENTMASK_NORMAL);
70 WPaneHandle *create_panehandle(WWindow *parent, const WFitParams *fp)
72 CREATEOBJ_IMPL(WPaneHandle, panehandle, (p, parent, fp));
76 void panehandle_deinit(WPaneHandle *pwin)
78 assert(pwin->splitfloat==NULL);
80 if(pwin->brush!=NULL){
81 grbrush_release(pwin->brush);
85 window_deinit(&(pwin->wwin));
95 static void panehandle_updategr(WPaneHandle *pwin)
97 panehandle_getbrush(pwin);
98 region_updategr_default((WRegion*)pwin);
102 static void panehandle_draw(WPaneHandle *pwin, bool complete)
106 if(pwin->brush==NULL)
111 g.w=REGION_GEOM(pwin).w;
112 g.h=REGION_GEOM(pwin).h;
114 grbrush_begin(pwin->brush, &g, (complete ? 0 : GRBRUSH_NO_CLEAR_OK));
116 grbrush_draw_borderline(pwin->brush, &g, pwin->bline);
118 grbrush_end(pwin->brush);
128 static DynFunTab panehandle_dynfuntab[]={
129 {region_updategr, panehandle_updategr},
130 {window_draw, panehandle_draw},
135 IMPLCLASS(WPaneHandle, WWindow, panehandle_deinit, panehandle_dynfuntab);