1 /* 2 * AiksaurusGTK - A GTK interface to the AikSaurus library 3 * Copyright (C) 2001 by Jared Davis 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 18 * 02111-1307, USA. 19 */ 20 21 #ifndef INCLUDED_GPL_JARED_AIKSAURUSGTK_PICBUTTON_H 22 #define INCLUDED_GPL_JARED_AIKSAURUSGTK_PICBUTTON_H 23 24 #include <glib.h> 25 #include <gtk/gtk.h> 26 27 #include "AiksaurusGTK_strlist.h" 28 29 class AiksaurusGTK_menudata; 30 class AiksaurusGTK_picbutton 31 { 32 private: 33 34 // Possible button states 35 36 bool d_hashover; 37 bool d_hasmenu; 38 bool d_mouseover; 39 bool d_menushowing; 40 bool d_enabled; 41 42 43 // Member Widgets 44 45 GtkWidget* d_window_ptr; 46 GtkWidget* d_button_ptr; 47 GtkWidget* d_pixmap_ptr; 48 GtkStyle* d_style_ptr; 49 50 int d_numVisible; 51 52 GtkWidget* d_menu_ptr; 53 GtkWidget* d_menu_button_ptr; 54 GdkBitmap* d_menu_mask_ptr; 55 GtkWidget* d_menu_pixmap_widget_ptr; 56 57 GtkSignalFunc d_onclick_function; 58 gpointer d_onclick_data; 59 60 AiksaurusGTK_menudata* d_menu_data_ptr; 61 AiksaurusGTK_strlist* d_menu_options_ptr; 62 63 // Callback Functions 64 65 static void cbHover(GtkWidget* w, gpointer data); 66 static void cbUnhover(GtkWidget* w, gpointer data); 67 static void cbPopMenu(GtkWidget* w, gpointer data); 68 static void cbPopupFunction(GtkMenu* menu, int* x, int* y, gboolean* notUsedBool, gpointer data); 69 static void cbSelectionDone(GtkMenuShell* menushell, gpointer data); 70 static void cbMenuActivate(GtkMenuItem* item, gpointer data); 71 72 // Mouse Hovering Actions 73 74 void handleRelief(); 75 void hover(); 76 void unhover(); 77 78 79 // Menu Activation and Deactivation 80 81 void popMenu(); 82 void popupFunction(int* x, int* y); 83 void selectionDone(); 84 void menuActivate(gpointer item); 85 86 void menuCreate(); 87 88 89 // Prevent Copying and Assignment 90 91 AiksaurusGTK_picbutton(const AiksaurusGTK_picbutton&); 92 const AiksaurusGTK_picbutton& operator=(const AiksaurusGTK_picbutton&); 93 94 95 96 public: 97 98 // Construction and Destruction 99 100 AiksaurusGTK_picbutton(GtkWidget *window, const char** normal); 101 AiksaurusGTK_picbutton(GtkWidget *window, const char* stock); 102 ~AiksaurusGTK_picbutton(); 103 104 105 // Manipulation 106 107 void setHoverPicture(const char** hover); 108 void addMenu(const AiksaurusGTK_strlist& options, GtkSignalFunc onClick, gpointer onClickData); 109 void updateMenuOptions(); 110 void limitVisibleOptions(int numVisible); 111 112 void disable(); 113 void enable(); 114 115 GtkWidget* getButton(); 116 GtkWidget* getMenuButton(); 117 }; 118 119 #endif // INCLUDED_GPL_JARED_AIKSAURUSGTK_PICBUTTON_H 120