1 /* -*- Mode: C; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3 -*- */ 2 3 /* 4 * GImageView 5 * Copyright (C) 2001 Takuro Ashie 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 * 21 * $Id: gimv_zlist.h,v 1.4 2004/04/11 05:07:28 makeinu Exp $ 22 */ 23 24 /* 25 * These codes are mostly taken from Another X image viewer. 26 * 27 * Another X image viewer Author: 28 * David Ramboz <dramboz@users.sourceforge.net> 29 */ 30 31 32 #ifndef _GIMV_ZLIST_H_ 33 #define _GIMV_ZLIST_H_ 34 35 #ifdef HAVE_CONFIG_H 36 #include "config.h" 37 #endif 38 39 #include "gimv_scrolled.h" 40 41 #define GIMV_TYPE_ZLIST (gimv_zlist_get_type ()) 42 #define GIMV_ZLIST(widget) (GTK_CHECK_CAST ((widget), GIMV_TYPE_ZLIST, GimvZList)) 43 #define GIMV_ZLIST_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMV_TYPE_ZLIST, GimvZListClass)) 44 #define GIMV_IS_ZLIST(widget) (GTK_CHECK_TYPE ((widget), GIMV_TYPE_ZLIST)) 45 #define GIMV_IS_ZLIST_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMV_TYPE_ZLIST)) 46 47 enum { 48 GIMV_ZLIST_HORIZONTAL = 1 << 1, 49 GIMV_ZLIST_1 = 1 << 2, 50 GIMV_ZLIST_USES_DND = 1 << 3, /* not implemented yet */ 51 GIMV_ZLIST_HIGHLIGHTED = 1 << 4 52 }; 53 54 typedef enum { 55 GIMV_ZLIST_REGION_SELECT_OFF, 56 GIMV_ZLIST_REGION_SELECT_NORMAL, 57 GIMV_ZLIST_REGION_SELECT_EXPAND, /* shift mask */ 58 GIMV_ZLIST_REGION_SELECT_TOGGLE /* control mask */ 59 } GimvZListRegionSelectMode; 60 61 typedef struct _GimvZList GimvZList; 62 typedef struct _GimvZListClass GimvZListClass; 63 64 65 struct _GimvZList 66 { 67 GimvScrolled scrolled; 68 69 guint flags; 70 71 gint cell_width; 72 gint cell_height; 73 74 gint rows; 75 gint columns; 76 77 GArray *cells; 78 gint cell_count; 79 80 gint selection_mode; 81 GList *selection; 82 gint focus; 83 gint anchor; 84 85 GimvZListRegionSelectMode region_select; 86 GdkGC *region_line_gc; 87 GList *selection_mask; 88 89 gint cell_x_pad, cell_y_pad; 90 gint x_pad, y_pad; 91 92 GtkWidget *entered_cell; 93 }; 94 95 struct _GimvZListClass 96 { 97 GimvScrolledClass parent_class; 98 99 void (*clear) (GimvZList *list); 100 void (*cell_draw) (GimvZList *list, 101 gpointer cell, 102 GdkRectangle *cell_area, 103 GdkRectangle *area); 104 void (*cell_size_request) (GimvZList *list, 105 gpointer cell, 106 GtkRequisition *requisition); 107 void (*cell_draw_focus) (GimvZList *list, 108 gpointer cell, 109 GdkRectangle *cell_area); 110 void (*cell_draw_default) (GimvZList *list, 111 gpointer cell, 112 GdkRectangle *cell_area); 113 void (*cell_select) (GimvZList *list, 114 gint index); 115 void (*cell_unselect) (GimvZList *list, 116 gint index); 117 }; 118 119 120 GtkType gimv_zlist_get_type (void); 121 122 void gimv_zlist_construct (GimvZList *list, 123 gint flags); 124 GtkWidget *gimv_zlist_new (guint flags); 125 void gimv_zlist_set_to_vertical (GimvZList *zlist); 126 void gimv_zlist_set_to_horizontal (GimvZList *zlist); 127 guint gimv_zlist_add (GimvZList *list, 128 gpointer cell); 129 guint gimv_zlist_insert (GimvZList *list, 130 guint pos, 131 gpointer cell); 132 void gimv_zlist_remove (GimvZList *list, 133 gpointer cell); 134 void gimv_zlist_clear (GimvZList *list); 135 void gimv_zlist_set_selection_mode (GimvZList *list, 136 GtkSelectionMode mode); 137 void gimv_zlist_set_cell_padding (GimvZList *list, 138 gint x_pad, 139 gint y_pad); 140 void gimv_zlist_set_cell_size (GimvZList *list, 141 gint width, 142 gint height); 143 void gimv_zlist_set_1 (GimvZList *list, 144 gint one); 145 gpointer gimv_zlist_cell_from_xy (GimvZList *list, 146 gint x, 147 gint y); 148 gint gimv_zlist_cell_index_from_xy (GimvZList *list, 149 gint x, 150 gint y); 151 void gimv_zlist_cell_select (GimvZList *list, 152 gint index); 153 void gimv_zlist_cell_unselect (GimvZList *list, 154 gint index); 155 void gimv_zlist_cell_toggle (GimvZList *list, 156 gint index); 157 void gimv_zlist_unselect_all (GimvZList *list); 158 void gimv_zlist_extend_selection (GimvZList *list, 159 gint to); 160 void gimv_zlist_cell_select_by_region (GimvZList *list, 161 guint start_col, 162 guint start_row, 163 guint end_col, 164 guint end_row); 165 void gimv_zlist_cell_select_by_pixel_region (GimvZList *list, 166 gint start_x, 167 gint start_y, 168 gint end_x, 169 gint end_y); 170 void gimv_zlist_set_selection_mask (GimvZList *list, 171 GList *mask_list); 172 void gimv_zlist_unset_selection_mask (GimvZList *list); 173 void gimv_zlist_moveto (GimvZList *list, 174 gint index); 175 void gimv_zlist_cell_set_focus (GimvZList *list, 176 gint index); 177 void gimv_zlist_cell_unset_focus (GimvZList *list); 178 179 gboolean gimv_zlist_get_cell_area (GimvZList *list, 180 gint index, 181 GdkRectangle *area); 182 183 /* protected */ 184 #define GIMV_ZLIST_CELL_FROM_INDEX(list, index) \ 185 (g_array_index (GIMV_ZLIST(list)->cells, gpointer, index)) 186 187 void gimv_zlist_draw_cell (GimvZList *list, 188 gint index); 189 gint gimv_zlist_cell_index (GimvZList *list, 190 gpointer cell); 191 gint gimv_zlist_update_cell_size (GimvZList *list, 192 gpointer cell); 193 194 #endif /* _GIMV_ZLIST_H_ */ 195