Commit 7527ec24 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

add a w/r 'text' property. (gee_set_property) : ditto. (gee_get_property)


2003-09-13  Jody Goldberg <jody@gnome.org>

	* gnumeric-expr-entry.c (gee_class_init) : add a w/r 'text' property.
	(gee_set_property) : ditto.
	(gee_get_property) : ditto.

2003-09-13  Jody Goldberg <jody@gnome.org>

	* graph/gog-view.c (gog_view_size_child_request) : hard code some
	  inter-child padding.  We can be more elegant in the future.
	(gog_view_size_allocate_real) : ditto.

	* graph/gog-axis.c (gog_axis_view_size_request) : request space for
	  children too.
parent 2fd453ab
......@@ -24,6 +24,7 @@ Jody:
Gnumeric-1.0.x
* Support index/implicit axis for scatter plots
* Fix horizontal data sets
* Auto pad between chart child with compass layouts
Jon Kåre:
* Ensure that scrollbars always show up in font combo when
......
2003-09-13 Jody Goldberg <jody@gnome.org>
* graph/gog-view.c (gog_view_size_child_request) : hard code some
inter-child padding. We can be more elegant in the future.
(gog_view_size_allocate_real) : ditto.
* graph/gog-axis.c (gog_axis_view_size_request) : request space for
children too.
2003-09-13 Jon K Hellan <hellan@acm.org>
* graph/gog-legend.c (cb_render_elements): Allow for floating
......
......@@ -62,7 +62,7 @@ struct _GogAxis {
gboolean major_tick_labeled;
gboolean inverted;
double bound_min, bound_max, bound_step;
double bound_min, bound_max, major_tick;
double min_val, max_val;
double logical_min_val, logical_max_val;
gpointer min_contrib, max_contrib; /* NULL means use the manual sources */
......@@ -315,7 +315,7 @@ gog_axis_update (GogObject *obj)
/* we want the bounds to be loose so jump up a step if we get too close */
axis->bound_min = step * floor (gnumeric_sub_epsilon (minima/step));
axis->bound_max = step * ceil (gnumeric_add_epsilon (maxima/step));
axis->bound_step = step;
axis->major_tick = step;
/* pull to zero if its nearby */
if (axis->bound_min > 0 && (axis->bound_min - 10. * step) < 0)
......@@ -323,7 +323,7 @@ gog_axis_update (GogObject *obj)
if (axis->bound_max < 0 && (axis->bound_max + 10. * step) < 0)
axis->bound_max = 0;
} else
axis->bound_min = axis->bound_max = axis->bound_step = 0.;
axis->bound_min = axis->bound_max = axis->major_tick = 0.;
if (old_min != axis->bound_min || old_max != axis->bound_max)
gog_object_emit_changed (GOG_OBJECT (obj), TRUE);
......@@ -682,16 +682,16 @@ gog_axis_bound_changed (GogAxis *axis, GogObject *contrib)
static unsigned
gog_axis_num_markers (GogAxis *axis)
{
if (axis->bound_step <= 0.)
if (axis->major_tick <= 0.)
return 0;
return 1 + fabs (axis->bound_max - axis->bound_min) / (double)axis->bound_step;
return 1 + fabs (axis->bound_max - axis->bound_min) / (double)axis->major_tick;
}
static char *
gog_axis_get_marker (GogAxis *axis, unsigned i)
{
return g_strdup_printf ("%g", axis->bound_min + ((double)i) * axis->bound_step);
return g_strdup_printf ("%g", axis->bound_min + ((double)i) * axis->major_tick);
}
/****************************************************************************/
......@@ -706,23 +706,23 @@ typedef GogViewClass GogAxisViewClass;
static GogViewClass *aview_parent_klass;
static void
gog_axis_view_size_request (GogView *view, GogViewRequisition *req)
gog_axis_view_size_request (GogView *v, GogViewRequisition *req)
{
GogAxis *axis = GOG_AXIS (view->model);
GogAxis *axis = GOG_AXIS (v->model);
GogViewRequisition tmp;
gboolean const is_horiz = axis->type == GOG_AXIS_X;
int i;
double total = 0., max = 0., tick_major = 0., tick_minor = 0., pad = 0.;
double line_width = gog_renderer_line_size (
view->renderer, axis->base.style->line.width);
v->renderer, axis->base.style->line.width);
/* TODO : Think about rotating things or dropping markers periodically if
* things are too big */
if (axis->major_tick_labeled) {
gog_renderer_push_style (view->renderer, axis->base.style);
gog_renderer_push_style (v->renderer, axis->base.style);
for (i = gog_axis_num_markers (axis) ; i-- > 0 ; ) {
char *txt = gog_axis_get_marker (axis, i);
gog_renderer_measure_text (view->renderer, txt, &tmp);
gog_renderer_measure_text (v->renderer, txt, &tmp);
g_free (txt);
if (is_horiz) {
total += tmp.w;
......@@ -734,33 +734,36 @@ gog_axis_view_size_request (GogView *view, GogViewRequisition *req)
max = tmp.w;
}
}
gog_renderer_pop_style (view->renderer);
gog_renderer_pop_style (v->renderer);
}
tmp = *req; /* store available */
max += line_width;
if (is_horiz) {
if (axis->major_tick_labeled)
pad = gog_renderer_pt2r_y (view->renderer, TICK_LABEL_PAD);
pad = gog_renderer_pt2r_y (v->renderer, TICK_LABEL_PAD);
if (axis->major.tick_out)
tick_major = gog_renderer_pt2r_y (view->renderer,
tick_major = gog_renderer_pt2r_y (v->renderer,
axis->major.size_pts);
if (axis->minor.tick_out)
tick_minor = gog_renderer_pt2r_y (view->renderer,
tick_minor = gog_renderer_pt2r_y (v->renderer,
axis->minor.size_pts);
req->w = total;
req->h = max + MAX (tick_major, tick_minor) + pad;
} else {
if (axis->major_tick_labeled)
pad = gog_renderer_pt2r_x (view->renderer, TICK_LABEL_PAD);
pad = gog_renderer_pt2r_x (v->renderer, TICK_LABEL_PAD);
if (axis->major.tick_out)
tick_major = gog_renderer_pt2r_x (view->renderer,
tick_major = gog_renderer_pt2r_x (v->renderer,
axis->major.size_pts);
if (axis->minor.tick_out)
tick_minor = gog_renderer_pt2r_x (view->renderer,
tick_minor = gog_renderer_pt2r_x (v->renderer,
axis->minor.size_pts);
req->h = total;
req->w = max + MAX (tick_major, tick_minor) + pad;
}
gog_view_size_child_request (v, &tmp, req);
}
static void
......
......@@ -51,6 +51,9 @@ static GType gog_label_view_get_type (void);
static GObjectClass *label_parent_klass;
static GogViewClass *lview_parent_klass;
/* a property ? */
#define PAD_HACK 4 /* pts */
static void
gog_label_set_property (GObject *obj, guint param_id,
GValue const *value, GParamSpec *pspec)
......@@ -180,50 +183,60 @@ typedef GogViewClass GogLabelViewClass;
#define IS_GOG_LABEL_VIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GOG_LABEL_VIEW_TYPE))
static void
gog_label_view_size_request (GogView *view, GogViewRequisition *req)
gog_label_view_size_request (GogView *v, GogViewRequisition *req)
{
GogLabel *label = GOG_LABEL (view->model);
GogLabel *l = GOG_LABEL (v->model);
double outline = gog_renderer_line_size (
view->renderer, label->base.style->outline.width);
v->renderer, l->base.style->outline.width);
req->w = req->h = 1.;
if (label->text.data != NULL) {
char const *text = go_data_scalar_get_str (GO_DATA_SCALAR (label->text.data));
if (l->text.data != NULL) {
char const *text = go_data_scalar_get_str (GO_DATA_SCALAR (l->text.data));
if (text != NULL) {
gog_renderer_push_style (view->renderer, label->base.style);
gog_renderer_measure_text (view->renderer, text, req);
gog_renderer_pop_style (view->renderer);
gog_renderer_push_style (v->renderer, l->base.style);
gog_renderer_measure_text (v->renderer, text, req);
gog_renderer_pop_style (v->renderer);
}
}
req->w += outline * 2;
req->h += outline * 2;
if (outline > 0) {
double pad_y = gog_renderer_pt2r_y (v->renderer, PAD_HACK);
double pad_x = gog_renderer_pt2r_y (v->renderer, PAD_HACK);
req->w += outline * 2 + pad_x;
req->h += outline * 2 + pad_y;
}
}
static void
gog_label_view_size_allocate (GogView *view, GogViewAllocation const *a)
gog_label_view_size_allocate (GogView *v, GogViewAllocation const *a)
{
GogLabel *label = GOG_LABEL (view->model);
GogLabel *l = GOG_LABEL (v->model);
GogViewAllocation res = *a;
double outline = gog_renderer_line_size (
view->renderer, label->base.style->outline.width);
v->renderer, l->base.style->outline.width);
res.x += outline;
res.y += outline;
res.w -= outline * 2.;
res.h -= outline * 2.;
(lview_parent_klass->size_allocate) (view, &res);
/* We only need internal padding if there is an outline */
if (outline > 0) {
double pad_x = gog_renderer_pt2r_x (v->renderer, PAD_HACK);
double pad_y = gog_renderer_pt2r_y (v->renderer, PAD_HACK);
res.x += outline + pad_x/2;
res.y += outline + pad_y/2;
res.w -= outline * 2. + pad_x;
res.h -= outline * 2. + pad_y;
}
(lview_parent_klass->size_allocate) (v, &res);
}
static void
gog_label_view_render (GogView *view, GogViewAllocation const *bbox)
{
GogLabel *label = GOG_LABEL (view->model);
GogLabel *l = GOG_LABEL (view->model);
gog_renderer_push_style (view->renderer, label->base.style);
gog_renderer_push_style (view->renderer, l->base.style);
gog_renderer_draw_rectangle (view->renderer, &view->allocation);
if (label->text.data != NULL) {
char const *text = go_data_scalar_get_str (GO_DATA_SCALAR (label->text.data));
if (l->text.data != NULL) {
char const *text = go_data_scalar_get_str (GO_DATA_SCALAR (l->text.data));
if (text != NULL) {
ArtPoint point;
point.x = view->residual.x;
......
......@@ -27,6 +27,9 @@
#include <gsf/gsf-impl-utils.h>
#include <src/gnumeric-i18n.h>
/* this should be per model */
#define PAD_HACK 4 /* pts */
enum {
GOG_VIEW_PROP_0,
GOG_VIEW_PROP_PARENT,
......@@ -198,6 +201,8 @@ gog_view_size_allocate_real (GogView *view, GogViewAllocation const *allocation)
GogObjectPosition pos;
GogViewRequisition req;
GogViewAllocation tmp, available = *allocation, res = *allocation;
double const pad_h = gog_renderer_pt2r_y (view->renderer, PAD_HACK);
double const pad_w = gog_renderer_pt2r_x (view->renderer, PAD_HACK);
for (ptr = view->children; ptr != NULL ; ptr = ptr->next) {
child = ptr->data;
......@@ -221,27 +226,27 @@ gog_view_size_allocate_real (GogView *view, GogViewAllocation const *allocation)
tmp = res;
if (pos & GOG_POSITION_N) {
res.y += req.h;
res.h -= req.h;
res.y += req.h + pad_h;
res.h -= req.h + pad_h;
tmp.h = req.h;
vertical = FALSE;
} else if (pos & GOG_POSITION_S) {
res.h -= req.h;
tmp.y = res.y + res.h;
res.h -= req.h + pad_h;
tmp.y = res.y + res.h + pad_h;
tmp.h = req.h;
vertical = FALSE;
}
if (pos & GOG_POSITION_E) {
res.w -= req.w;
tmp.x = res.x + res.w;
res.w -= req.w + pad_w;
tmp.x = res.x + res.w + pad_w;
tmp.w = req.w;
/* For NE & NW only alignment fill makes sense */
if (pos & (GOG_POSITION_N|GOG_POSITION_S))
pos = GOG_POSITION_ALIGN_FILL;
} else if (pos & GOG_POSITION_W) {
res.x += req.w;
res.w -= req.w;
res.x += req.w + pad_w;
res.w -= req.w + pad_w;
tmp.w = req.w;
/* For NE & NW only alignment fill makes sense */
if (pos & (GOG_POSITION_N|GOG_POSITION_S))
......@@ -523,6 +528,8 @@ gog_view_size_child_request (GogView *view,
GogView *child;
GogObjectPosition pos;
GogViewRequisition req;
double const pad_h = gog_renderer_pt2r_y (view->renderer, PAD_HACK);
double const pad_w = gog_renderer_pt2r_x (view->renderer, PAD_HACK);
/* walk the list in reverse */
list = g_slist_reverse (g_slist_copy (view->children));
......@@ -537,12 +544,12 @@ gog_view_size_child_request (GogView *view,
gog_view_size_request (child, &req);
if (pos & (GOG_POSITION_N|GOG_POSITION_S))
res->h += req.h;
res->h += req.h + pad_h;
else if (res->h < req.h)
res->h = req.h;
if (pos & (GOG_POSITION_E|GOG_POSITION_W))
res->w += req.w;
res->w += req.w + pad_w;
else if (res->w < req.w)
res->w = req.w;
......
2003-09-13 Jody Goldberg <jody@gnome.org>
* gnumeric-expr-entry.c (gee_class_init) : add a w/r 'text' property.
(gee_set_property) : ditto.
(gee_get_property) : ditto.
2003-09-10 Jon K Hellan <hellan@acm.org>
* gnumeric-combo-text.c (cb_scroll_size_request): Compute size
......
......@@ -84,6 +84,7 @@ enum {
PROP_0,
PROP_UPDATE_POLICY,
PROP_WITH_ICON,
PROP_TEXT,
PROP_SCG,
PROP_WBCG
};
......@@ -164,6 +165,10 @@ gee_set_property (GObject *object,
gtk_object_destroy (GTK_OBJECT (gee->icon));
break;
case PROP_TEXT:
gnm_expr_entry_load_from_text (gee, g_value_get_string (value));
break;
case PROP_SCG:
gnm_expr_entry_set_scg (gee,
SHEET_CONTROL_GUI (g_value_get_object (value)));
......@@ -191,6 +196,9 @@ gee_get_property (GObject *object,
case PROP_WITH_ICON:
g_value_set_boolean (value, gee->icon != NULL);
break;
case PROP_TEXT:
g_value_set_string (value, gnm_expr_entry_get_text (gee));
break;
case PROP_SCG:
g_value_set_object (value, G_OBJECT (gee->scg));
break;
......@@ -450,6 +458,12 @@ gee_class_init (GObjectClass *gobject_class)
"Should there be an icon to the right of the entry",
TRUE,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_TEXT,
g_param_spec_string ("text", "Text",
"The contents of the entry",
"",
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (gobject_class,
PROP_SCG,
g_param_spec_object ("scg", "SheetControlGUI",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment