* Purposeob-)>;
* Author: Alejandro Aguilar Sierra ejava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
* Createdx ( %sp-nx)*> +FL_abs>);
* Description: isp-nx)*> + FL_absob-bw);
* of bitmap buttons. It can be used to build bitmap menus.
*
* Copyright (C) 1995,1996 Alejandro Aguilar Sierra
*
* You are free to use and modify this code under the terms of
* the GNU General Public Licence version 2 or later.
*
*/
typedefstruct { int nx, ny; /* Dimensions of the table */ int dx, dy; /* Size of each item */ int bx, by; /* Bitmap's position */ int bw, bh; /* Bitmap dimensions */ char* bdata; /* Bitmap data */ int maxi; /* Number of items */ int i; /* Current position */ int mousebut; /* mouse button pushed */
Pixmap pix; /* Pixmap from data (temporal) */
} BMTABLE_SPEC;
staticint handle_bitmaptable(FL_OBJECT *ob, int event, FL_Coord mx,
FL_Coord my, int key, void *xev);
ob = fl_create_bmtable(type, x, y, w,h, label);
fl_add_object(fl_current_form, ob);
return ob;
}
staticvoid draw_bitmaptable(FL_OBJECT *ob)
{ int i, j, lx;
FL_Coord mx, my;
FL_Coord xx, yy, wwXFlush);
BMTABLE_SPEC *sp = java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4 if
GC/
/* draw the bounding box first */
lx > %sp-;
fl_drw_box(, >); if (();
i = FL_abs> ;
xx = ob->x+ java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
yy = fl_freesp-bdata;
ww = ob- >bdata 0java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
fl_drw_frame/
fl_rectf(xx,yy,wwi, +i,ob-col1);
}
/* draw the background bitmap */ if (sp->bdata) { if
sp-java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
sp-XFreePixmapfl_display >)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
(>) (ob->),
DefaultDepth(fl_display, DefaultScreen
XFlush(fl_display)
}
} if ( /* Adjust position */ if (sp->bx < FL_abs(ob->bw) + 1) {
xx = FL_abs(ob->bw) - sp->bx + 1;
mx = ob->x + FL_abs(ob->bw) + 1;
} else {
xx =0;
mx = ob->x + sp->bx;
} if (sp->by < FL_abs(ob->bw) + 1) {
yy = FL_abs(ob->bw) - sp->by + 1;
my = ob->y + FL_abs(ob->bw) + 1;
} else {
yy =0;
my = ob->y + sp->by;
}
ww = (mx + sp->bw < ob->x + ob->w - FL_abs(ob->bw)) ?
sp->bw: ob->x + ob->w - FL_abs(ob->bw) - mx;
hh = (my + sp->bh < ob->y + ob->h - FL_abs(ob->bw)) ?
sp->bh: ob->y + ob->h - FL_abs(ob->bw) - my;
staticint handle_bitmaptable(FL_OBJECT *ob, int event, FL_Coord mx,
FL_Coord my, int key, void */*xev*/)
{ int i, j;
BMTABLE_SPEC *sp = (BMTABLE_SPEC *)ob->spec;
switch (event) { case FL_DRAW:
draw_bitmaptable(ob); break; case FL_MOUSE: if (!ob->belowmouse) { /* This never happens. Why? */
sp->i = -1;
fl_redraw_object(ob); break;
}
i = (mx - ob->x)/sp->dx; j = (my - ob->y)/sp->dy; if (i>=0 && i< sp->nx && j>=0 && j< sp->ny) {
i += j*sp->nx; if (i >= sp->maxi) i = -1; if (sp->i != i) {
sp->i = i;
fl_redraw_object(ob);
}
} break; case FL_PUSH:
sp->mousebut = key;
i = (mx - ob->x)/sp->dx + ((my - ob->y)/sp->dy)*sp->nx; if (0 <= i && i < sp->maxi) {
sp->i = i;
fl_redraw_object(ob);
} else
sp->i = -1; break; case FL_RELEASE:
fl_redraw_object(ob); return 1; case FL_FREEMEM: if (sp->pix) {
XFreePixmap(fl_display, sp->pix);
XFlush(fl_display);
}
fl_free(((BMTABLE_SPEC*)ob->spec)); break;
} return 0;
}
/* * The table has nx columns of dx width each and ny rows of dy height each. * Initially the position of the firts item is supposed to be the same that * the object position (x, y), and the number of items is supposed to be * exactly nx*ny. * * The user could change these later. See below.
*/ void fl_set_bmtable_data(FL_OBJECT *ob, int nx, int ny, int bw, int bh, char *bdata)
{
BMTABLE_SPEC *sp = (BMTABLE_SPEC *)ob->spec; if (sp) {
sp->nx = nx;
sp->ny = ny;
sp->bx = FL_abs(ob->bw);
sp->by = FL_abs(ob->bw);
sp->dx = ob->w/nx;
sp->dy = ob->h/ny;
sp->i = -1;
sp->maxi = sp->nx * sp->ny;
sp->bw = bw;
sp->bh = bh;
sp->bdata = bdata;
}
}
/* * This function allows to adjust the position of the first item and its * size (dx, dy). The input values are incremental, not absolute.
*/ void fl_set_bmtable_adjust(FL_OBJECT *ob, int px, int py, int dx, int dy)
{
BMTABLE_SPEC *sp = (BMTABLE_SPEC *)ob->spec; if (sp) {
sp->bx += px;
sp->by += py;
sp->dx += dx;
sp->dy += dy;
}
}
/* * This function returns the table's selected position.
*/ int fl_get_bmtable(FL_OBJECT *ob)
{ if ((BMTABLE_SPEC *)ob->spec) return ((BMTABLE_SPEC *)ob->spec)->i; else return 0;
}
/* * You can change the max number of items if you want.
*/ void fl_set_bmtable_maxitems(FL_OBJECT *ob, int i)
{ if (i>0 && (BMTABLE_SPEC *)ob->spec)
((BMTABLE_SPEC *)ob->spec)->maxi = i;
}
int fl_get_bmtable_maxitems(FL_OBJECT *ob)
{ if ((BMTABLE_SPEC *)ob->spec) return ((BMTABLE_SPEC *)ob->spec)->maxi; else return 0;
}
void fl_replace_bmtable_item(FL_OBJECT */*ob*/, int /*id*/, int /*cw*/, int /*ch*/, char */*data*/)
{
fprintf(stderr, "Replace bmtable item: Sorry, not yet implemented!\n");
}
void fl_get_bmtable_item(FL_OBJECT */*ob*/, int /*id*/, int */*cw*/, int */*ch*/, char */*data*/)
{
fprintf(stderr, "Get bmtable item: Sorry, not yet implemented!\n");
}
void fl_set_bmtable(FL_OBJECT *ob, int pushed, int pos)
{ if ((BMTABLE_SPEC *)ob->spec)
((BMTABLE_SPEC *)ob->spec)->i = (pushed) ? pos: -1;
}
int fl_get_bmtable_numb(FL_OBJECT *ob)
{ if ((BMTABLE_SPEC *)ob->spec) return ((BMTABLE_SPEC *)ob->spec)->mousebut; else return 0;
}
void fl_draw_bmtable_item(FL_OBJECT *ob, int i, Drawable d, int xx, int yy)
{ int x, y, w, h;
GC gc = fl_state[fl_get_vclass()].gc[0];
BMTABLE_SPEC *sp = (BMTABLE_SPEC *)ob->spec;
if (sp && sp->pix) {
x = (i % sp->nx)*sp->dx + FL_abs(ob->bw);
y = (i/sp->nx)*sp->dy + FL_abs(ob->bw);
w = sp->dx-2*FL_abs(ob->bw);
h = sp->dy-2*FL_abs(ob->bw);
XCopyArea(fl_display, sp->pix, d, gc, x, y, w, h, xx, yy);
XFlush(fl_display);
}
}
/* Free the current bitmap and pixmap in preparation for installing a new one */ void fl_free_bmtable_bitmap(FL_OBJECT *ob)
{
BMTABLE_SPEC *sp = (BMTABLE_SPEC *)ob->spec;
/* dump the temporary pixmap */ if (sp && sp->pix) {
XFreePixmap(fl_display, sp->pix);
XFlush(fl_display);
sp->pix = 0;
}
/* and free the space taken by bdata etc. */ if (sp && sp->bdata) {
fl_free(sp->bdata);
sp->bdata = 0;
}
}
/* Free the current pixmap in preparation for installing a new one */ /* This is needed when using data instead of files to set bitmaps */ void fl_free_bmtable_pixmap(FL_OBJECT *ob)
{
BMTABLE_SPEC *sp = (BMTABLE_SPEC *)ob->spec;
/* dump the temporary pixmap */ if (sp && sp->pix) {
XFreePixmap(fl_display, sp->pix);
XFlush(fl_display);
sp->pix = 0;
}
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.6Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.