static int growcol_mouse(GGadget *g, GEvent *event) { GRowCol *grc = (GRowCol *) g; int pos; if ( !g->takes_input || (g->state!=gs_active && g->state!=gs_enabled && g->state!=gs_focused)) return( false ); if ( event->type == et_crossing ) return( false ); if ( event->type==et_mousemove && !grc->pressed && !grc->parentpressed ) { if ( GGadgetWithin(g,event->u.mouse.x,event->u.mouse.y) && g->popup_msg ) GGadgetPreparePopup(g->base,g->popup_msg); return( true ); } else if ( event->type==et_mouseup && grc->parentpressed && !GGadgetInnerWithin(&grc->g,event->u.mouse.x,event->u.mouse.y)) { grc->parentpressed = false; GDrawPointerUngrab(GDrawGetDisplayOfWindow(grc->g.base)); } else if ( event->type==et_mousemove && grc->parentpressed && GGadgetInnerWithin(&grc->g,event->u.mouse.x,event->u.mouse.y)) { if ( grc->pressed == NULL ) grc->pressed = GDrawRequestTimer(g->base,GRowColScrollTime,GRowColScrollTime,NULL); GDrawPointerUngrab(GDrawGetDisplayOfWindow(grc->g.base)); grc->parentpressed = false; growcol_scroll_selbymouse(grc,event); return( true ); } else if ( event->type==et_mousemove && grc->pressed ) { growcol_scroll_selbymouse(grc,event); return( true ); } else if ( event->type==et_mousedown ) { if ( grc->pressed == NULL ) grc->pressed = GDrawRequestTimer(g->base,GRowColScrollTime,GRowColScrollTime,NULL); pos = GRowColIndexFromPos(grc,event->u.mouse.y); if ( pos==-1 ) return( true ); /* Do Nothing, nothing selectable */ else if ( !grc->exactly_one && grc->ti[pos]->selected && (event->u.mouse.state&(ksm_control|ksm_shift))) { grc->ti[pos]->selected = false; } else if ( !grc->multiple_sel || !(event->u.mouse.state&(ksm_control|ksm_shift))) { GRowColClearSel(grc); grc->ti[pos]->selected = true; grc->start = grc->end = pos; } else if ( event->u.mouse.state&ksm_control ) { grc->ti[pos]->selected = !grc->ti[pos]->selected; grc->start = grc->end = pos; } else if ( event->u.mouse.state&ksm_shift ) { GRowColExpandSelection(grc,pos); } _ggadget_redraw(&grc->g); } else if ( event->type==et_mouseup && grc->pressed ) { GDrawCancelTimer(grc->pressed); grc->pressed = NULL; if ( GGadgetInnerWithin(&grc->g,event->u.mouse.x,event->u.mouse.y) ) { growcol_scroll_selbymouse(grc,event); if ( event->u.mouse.clicks==2 ) GRowColDoubleClick(grc); else GRowColSelected(grc); } } else return( false ); return( true ); }
static int glist_mouse(GGadget *g, GEvent *event) { GDList *gl = (GDList *) g; int pos; if ( !g->takes_input || (g->state!=gs_active && g->state!=gs_enabled && g->state!=gs_focused)) return( false ); if ( event->type == et_crossing ) return( false ); if (( event->type==et_mouseup || event->type==et_mousedown ) && (event->u.mouse.button>=4 && event->u.mouse.button<=7)) { if ( gl->vsb!=NULL ) return( GGadgetDispatchEvent(&gl->vsb->g,event)); else return( true ); } if ( event->type==et_mousemove && !gl->pressed && !gl->parentpressed ) { if ( GGadgetWithin(g,event->u.mouse.x,event->u.mouse.y) ) { if ( gl->popup_callback!=NULL ) (gl->popup_callback)(g,GListIndexFromPos(gl,event->u.mouse.y)); else if ( g->popup_msg ) GGadgetPreparePopup(g->base,g->popup_msg); } return( true ); } else if ( event->type==et_mouseup && gl->parentpressed /* && !GGadgetInnerWithin(&gl->g,event->u.mouse.x,event->u.mouse.y)*/ ) { gl->parentpressed = false; GDrawPointerUngrab(GDrawGetDisplayOfWindow(gl->g.base)); } else if ( event->type==et_mousemove && gl->parentpressed && GGadgetInnerWithin(&gl->g,event->u.mouse.x,event->u.mouse.y)) { if ( gl->pressed == NULL ) gl->pressed = GDrawRequestTimer(g->base,GListScrollTime,GListScrollTime,NULL); GDrawPointerUngrab(GDrawGetDisplayOfWindow(gl->g.base)); gl->parentpressed = false; glist_scroll_selbymouse(gl,event); return( true ); } else if ( event->type==et_mousemove && gl->pressed ) { glist_scroll_selbymouse(gl,event); return( true ); } else if ( event->type==et_mousedown ) { if ( gl->pressed == NULL ) gl->pressed = GDrawRequestTimer(g->base,GListScrollTime,GListScrollTime,NULL); pos = GListIndexFromPos(gl,event->u.mouse.y); if ( pos==-1 ) return( true ); /* Do Nothing, nothing selectable */ else if ( !gl->exactly_one && gl->ti[pos]->selected && (event->u.mouse.state&(ksm_control|ksm_shift))) { gl->ti[pos]->selected = false; gl->start = gl->end = 0xffff; } else if ( !gl->multiple_sel || (!gl->ti[pos]->selected && !(event->u.mouse.state&(ksm_control|ksm_shift)))) { GListClearSel(gl); gl->ti[pos]->selected = true; gl->start = gl->end = pos; } else if ( event->u.mouse.state&ksm_control || ((event->u.mouse.state&ksm_shift) && gl->ti[pos]->selected)) { gl->ti[pos]->selected = !gl->ti[pos]->selected; gl->start = gl->end = pos; } else if ( event->u.mouse.state&ksm_shift ) { GListExpandSelection(gl,pos); } else { gl->ti[pos]->selected = true; gl->start = gl->end = pos; } _ggadget_redraw(&gl->g); } else if ( event->type==et_mouseup && gl->pressed ) { GDrawCancelTimer(gl->pressed); gl->pressed = NULL; if ( GGadgetInnerWithin(&gl->g,event->u.mouse.x,event->u.mouse.y) ) { pos = GListIndexFromPos(gl,event->u.mouse.y); if ( !(event->u.mouse.state&(ksm_control|ksm_shift)) || gl->start!=0xffff ) glist_scroll_selbymouse(gl,event); if ( event->u.mouse.clicks==2 ) GListDoubleClick(gl,true,pos); else GListSelected(gl,true,pos); } } else return( false ); return( true ); }