static status computeSlider(Slider s) { if ( notNil(s->request_compute) ) { int ny, vx, vy, lx, ly, sx, sy, hx, hy; int w, h; int sw, sh; obtainClassVariablesObject(s); compute_slider(s, &ny, &vx, &vy, &lx, &ly, &sx, &sy, &hx, &hy); h = SLIDER_HEIGHT; h = max(h, ly+valInt(getHeightFont(s->label_font))); h = max(h, vy+valInt(getHeightFont(s->value_font))); if ( s->show_value == ON ) { char buf[100]; string str; sprintf(buf, INTPTR_FORMAT, valInt(s->high)); str_set_ascii(&str, buf); str_size(&str, s->value_font, &sw, &sh); w = hx + sw; } else w = hx; CHANGING_GRAPHICAL(s, assign(s->area, w, toInt(w)); assign(s->area, h, toInt(h))); assign(s, request_compute, NIL); }
static status initialiseElevation(Elevation e, Any name, Int height, Any colour, Any relief, Any shadow, Name kind, Any bg) { if ( isDefault(name) ) name = NIL; assign(e, name, name); assign(e, background, bg); if ( isDefault(height) && isInteger(name) ) height = name; if ( notDefault(colour) ) assign(e, colour, colour); if ( notDefault(relief) ) assign(e, relief, relief); if ( notDefault(shadow) ) assign(e, shadow, shadow); if ( notDefault(kind) ) assign(e, kind, kind); if ( notDefault(height) ) assign(e, height, height); obtainClassVariablesObject(e); if ( notNil(name) ) appendHashTable(ElevationTable, name, e); succeed; }
static status initialiseLBox(LBox lb, Int w) { if ( isDefault(w) ) w = getClassVariableValueObject(lb, NAME_width); obtainClassVariablesObject(lb); initialiseDevice((Device)lb); assign(lb->area, w, w); succeed; }
static status initialiseMoveOutlineGesture(MoveOutlineGesture g, Name button, Modifier modifier) { initialiseMoveGesture((MoveGesture) g, button, modifier); obtainClassVariablesObject(g); assign(g, outline, newObject(ClassBox, EAV)); send(g->outline, NAME_texture, getClassVariableValueObject(g, NAME_texture), EAV); send(g->outline, NAME_recogniser, newObject(ClassMoveGesture, g->button, g->modifier, EAV), EAV); succeed; }
status initialiseGesture(Gesture g, Name button, Modifier modifier) { if ( notDefault(button) ) assign(g, button, button); if ( notDefault(modifier) ) assign(g, modifier, modifier); assign(g, active, ON); assign(g, status, NAME_inactive); assign(g, cursor, DEFAULT); return obtainClassVariablesObject(g); }
static status computeText(TextObj t) { if ( notNil(t->request_compute) ) { obtainClassVariablesObject(t); CHANGING_GRAPHICAL(t, if ( t->request_compute == NAME_position ) initPositionText(t); else if ( t->request_compute == NAME_area ) initAreaText(t); changedEntireImageGraphical(t)); assign(t, request_compute, NIL); }
static void compute_label_slider(Slider s, int *lw, int *lh) { if ( s->show_label == ON ) { if ( isDefault(s->label_font) ) obtainClassVariablesObject(s); dia_label_size(s, lw, lh, NULL); *lw += valInt(getExFont(s->label_font)); if ( notDefault(s->label_width) ) *lw = max(valInt(s->label_width), *lw); } else { *lw = *lh = 0; } }
static status initialiseTable(Table tab) { initialiseLayoutManager(tab); assign(tab, rows, newObject(ClassVector, EAV)); assign(tab, columns, newObject(ClassVector, EAV)); assign(tab, current, newObject(ClassPoint, ONE, ONE, EAV)); assign(tab, area, newObject(ClassArea, EAV)); assign(tab, changed, OFF); assign(tab, width, DEFAULT); obtainClassVariablesObject(tab); succeed; }
static status computeLabel(Label lb) { if ( notNil(lb->request_compute) ) { int w, h, b; TRY(obtainClassVariablesObject(lb)); b = valInt(lb->border); if ( notNil(lb->elevation) ) b += abs(valInt(lb->elevation->height)); if ( instanceOfObject(lb->selection, ClassCharArray) ) { String s = &((CharArray)lb->selection)->data; int minw; int ex = valInt(getExFont(lb->font)); if ( lb->wrap == NAME_clip ) { LocalString(buf, s->iswide, s->size+1); str_one_line(buf, s); s = buf; } str_size(s, lb->font, &w, &h); w += ex; if ( notDefault(lb->width) ) minw = valInt(lb->width) - 2*b; else minw = (valInt(lb->length)+1) * ex; w = max(w, minw); } else /*if ( instanceOfObject(lb->selection, ClassImage) )*/ { Image image = (Image) lb->selection; w = valInt(image->size->w); h = valInt(image->size->h); } w += 2*b; h += 2*b; CHANGING_GRAPHICAL(lb, assign(lb->area, w, toInt(w)); assign(lb->area, h, toInt(h)); changedEntireImageGraphical(lb)); assign(lb, request_compute, NIL); }
static status computeButton(Button b) { if ( notNil(b->request_compute) ) { int w, h, isimage; TRY(obtainClassVariablesObject(b)); dia_label_size(b, &w, &h, &isimage); if ( b->look == NAME_winMenuBar || b->look == NAME_gtkMenuBar ) { if ( !isimage ) { w += valInt(getExFont(b->label_font)) * 2; if ( b->look == NAME_gtkMenuBar ) h += 4; } else { w += 4; h += 4; } } else { if ( isimage ) { w += 4; h += 4; } else { Size size = getClassVariableValueObject(b, NAME_size); h += 6; w += 10 + valInt(b->radius); if ( notNil(b->popup) ) { if ( notNil(b->popup->popup_image) ) w += valInt(b->popup->popup_image->size->w) + 5; else if ( b->look == NAME_motif || b->look == NAME_gtk ) w += 12 + 5; else w += 9 + 5; } w = max(valInt(size->w), w); h = max(valInt(size->h), h); } } CHANGING_GRAPHICAL(b, assign(b->area, w, toInt(w)); assign(b->area, h, toInt(h))); assign(b, request_compute, NIL); }
static status rangeIntItem(IntItem ii, Int low, Int high) { char buf[48]; Type t = NULL; char s1[24], s2[24]; int b = valInt(getClassVariableValueObject(ii, NAME_border)); obtainClassVariablesObject(ii); if ( isDefault(low) ) { if ( isDefault(high) ) { t = TypeInt; sprintf(s1, INTPTR_FORMAT, PCE_MIN_INT); sprintf(s2, INTPTR_FORMAT, PCE_MAX_INT); } else { sprintf(s1, INTPTR_FORMAT, PCE_MIN_INT); sprintf(s2, INTPTR_FORMAT, valInt(high)); sprintf(buf, ".." INTPTR_FORMAT, valInt(high)); } } else { if ( isDefault(high) ) { sprintf(s1, INTPTR_FORMAT, valInt(low)); sprintf(s2, INTPTR_FORMAT, PCE_MAX_INT); sprintf(buf, INTPTR_FORMAT "..", valInt(low)); } else { sprintf(s1, INTPTR_FORMAT, valInt(low)); sprintf(s2, INTPTR_FORMAT, valInt(high)); sprintf(buf, INTPTR_FORMAT ".." INTPTR_FORMAT, valInt(low), valInt(high)); } } if ( !t ) t = checkType(CtoName(buf), TypeType, NIL); assign(ii, type, t); assign(ii, hor_stretch, ZERO); valueWidthTextItem((TextItem)ii, toInt(max(width_text(ii->value_font, s1), width_text(ii->value_font, s2)) + 2*b + 5 + + text_item_combo_width((TextItem)ii))); succeed; }