Commit 79f69b16 authored by Jay Painter's avatar Jay Painter

GtkCList updates: Click-Drag column resizing, a couple of layout

fixes, show/hide functions for the title buttons, and I've replaced
gtk_clist_new with gtk_clist_new_with_titles.  gtk_clist_new will
create a list without title bars which can be added later by calling
gtk_clist_set_column_(title/widget) for the column button you want to add.
A column button for column 0 always exhists, and buttons span all columns
until they come to the next exhisting button, or the last column. -Jay
parent 1a8765e6
This diff is collapsed.
......@@ -27,7 +27,6 @@
#include <gtk/gtkhscrollbar.h>
#include <gtk/gtkvscrollbar.h>
#ifdef __cplusplus
extern "C"
{
......@@ -38,7 +37,8 @@ enum
{
CLIST_FROZEN = 1 << 0,
CLIST_IN_DRAG = 1 << 1,
CLIST_ROW_HEIGHT_SET = 1 << 2
CLIST_ROW_HEIGHT_SET = 1 << 2,
CLIST_SHOW_TITLES = 1 << 3
};
/* cell types */
......@@ -62,6 +62,7 @@ typedef enum
#define GTK_CLIST_FROZEN(clist) (GTK_CLIST_FLAGS (clist) & CLIST_FROZEN)
#define GTK_CLIST_IN_DRAG(clist) (GTK_CLIST_FLAGS (clist) & CLIST_IN_DRAG)
#define GTK_CLIST_ROW_HEIGHT_SET(clist) (GTK_CLIST_FLAGS (clist) & CLIST_ROW_HEIGHT_SET)
#define GTK_CLIST_SHOW_TITLES(clist) (GTK_CLIST_FLAGS (clist) & CLIST_SHOW_TITLES)
/* pointer casting for cells */
#define GTK_CELL_TEXT(cell) (((GtkCellText *) &(cell)))
......@@ -172,6 +173,8 @@ struct _GtkCListColumn
GdkRectangle area;
GtkWidget *button;
GdkWindow *window;
gint width;
GtkJustification justification;
};
......@@ -261,8 +264,9 @@ struct _GtkCell
guint gtk_clist_get_type (void);
/* create a new GtkCList */
GtkWidget *gtk_clist_new (int columns,
gchar * titles[]);
GtkWidget *gtk_clist_new (int columns);
GtkWidget *gtk_clist_new_with_titles (int columns,
gchar * titles[]);
/* set the border style of the clist */
void gtk_clist_set_border (GtkCList * clist,
......@@ -285,6 +289,10 @@ void gtk_clist_set_policy (GtkCList * clist,
void gtk_clist_freeze (GtkCList * clist);
void gtk_clist_thaw (GtkCList * clist);
/* show and hide the column title buttons */
void gtk_clist_column_titles_show (GtkCList * clist);
void gtk_clist_column_titles_hide (GtkCList * clist);
/* set the title in the column title button */
void gtk_clist_set_column_title (GtkCList * clist,
gint column,
......
......@@ -1658,6 +1658,18 @@ remove_row_clist (GtkWidget *widget, gpointer data)
clist_rows--;
}
void
show_titles_clist (GtkWidget *widget, gpointer data)
{
gtk_clist_column_titles_show (GTK_CLIST (data));
}
void
hide_titles_clist (GtkWidget *widget, gpointer data)
{
gtk_clist_column_titles_hide (GTK_CLIST (data));
}
void
select_clist (GtkWidget *widget,
gint row,
......@@ -1736,10 +1748,11 @@ create_clist ()
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
gtk_widget_show (box2);
/* create this here so we have a pointer to throw at the
/* create GtkCList here so we have a pointer to throw at the
* button callbacks -- more is done with it later */
clist = gtk_clist_new (TESTGTK_CLIST_COLUMNS, titles);
clist = gtk_clist_new_with_titles (TESTGTK_CLIST_COLUMNS, titles);
/* control buttons */
button = gtk_button_new_with_label ("Add 1,000 Rows");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
......@@ -1781,12 +1794,38 @@ create_clist ()
gtk_widget_show (button);
/* second layer of buttons */
box2 = gtk_hbox_new (FALSE, 10);
gtk_container_border_width (GTK_CONTAINER (box2), 10);
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
gtk_widget_show (box2);
button = gtk_button_new_with_label ("Show Title Buttons");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (button),
"clicked",
(GtkSignalFunc) show_titles_clist,
(gpointer) clist);
gtk_widget_show (button);
button = gtk_button_new_with_label ("Hide Title Buttons");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (button),
"clicked",
(GtkSignalFunc) hide_titles_clist,
(gpointer) clist);
gtk_widget_show (button);
/* vbox for the list itself */
box2 = gtk_vbox_new (FALSE, 10);
gtk_container_border_width (GTK_CONTAINER (box2), 10);
gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
gtk_widget_show (box2);
/*
* the rest of the clist configuration
*/
......
......@@ -1658,6 +1658,18 @@ remove_row_clist (GtkWidget *widget, gpointer data)
clist_rows--;
}
void
show_titles_clist (GtkWidget *widget, gpointer data)
{
gtk_clist_column_titles_show (GTK_CLIST (data));
}
void
hide_titles_clist (GtkWidget *widget, gpointer data)
{
gtk_clist_column_titles_hide (GTK_CLIST (data));
}
void
select_clist (GtkWidget *widget,
gint row,
......@@ -1736,10 +1748,11 @@ create_clist ()
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
gtk_widget_show (box2);
/* create this here so we have a pointer to throw at the
/* create GtkCList here so we have a pointer to throw at the
* button callbacks -- more is done with it later */
clist = gtk_clist_new (TESTGTK_CLIST_COLUMNS, titles);
clist = gtk_clist_new_with_titles (TESTGTK_CLIST_COLUMNS, titles);
/* control buttons */
button = gtk_button_new_with_label ("Add 1,000 Rows");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
......@@ -1781,12 +1794,38 @@ create_clist ()
gtk_widget_show (button);
/* second layer of buttons */
box2 = gtk_hbox_new (FALSE, 10);
gtk_container_border_width (GTK_CONTAINER (box2), 10);
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
gtk_widget_show (box2);
button = gtk_button_new_with_label ("Show Title Buttons");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (button),
"clicked",
(GtkSignalFunc) show_titles_clist,
(gpointer) clist);
gtk_widget_show (button);
button = gtk_button_new_with_label ("Hide Title Buttons");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (button),
"clicked",
(GtkSignalFunc) hide_titles_clist,
(gpointer) clist);
gtk_widget_show (button);
/* vbox for the list itself */
box2 = gtk_vbox_new (FALSE, 10);
gtk_container_border_width (GTK_CONTAINER (box2), 10);
gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
gtk_widget_show (box2);
/*
* the rest of the clist configuration
*/
......
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