示例#1
0
static void GRadioChanged(GRadio *gr) {
    GEvent e;

    if ( gr->isradio && gr->ison )
return;		/* Do Nothing, it's already on */
    else if ( gr->isradio ) {
	GRadio *other;
	for ( other=gr->post; other!=gr; other = other->post ) {
	    if ( other->ison ) {
		other->ison = false;
		_ggadget_redraw((GGadget *) other);
	    }
	}
    } else
	/* Checkboxes just default down */;
    gr->ison = !gr->ison;
    e.type = et_controlevent;
    e.w = gr->g.base;
    e.u.control.subtype = et_radiochanged;
    e.u.control.g = &gr->g;
    if ( gr->g.handle_controlevent != NULL )
	(gr->g.handle_controlevent)(&gr->g,&e);
    else
	GDrawPostEvent(&e);
}
示例#2
0
static void GScrollBarChanged(GScrollBar *gsb, enum sb sbtype, int32 pos) {
    GEvent e;
    int active_len;

    if ( gsb->g.vert ) {
	active_len = gsb->g.inner.height;
    } else {
	active_len = gsb->g.inner.width;
    }
    if ( active_len<=0 )
	active_len = 1;

    e.type = et_controlevent;
    e.w = gsb->g.base;
    e.u.control.subtype = et_scrollbarchange;
    e.u.control.g = &gsb->g;
    e.u.control.u.sb.type = sbtype;
    e.u.control.u.sb.pos = (pos-gsb->thumboff)*(gsb->sb_max-gsb->sb_min)/active_len +
	    gsb->sb_min;
    if ( e.u.control.u.sb.pos > gsb->sb_max-gsb->sb_mustshow )
	e.u.control.u.sb.pos = gsb->sb_max-gsb->sb_mustshow;
    if ( e.u.control.u.sb.pos < gsb->sb_min )
	e.u.control.u.sb.pos = gsb->sb_min;

    if ( gsb->g.handle_controlevent!=NULL )
	(gsb->g.handle_controlevent)(&gsb->g,&e);
    else
	GDrawPostEvent(&e);
}
示例#3
0
static void GListClose(GDList *l) {
    GEvent e;

    e.type = et_close;
    e.w = l->g.base;
    if ( l->g.handle_controlevent != NULL )
	(l->g.handle_controlevent)(&l->g,&e);
    else
	GDrawPostEvent(&e);
}
static void GRowColDoubleClick(GRowCol *l) {
    GEvent e;

    e.type = et_controlevent;
    e.w = l->g.base;
    e.u.control.subtype = et_listdoubleclick;
    e.u.control.g = &l->g;
    if ( l->g.handle_controlevent != NULL )
	(l->g.handle_controlevent)(&l->g,&e);
    else
	GDrawPostEvent(&e);
}
示例#5
0
static void GTabSetChanged(GTabSet *gts,int oldsel) {
    GEvent e;

    e.type = et_controlevent;
    e.w = gts->g.base;
    e.u.control.subtype = et_radiochanged;
    e.u.control.g = &gts->g;
    if ( gts->g.handle_controlevent != NULL )
	(gts->g.handle_controlevent)(&gts->g,&e);
    else
	GDrawPostEvent(&e);
}
static void GRowColSelected(GRowCol *l) {
    GEvent e;

    e.type = et_controlevent;
    e.w = l->g.base;
    e.u.control.subtype = et_listselected;
    e.u.control.g = &l->g;
    e.u.control.u.list.from_mouse = false;
    if ( l->g.handle_controlevent != NULL )
	(l->g.handle_controlevent)(&l->g,&e);
    else
	GDrawPostEvent(&e);
}
示例#7
0
static void GListDoubleClick(GDList *l,int frommouse,int index) {
    GEvent e;

    e.type = et_controlevent;
    e.w = l->g.base;
    e.u.control.subtype = et_listdoubleclick;
    e.u.control.g = &l->g;
    e.u.control.u.list.from_mouse = frommouse;
    e.u.control.u.list.changed_index = index;
    if ( l->g.handle_controlevent != NULL )
	(l->g.handle_controlevent)(&l->g,&e);
    else
	GDrawPostEvent(&e);
}
示例#8
0
static int _GWidget_TopLevel_Key(GWindow top, GWindow ew, GEvent *event) {
    GTopLevelD *topd = (GTopLevelD *) (top->widget_data);
    int handled=0;
    GEvent sub;

    if ( !top->is_popup )
	last_input_window = top;

    /* If the palette has the focus, and it usually will under kde, then */
    /*  give the event to the main window if the cursor is outside of the palette */
    if ( topd->ispalette ) {
	if ( event->u.chr.x<-2 || event->u.chr.x>top->pos.width+2 ||
		event->u.chr.y<-2 || event->u.chr.y>top->pos.height+2 ) {
	    GPoint p;
	    topd = topd->owner;
	    p.x = event->u.chr.x; p.y = event->u.chr.y;
	    GDrawTranslateCoordinates(ew,topd->w,&p);
	    event->u.chr.x = p.x; event->u.chr.y = p.y;
	    ew = top = topd->w;
	    event->w = top;
	}
    }
    /* Check for mnemonics and shortcuts */
    if ( event->type == et_char && !GKeysymIsModifier(event->u.chr.keysym) ) {
	handled = GMenuPopupCheckKey(event);
	if ( topd->ispalette ) {
	    if ( !(handled = GMenuBarCheckKey(top,topd->owner->gmenubar,event)) )
		handled = GWidgetCheckMn((GContainerD *) topd->owner,event);
	}
	if ( !handled )
	    if ( !(handled = GMenuBarCheckKey(top,topd->gmenubar,event)) )
		handled = GWidgetCheckMn((GContainerD *) topd,event);
    }
    if ( handled )
	/* No op */;
    else if ( topd->popupowner!=NULL ) {
	/* When we've got an active popup (menu, list, etc.) all key events */
	/*  go to the popups owner (which, presumably sends them to the popup)*/
	if ( topd->popupowner->funcs->handle_key !=NULL )
	    handled = (topd->popupowner->funcs->handle_key)(topd->popupowner,event);
    } else if ( topd->gfocus!=NULL && topd->gfocus->funcs->handle_key )
	handled = (topd->gfocus->funcs->handle_key)(topd->gfocus,event);
    else if ( topd->wfocus!=NULL ) {
	if ( topd->wfocus->widget_data==NULL ) {
	    if ( topd->wfocus->eh!=NULL )
		handled = (topd->wfocus->eh)(topd->wfocus,event);
	} else if ( topd->wfocus->widget_data->e_h!=NULL )
	    handled = (topd->wfocus->widget_data->e_h)(topd->wfocus,event);
    }
    if ( !handled ) {
	if ( ew->widget_data==NULL ) {
	    if ( ew->eh!=NULL )
		handled = (ew->eh)(ew,event);
	} else if ( ew->widget_data->e_h!=NULL )
	    handled = (ew->widget_data->e_h)(ew,event);
    }

    if ( event->type==et_charup )
return( handled );
    /* If no one wanted it then try keyboard navigation */
    /* Tab or back tab cycles the focus through our widgets/gadgets */
    if ( !handled && (event->u.chr.keysym==GK_Tab || event->u.chr.keysym==GK_BackTab )) {
	if ( event->u.chr.keysym==GK_BackTab || (event->u.chr.state&ksm_shift) )
	    GWidgetPrevFocus(ew);
	else
	    GWidgetNextFocus(ew);
	handled = true;
    }
    /* Return activates the default button (if there is one) */
    else if ( !handled && (event->u.chr.keysym==GK_Return || event->u.chr.keysym==GK_KP_Enter) &&
	    topd->gdef!=NULL ) {
	sub.type = et_controlevent;
	sub.w = topd->gdef->base;
	sub.u.control.subtype = et_buttonactivate;
	sub.u.control.g = topd->gdef;
	sub.u.control.u.button.clicks = 0;
	if ( topd->gdef->handle_controlevent != NULL )
	    (topd->gdef->handle_controlevent)(topd->gdef,&sub);
	else
	    GDrawPostEvent(&sub);
    }
    /* Escape activates the cancel button (if there is one) */
    /*  (On the mac, Command-. has that meaning) */
    else if ( !handled && topd->gcancel!=NULL &&
	    (event->u.chr.keysym==GK_Escape ||
	     ((GMenuMask()&ksm_cmdmacosx) &&
	      (event->u.chr.state&GMenuMask())==ksm_cmdmacosx &&
	      event->u.chr.keysym=='.'))) {
	sub.type = et_controlevent;
	sub.w = topd->gcancel->base;
	sub.u.control.subtype = et_buttonactivate;
	sub.u.control.g = topd->gcancel;
	sub.u.control.u.button.clicks = 0;
	if ( topd->gcancel->handle_controlevent != NULL )
	    (topd->gcancel->handle_controlevent)(topd->gcancel,&sub);
	else
	    GDrawPostEvent(&sub);
    }
return( handled );
}