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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
/*
* ion/ioncore/groupedpholder.c
*
* Copyright (c) Tuomo Valkonen 2005-2007.
*
* See the included file LICENSE for details.
*/
#include <libtu/objp.h>
#include <libtu/obj.h>
#include "group.h"
#include "group-cw.h"
#include "groupedpholder.h"
/*{{{ Init/deinit */
bool groupedpholder_init(WGroupedPHolder *ph, WPHolder *cont)
{
assert(cont!=NULL);
pholder_init(&(ph->ph));
ph->cont=cont;
return TRUE;
}
WGroupedPHolder *create_groupedpholder(WPHolder *cont)
{
CREATEOBJ_IMPL(WGroupedPHolder, groupedpholder, (p, cont));
}
void groupedpholder_deinit(WGroupedPHolder *ph)
{
if(ph->cont!=NULL){
destroy_obj((Obj*)ph->cont);
ph->cont=NULL;
}
pholder_deinit(&(ph->ph));
}
/*}}}*/
/*{{{ Attach */
static bool grouped_do_attach_final(WGroupCW *cwg,
WRegion *reg,
WGroupAttachParams *param)
{
if(!param->geom_set){
/* Comm. hack */
REGION_GEOM(cwg)=REGION_GEOM(reg);
}
param->geom_set=1;
param->geom.x=0;
param->geom.y=0;
param->geom.w=REGION_GEOM(reg).w;
param->geom.h=REGION_GEOM(reg).h;
param->szplcy=SIZEPOLICY_FULL_EXACT;
param->szplcy_set=TRUE;
return group_do_attach_final(&cwg->grp, reg, param);
}
WRegion *grouped_handler(WWindow *par,
const WFitParams *fp,
void *frp_)
{
WRegionAttachData *data=(WRegionAttachData*)frp_;
WGroupAttachParams param=GROUPATTACHPARAMS_INIT;
WGroupCW *cwg;
WRegion *reg;
cwg=create_groupcw(par, fp);
if(cwg==NULL)
return NULL;
param.level_set=1;
param.level=STACKING_LEVEL_BOTTOM;
param.switchto_set=1;
param.switchto=1;
param.bottom=1;
if(!(fp->mode®ION_FIT_WHATEVER)){
/* Comm. hack */
param.geom_set=TRUE;
}
reg=region_attach_helper((WRegion*)cwg, par, fp,
(WRegionDoAttachFn*)grouped_do_attach_final,
¶m, data);
if(reg==NULL){
destroy_obj((Obj*)cwg);
return NULL;
}
return (WRegion*)cwg;
}
WRegion *groupedpholder_do_attach(WGroupedPHolder *ph, int flags,
WRegionAttachData *data)
{
WRegionAttachData data2;
if(ph->cont==NULL)
return FALSE;
data2.type=REGION_ATTACH_NEW;
data2.u.n.fn=grouped_handler;
data2.u.n.param=data;
return pholder_do_attach(ph->cont, flags, &data2);
}
/*}}}*/
/*{{{ Other dynfuns */
bool groupedpholder_do_goto(WGroupedPHolder *ph)
{
return (ph->cont!=NULL
? pholder_goto(ph->cont)
: FALSE);
}
WRegion *groupedpholder_do_target(WGroupedPHolder *ph)
{
return (ph->cont!=NULL
? pholder_target(ph->cont)
: NULL);
}
WPHolder *groupedpholder_do_root(WGroupedPHolder *ph)
{
WPHolder *root;
if(ph->cont==NULL)
return NULL;
root=pholder_root(ph->cont);
return (root!=ph->cont
? root
: &ph->ph);
}
/*}}}*/
/*{{{ Class information */
static DynFunTab groupedpholder_dynfuntab[]={
{(DynFun*)pholder_do_attach,
(DynFun*)groupedpholder_do_attach},
{(DynFun*)pholder_do_goto,
(DynFun*)groupedpholder_do_goto},
{(DynFun*)pholder_do_target,
(DynFun*)groupedpholder_do_target},
{(DynFun*)pholder_do_root,
(DynFun*)groupedpholder_do_root},
END_DYNFUNTAB
};
IMPLCLASS(WGroupedPHolder, WPHolder, groupedpholder_deinit,
groupedpholder_dynfuntab);
/*}}}*/
|