g_error widget_derive(struct widget **w, handle *h, int type,struct widget *parent, handle hparent,int rship,int owner) { g_error e; DBG("type %d, rship %d, parent %p, owner %d\n",type,rship,parent,owner); /* Allow using this to detach widgets too. Makes sense, since this is called * by the attachwidget request handler. */ if (!parent) return widget_attach(*w, NULL, NULL, 0); switch (rship) { case PG_DERIVE_INSIDE: if (*w == NULL ) { e = widget_create(w,h, type, parent->dt, hparent, owner); errorcheck; } e = widget_attach(*w, parent->dt,parent->sub,hparent); break; case PG_DERIVE_AFTER: if ( *w == NULL ) { e = widget_create(w,h, type, parent->dt, parent->container, owner); errorcheck; } e = widget_attach(*w,parent->dt,parent->out,parent->container); break; case PG_DERIVE_BEFORE: case PG_DERIVE_BEFORE_OLD: if ( *w == NULL ) { e = widget_create(w,h, type, parent->dt, parent->container, owner); errorcheck; } e = widget_attach(*w,parent->dt,parent->where,parent->container); break; default: return mkerror(PG_ERRT_BADPARAM,22); } /* Error checking code common to all cases */ if (iserror(e)) { widget_remove(*w); errorcheck; } if ((*w)->def->post_attach) { e = (*w)->def->post_attach(*w,parent,rship); errorcheck; } return success; }
void widget_menu_release(widget *w) { widget_remove((widget*)w->data2); widget *wdata = (widget*)w->data2; if(!wdata)return; widget *x = wdata->child; if(!x)return; while(x) { if(mouse_x > x->parent->pos.x) if(mouse_x < x->parent->pos.x + x->parent->size.x) if(mouse_y > x->parent->pos.y + x->pos.y) if(mouse_y < x->parent->pos.y + x->pos.y + x->size.y) { if(x->action)x->action(x); return; } x = x->next; } }
void widget_window_onclick(widget *w) { widget_remove(w); widget_add(w); // send to foreground w->delta.x = mouse_x - w->pos.x; w->delta.y = mouse_y - w->pos.y; if(w->delta.y > 5) if(w->delta.y < 30) { if( w->delta.x > (w->size.x - 50) ) w->clicked=3; // end else w->clicked=2; // dragging return; } if(w->noResize)return; if(w->delta.y > w->size.y - 10) // dragging down { w->clicked = 4; // resize bottom if(w->delta.x < 10)w->clicked = 5; // resize bottom left if(w->delta.x > (w->size.x-10))w->clicked = 6; // resize bottom right return; } if(w->delta.x < 10) { w->clicked = 7; // resize left } if(w->delta.x > (w->size.x - 10)) { w->clicked = 8; // resize right } }
/* Free any object in a handlenode */ void object_free(struct handlenode *n) { #ifdef DEBUG_KEYS num_handles--; #endif #ifdef DEBUG_MEMORY printf("Enter object free of handle 0x%08X, type %d\n",n->id,n->type & PG_TYPEMASK); #endif if (!(n->type & HFLAG_NFREE)) { switch (n->type & PG_TYPEMASK) { case PG_TYPE_BITMAP: VID(bitmap_free) ((hwrbitmap)n->obj); break; case PG_TYPE_WIDGET: widget_remove((struct widget *)n->obj); break; case PG_TYPE_THEME: theme_remove((struct pgmemtheme *)n->obj); break; case PG_TYPE_DRIVER: unload_inlib((struct inlib *)n->obj); break; case PG_TYPE_WT: wt_free((struct pgmemwt *)n->obj); break; case PG_TYPE_INFILTER: infilter_delete((struct infilter *)n->obj); break; case PG_TYPE_CURSOR: cursor_delete((struct cursor *)n->obj); break; case PG_TYPE_PGSTRING: pgstring_delete((struct pgstring *)n->obj); break; case PG_TYPE_FONTDESC: font_descriptor_destroy((struct font_descriptor *)n->obj); break; /* Object types that are memory-managed independently of their handles */ case PG_TYPE_DIVTREE: case PG_TYPE_PARAGRAPH: break; default: g_free(n->obj); } } #ifdef DEBUG_MEMORY printf("Leave object free of handle 0x%08X, type %d\n",n->id,n->type & PG_TYPEMASK); #endif }