1 /* 2 * This file is part of d-handy. 3 * 4 * d-handy is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * d-handy 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 Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with d-handy; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 module handy.Keypad; 20 21 private import glib.ConstructionException; 22 private import gobject.ObjectG; 23 private import gtk.Bin; 24 private import gtk.BuildableIF; 25 private import gtk.BuildableT; 26 private import gtk.Entry; 27 private import gtk.Widget; 28 private import handy.c.functions; 29 public import handy.c.types; 30 31 32 /** */ 33 public class Keypad : Bin 34 { 35 /** the main Gtk struct */ 36 protected HdyKeypad* hdyKeypad; 37 38 /** Get the main Gtk struct */ 39 public HdyKeypad* getKeypadStruct(bool transferOwnership = false) 40 { 41 if (transferOwnership) 42 ownedRef = false; 43 return hdyKeypad; 44 } 45 46 /** the main Gtk struct as a void* */ 47 protected override void* getStruct() 48 { 49 return cast(void*)hdyKeypad; 50 } 51 52 /** 53 * Sets our main struct and passes it to the parent class. 54 */ 55 public this (HdyKeypad* hdyKeypad, bool ownedRef = false) 56 { 57 this.hdyKeypad = hdyKeypad; 58 super(cast(GtkBin*)hdyKeypad, ownedRef); 59 } 60 61 62 /** */ 63 public static GType getType() 64 { 65 return hdy_keypad_get_type(); 66 } 67 68 /** 69 * Create a new #HdyKeypad widget. 70 * 71 * Params: 72 * symbolsVisible = whether the hash, plus, and asterisk symbols should be visible 73 * lettersVisible = whether the letters below the digits should be visible 74 * 75 * Returns: the newly created #HdyKeypad widget 76 * 77 * Since: 0.0.12 78 * 79 * Throws: ConstructionException GTK+ fails to create the object. 80 */ 81 public this(bool symbolsVisible, bool lettersVisible) 82 { 83 auto __p = hdy_keypad_new(symbolsVisible, lettersVisible); 84 85 if(__p is null) 86 { 87 throw new ConstructionException("null returned by new"); 88 } 89 90 this(cast(HdyKeypad*) __p); 91 } 92 93 /** 94 * Returns the amount of space between the columns of @self. 95 * 96 * Returns: the column spacing of @self 97 * 98 * Since: 1.0 99 */ 100 public uint getColumnSpacing() 101 { 102 return hdy_keypad_get_column_spacing(hdyKeypad); 103 } 104 105 /** 106 * Returns the widget for the lower right corner (or left, in RTL locales) of 107 * @self. 108 * 109 * Returns: the end action widget 110 * 111 * Since: 1.0 112 */ 113 public Widget getEndAction() 114 { 115 auto __p = hdy_keypad_get_end_action(hdyKeypad); 116 117 if(__p is null) 118 { 119 return null; 120 } 121 122 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 123 } 124 125 /** 126 * Get the connected entry. See hdy_keypad_set_entry() for details. 127 * 128 * Returns: the set #GtkEntry or %NULL if no widget was set 129 * 130 * Since: 1.0 131 */ 132 public Entry getEntry() 133 { 134 auto __p = hdy_keypad_get_entry(hdyKeypad); 135 136 if(__p is null) 137 { 138 return null; 139 } 140 141 return ObjectG.getDObject!(Entry)(cast(GtkEntry*) __p); 142 } 143 144 /** 145 * Returns whether @self should display the standard letters below the digits on 146 * its buttons. 147 * 148 * Returns: whether the letters below the digits should be visible 149 * 150 * Since: 1.0 151 */ 152 public bool getLettersVisible() 153 { 154 return hdy_keypad_get_letters_visible(hdyKeypad) != 0; 155 } 156 157 /** 158 * Returns the amount of space between the rows of @self. 159 * 160 * Returns: the row spacing of @self 161 * 162 * Since: 1.0 163 */ 164 public uint getRowSpacing() 165 { 166 return hdy_keypad_get_row_spacing(hdyKeypad); 167 } 168 169 /** 170 * Returns the widget for the lower left corner (or right, in RTL locales) of 171 * @self. 172 * 173 * Returns: the start action widget 174 * 175 * Since: 1.0 176 */ 177 public Widget getStartAction() 178 { 179 auto __p = hdy_keypad_get_start_action(hdyKeypad); 180 181 if(__p is null) 182 { 183 return null; 184 } 185 186 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 187 } 188 189 /** 190 * Returns whether @self should display the standard letters below the digits on 191 * its buttons. 192 * 193 * Returns Whether @self should display the hash and asterisk buttons, and 194 * should display the plus symbol at the bottom of its 0 button. 195 * 196 * Returns: whether the hash, plus, and asterisk symbols should be visible 197 * 198 * Since: 1.0 199 */ 200 public bool getSymbolsVisible() 201 { 202 return hdy_keypad_get_symbols_visible(hdyKeypad) != 0; 203 } 204 205 /** 206 * Sets the amount of space between columns of @self. 207 * 208 * Params: 209 * spacing = the amount of space to insert between columns 210 * 211 * Since: 1.0 212 */ 213 public void setColumnSpacing(uint spacing) 214 { 215 hdy_keypad_set_column_spacing(hdyKeypad, spacing); 216 } 217 218 /** 219 * Sets the widget for the lower right corner (or left, in RTL locales) of 220 * @self. 221 * 222 * Params: 223 * endAction = the end action widget 224 * 225 * Since: 1.0 226 */ 227 public void setEndAction(Widget endAction) 228 { 229 hdy_keypad_set_end_action(hdyKeypad, (endAction is null) ? null : endAction.getWidgetStruct()); 230 } 231 232 /** 233 * Binds @entry to @self and blocks any input which wouldn't be possible to type 234 * with with the keypad. 235 * 236 * Params: 237 * entry = a #GtkEntry 238 * 239 * Since: 0.0.12 240 */ 241 public void setEntry(Entry entry) 242 { 243 hdy_keypad_set_entry(hdyKeypad, (entry is null) ? null : entry.getEntryStruct()); 244 } 245 246 /** 247 * Sets whether @self should display the standard letters below the digits on 248 * its buttons. 249 * 250 * Params: 251 * lettersVisible = whether the letters below the digits should be visible 252 * 253 * Since: 1.0 254 */ 255 public void setLettersVisible(bool lettersVisible) 256 { 257 hdy_keypad_set_letters_visible(hdyKeypad, lettersVisible); 258 } 259 260 /** 261 * Sets the amount of space between rows of @self. 262 * 263 * Params: 264 * spacing = the amount of space to insert between rows 265 * 266 * Since: 1.0 267 */ 268 public void setRowSpacing(uint spacing) 269 { 270 hdy_keypad_set_row_spacing(hdyKeypad, spacing); 271 } 272 273 /** 274 * Sets the widget for the lower left corner (or right, in RTL locales) of 275 * @self. 276 * 277 * Params: 278 * startAction = the start action widget 279 * 280 * Since: 1.0 281 */ 282 public void setStartAction(Widget startAction) 283 { 284 hdy_keypad_set_start_action(hdyKeypad, (startAction is null) ? null : startAction.getWidgetStruct()); 285 } 286 287 /** 288 * Sets whether @self should display the hash and asterisk buttons, and should 289 * display the plus symbol at the bottom of its 0 button. 290 * 291 * Params: 292 * symbolsVisible = whether the hash, plus, and asterisk symbols should be visible 293 * 294 * Since: 1.0 295 */ 296 public void setSymbolsVisible(bool symbolsVisible) 297 { 298 hdy_keypad_set_symbols_visible(hdyKeypad, symbolsVisible); 299 } 300 }