本文整理汇总了C++中TKobj函数的典型用法代码示例。如果您正苦于以下问题:C++ TKobj函数的具体用法?C++ TKobj怎么用?C++ TKobj使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TKobj函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tkcvswindgeom
static void
tkcvswindgeom(Tk *sub, int x, int y, int w, int h)
{
TkCitem *i;
Tk *parent;
TkCanvas *c;
TkCwind *win;
USED(x);
USED(y);
parent = sub->parent;
win = nil;
c = TKobj(TkCanvas, parent);
for(i = c->head; i; i = i->next) {
if(i->type == TkCVwindow) {
win = TKobj(TkCwind, i);
if(win->sub == sub)
break;
}
}
tkbbmax(&c->update, &i->p.bb);
if((win->flags & Tksetwidth) == 0)
win->width = w;
if ((win->flags & Tksetheight) == 0)
win->height = h;
sub->req.width = w;
sub->req.height = h;
tkcvswindsize(i);
tkbbmax(&c->update, &i->p.bb);
tkcvsdirty(parent);
}
示例2: tkcvssubdestry
static void
tkcvssubdestry(Tk *sub)
{
Tk *tk;
TkCitem *i;
TkCanvas *c;
TkCwind *win;
tk = sub->parent;
if(tk == nil)
return;
if(0)print("tkcvssubdestry %p %q\n", sub, tkname(sub));
i = tkcvsfindwin(sub);
if(i == nil)
return;
win = TKobj(TkCwind, i);
if(win->sub != sub){
if(win->sub != nil)
print("inconsistent tkcvssubdestry %p %q\n", sub, tkname(sub));
return;
}
c = TKobj(TkCanvas, tk);
tkbbmax(&c->update, &i->p.bb);
tkcvssetdirty(tk);
win->focus = nil;
win->sub = nil;
sub->parent = nil;
sub->geom = nil;
}
示例3: tkcvsrectcreat
char*
tkcvsrectcreat(Tk* tk, char *arg, char **val)
{
char *e;
TkCrect *r;
TkCitem *i;
TkCanvas *c;
TkOptab tko[3];
c = TKobj(TkCanvas, tk);
i = tkcnewitem(tk, TkCVrect, sizeof(TkCitem)+sizeof(TkCrect));
if(i == nil)
return TkNomem;
r = TKobj(TkCrect, i);
r->width = TKI2F(1);
e = tkparsepts(tk->env->top, &i->p, &arg, 0);
if(e != nil) {
tkcvsfreeitem(i);
return e;
}
if(i->p.npoint != 2) {
tkcvsfreeitem(i);
return TkFewpt;
}
tko[0].ptr = r;
tko[0].optab = rectopts;
tko[1].ptr = i;
tko[1].optab = itemopts;
tko[2].ptr = nil;
e = tkparse(tk->env->top, arg, tko, nil);
if(e != nil) {
tkcvsfreeitem(i);
return e;
}
tkmkstipple(r->stipple);
e = tkcaddtag(tk, i, 1);
if(e != nil) {
tkcvsfreeitem(i);
return e;
}
tkcvsrectsize(i);
e = tkvalue(val, "%d", i->id);
if(e != nil) {
tkcvsfreeitem(i);
return e;
}
tkcvsappend(c, i);
tkbbmax(&c->update, &i->p.bb);
tkcvssetdirty(tk);
return nil;
}
示例4: tkcvslinecreat
char*
tkcvslinecreat(Tk* tk, char *arg, char **val)
{
char *e;
TkCline *l;
TkCitem *i;
TkCanvas *c;
TkOptab tko[3];
c = TKobj(TkCanvas, tk);
i = tkcnewitem(tk, TkCVline, sizeof(TkCitem)+sizeof(TkCline));
if(i == nil)
return TkNomem;
l = TKobj(TkCline, i);
l->width = TKI2F(1);
e = tkparsepts(tk->env->top, &i->p, &arg, 0);
if(e != nil) {
tkcvsfreeitem(i);
return e;
}
tko[0].ptr = l;
tko[0].optab = lineopts;
tko[1].ptr = i;
tko[1].optab = itemopts;
tko[2].ptr = nil;
e = tkparse(tk->env->top, arg, tko, nil);
if(e != nil) {
tkcvsfreeitem(i);
return e;
}
tkmkpen(&l->pen, i->env, l->stipple);
e = tkcaddtag(tk, i, 1);
if(e != nil) {
tkcvsfreeitem(i);
return e;
}
tkcvslinesize(i);
e = tkvalue(val, "%d", i->id);
if(e != nil) {
tkcvsfreeitem(i);
return e;
}
tkcvsappend(c, i);
tkbbmax(&c->update, &i->p.bb);
tkcvssetdirty(tk);
return nil;
}
示例5: tklabelmargin
int
tklabelmargin(Tk *tk)
{
TkLabel *tkl;
Image *img;
switch(tk->type){
case TKseparator:
return 0;
case TKlabel:
case TKcascade:
tkl = TKobj(TkLabel, tk);
img = nil;
if (tkl->img != nil)
img = tkl->img->img;
else if (tkl->bitmap != nil)
img = tkl->bitmap;
if (img != nil)
return Bitpadx;
return Textpadx;
default:
fprint(2, "label margin: type %d\n", tk->type);
return 0;
}
}
示例6: x2index
static int
x2index(Tk *tk, int x, int *xc)
{
TkEntry *tke = TKobj(TkEntry, tk);
int t0, t1, r, q;
t0 = 0;
t1 = tke->textlen;
while (t0 <= t1) {
r = (t0 + t1) / 2;
q = entrytextwidth(tk, r);
if (q == x) {
if (xc != nil)
*xc = q;
return r;
}
if (q < x)
t0 = r + 1;
else
t1 = r - 1;
}
if (xc != nil)
*xc = t1 > 0 ? entrytextwidth(tk, t1) : 0;
if (t1 < 0)
t1 = 0;
return t1;
}
示例7: tkscalebut1p
static char*
tkscalebut1p(Tk *tk, char *arg, char **val)
{
int z[2];
char *v, *e;
TkScale *tks = TKobj(TkScale, tk);
int repeat;
USED(val);
v = tkscaleposn(tk->env, tk, arg, z);
if(v == nil)
return TkBadvl;
e = nil;
if(v[0] == '\0' || z[0] < tks->center-tks->sw || z[0] > tks->center+tks->sw)
return nil;
if(v == slider) {
tks->flag |= Dragging;
tks->relief = TKsunken;
tks->pix = z[1];
tks->base = tks->value;
tkscalecheckvalue(tk);
} else {
e = stepscale(tk, v, &repeat);
if (e == nil && repeat) {
tks->flag |= Autorepeat;
tkrepeat(tk, screpeat, v, TkRptpause, TkRptinterval);
}
}
tk->dirty = tkrect(tk, 1);
return e;
}
示例8: tkentrybbox
/*
* return bounding box of character at index, in coords relative to
* the top left position of the text.
*/
static Rectangle
tkentrybbox(Tk *tk, int index)
{
TkEntry *tke;
TkEnv *env;
Display *d;
int x, cw, locked;
Rectangle r;
tke = TKobj(TkEntry, tk);
env = tk->env;
d = env->top->display;
locked = lockdisplay(d);
x = entrytextwidth(tk, index);
if (index < tke->textlen)
cw = entrytextwidth(tk, index+1) - x;
else
cw = Inswidth;
if(locked)
unlockdisplay(d);
r.min.x = x;
r.min.y = 0;
r.max.x = x + cw;
r.max.y = env->font->height;
return r;
}
示例9: tkcvswindsize
static void
tkcvswindsize(TkCitem *i)
{
Tk *s;
int bw;
Point p;
TkGeom old;
TkCwind *w;
w = TKobj(TkCwind, i);
s = w->sub;
if(s == nil)
return;
if(w->width != s->act.width || w->height != s->act.height) {
old = s->act;
s->act.width = w->width;
s->act.height = w->height;
if(s->slave) {
tkpackqit(s);
tkrunpack(s->env->top);
}
tkdeliver(s, TkConfigure, &old);
}
p = tkcvsanchor(i->p.drawpt[0], s->act.width, s->act.height, w->flags);
s->act.x = p.x;
s->act.y = p.y;
bw = 2*s->borderwidth;
i->p.bb.min = p;
i->p.bb.max.x = p.x + s->act.width + bw;
i->p.bb.max.y = p.y + s->act.height + bw;
}
示例10: tkcvsitemconf
static char*
tkcvsitemconf(Tk *tk, char *arg, char **val)
{
char *e;
TkName *f;
TkCtag *t;
TkCitem *i;
TkCanvas *c;
char buf[Tkmaxitem];
USED(val);
arg = tkword(tk->env->top, arg, buf, buf+sizeof(buf), nil);
f = tkctaglook(tk, nil, buf);
if(f == nil || f->obj == nil)
return TkBadtg;
c = TKobj(TkCanvas, tk);
for(t = f->obj; t; t = t->taglist) {
for(i = c->head; i; i = i->next) {
if(i == t->item) {
tkbbmax(&c->update, &i->p.bb);
e = tkcimethod[i->type].conf(tk, i, arg);
tkbbmax(&c->update, &i->p.bb);
tkcvssetdirty(tk);
if(e != nil)
return e;
}
}
}
return nil;
}
示例11: tkcvssv
void
tkcvssv(Tk *tk)
{
TkCanvas *c;
int top, bot, height;
char val[Tkminitem], cmd[Tkmaxitem], *v, *e;
c = TKobj(TkCanvas, tk);
if(c->yscroll == nil)
return;
top = 0;
bot = TKI2F(1);
height = Dy(c->region);
if(height != 0) {
top = TKI2F(c->view.y)/height;
bot = TKI2F(c->view.y+tk->act.height)/height;
}
v = tkfprint(val, top);
*v++ = ' ';
tkfprint(v, bot);
snprint(cmd, sizeof(cmd), "%s %s", c->yscroll, val);
e = tkexec(tk->env->top, cmd, nil);
if ((e != nil) && (tk->name != nil))
print("tk: yscrollcommand \"%s\": %s\n", tk->name->name, e);
}
示例12: tkfreelabel
void
tkfreelabel(Tk *tk)
{
Image *i;
int locked;
Display *d;
TkLabel *tkl;
tkl = TKobj(TkLabel, tk);
if(tkl->text != nil)
free(tkl->text);
if(tkl->command != nil)
free(tkl->command);
if(tkl->value != nil)
free(tkl->value);
if(tkl->variable != nil) {
tkfreevar(tk->env->top, tkl->variable, tk->flag & Tkswept);
free(tkl->variable);
}
if(tkl->img != nil)
tkimgput(tkl->img);
i = tkl->bitmap;
if(i != nil) {
d = i->display;
locked = lockdisplay(d);
freeimage(i);
if(locked)
unlockdisplay(d);
}
if(tkl->menu != nil)
free(tkl->menu);
}
示例13: tkcvscanvx
static char*
tkcvscanvx(Tk *tk, char *arg, char **val)
{
int x, s;
TkCanvas *c;
Point p;
char buf[Tkmaxitem];
c = TKobj(TkCanvas, tk);
arg = tkword(tk->env->top, arg, buf, buf+sizeof(buf), nil);
if(buf[0] == '\0')
return TkBadvl;
p = tkposn(tk);
x = atoi(buf) + c->view.x - (p.x + tk->borderwidth);
if(*arg) {
tkword(tk->env->top, arg, buf, buf+sizeof(buf), nil);
s = atoi(buf);
if (s) {
if (x>=0)
x = ((x+s/2)/s)*s;
else
x = ((x-s/2)/s)*s;
}
}
return tkvalue(val, "%d", x);
}
示例14: tkcvslinesize
void
tkcvslinesize(TkCitem *i)
{
TkCline *l;
int j, w, as, shape[3], arrow;
l = TKobj(TkCline, i);
w = TKF2I(l->width);
i->p.bb = bbnil;
tkpolybound(i->p.drawpt, i->p.npoint, &i->p.bb);
l->arrowf = l->capstyle;
l->arrowl = l->capstyle;
if(l->arrow != 0) {
as = w/3;
if(as < 1)
as = 1;
for(j = 0; j < 3; j++) {
shape[j] = l->shape[j];
if(shape[j] == 0)
shape[j] = as * cvslshape[j];
}
arrow = ARROW(TKF2I(shape[0]), TKF2I(shape[1]), TKF2I(shape[2]));
if(l->arrow & TkCarrowf)
l->arrowf = arrow;
if(l->arrow & TkCarrowl)
l->arrowl = arrow;
w += shape[2];
}
i->p.bb = insetrect(i->p.bb, -w);
}
示例15: tkcvslinedraw
void
tkcvslinedraw(Image *img, TkCitem *i, TkEnv *pe)
{
int w;
Point *p;
TkCline *l;
Image *pen;
USED(pe);
l = TKobj(TkCline, i);
pen = l->pen;
if(pen == nil)
pen = tkgc(i->env, TkCforegnd);
w = TKF2I(l->width)/2;
if(w < 0)
return;
p = i->p.drawpt;
if(l->smooth == BoolT && i->p.npoint >= 3)
bezspline(img, p, i->p.npoint, l->arrowf, l->arrowl, w, pen, p[0]);
else
poly(img, p, i->p.npoint, l->arrowf, l->arrowl, w, pen, p[0]);
}