1 /* 2 * $Id: button.h,v 1.13 2016/01/31 21:08:37 tom Exp $ 3 */ 4 5 #ifndef CDKINCLUDES 6 #ifndef CDKBUTTON_H 7 #define CDKBUTTON_H 1 8 9 #include "cdk.h" 10 11 #ifndef CDK_H 12 #define CDKINCLUDES 13 #include <cdk.h> 14 #undef CDKINCLUDES 15 #include <binding.h> 16 #include <cdkscreen.h> 17 #include <cdk_objs.h> 18 #endif 19 20 /* 21 * Changes 2002-2012,2016 copyright Thomas E. Dickey 22 * 23 * Copyright 1999, Grant Edwards 24 * All rights reserved. 25 * 26 * Redistribution and use in source and binary forms, with or without 27 * modification, are permitted provided that the following conditions 28 * are met: 29 * 1. Redistributions of source code must retain the above copyright 30 * notice, this list of conditions and the following disclaimer. 31 * 2. Redistributions in binary form must reproduce the above copyright 32 * notice, this list of conditions and the following disclaimer in the 33 * documentation and/or other materials provided with the distribution. 34 * 3. All advertising materials mentioning features or use of this software 35 * must display the following acknowledgment: 36 * This product includes software developed by Grant Edwards 37 * and contributors. 38 * 4. Neither the name of Grant Edwards, nor the names of contributors 39 * may be used to endorse or promote products derived from this software 40 * without specific prior written permission. 41 * 42 * THIS SOFTWARE IS PROVIDED BY GRANT EDWARDS AND CONTRIBUTORS ``AS IS'' AND 43 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 44 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 45 * ARE DISCLAIMED. IN NO EVENT SHALL GRANT EDWARDS OR CONTRIBUTORS BE LIABLE 46 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 47 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 48 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 49 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 50 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 51 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 52 * SUCH DAMAGE. 53 */ 54 55 /* 56 * Declare any definitions you need to make. 57 */ 58 typedef struct SButton CDKBUTTON; 59 60 typedef void (*tButtonCallback)(struct SButton *button); 61 62 63 /* 64 * Declare the CDK label structure. 65 */ 66 struct SButton { 67 CDKOBJS obj; 68 WINDOW * parent; 69 WINDOW * win; 70 WINDOW * shadowWin; 71 chtype * info; 72 tButtonCallback callback; 73 int infoLen; 74 int infoPos; 75 int boxWidth; 76 int boxHeight; 77 int xpos; 78 int ypos; 79 int rows; 80 EExitType exitType; 81 boolean shadow; 82 chtype highlight; 83 void * callbackData; 84 }; 85 86 /* 87 * This sets the callback function of the button's argument. 88 */ 89 #define setCDKButtonCBArgs(button, argPtr) \ 90 ((button)->callbackData = (void*)(argPtr)) 91 92 #define getCDKButtonCBArgs(button, argType) \ 93 ((argType) ((button)->callbackData)) 94 95 96 /* 97 * This sets the button's highlight mode. 98 */ 99 #define CDKButtonHighlightOf(button) \ 100 ((button)->highlight) 101 102 #define setCDKButtonHighlight(button, highlightMode) \ 103 (CDKButtonHighlightOf(button) = (highlightMode)) 104 105 #define getCDKButtonHighlight(button) \ 106 CDKButtonHighlightOf(button) 107 108 /* 109 * This creates a new CDK button widget. 110 */ 111 CDKBUTTON *newCDKButton ( 112 CDKSCREEN * /* screen */, 113 int /* xPos */, 114 int /* yPos */, 115 const char * /* button text */, 116 tButtonCallback /* callback function */, 117 boolean /* Box */, 118 boolean /* shadow */); 119 120 /* 121 * This was added to make the builder simpler. All this will 122 * do is call drawCDKLabel. 123 */ 124 int activateCDKButton ( 125 CDKBUTTON * /* button */, 126 chtype * /* actions */); 127 128 /* 129 * This injects a single character into the widget. 130 */ 131 #define injectCDKButton(obj,input) injectCDKObject(obj,input,Int) 132 133 /* 134 * This sets multiple attributes of the widget. 135 */ 136 void setCDKButton ( 137 CDKBUTTON * /* button */, 138 const char * /* text */, 139 boolean /* Box */); 140 141 /* 142 * This sets the contents of the button. 143 */ 144 void setCDKButtonMessage ( 145 CDKBUTTON * /* button */, 146 const char * /* mesg */); 147 148 chtype *getCDKButtonMessage ( 149 CDKBUTTON *); 150 151 /* 152 * This sets the box attribute of the widget. 153 */ 154 void setCDKButtonBox ( 155 CDKBUTTON * /* button */, 156 boolean /* Box */); 157 158 boolean getCDKButtonBox ( 159 CDKBUTTON * /* button */); 160 161 /* 162 * This draws the button. 163 */ 164 #define drawCDKButton(obj,Box) drawCDKObject(obj,Box) 165 166 /* 167 * These set the drawing characters of the widget. 168 */ 169 #define setCDKButtonULChar(w,c) setULCharOf(w,c) 170 #define setCDKButtonURChar(w,c) setURCharOf(w,c) 171 #define setCDKButtonLLChar(w,c) setLLCharOf(w,c) 172 #define setCDKButtonLRChar(w,c) setLRCharOf(w,c) 173 #define setCDKButtonVerticalChar(w,c) setVTCharOf(w,c) 174 #define setCDKButtonHorizontalChar(w,c) setHZCharOf(w,c) 175 #define setCDKButtonBoxAttribute(w,c) setBXAttrOf(w,c) 176 177 /* 178 * This sets the background color of the widget. 179 */ 180 #define setCDKButtonBackgroundColor(w,c) setCDKObjectBackgroundColor(ObjOf(w),c) 181 182 /* 183 * This sets the background attribute of the widget. 184 */ 185 #define setCDKButtonBackgroundAttrib(w,c) setBKAttrOf(w,c) 186 187 /* 188 * This erases the button. 189 */ 190 #define eraseCDKButton(obj) eraseCDKObject(obj) 191 192 /* 193 * This destroys the button and the memory used by it. 194 */ 195 #define destroyCDKButton(obj) destroyCDKObject(obj) 196 197 /* 198 * This moves the button to a new screen location. 199 */ 200 #define moveCDKButton(obj,xpos,ypos,relative,refresh) moveCDKObject(obj,xpos,ypos,relative,refresh) 201 202 /* 203 * This allows the user to interactively position the button. 204 */ 205 void positionCDKButton (CDKBUTTON *); 206 207 #endif /* CDKBUTTON_H */ 208 #endif /* CDKINCLUDES */ 209