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