Пример #1
0
Any
RedrawBoxFigure(Figure f, Area area)
{ Any rval = NIL;

  if ( f->pen != ZERO || notNil(f->background) || notNil(f->elevation) )
  { int x, y, w, h;

    initialiseDeviceGraphical(f, &x, &y, &w, &h);
    if ( f->pen == ZERO && f->radius == ZERO && isNil(f->elevation) )
    { r_fill(x, y, w, h, f->background);
      rval = f->background;
    } else
    { r_thickness(valInt(f->pen));
      r_dash(f->texture);

      if ( notNil(f->elevation) )
      { r_3d_box(x, y, w, h, valInt(f->radius), f->elevation, TRUE);
	rval = f->elevation->background;
      } else
      { r_box(x, y, w, h, valInt(f->radius), f->background);
	rval = f->background;
      }
    }
  }

  return rval;
}
Пример #2
0
static status
RedrawAreaTextMargin(TextMargin m, Area a)
{ int x, y, w, h;
  Elevation z = getClassVariableValueObject(m, NAME_elevation);
  Any obg;

  initialiseDeviceGraphical(m, &x, &y, &w, &h);

  margin_x = x;
  margin_y = y;

  obg = r_background(m->background);
  r_clear(x, y, w, h);
  if ( z && notNil(z) )
    r_3d_box(x, y, w, h, 0, z, FALSE);
  else
  { r_thickness(valInt(m->pen));
    r_dash(m->texture);
    r_box(x, y, w, h, 0, NIL);
  }

  scan_fragment_icons(m, paint_fragment, NAME_forSome, NIL);
  RedrawAreaGraphical(m, a);
  r_background(obg);

  succeed;
}
Пример #3
0
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);
}
Пример #4
0
static status
RedrawAreaCircle(Circle c, Area a)
{ int x, y, w, h;

  initialiseDeviceGraphical(c, &x, &y, &w, &h);
  NormaliseArea(x, y, w, h);
  r_thickness(valInt(c->pen));
  r_dash(c->texture);
  r_ellipse(x, y, w, h, c->fill_pattern);

  return RedrawAreaGraphical(c, a);
}
Пример #5
0
static status
RedrawAreaLabel(Label lb, Area a)
{ int x, y, w, h;
  Elevation z = lb->elevation;
  int preview = (lb->status == NAME_preview && notNil(lb->message));

  initialiseDeviceGraphical(lb, &x, &y, &w, &h);

  if ( notNil(z) )
    r_3d_box(x, y, w, h, 0, z, !preview);

  x += valInt(lb->border);
  y += valInt(lb->border);
  w -= 2*valInt(lb->border);
  h -= 2*valInt(lb->border);

  if ( lb->wrap == NAME_clip )
    d_clip(x, y, w, h);

  if ( instanceOfObject(lb->selection, ClassCharArray) )
  { String s = &((CharArray)lb->selection)->data;

    if ( notNil(z) )
      x += valInt(getExFont(lb->font))/2;

    if ( lb->wrap == NAME_clip )
    { LocalString(buf, s->iswide, s->size+1);

      str_one_line(buf, s);
      s = buf;
    }
    str_label(s, 0, lb->font, x, y, w, h, NAME_left, NAME_top,
	      lb->active == ON ? 0 : LABEL_INACTIVE);
  } else /*if ( instanceOfObject(lb->selection, ClassImage) )*/
  { Image image = (Image) lb->selection;

    r_image(image, 0, 0, x, y, w, h, ON);
  }

  if ( lb->wrap == NAME_clip )
    d_clip_done();

  if ( preview && isNil(z) )
    r_complement(x, y, w, h);

  return RedrawAreaGraphical(lb, a);
}
Пример #6
0
static status
RedrawMenuBarButton(Button b, Area a)
{ int x, y, w, h;
  Any ofg = NIL;
  int flags = 0;

  initialiseDeviceGraphical(b, &x, &y, &w, &h);
  NormaliseArea(x, y, w, h);

  if ( b->status == NAME_preview )
  { Elevation e;

    if ( b->look == NAME_gtkMenuBar &&
	 (e = getClassVariableValueObject(b, NAME_previewElevation)) &&
	 notNil(e) )
    { r_3d_box(x, y, w, h, 0, e, TRUE);
    } else /* if ( b->look == NAME_winMenuBar ) */
    { Any fg = getClassVariableValueObject(b, NAME_selectedForeground);
      Any bg = getClassVariableValueObject(b, NAME_selectedBackground);

      if ( !fg ) fg = WHITE_COLOUR;
      if ( !bg ) bg = BLACK_COLOUR;
      r_fill(x, y, w, h, bg);
      ofg = r_colour(fg);
    }
  }

  if ( b->active == OFF )
    flags |= LABEL_INACTIVE;

  RedrawLabelDialogItem(b, accelerator_code(b->accelerator),
			x, y, w, h,
			NAME_center, NAME_center, flags);

  if ( notNil(ofg) )
    r_colour(ofg);

  succeed;
}
Пример #7
0
static status
RedrawAreaTextItem(TextItem ti, Area a)
{ int x, y, w, h;
  int al, av, am;
  int lw, lh;
  int fw = valInt(getExFont(ti->value_text->font));
  Elevation z = getClassVariableValueObject(ti, NAME_elevation);
  int tx, ty, tw, th;
  TextObj vt = ti->value_text;
  int flags = 0;

  initialiseDeviceGraphical(ti, &x, &y, &w, &h);

  al = valInt(getAscentFont(ti->label_font));
  av = valInt(getAscentFont(vt->font)) + valInt(vt->border);
  am = max(al, av);

  compute_label_text_item(ti, &lw, &lh);
  if ( ti->show_label == ON )
  { RedrawLabelDialogItem(ti,
			  accelerator_code(ti->accelerator),
			  x, y+am-al, lw-fw, h,
			  ti->label_format, NAME_top,
			  ti->active == ON ? 0 : LABEL_INACTIVE);
  }

  tx = x+lw;
  ty = y+am-av;
  tw = valInt(vt->area->w);
  th = valInt(vt->area->h);

  if ( ti->editable == ON && ti->active == ON )
    flags |= TEXTFIELD_EDITABLE;
  flags |= combo_flags(ti);

  if ( !ws_entry_field(tx, ty, tw+text_item_combo_width(ti), th, flags) )
  { if ( flags & TEXTFIELD_EDITABLE )
    { if ( z && notNil(z) )
      { int zh = abs(valInt(z->height));
	int ly = y+am+zh+valInt(getDescentFont(vt->font));

	r_3d_line(x+lw, ly, x+lw+tw, ly, z, TRUE);
      } else if ( ti->pen != ZERO )
      { int pen = valInt(ti->pen);
	int ly = y+am+1+pen/2;

	r_dash(ti->texture);
	r_thickness(valInt(ti->pen));

	r_line(x+lw, ly, x+lw+tw, ly);
      }
    }
    if ( flags & (TEXTFIELD_COMBO|TEXTFIELD_COMBO_DOWN) )
    { int trh = 8;
      int trw = 9;
      int trx, try;
      int up = (flags & TEXTFIELD_COMBO) ? TRUE : FALSE;

      trx = tx+tw+5;
      try = y + (h-trh)/2;

      r_3d_triangle(trx+trw/2, try+trh, trx, try, trx+trw, try, z, up, 0x3);
    }
    if ( flags & TEXTFIELD_STEPPER )
    { int sw = STEPPER_BOX_W;
      int bx = x+w-sw;
      int bh = (h+1)/2;
      int iw, ih, ix, dy;
      Elevation e = getClassVariableValueClass(ClassButton, NAME_elevation);

      r_3d_box(bx, y,    sw, bh,   0, e, !(flags & TEXTFIELD_INCREMENT));
      r_3d_box(bx, y+bh, sw, h-bh, 0, e, !(flags & TEXTFIELD_DECREMENT));

      iw = valInt(INT_ITEM_IMAGE->size->w)/2;
      ih = valInt(INT_ITEM_IMAGE->size->h);
      ix = x + w - (sw+iw+1)/2;
      dy = (bh-ih+1)/2;

      r_image(INT_ITEM_IMAGE, 0,  0, ix, y+dy,      iw, ih, ON);
      r_image(INT_ITEM_IMAGE, iw, 0, ix, y+h-dy-ih, iw, ih, ON);
    }
  }
Пример #8
0
static status
RedrawAreaSlider(Slider s, Area a)
{ int x, y, w, h;
  int ny, vx, vy, lx, ly, sx, sy, hx, hy;
  int vv;
  int bw = (s->look == NAME_x ? BAR_WIDTH : OL_BOX_WIDTH);
  float lv = convert_value(s->low);
  float hv = convert_value(s->high);
  float dv = convert_value(s->displayed_value);
  int lflags = (s->active == ON ? 0 : LABEL_INACTIVE);

  if ( dv < lv )
    dv = lv;
  else if ( dv > hv )
    dv = hv;

  if ( hv > lv )
    vv = rfloat(((float) (valInt(s->width) - bw) * (dv - lv)) / (hv - lv));
  else
    vv = 0;

  initialiseDeviceGraphical(s, &x, &y, &w, &h);
  NormaliseArea(x, y, w, h);
  r_thickness(valInt(s->pen));
  r_dash(s->texture);

  compute_slider(s, &ny, &vx, &vy, &lx, &ly, &sx, &sy, &hx, &hy);
  r_clear(x, y, w, h);

  if ( s->show_label == ON )
  { int ex = valInt(getExFont(s->label_font));

    RedrawLabelDialogItem(s,
			  accelerator_code(s->accelerator),
			  x, y+ny, vx-ex, 0,
			  s->label_format, NAME_top,
			  lflags);
  }

  if ( s->look == NAME_motif )
  { int by = y+sy+(SLIDER_HEIGHT-OL_BAR_HEIGHT)/2;
    int ex  = x + sx + valInt(s->width);
    Elevation z = getClassVariableValueObject(s, NAME_elevation);

    r_3d_box(x+sx, by, vv, OL_BAR_HEIGHT, 0, z, FALSE);
    r_3d_box(x+sx+vv+bw, by, ex-(x+sx+vv+bw), OL_BAR_HEIGHT, 0, z, FALSE);
    r_3d_box(x+sx+vv, y+sy, bw, SLIDER_HEIGHT, 0, z, TRUE);
  } else if ( s->look == NAME_openLook )
  { int by = y+sy+(SLIDER_HEIGHT-OL_BAR_HEIGHT)/2;
    int ly2 = by+OL_BAR_HEIGHT-1;
    int ex  = x + sx + valInt(s->width);

    r_fill(x+sx, by+1, 1, OL_BAR_HEIGHT-2, BLACK_IMAGE);
    r_fill(x+sx+1, by, vv-2, OL_BAR_HEIGHT, BLACK_IMAGE);
    r_line(x+sx+1+vv+bw, by, ex-2, by);
    r_line(x+sx+1+vv+bw, ly2, ex-2, ly2);
    r_line(ex-1, by+1, ex-1, ly2-1);
    r_shadow_box(x+sx+vv, y+sy, bw, SLIDER_HEIGHT, 0, 1, NIL);
  } else
  { r_fill(x+sx, y+sy, vv, SLIDER_HEIGHT, GREY50_IMAGE);
    r_box(x+sx, y+sy, valInt(s->width), SLIDER_HEIGHT, 0, NIL);
    r_fill(x+sx+vv, y+sy, bw, SLIDER_HEIGHT, BLACK_IMAGE);
  }

  if ( s->show_value == ON )
  { char buf[100];
    string str;

    buf[0] = '[';
    format_value(s, &buf[1], s->displayed_value);
    strcat(buf, "]");
    str_set_ascii(&str, buf);
    str_label(&str, 0, s->value_font,
	      x+vx, y+vy, 0, 0, NAME_left, NAME_top, lflags);
    format_value(s, buf, s->low);
    str_set_ascii(&str, buf);
    str_label(&str, 0, s->value_font,
	      x+lx, y+ly, 0, 0, NAME_left, NAME_top, lflags);
    format_value(s, buf, s->high);
    str_set_ascii(&str, buf);
    str_label(&str, 0, s->value_font,
	      x+hx, y+hy, 0, 0, NAME_left, NAME_top, lflags);
  }

  return RedrawAreaGraphical(s, a);
}
Пример #9
0
static status
RedrawAreaArc(Arc a, Area area)
{ int x, y, w, h;
  int aw = valInt(a->size->w);
  int ah = valInt(a->size->h);
  int sx, sy, ex, ey;
  int cx, cy;

  initialiseDeviceGraphical(a, &x, &y, &w, &h);

  points_arc(a, &sx, &sy, &ex, &ey);
  cx = valInt(a->position->x);
  cy = valInt(a->position->y);

  r_thickness(valInt(a->pen));
  r_dash(a->texture);

#ifndef WIN32_GRAPHICS
  r_arcmode(a->close == NAME_none ? NAME_pieSlice : a->close);
  r_arc(valInt(a->position->x) - aw, valInt(a->position->y) - ah,
	2*aw, 2*ah,
	rfloat(valReal(a->start_angle)*64.0), rfloat(valReal(a->size_angle)*64.0),
	a->fill_pattern);

  if ( a->close != NAME_none && a->pen != ZERO )
  { if ( a->close == NAME_chord )
    { r_line(sx, sy, ex, ey);
    } else /* if ( a->close == NAME_pieSlice ) */
    { r_line(cx, cy, sx, sy);
      r_line(cx, cy, ex, ey);
    }
  }

#else /*WIN32_GRAPHICS*/

{ int ax, ay, bx, by;
  double sa = valReal(a->size_angle);
  int large;

  if ( sa >= 0.0 )
  { ax = sx, ay = sy, bx = ex, by = ey;
    large = (sa >= 180.0);
  } else
  { ax = ex, ay = ey, bx = sx, by = sy;
    large = (sa <= -180.0);
  }

  r_msarc(valInt(a->position->x) - aw, valInt(a->position->y) - ah,
	  2*aw, 2*ah,
	  ax, ay, bx, by, large,
	  a->close, a->fill_pattern);
}

#endif /* __WINDOWS__ */

  if (notNil(a->first_arrow))
  { Any av[4];

    av[0] = toInt(sx);
    av[1] = toInt(sy);

    if ( valReal(a->size_angle) >= 0.0 )
    { av[2] = toInt(sx+(sy-cy));
      av[3] = toInt(sy-(sx-cx));
    } else
    { av[2] = toInt(sx-(sy-cy));
      av[3] = toInt(sy+(sx-cx));
    }

    if ( qadSendv(a->first_arrow, NAME_points, 4, av) )
    { assign(a->first_arrow, displayed, ON);
      ComputeGraphical(a->first_arrow);
      RedrawArea(a->first_arrow, area);
    }
  }
  if (notNil(a->second_arrow))
  { Any av[4];

    av[0] = toInt(ex);
    av[1] = toInt(ey);

    if ( valReal(a->size_angle) >= 0.0 )
    { av[2] = toInt(ex-(ey-cy));
      av[3] = toInt(ey+(ex-cx));
    } else
    { av[2] = toInt(ex+(ey-cy));
      av[3] = toInt(ey-(ex-cx));
    }

    if ( qadSendv(a->second_arrow, NAME_points, 4, av) )
    { assign(a->second_arrow, displayed, ON);
      ComputeGraphical(a->second_arrow);
      RedrawArea(a->second_arrow, area);
    }
  }

  return RedrawAreaGraphical(a, area);
}