aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-08-25 03:06:54 +0800
committerChris Lahey <clahey@src.gnome.org>2000-08-25 03:06:54 +0800
commit695baf618d363f760ec81d109c6e6185e510b1e7 (patch)
tree40d7700b26e6041ac8c8ef7e40cc15fe25ba43c0
parent483c3d3ffc0addb346611c0a544f214784e349b1 (diff)
downloadgsoc2013-evolution-695baf618d363f760ec81d109c6e6185e510b1e7.tar
gsoc2013-evolution-695baf618d363f760ec81d109c6e6185e510b1e7.tar.gz
gsoc2013-evolution-695baf618d363f760ec81d109c6e6185e510b1e7.tar.bz2
gsoc2013-evolution-695baf618d363f760ec81d109c6e6185e510b1e7.tar.lz
gsoc2013-evolution-695baf618d363f760ec81d109c6e6185e510b1e7.tar.xz
gsoc2013-evolution-695baf618d363f760ec81d109c6e6185e510b1e7.tar.zst
gsoc2013-evolution-695baf618d363f760ec81d109c6e6185e510b1e7.zip
Added infrastructure for setting the justification of columns. Still need
2000-08-24 Christopher James Lahey <clahey@helixcode.com> * e-cell-text.c, e-cell-toggle.c, e-cell-tree.c, e-cell.c, e-cell.h, e-table-col.c, e-table-col.h, e-table-item.c: Added infrastructure for setting the justification of columns. Still need to change the cells to support it and need to add user interface to change the justification. svn path=/trunk/; revision=5010
-rw-r--r--widgets/e-table/ChangeLog8
-rw-r--r--widgets/e-table/e-cell-text.c5
-rw-r--r--widgets/e-table/e-cell-toggle.c7
-rw-r--r--widgets/e-table/e-cell-tree.c7
-rw-r--r--widgets/e-table/e-cell.c6
-rw-r--r--widgets/e-table/e-cell.h18
-rw-r--r--widgets/e-table/e-table-col.c1
-rw-r--r--widgets/e-table/e-table-col.h2
-rw-r--r--widgets/e-table/e-table-item.c19
-rw-r--r--widgets/table/e-cell-text.c5
-rw-r--r--widgets/table/e-cell-toggle.c7
-rw-r--r--widgets/table/e-cell-tree.c7
-rw-r--r--widgets/table/e-cell.c6
-rw-r--r--widgets/table/e-cell.h18
-rw-r--r--widgets/table/e-table-col.c1
-rw-r--r--widgets/table/e-table-col.h2
-rw-r--r--widgets/table/e-table-item.c19
17 files changed, 116 insertions, 22 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index 67ea4c155c..d4c0377160 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,3 +1,11 @@
+2000-08-24 Christopher James Lahey <clahey@helixcode.com>
+
+ * e-cell-text.c, e-cell-toggle.c, e-cell-tree.c, e-cell.c,
+ e-cell.h, e-table-col.c, e-table-col.h, e-table-item.c: Added
+ infrastructure for setting the justification of columns. Still
+ need to change the cells to support it and need to add user
+ interface to change the justification.
+
2000-08-23 Christopher James Lahey <clahey@helixcode.com>
* e-table-subset-variable.c: Fixed a bug in
diff --git a/widgets/e-table/e-cell-text.c b/widgets/e-table/e-cell-text.c
index 5a7f8d514e..10e3f7b8c6 100644
--- a/widgets/e-table/e-cell-text.c
+++ b/widgets/e-table/e-cell-text.c
@@ -422,7 +422,7 @@ ect_free_color (gchar *color_spec, GdkColor *color, GdkColormap *colormap)
*/
static void
ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected,
+ int model_col, int view_col, int row, ECellFlags flags,
int x1, int y1, int x2, int y2)
{
/* New ECellText */
@@ -444,9 +444,12 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
ECellTextLineBreaks *linebreaks;
GdkColor *foreground, *cell_foreground, *cursor_color;
gchar *color_spec;
+ gboolean selected;
EFontStyle style = E_FONT_PLAIN;
+ selected = flags & E_CELL_SELECTED;
+
if (ect->bold_column >= 0 && e_table_model_value_at(ecell_view->e_table_model, ect->bold_column, row))
style = E_FONT_BOLD;
diff --git a/widgets/e-table/e-cell-toggle.c b/widgets/e-table/e-cell-toggle.c
index 1be01348db..f0a05b488a 100644
--- a/widgets/e-table/e-cell-toggle.c
+++ b/widgets/e-table/e-cell-toggle.c
@@ -84,18 +84,21 @@ etog_unrealize (ECellView *ecv)
*/
static void
etog_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected,
+ int model_col, int view_col, int row, ECellFlags flags,
int x1, int y1, int x2, int y2)
{
ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell);
+ gboolean selected;
#if 0
ECellToggleView *toggle_view = (ECellToggleView *) ecell_view;
#endif
GdkPixbuf *image;
int x, y, width, height;
-
+
const int value = GPOINTER_TO_INT (
e_table_model_value_at (ecell_view->e_table_model, model_col, row));
+
+ selected = flags & E_CELL_SELECTED;
if (value >= toggle->n_states){
g_warning ("Value from the table model is %d, the states we support are [0..%d)\n",
diff --git a/widgets/e-table/e-cell-tree.c b/widgets/e-table/e-cell-tree.c
index d4106271e6..3cc06a73ee 100644
--- a/widgets/e-table/e-cell-tree.c
+++ b/widgets/e-table/e-cell-tree.c
@@ -151,7 +151,7 @@ ect_unrealize (ECellView *ecv)
*/
static void
ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected,
+ int model_col, int view_col, int row, ECellFlags flags,
int x1, int y1, int x2, int y2)
{
ECellTreeView *tree_view = (ECellTreeView *)ecell_view;
@@ -161,10 +161,13 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
GtkWidget *canvas = GTK_WIDGET (tree_view->canvas);
GdkGC *fg_gc = canvas->style->fg_gc[GTK_STATE_ACTIVE];
GdkColor *foreground;
+ gboolean selected;
int offset, subcell_offset;
gboolean expanded, expandable;
+ selected = flags & E_CELL_SELECTED;
+
/* only draw the tree effects if we're the active sort */
if (/* XXX */ TRUE) {
GdkPixbuf *node_image;
@@ -286,7 +289,7 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
/* Now cause our subcell to draw its contents, shifted by
subcell_offset pixels */
e_cell_draw (tree_view->subcell_view, drawable,
- model_col, view_col, row, selected,
+ model_col, view_col, row, flags,
x1 + subcell_offset, y1, x2, y2);
}
diff --git a/widgets/e-table/e-cell.c b/widgets/e-table/e-cell.c
index 75be2ce916..3212157675 100644
--- a/widgets/e-table/e-cell.c
+++ b/widgets/e-table/e-cell.c
@@ -36,7 +36,7 @@ ec_unrealize (ECellView *e_cell)
static void
ec_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected,
+ int model_col, int view_col, int row, ECellFlags flags,
int x1, int y1, int x2, int y2)
{
g_error ("e-cell-draw invoked\n");
@@ -151,10 +151,10 @@ e_cell_unrealize (ECellView *ecell_view)
void
e_cell_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected, int x1, int y1, int x2, int y2)
+ int model_col, int view_col, int row, ECellFlags flags, int x1, int y1, int x2, int y2)
{
E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->draw (
- ecell_view, drawable, model_col, view_col, row, selected, x1, y1, x2, y2);
+ ecell_view, drawable, model_col, view_col, row, flags, x1, y1, x2, y2);
}
void
diff --git a/widgets/e-table/e-cell.h b/widgets/e-table/e-cell.h
index 40b257f264..3b12aab1e3 100644
--- a/widgets/e-table/e-cell.h
+++ b/widgets/e-table/e-cell.h
@@ -14,6 +14,20 @@
typedef struct _ECell ECell;
typedef struct _ECellView ECellView;
+typedef enum _ECellFlags ECellFlags;
+
+enum _ECellFlags {
+ E_CELL_SELECTED = 1 << 0,
+
+ E_CELL_JUSTIFICATION = 3 << 1,
+ E_CELL_JUSTIFY_CENTER = 0 << 1,
+ E_CELL_JUSTIFY_LEFT = 1 << 1,
+ E_CELL_JUSTIFY_RIGHT = 2 << 1,
+ E_CELL_JUSTIFY_FILL = 3 << 1,
+
+ E_CELL_ALIGN_LEFT = 1 << 1,
+ E_CELL_ALIGN_RIGHT = 1 << 2,
+};
struct _ECell {
GtkObject object;
@@ -41,7 +55,7 @@ typedef struct {
void (*draw) (ECellView *ecell_view, GdkDrawable *drawable,
int model_col, int view_col, int row,
- gboolean selected, int x1, int y1, int x2, int y2);
+ ECellFlags flags, int x1, int y1, int x2, int y2);
gint (*event) (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row);
void (*focus) (ECellView *ecell_view, int model_col, int view_col,
int row, int x1, int y1, int x2, int y2);
@@ -67,7 +81,7 @@ void e_cell_realize (ECellView *ecell_view);
void e_cell_unrealize (ECellView *ecell_view);
void e_cell_draw (ECellView *ecell_view, GdkDrawable *dr,
- int model_col, int view_col, int row, gboolean selected,
+ int model_col, int view_col, int row, ECellFlags flags,
int x1, int y1, int x2, int y2);
void e_cell_print (ECellView *ecell_view, GnomePrintContext *context,
int model_col, int view_col, int row,
diff --git a/widgets/e-table/e-table-col.c b/widgets/e-table/e-table-col.c
index e767aa5567..0e7c14f748 100644
--- a/widgets/e-table/e-table-col.c
+++ b/widgets/e-table/e-table-col.c
@@ -84,6 +84,7 @@ e_table_col_init (ETableCol *etc)
etc->width = 0;
etc->sortable = 1;
etc->groupable = 1;
+ etc->justification = GTK_JUSTIFY_LEFT;
}
E_MAKE_TYPE(e_table_col, "ETableCol", ETableCol, e_table_col_class_init, e_table_col_init, PARENT_TYPE);
diff --git a/widgets/e-table/e-table-col.h b/widgets/e-table/e-table-col.h
index 39aeb26ba9..c2585f8166 100644
--- a/widgets/e-table/e-table-col.h
+++ b/widgets/e-table/e-table-col.h
@@ -40,6 +40,8 @@ struct _ETableCol {
unsigned int groupable:1;
int col_idx;
+ GtkJustification justification;
+
ETableColArrow arrow;
ECell *ecell;
diff --git a/widgets/e-table/e-table-item.c b/widgets/e-table/e-table-item.c
index 0f70861f1e..afa1bb8f96 100644
--- a/widgets/e-table/e-table-item.c
+++ b/widgets/e-table/e-table-item.c
@@ -1192,6 +1192,7 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
ETableCol *ecol = e_table_header_get_column (eti->header, col);
ECellView *ecell_view = eti->cell_views [col];
gboolean col_selected = selected;
+ ECellFlags flags;
switch (eti->cursor_mode) {
case E_TABLE_CURSOR_SIMPLE:
if (cursor_col == ecol->col_idx && cursor_row == view_to_model_row(eti, row))
@@ -1215,7 +1216,23 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
gdk_draw_rectangle (drawable, eti->fill_gc, TRUE,
xd, yd, ecol->width, height);
- e_cell_draw (ecell_view, drawable, ecol->col_idx, col, row, col_selected,
+ flags = col_selected ? E_CELL_SELECTED : 0;
+ switch (ecol->justification) {
+ case GTK_JUSTIFY_LEFT:
+ flags |= E_CELL_JUSTIFY_LEFT;
+ break;
+ case GTK_JUSTIFY_RIGHT:
+ flags |= E_CELL_JUSTIFY_RIGHT;
+ break;
+ case GTK_JUSTIFY_CENTER:
+ flags |= E_CELL_JUSTIFY_CENTER;
+ break;
+ case GTK_JUSTIFY_FILL:
+ flags |= E_CELL_JUSTIFY_FILL;
+ break;
+ }
+
+ e_cell_draw (ecell_view, drawable, ecol->col_idx, col, row, flags,
xd, yd, xd + ecol->width, yd + height);
if (view_to_model_col(eti, col) == cursor_col && view_to_model_row(eti, row) == cursor_row){
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
index 5a7f8d514e..10e3f7b8c6 100644
--- a/widgets/table/e-cell-text.c
+++ b/widgets/table/e-cell-text.c
@@ -422,7 +422,7 @@ ect_free_color (gchar *color_spec, GdkColor *color, GdkColormap *colormap)
*/
static void
ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected,
+ int model_col, int view_col, int row, ECellFlags flags,
int x1, int y1, int x2, int y2)
{
/* New ECellText */
@@ -444,9 +444,12 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
ECellTextLineBreaks *linebreaks;
GdkColor *foreground, *cell_foreground, *cursor_color;
gchar *color_spec;
+ gboolean selected;
EFontStyle style = E_FONT_PLAIN;
+ selected = flags & E_CELL_SELECTED;
+
if (ect->bold_column >= 0 && e_table_model_value_at(ecell_view->e_table_model, ect->bold_column, row))
style = E_FONT_BOLD;
diff --git a/widgets/table/e-cell-toggle.c b/widgets/table/e-cell-toggle.c
index 1be01348db..f0a05b488a 100644
--- a/widgets/table/e-cell-toggle.c
+++ b/widgets/table/e-cell-toggle.c
@@ -84,18 +84,21 @@ etog_unrealize (ECellView *ecv)
*/
static void
etog_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected,
+ int model_col, int view_col, int row, ECellFlags flags,
int x1, int y1, int x2, int y2)
{
ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell);
+ gboolean selected;
#if 0
ECellToggleView *toggle_view = (ECellToggleView *) ecell_view;
#endif
GdkPixbuf *image;
int x, y, width, height;
-
+
const int value = GPOINTER_TO_INT (
e_table_model_value_at (ecell_view->e_table_model, model_col, row));
+
+ selected = flags & E_CELL_SELECTED;
if (value >= toggle->n_states){
g_warning ("Value from the table model is %d, the states we support are [0..%d)\n",
diff --git a/widgets/table/e-cell-tree.c b/widgets/table/e-cell-tree.c
index d4106271e6..3cc06a73ee 100644
--- a/widgets/table/e-cell-tree.c
+++ b/widgets/table/e-cell-tree.c
@@ -151,7 +151,7 @@ ect_unrealize (ECellView *ecv)
*/
static void
ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected,
+ int model_col, int view_col, int row, ECellFlags flags,
int x1, int y1, int x2, int y2)
{
ECellTreeView *tree_view = (ECellTreeView *)ecell_view;
@@ -161,10 +161,13 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
GtkWidget *canvas = GTK_WIDGET (tree_view->canvas);
GdkGC *fg_gc = canvas->style->fg_gc[GTK_STATE_ACTIVE];
GdkColor *foreground;
+ gboolean selected;
int offset, subcell_offset;
gboolean expanded, expandable;
+ selected = flags & E_CELL_SELECTED;
+
/* only draw the tree effects if we're the active sort */
if (/* XXX */ TRUE) {
GdkPixbuf *node_image;
@@ -286,7 +289,7 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
/* Now cause our subcell to draw its contents, shifted by
subcell_offset pixels */
e_cell_draw (tree_view->subcell_view, drawable,
- model_col, view_col, row, selected,
+ model_col, view_col, row, flags,
x1 + subcell_offset, y1, x2, y2);
}
diff --git a/widgets/table/e-cell.c b/widgets/table/e-cell.c
index 75be2ce916..3212157675 100644
--- a/widgets/table/e-cell.c
+++ b/widgets/table/e-cell.c
@@ -36,7 +36,7 @@ ec_unrealize (ECellView *e_cell)
static void
ec_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected,
+ int model_col, int view_col, int row, ECellFlags flags,
int x1, int y1, int x2, int y2)
{
g_error ("e-cell-draw invoked\n");
@@ -151,10 +151,10 @@ e_cell_unrealize (ECellView *ecell_view)
void
e_cell_draw (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row, gboolean selected, int x1, int y1, int x2, int y2)
+ int model_col, int view_col, int row, ECellFlags flags, int x1, int y1, int x2, int y2)
{
E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->draw (
- ecell_view, drawable, model_col, view_col, row, selected, x1, y1, x2, y2);
+ ecell_view, drawable, model_col, view_col, row, flags, x1, y1, x2, y2);
}
void
diff --git a/widgets/table/e-cell.h b/widgets/table/e-cell.h
index 40b257f264..3b12aab1e3 100644
--- a/widgets/table/e-cell.h
+++ b/widgets/table/e-cell.h
@@ -14,6 +14,20 @@
typedef struct _ECell ECell;
typedef struct _ECellView ECellView;
+typedef enum _ECellFlags ECellFlags;
+
+enum _ECellFlags {
+ E_CELL_SELECTED = 1 << 0,
+
+ E_CELL_JUSTIFICATION = 3 << 1,
+ E_CELL_JUSTIFY_CENTER = 0 << 1,
+ E_CELL_JUSTIFY_LEFT = 1 << 1,
+ E_CELL_JUSTIFY_RIGHT = 2 << 1,
+ E_CELL_JUSTIFY_FILL = 3 << 1,
+
+ E_CELL_ALIGN_LEFT = 1 << 1,
+ E_CELL_ALIGN_RIGHT = 1 << 2,
+};
struct _ECell {
GtkObject object;
@@ -41,7 +55,7 @@ typedef struct {
void (*draw) (ECellView *ecell_view, GdkDrawable *drawable,
int model_col, int view_col, int row,
- gboolean selected, int x1, int y1, int x2, int y2);
+ ECellFlags flags, int x1, int y1, int x2, int y2);
gint (*event) (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row);
void (*focus) (ECellView *ecell_view, int model_col, int view_col,
int row, int x1, int y1, int x2, int y2);
@@ -67,7 +81,7 @@ void e_cell_realize (ECellView *ecell_view);
void e_cell_unrealize (ECellView *ecell_view);
void e_cell_draw (ECellView *ecell_view, GdkDrawable *dr,
- int model_col, int view_col, int row, gboolean selected,
+ int model_col, int view_col, int row, ECellFlags flags,
int x1, int y1, int x2, int y2);
void e_cell_print (ECellView *ecell_view, GnomePrintContext *context,
int model_col, int view_col, int row,
diff --git a/widgets/table/e-table-col.c b/widgets/table/e-table-col.c
index e767aa5567..0e7c14f748 100644
--- a/widgets/table/e-table-col.c
+++ b/widgets/table/e-table-col.c
@@ -84,6 +84,7 @@ e_table_col_init (ETableCol *etc)
etc->width = 0;
etc->sortable = 1;
etc->groupable = 1;
+ etc->justification = GTK_JUSTIFY_LEFT;
}
E_MAKE_TYPE(e_table_col, "ETableCol", ETableCol, e_table_col_class_init, e_table_col_init, PARENT_TYPE);
diff --git a/widgets/table/e-table-col.h b/widgets/table/e-table-col.h
index 39aeb26ba9..c2585f8166 100644
--- a/widgets/table/e-table-col.h
+++ b/widgets/table/e-table-col.h
@@ -40,6 +40,8 @@ struct _ETableCol {
unsigned int groupable:1;
int col_idx;
+ GtkJustification justification;
+
ETableColArrow arrow;
ECell *ecell;
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index 0f70861f1e..afa1bb8f96 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -1192,6 +1192,7 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
ETableCol *ecol = e_table_header_get_column (eti->header, col);
ECellView *ecell_view = eti->cell_views [col];
gboolean col_selected = selected;
+ ECellFlags flags;
switch (eti->cursor_mode) {
case E_TABLE_CURSOR_SIMPLE:
if (cursor_col == ecol->col_idx && cursor_row == view_to_model_row(eti, row))
@@ -1215,7 +1216,23 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
gdk_draw_rectangle (drawable, eti->fill_gc, TRUE,
xd, yd, ecol->width, height);
- e_cell_draw (ecell_view, drawable, ecol->col_idx, col, row, col_selected,
+ flags = col_selected ? E_CELL_SELECTED : 0;
+ switch (ecol->justification) {
+ case GTK_JUSTIFY_LEFT:
+ flags |= E_CELL_JUSTIFY_LEFT;
+ break;
+ case GTK_JUSTIFY_RIGHT:
+ flags |= E_CELL_JUSTIFY_RIGHT;
+ break;
+ case GTK_JUSTIFY_CENTER:
+ flags |= E_CELL_JUSTIFY_CENTER;
+ break;
+ case GTK_JUSTIFY_FILL:
+ flags |= E_CELL_JUSTIFY_FILL;
+ break;
+ }
+
+ e_cell_draw (ecell_view, drawable, ecol->col_idx, col, row, flags,
xd, yd, xd + ecol->width, yd + height);
if (view_to_model_col(eti, col) == cursor_col && view_to_model_row(eti, row) == cursor_row){