| 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 |
|
| 49 |
int d_numVisible; |
| 50 |
|
| 51 |
GtkWidget* d_menu_ptr; |
| 52 |
GtkWidget* d_menu_button_ptr; |
| 53 |
GdkPixbuf* d_menu_mask_ptr; |
| 54 |
GtkWidget* d_menu_pixmap_widget_ptr; |
| 55 |
|
| 56 |
GCallback d_onclick_function; |
| 57 |
gpointer d_onclick_data; |
| 58 |
|
| 59 |
AiksaurusGTK_menudata* d_menu_data_ptr; |
| 60 |
AiksaurusGTK_strlist* d_menu_options_ptr; |
| 61 |
|
| 62 |
// Callback Functions |
| 63 |
|
| 64 |
static void cbHover(GtkWidget* w, gpointer data); |
| 65 |
static void cbUnhover(GtkWidget* w, gpointer data); |
| 66 |
static void cbPopMenu(GtkWidget* w, gpointer data); |
| 67 |
static void cbPopupFunction(GtkMenu* menu, int* x, int* y, gboolean* notUsedBool, gpointer data); |
| 68 |
static void cbSelectionDone(GtkMenuShell* menushell, gpointer data); |
| 69 |
static void cbMenuActivate(GtkMenuItem* item, gpointer data); |
| 70 |
|
| 71 |
// Mouse Hovering Actions |
| 72 |
|
| 73 |
void handleRelief(); |
| 74 |
void hover(); |
| 75 |
void unhover(); |
| 76 |
|
| 77 |
|
| 78 |
// Menu Activation and Deactivation |
| 79 |
|
| 80 |
void popMenu(); |
| 81 |
void popupFunction(int* x, int* y); |
| 82 |
void selectionDone(); |
| 83 |
void menuActivate(gpointer item); |
| 84 |
|
| 85 |
void menuCreate(); |
| 86 |
|
| 87 |
|
| 88 |
// Prevent Copying and Assignment |
| 89 |
|
| 90 |
AiksaurusGTK_picbutton(const AiksaurusGTK_picbutton&); |
| 91 |
const AiksaurusGTK_picbutton& operator=(const AiksaurusGTK_picbutton&); |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
public: |
| 96 |
|
| 97 |
// Construction and Destruction |
| 98 |
|
| 99 |
AiksaurusGTK_picbutton(GtkWidget *window, const char** normal); |
| 100 |
AiksaurusGTK_picbutton(GtkWidget *window, const char* stock); |
| 101 |
~AiksaurusGTK_picbutton(); |
| 102 |
|
| 103 |
|
| 104 |
// Manipulation |
| 105 |
|
| 106 |
void setHoverPicture(const char** hover); |
| 107 |
void addMenu(const AiksaurusGTK_strlist& options, GCallback onClick, gpointer onClickData); |
| 108 |
void updateMenuOptions(); |
| 109 |
void limitVisibleOptions(int numVisible); |
| 110 |
|
| 111 |
void disable(); |
| 112 |
void enable(); |
| 113 |
|
| 114 |
GtkWidget* getButton(); |
| 115 |
GtkWidget* getMenuButton(); |
| 116 |
}; |
| 117 |
|
| 118 |
#endif // INCLUDED_GPL_JARED_AIKSAURUSGTK_PICBUTTON_H |