1 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */ 2 3 /* AbiSource Program Utilities 4 * Copyright (C) 1998 AbiSource, Inc. 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 * 02110-1301 USA. 20 */ 21 22 #ifndef EV_TOOLBAR_ACTIONS_H 23 #define EV_TOOLBAR_ACTIONS_H 24 25 /**************************************************************** 26 ***************************************************************** 27 ** This file defines a framework for the set of actions which 28 ** may be bound to a Toolbar Id. This binding is independent of 29 ** the actual toolbar containing the item and actual toolbar layout. 30 ** 31 ** We create one EV_Toolbar_Action per toolbar-item per application. 32 ** 33 ** We create one EV_Toolbar_ActionSet per application. 34 ** 35 ***************************************************************** 36 ****************************************************************/ 37 38 #include "ut_types.h" 39 #include "xap_Types.h" 40 #include "xav_Listener.h" 41 42 class XAP_App; 43 class AV_View; 44 class EV_Toolbar_Label; 45 46 47 /*****************************************************************/ 48 49 typedef enum _ev_Toolbar_ItemState /* values may be ORed */ 50 { 51 EV_TIS_ZERO = 0x00, 52 EV_TIS_Gray = 0x01, /* should be grayed */ 53 EV_TIS_Toggled = 0x02, /* should be pressed down */ 54 EV_TIS_UseString = 0x04, /* should reference pszState */ 55 EV_TIS_Hidden = 0x08 /* stronger version of Gray, you want to hide if possible */ 56 57 } EV_Toolbar_ItemState; 58 59 typedef EV_Toolbar_ItemState ( EV_GetToolbarItemState_Fn )(AV_View * pAV_View, XAP_Toolbar_Id id, const char ** pszState); 60 typedef EV_Toolbar_ItemState (*EV_GetToolbarItemState_pFn)(AV_View * pAV_View, XAP_Toolbar_Id id, const char ** pszState); 61 #ifdef ABI_DLL 62 #define Defun_EV_GetToolbarItemState_Fn(fn) EV_Toolbar_ItemState fn(AV_View * pAV_View, XAP_Toolbar_Id id, const char ** pszState) 63 #else 64 #define Defun_EV_GetToolbarItemState_Fn(fn) ABI_EXPORT EV_Toolbar_ItemState fn(AV_View * pAV_View, XAP_Toolbar_Id id, const char ** pszState) 65 #endif 66 67 #define EV_TIS_ShouldBeGray(tis) (((tis) & EV_TIS_Gray)!=0) 68 #define EV_TIS_ShouldBeHidden(tis) (((tis) & EV_TIS_Hidden)!=0) 69 #define EV_TIS_ShouldBeToggled(tis) (((tis) & EV_TIS_Toggled)!=0) 70 #define EV_TIS_ShouldUseString(tis) (((tis) & EV_TIS_UseString)!=0) 71 72 /*****************************************************************/ 73 74 typedef enum _ev_Toolbar_ItemType 75 { 76 EV_TBIT_BOGUS = 0, 77 EV_TBIT_PushButton = 1, /* simple push to fire */ 78 EV_TBIT_ToggleButton = 2, /* push-on/push-off */ 79 EV_TBIT_GroupButton = 3, /* like a Toggle, but w/group semantics */ 80 EV_TBIT_EditText = 4, /* text entry field */ 81 EV_TBIT_DropDown = 5, /* list box w/no text entry */ 82 EV_TBIT_ComboBox = 6, /* list box w/ text entry */ 83 EV_TBIT_StaticLabel = 7, /* a static control */ 84 EV_TBIT_Spacer = 8, /* for extra space between buttons */ 85 EV_TBIT_ColorFore = 9, /* control to set the foreground color */ 86 EV_TBIT_ColorBack = 10, /* control to set the background color */ 87 EV_TBIT_MenuButton = 11 /* Button that brings up a menu */ 88 89 } EV_Toolbar_ItemType; 90 91 /*****************************************************************/ 92 93 class ABI_EXPORT EV_Toolbar_Action 94 { 95 public: 96 EV_Toolbar_Action(XAP_Toolbar_Id id, 97 EV_Toolbar_ItemType type, 98 const char * szMethodName, 99 AV_ChangeMask maskOfInterest, 100 EV_GetToolbarItemState_pFn pfnGetState); 101 ~EV_Toolbar_Action(void); 102 103 XAP_Toolbar_Id getToolbarId(void) const; 104 EV_Toolbar_ItemType getItemType(void) const; 105 const char * getMethodName(void) const; 106 AV_ChangeMask getChangeMaskOfInterest(void) const; 107 EV_Toolbar_ItemState getToolbarItemState(AV_View * pView, const char ** pszState) const; 108 109 protected: 110 XAP_Toolbar_Id m_id; 111 EV_Toolbar_ItemType m_type; 112 char * m_szMethodName; /* name of method to invoke */ 113 114 AV_ChangeMask m_maskOfInterest; 115 EV_GetToolbarItemState_pFn m_pfnGetState; 116 }; 117 118 /*****************************************************************/ 119 120 class ABI_EXPORT EV_Toolbar_ActionSet /* a glorified array with bounds checking */ 121 { 122 public: 123 EV_Toolbar_ActionSet(XAP_Toolbar_Id first, XAP_Toolbar_Id last); 124 ~EV_Toolbar_ActionSet(void); 125 126 bool setAction(XAP_Toolbar_Id id, 127 EV_Toolbar_ItemType type, 128 const char * szMethodName, 129 AV_ChangeMask maskOfInterest, 130 EV_GetToolbarItemState_pFn pfnGetState); 131 EV_Toolbar_Action * getAction(XAP_Toolbar_Id id) const; 132 133 protected: 134 EV_Toolbar_Action ** m_actionTable; 135 XAP_Toolbar_Id m_first; 136 XAP_Toolbar_Id m_last; 137 }; 138 139 #endif /* EV_TOOLBAR_ACTIONS_H */ 140