plan9fox/libpanel/label.c
xfnw 856abd2f7d Squashed 'sys/src/cmd/gopher/' content from commit 3680728b6
git-subtree-dir: sys/src/cmd/gopher
git-subtree-split: 3680728b631ed65201b397f4ae3e5d1b03be42f9
2022-07-01 15:46:23 -04:00

50 lines
1.2 KiB
C

#include <u.h>
#include <libc.h>
#include <draw.h>
#include <event.h>
#include <panel.h>
#include "pldefs.h"
typedef struct Label Label;
struct Label{
int placement;
Icon *icon;
};
void pl_drawlabel(Panel *p){
Label *l;
l=p->data;
pl_drawicon(p->b, pl_box(p->b, p->r, PASSIVE), l->placement, p->flags, l->icon);
}
int pl_hitlabel(Panel *p, Mouse *m){
USED(p, m);
return 0;
}
void pl_typelabel(Panel *p, Rune c){
USED(p, c);
}
Point pl_getsizelabel(Panel *p, Point children){
USED(children); /* shouldn't have any children */
return pl_boxsize(pl_iconsize(p->flags, ((Label *)p->data)->icon), PASSIVE);
}
void pl_childspacelabel(Panel *g, Point *ul, Point *size){
USED(g, ul, size);
}
void plinitlabel(Panel *v, int flags, Icon *icon){
v->flags=flags|LEAF;
((Label *)(v->data))->icon=icon;
v->draw=pl_drawlabel;
v->hit=pl_hitlabel;
v->type=pl_typelabel;
v->getsize=pl_getsizelabel;
v->childspace=pl_childspacelabel;
v->kind="label";
}
Panel *pllabel(Panel *parent, int flags, Icon *icon){
Panel *p;
p=pl_newpanel(parent, sizeof(Label));
plinitlabel(p, flags, icon);
plplacelabel(p, PLACECEN);
return p;
}
void plplacelabel(Panel *p, int placement){
((Label *)(p->data))->placement=placement;
}