[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: CVS update: s_visibility.c
User: sdb
Date: 06/08/12 14:58:48
Modified: . s_visibility.c x_fileselect.c x_gtksheet.c
x_window.c
Log:
Made cell text different colors depending upon attribute visibility.
Revision Changes Path
1.3 +66 -2 eda/geda/gaf/gattrib/src/s_visibility.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: s_visibility.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gattrib/src/s_visibility.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- s_visibility.c 6 Aug 2006 16:45:28 -0000 1.2
+++ s_visibility.c 12 Aug 2006 18:58:48 -0000 1.3
@@ -80,7 +80,11 @@
/* ---------------------------------------------------------------------- *
- * s_visibility_set_invisible -- This sets the selected cells to INVISIBLE.
+ * s_visibility_set_invisible -- This sets the selected cells to
+ * INVISIBLE.
+ * This fcn is called from the menu, it assumes you have
+ * selected a range of cells which are carried in the global
+ * variable "sheet".
* ---------------------------------------------------------------------- */
void s_visibility_set_invisible() {
gint i, j;
@@ -103,17 +107,26 @@
#ifdef DEBUG
printf("In s_visibility_set_invisible, range/col/row selected.\n");
#endif
+
row_start = sheet->range.row0;
row_end = sheet->range.rowi;
col_start = sheet->range.col0;
col_end = sheet->range.coli;
for (i=row_start; i<=row_end; i++) {
for (j=col_start; j<=col_end; j++) {
+ /* first set cell in SHEET_DATA to invisible */
s_visibility_set_cell(cur_page, i, j,
INVISIBLE,
LEAVE_NAME_VALUE_ALONE);
+ /* Now set cell in gtksheet to desired color */
+ /* Color names are defined
+ * in libgeda/include/colors.h */
+ x_gtksheet_set_cell_text_color(sheet, i, j, GREY);
+
}
}
+ /* Now return sheet to normal -- unselect range */
+ gtk_sheet_unselect_range (sheet);
break;
case GTK_SHEET_NORMAL:
@@ -125,6 +138,12 @@
sheet->active_cell.col,
INVISIBLE,
LEAVE_NAME_VALUE_ALONE);
+
+ x_gtksheet_set_cell_text_color(sheet,
+ sheet->active_cell.row,
+ sheet->active_cell.col,
+ GREY);
+
break;
}
@@ -134,6 +153,9 @@
/* ---------------------------------------------------------------------- *
* s_visibility_set_name_only -- This sets the selected cells to NAME_ONLY.
+ * This fcn is invoked from the menu, it assumes you have
+ * selected a range of cells which are carried in the global
+ * variable "sheet".
* ---------------------------------------------------------------------- */
void s_visibility_set_name_only() {
gint i, j;
@@ -162,8 +184,15 @@
for (i=row_start; i<=row_end; i++) {
for (j=col_start; j<=col_end; j++) {
s_visibility_set_cell(cur_page, i, j, VISIBLE, SHOW_NAME);
+ /* Color names are defined
+ * in libgeda/include/colors.h */
+ x_gtksheet_set_cell_text_color(sheet, i, j, RED);
+
}
}
+ /* Now return sheet to normal -- unselect range */
+ gtk_sheet_unselect_range (sheet);
+
break;
case GTK_SHEET_NORMAL:
@@ -171,6 +200,11 @@
sheet->active_cell.row,
sheet->active_cell.col,
VISIBLE, SHOW_NAME);
+ x_gtksheet_set_cell_text_color(sheet,
+ sheet->active_cell.row,
+ sheet->active_cell.col,
+ RED);
+
break;
}
@@ -178,6 +212,9 @@
/* ---------------------------------------------------------------------- *
* s_visibility_set_value_only -- This sets the selected cells to VALUE_ONLY.
+ * This fcn is invoked from the menu, it assumes you have
+ * selected a range of cells which are carried in the global
+ * variable "sheet".
* ---------------------------------------------------------------------- */
void s_visibility_set_value_only() {
gint i, j;
@@ -206,8 +243,15 @@
for (i=row_start; i<=row_end; i++) {
for (j=col_start; j<=col_end; j++) {
s_visibility_set_cell(cur_page, i, j, VISIBLE, SHOW_VALUE);
+ /* Color names are defined
+ * in libgeda/include/colors.h */
+ x_gtksheet_set_cell_text_color(sheet, i, j, BLACK);
+
}
}
+ /* Now return sheet to normal -- unselect range */
+ gtk_sheet_unselect_range (sheet);
+
break;
case GTK_SHEET_NORMAL:
@@ -218,13 +262,21 @@
sheet->active_cell.row,
sheet->active_cell.col,
VISIBLE, SHOW_VALUE);
+ x_gtksheet_set_cell_text_color(sheet,
+ sheet->active_cell.row,
+ sheet->active_cell.col,
+ BLACK);
break;
}
}
/* ---------------------------------------------------------------------- *
- * s_visibility_set_name_and_value -- This sets the selected cells to NAME_AND_VALUE
+ * s_visibility_set_name_and_value -- This sets the selected cells
+ * to NAME_AND_VALUE
+ * This fcn is invoked from the menu, it assumes you have
+ * selected a range of cells which are carried in the global
+ * variable "sheet".
* ---------------------------------------------------------------------- */
void s_visibility_set_name_and_value() {
gint i, j;
@@ -250,8 +302,15 @@
for (i=row_start; i<=row_end; i++) {
for (j=col_start; j<=col_end; j++) {
s_visibility_set_cell(cur_page, i, j, VISIBLE, SHOW_NAME_VALUE);
+ /* Color names are defined
+ * in libgeda/include/colors.h */
+ x_gtksheet_set_cell_text_color(sheet, i, j, BLUE);
+
}
}
+ /* Now return sheet to normal -- unselect range */
+ gtk_sheet_unselect_range (sheet);
+
break;
case GTK_SHEET_NORMAL:
@@ -260,6 +319,11 @@
sheet->active_cell.col,
VISIBLE,
SHOW_NAME_VALUE);
+ x_gtksheet_set_cell_text_color(sheet,
+ sheet->active_cell.row,
+ sheet->active_cell.col,
+ BLUE);
+
break;
}
1.12 +4 -66 eda/geda/gaf/gattrib/src/x_fileselect.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: x_fileselect.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gattrib/src/x_fileselect.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- x_fileselect.c 6 Aug 2006 16:45:28 -0000 1.11
+++ x_fileselect.c 12 Aug 2006 18:58:48 -0000 1.12
@@ -596,24 +596,6 @@
{
gtk_widget_destroy(GTK_WIDGET(f_current->xfwindow));
-#if 0 /* this isn't relavent anymore */
- w_current = f_current->toplevel;
-
- if (f_current->filesel_type == SAVEAS_QUIT) {
- exit_dialog(w_current);
- }
-
- if (f_current->filesel_type == SAVEAS_OPEN) {
- x_fileselect_setup(w_current, FILESELECT, SAVEAS_OPEN);
- }
-
- if (f_current->filesel_type == SAVEAS_NEW) {
- w_current->page_current->CHANGED = 0;
- i_callback_file_new(w_current, 0, NULL);
- }
-#endif
-
- /* do nothing if close is pressed for SAVEAS_CLOSE case */
return;
}
@@ -663,20 +645,6 @@
x_fileselect_close(NULL, f_current);
-#if 0
- /* What do these do? */
- if (f_current->filesel_type == SAVEAS_QUIT) {
- x_window_close(w_current);
- } else if (f_current->filesel_type == SAVEAS_OPEN) {
- i_callback_file_open(w_current, 0, NULL);
- } else if (f_current->filesel_type == SAVEAS_NEW) {
- i_callback_file_new(w_current, 0, NULL);
- } else if (f_current->filesel_type == SAVEAS_CLOSE) {
- i_callback_page_close(w_current, 0, NULL);
- }
-#endif
-
- /* do nothing if SAVEAS_NONE */
} else {
s_log_message("Specify a Filename!\n");
}
@@ -1000,10 +968,6 @@
char *new_filename)
{
char *temp = NULL;
-#if 0
- char *ptr = NULL;
- int i;
-#endif
char *filename = NULL;
char *directory = NULL;
@@ -1025,37 +989,11 @@
f_current->directory = NULL;
}
-#if 0
- directory = (char *) g_malloc(sizeof(char) * (strlen(new_filename) + 1));
- filename = (char *) g_malloc(sizeof(char) * (strlen(new_filename) + 1));
-
- ptr = new_filename;
- temp = strrchr(new_filename, G_DIR_SEPARATOR);
- if (temp) {
- /* SDB asks: What is all this stuff for? */
- i = 0;
- while (ptr != temp && ptr[0] != '\0') {
- directory[i] = *ptr;
- ptr++;
- i++;
- }
- directory[i] = '\0';
- ptr++; /* skip over last '/' */
- i = 0;
- while (ptr[0] != '\0') {
- filename[i] = *ptr;
- ptr++;
- i++;
- }
- filename[i] = '\0';
- } else {
-#endif
- /* SDB says: This is what generally is run. What is the above stuff for? */
+ /* I wonder if I should do some checking on the
+ * filename to make sure it is sane? */
directory = getcwd(NULL, 1024);
filename = g_strdup(new_filename);
-#if 0
- }
-#endif
+
#if DEBUG
printf("In x_fileselect_update_dirfile_saveas, directory = %s\n", directory);
1.11 +105 -6 eda/geda/gaf/gattrib/src/x_gtksheet.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: x_gtksheet.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gattrib/src/x_gtksheet.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- x_gtksheet.c 6 Aug 2006 16:45:28 -0000 1.10
+++ x_gtksheet.c 12 Aug 2006 18:58:48 -0000 1.11
@@ -55,6 +55,7 @@
#include "../include/prototype.h" /* function prototypes */
#include "../include/globals.h"
+
#ifdef HAVE_LIBDMALLOC
#include <dmalloc.h>
#endif
@@ -179,6 +180,9 @@
/* "changed" signal raised when user changes anything in entry cell */
+ /* Note that the entry cell is the text entry field at the top of the
+ * sheet's working area (like in MS E*cel). I have removed this from
+ * gattrib, but leave the code in just in case I want to put it back. */
gtk_signal_connect(GTK_OBJECT(gtk_sheet_get_entry(GTK_SHEET(sheets[i]))),
"changed", (GtkSignalFunc) show_entry, NULL);
@@ -273,18 +277,38 @@
* x_gtksheet_add_cell_item:
*------------------------------------------------------------------*/
void
-x_gtksheet_add_cell_item(GtkSheet *sheet, int i, int j, gchar *text)
+x_gtksheet_add_cell_item(GtkSheet *sheet,gint i, gint j,
+ gchar *text,
+ gint visibility,
+ gint show_name_value)
{
/* Should I do some sanity checking here? */
gtk_sheet_set_cell(sheet, i, j, GTK_JUSTIFY_LEFT, text);
+ if (visibility == INVISIBLE) {
+ x_gtksheet_set_cell_text_color(sheet, i, j, GREY);
+ } else {
+ switch(show_name_value) {
+
+ case(SHOW_NAME_VALUE):
+ x_gtksheet_set_cell_text_color(sheet, i, j, BLUE);
+ break;
+
+ case(SHOW_NAME):
+ x_gtksheet_set_cell_text_color(sheet, i, j, RED);
+ break;
+
+ case(SHOW_VALUE):
+ x_gtksheet_set_cell_text_color(sheet, i, j, BLACK);
+ break;
+ }
+ } /* if (visibility == INVISIBLE) */
- /* Need to find a way to ensure that the text in a cell is clipped.
- * Otherwise, long attribs overwrite adjacent cells. */
- /* gtk_sheet_set_cell_attributes(GtkSheet *sheet, gint row, gint col, GtkSheetCellAttr attributes) */
+ /* Need to find a way to ensure that the text in a cell is clipped.
+ * Otherwise, long attribs overwrite adjacent cells. */
return;
}
@@ -316,6 +340,79 @@
}
+/* ----------------------------------------------------------------- *
+ * This fcn sets the color of a cell identified by row, col
+ * ----------------------------------------------------------------- */
+void x_gtksheet_set_cell_text_color(GtkSheet *sheet, gint row, gint col,
+ gint color_name)
+{
+ GtkSheetRange *range;
+ GdkColormap *cmap;
+ GdkColor *color;
+
+
+ /* First get the system color map and allocate the color */
+
+ cmap = gdk_colormap_get_system ();
+ color = g_malloc(sizeof(GdkColor));
+ switch(color_name) {
+ case RED:
+ color->red = 0xffff;
+ color->green = 0x0;
+ color->blue = 0x0;
+ break;
+
+ case BLUE:
+ color->red = 0x0;
+ color->green = 0x0;
+ color->blue = 0xffff;
+ break;
+
+ case BLACK:
+ color->red = 0x0;
+ color->green = 0x0;
+ color->blue = 0x0;
+ break;
+
+ case GREY:
+ color->red = 0x9999;
+ color->green = 0x9999;
+ color->blue = 0x9999;
+ break;
+ }
+
+ if (!gdk_colormap_alloc_color (cmap, color, FALSE, FALSE)) {
+ g_error ("couldn't allocate color");
+ return;
+ }
+ /* g_free(cmap); */
+
+ /* XXXXX Attempt to set cell color */
+ range = g_malloc(sizeof(GtkSheetRange));
+ if (range == NULL) {
+ g_error ("Can't malloc range");
+ return;
+ }
+ range->row0 = row;
+ range->rowi = row;
+ range->col0 = col;
+ range->coli = col;
+
+ /* Now set color */
+#ifdef DEBUG
+ printf("In x_gtksheet_set_cell_text_color, trying to set color.\n");
+#endif
+ gtk_sheet_range_set_foreground(sheet, range, color);
+#ifdef DEBUG
+ printf("In x_gtksheet_set_cell_text_color, done setting color.\n");
+#endif
+ g_free(color);
+ g_free(range);
+}
+
+
+
+
/* ==================== Private functions =================== */
/* The stuff below was copied over from testgtksheet.c */
@@ -543,8 +640,10 @@
}
/* ----------------------------------------------------------------- *
- * This fcn displays a text entry box. It is not needed now, but
- * may come in handy later.
+ * This fcn displays a text entry box at the
+ * top of the working area. It is removed since it
+ * is not needed now, but
+ * may come in handy later. Therefore I keep the code around.
* ----------------------------------------------------------------- */
void
show_entry(GtkWidget *widget, gpointer data)
1.10 +43 -17 eda/geda/gaf/gattrib/src/x_window.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: x_window.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gattrib/src/x_window.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- x_window.c 6 Aug 2006 16:45:28 -0000 1.9
+++ x_window.c 12 Aug 2006 18:58:48 -0000 1.10
@@ -83,8 +83,6 @@
/* note that the graphical widgets themselves (window, main_vbox, menu_bar)
* are globals defined in ../include/globals.h On pr_current I
* attach pointers to some of them here for future reference. */
-
- /* GdkFont *font; */
gint i;
/* ----- First initialize stuff in the top-level window ----- */
@@ -191,6 +189,9 @@
the accelerator table while generating menus.
*/
+#ifdef DEBUG
+ printf("In x_window_create_menu, about to create new item factory\n");
+#endif
item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>",
accel_group);
@@ -201,6 +202,7 @@
* to any data required in the callback. */
gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, pr_current);
+
/* Attach the new accelerator group to the window. */
/* SDB says: Here's where it comes in handy to have attached a pointer to
* the main window to the TOPLEVEL structure. */
@@ -229,9 +231,10 @@
void
x_window_add_items()
{
- int i, j;
- int num_rows, num_cols;
+ gint i, j;
+ gint num_rows, num_cols;
char *text;
+ gint visibility, show_name_value;
#ifdef DEBUG
fflush(stderr);
@@ -242,17 +245,23 @@
/* Do these sanity check to prevent later segfaults */
if (sheet_head->comp_count == 0) {
- fprintf(stderr, "\n\nNo components found in entire design! \nDo you have refdeses on your components? \nExiting. . . .\n");
+ fprintf(stderr, "\n\nNo components found in entire design!\n");
+ fprintf(stderr, "Do you have refdeses on your components? \n");
+ fprintf(stderr, "Exiting. . . .\n");
exit(0);
}
if (sheet_head->comp_attrib_count == 0) {
- fprintf(stderr, "\n\nNo configurable component attributes found in entire design! \nPlease attach at least some attributes before running gattrib. \nExiting. . . .\n");
+ fprintf(stderr, "\n\nNo configurable component attributes found in entire design!");
+ fprintf(stderr, "Please attach at least some attributes before running gattrib.\n");
+ fprintf(stderr, "Exiting. . . .\n");
exit(0);
}
if (sheet_head->pin_count == 0) {
- fprintf(stderr, "\n\nNo pins found on any components! \nPlease check your design. \nExiting. . . .\n");
+ fprintf(stderr, "\n\nNo pins found on any components!\n");
+ fprintf(stderr, "Please check your design.\n");
+ fprintf(stderr, "Exiting. . . .\n");
exit(0);
}
@@ -270,15 +279,19 @@
printf("In x_window_add_items, now load up the row and column labels.\n");
#endif
if (sheet_head->comp_count > 0 ) {
- x_gtksheet_add_row_labels(GTK_SHEET(sheets[0]), sheet_head->comp_count, sheet_head->master_comp_list_head);
- x_gtksheet_add_col_labels(GTK_SHEET(sheets[0]), sheet_head->comp_attrib_count, sheet_head->master_comp_attrib_list_head);
+ x_gtksheet_add_row_labels(GTK_SHEET(sheets[0]),
+ sheet_head->comp_count, sheet_head->master_comp_list_head);
+ x_gtksheet_add_col_labels(GTK_SHEET(sheets[0]),
+ sheet_head->comp_attrib_count, sheet_head->master_comp_attrib_list_head);
}
/* This is not ready. I need to implement net attributes */
if (sheet_head->net_count > 0 ) {
- x_gtksheet_add_row_labels(GTK_SHEET(sheets[1]), sheet_head->net_count, sheet_head->master_net_list_head);
- x_gtksheet_add_col_labels(GTK_SHEET(sheets[1]), sheet_head->net_attrib_count, sheet_head->master_net_attrib_list_head);
+ x_gtksheet_add_row_labels(GTK_SHEET(sheets[1]),
+ sheet_head->net_count, sheet_head->master_net_list_head);
+ x_gtksheet_add_col_labels(GTK_SHEET(sheets[1]),
+ sheet_head->net_attrib_count, sheet_head->master_net_attrib_list_head);
} else {
x_gtksheet_add_row_labels(GTK_SHEET(sheets[1]), 1, NULL);
x_gtksheet_add_col_labels(GTK_SHEET(sheets[1]), 1, NULL);
@@ -286,8 +299,10 @@
if (sheet_head->pin_count > 0 ) {
- x_gtksheet_add_row_labels(GTK_SHEET(sheets[2]), sheet_head->pin_count, sheet_head->master_pin_list_head);
- x_gtksheet_add_col_labels(GTK_SHEET(sheets[2]), sheet_head->pin_attrib_count, sheet_head->master_pin_attrib_list_head);
+ x_gtksheet_add_row_labels(GTK_SHEET(sheets[2]),
+ sheet_head->pin_count, sheet_head->master_pin_list_head);
+ x_gtksheet_add_col_labels(GTK_SHEET(sheets[2]),
+ sheet_head->pin_attrib_count, sheet_head->master_pin_attrib_list_head);
}
@@ -301,11 +316,15 @@
for (j = 0; j < num_cols; j++) {
if ( (sheet_head->component_table)[i][j].attrib_value ) { /* NULL = no entry */
text = (gchar *) g_strdup( (sheet_head->component_table)[i][j].attrib_value );
- x_gtksheet_add_cell_item( GTK_SHEET(sheets[0]), i, j, (gchar *) text );
+ visibility = (sheet_head->component_table)[i][j].visibility;
+ show_name_value = (sheet_head->component_table)[i][j].show_name_value;
+ x_gtksheet_add_cell_item( GTK_SHEET(sheets[0]), i, j, (gchar *) text,
+ visibility, show_name_value );
g_free(text);
}
}
}
+ /* Do I really need these shows here? */
gtk_widget_show( GTK_WIDGET(sheets[0]) );
gtk_widget_show( GTK_WIDGET(scrolled_windows[0]) );
@@ -320,11 +339,15 @@
for (j = 0; j < num_cols; j++) {
if ( (sheet_head->net_table)[i][j].attrib_value ) { /* NULL = no entry */
text = (gchar *) g_strdup( (sheet_head->net_table)[i][j].attrib_value );
- x_gtksheet_add_cell_item( GTK_SHEET(sheets[1]), i, j, (gchar *) text );
+ visibility = (sheet_head->net_table)[i][j].visibility;
+ show_name_value = (sheet_head->component_table)[i][j].show_name_value;
+ x_gtksheet_add_cell_item( GTK_SHEET(sheets[1]), i, j, (gchar *) text,
+ visibility, show_name_value );
g_free(text);
}
}
}
+ /* Do I really need these shows here? */
if (sheet_head->net_count > 0) {
gtk_widget_show( GTK_WIDGET(sheets[1]) );
gtk_widget_show( GTK_WIDGET(scrolled_windows[1]) );
@@ -341,11 +364,14 @@
for (j = 0; j < num_cols; j++) {
if ( (sheet_head->pin_table)[i][j].attrib_value ) { /* NULL = no entry */
text = (gchar *) g_strdup( (sheet_head->pin_table)[i][j].attrib_value );
- x_gtksheet_add_cell_item( GTK_SHEET(sheets[2]), i, j, (gchar *) text );
+ /* pins have no visibility attributes, must therefore provide default. */
+ x_gtksheet_add_cell_item( GTK_SHEET(sheets[2]), i, j, (gchar *) text,
+ VISIBLE, SHOW_VALUE );
g_free(text);
}
}
}
+ /* Do I really need these shows here? */
if (sheet_head->pin_count > 0) {
gtk_widget_show( GTK_WIDGET(sheets[2]) );
gtk_widget_show( GTK_WIDGET(scrolled_windows[2]) );
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs