static status terminatePopupGesture(PopupGesture g, EventObj ev) { Any context = g->context; PopupObj current = g->current; if ( notNil(current) ) { postEvent(ev, (Graphical) current, DEFAULT); if ( current->displayed == OFF ) /* for stayup */ { PceWindow sw; if ( !(sw = getWindowGraphical(ev->receiver)) ) sw = ev->window; assign(g, context, NIL); assign(g, current, NIL); grabPointerWindow(sw, OFF); send(current, NAME_execute, context, EAV); focusWindow(sw, NIL, NIL, NIL, NIL); } } succeed; }
static status eventPopupGesture(PopupGesture g, EventObj ev) { if ( g->status == NAME_active && isUpEvent(ev) ) { PceWindow sw; if ( !(sw = getWindowGraphical(ev->receiver)) ) sw = ev->window; if ( notNil(g->current) && g->current->displayed == OFF ) { send(g->current, NAME_open, ev->receiver, getAreaPositionEvent(ev, DEFAULT), EAV); attributeObject(g, NAME_Stayup, ON); grabPointerWindow(sw, ON); focusWindow(sw, ev->receiver, (Recogniser) g, g->cursor, NIL); } else if ( valInt(getClickTimeEvent(ev)) < 400 && getAttributeObject(g, NAME_Stayup) != ON ) { attributeObject(g, NAME_Stayup, ON); grabPointerWindow(sw, ON); focusWindow(sw, ev->receiver, (Recogniser) g, g->cursor, NIL); } else { send(g, NAME_terminate, EAV); if ( isNil(g->current) ) { grabPointerWindow(sw, OFF); focusWindow(sw, NIL, NIL, NIL, NIL); deleteAttributeObject(g, NAME_Stayup); assign(g, status, NAME_inactive); } } succeed; } else if ( notNil(g->current) && g->current->displayed == ON ) return postEvent(ev, (Graphical) g->current, DEFAULT); if ( eventGesture(g, ev) ) succeed; if ( g->status == NAME_active && isAEvent(ev, NAME_keyboard) ) { Name key; TRY(updatePopupGesture(g, ev)); key = characterName(getIdEvent(ev)); if ( send(g->current, NAME_key, key, EAV) ) { Any context = g->context; PopupObj current = g->current; assign(g, context, NIL); assign(g, current, NIL); send(current, NAME_execute, context, EAV); succeed; } else send(g, NAME_cancel, ev, EAV); } fail; }
status RedrawAreaButton(Button b, Area a) { int x, y, w, h; int defb; int rm = 0; /* right-margin */ PceWindow sw; int kbf; /* Button has keyboard focus */ int obhf; /* Other button has focus */ int focus; int swapbg = FALSE; int up; int flags = 0; Elevation z; if ( b->look == NAME_winMenuBar || b->look == NAME_gtkMenuBar ) return RedrawMenuBarButton(b, a); if ( b->active == OFF ) flags |= LABEL_INACTIVE; up = (b->status == NAME_active || b->status == NAME_inactive); defb = (b->default_button == ON); initialiseDeviceGraphical(b, &x, &y, &w, &h); NormaliseArea(x, y, w, h); if ( (sw = getWindowGraphical((Graphical)b)) ) { kbf = (sw->keyboard_focus == (Graphical) b); obhf = (!kbf && instanceOfObject(sw->keyboard_focus, ClassButton)); focus = (sw->input_focus == ON); } else kbf = obhf = focus = FALSE; /* should not happen */ if ( !ws_draw_button_face((DialogItem)b, x, y, w, h, up, defb, kbf && focus) ) draw_generic_button_face(b, x, y, w, h, up, defb, kbf && focus); if ( b->look == NAME_openLook && b->status == NAME_preview && !((z = getClassVariableValueObject(b, NAME_elevation)) && notNil(z)) ) { swapbg = TRUE; r_swap_background_and_foreground(); } if ( notNil(b->popup) && !instanceOfObject(b->label, ClassImage) ) rm = draw_button_popup_indicator(b, x, y, w, h, up); RedrawLabelDialogItem(b, accelerator_code(b->accelerator), x, y, w-rm, h, NAME_center, NAME_center, flags); if ( swapbg ) r_swap_background_and_foreground(); return RedrawAreaGraphical(b, a); }
static status terminateEditTextGesture(EditTextGesture g, EventObj ev) { TextObj t = ev->receiver; if ( instanceOfObject(t, ClassText) && notNil(t->selection) ) send(t, NAME_copy, EAV); if ( g->activate == ON ) { PceWindow sw = getWindowGraphical((Graphical)t); if ( sw ) send(sw, NAME_keyboardFocus, t, EAV); } succeed; }
static void draw_generic_button_face(Button b, int x, int y, int w, int h, int up, int defb, int focus) { Elevation z = getClassVariableValueObject(b, NAME_elevation); int r = valInt(b->radius); if ( z && notNil(z) ) /* 3-d style */ { int up = (b->status == NAME_inactive || b->status == NAME_active); if ( b->look == NAME_motif || b->look == NAME_gtk || b->look == NAME_win ) { int bx = x, by = y, bw = w, bh = h; if ( b->look == NAME_motif || b->look == NAME_gtk ) { if ( b->show_focus_border == ON ) { PceWindow sw = getWindowGraphical((Graphical)b); Graphical kbfocus = (sw ? sw->keyboard_focus : NIL); if ( focus || kbfocus == (Graphical) b || /* inactive focus */ (defb && !instanceOfObject(kbfocus, ClassButton)) ) { static Elevation e = NULL; if ( !e ) e = newObject(ClassElevation, ONE, EAV); bx -= GTK_BUTTON_MARGIN; by -= GTK_BUTTON_MARGIN; bw += GTK_BUTTON_MARGIN * 2; bh += GTK_BUTTON_MARGIN * 2; r_3d_box(bx, by, bw, bh, r, e, FALSE); } } if ( focus ) { int pen = valInt(b->pen); if ( pen > 0 ) { r_thickness(pen); r_box(x-pen, y-pen, w+2*pen, h+2*pen, r, NIL); } } } else { if ( defb ) { int pen = valInt(b->pen); bx -= pen; by -= pen; bw += 2*pen; bh += 2*pen; r_thickness(pen); r_box(bx, by, bw, bh, r, NIL); } } } r_3d_box(x, y, w, h, r, z, up); if ( b->look == NAME_openLook && defb ) { Any old; old = r_colour(r_elevation_shadow(z)); r_box(x+2, y+2, w-4, h-4, r, NIL); r_colour(old); } } else /* 2-d style */ { int swapc = 0; int pen = valInt(b->pen); int radius = valInt(b->radius); int shadow = valInt(b->shadow); if ( defb && b->look != NAME_openLook ) pen++; r_thickness(pen); r_dash(b->texture); if ( up ) { r_shadow_box(x, y, w, h, radius, shadow, NIL); } else if ( b->status == NAME_preview ) { r_shadow_box(x, y, w, h, radius, shadow, BLACK_IMAGE); swapc = TRUE; } else if ( b->status == NAME_execute ) { r_shadow_box(x, y, w, h, radius, shadow, GREY25_IMAGE); } if ( swapc ) r_swap_background_and_foreground(); if ( defb && b->look == NAME_openLook ) r_box(x+pen, y+pen, w-2*pen-shadow, h-2*pen-shadow, radius, NIL); if ( swapc ) r_swap_background_and_foreground(); } }