1 /* 2 * gnc-currency-edit.h -- Currency editor widget 3 * 4 * Copyright (C) 2000 Free Software Foundation 5 * All rights reserved. 6 * 7 * Dave Peticolas <dave@krondo.com> 8 * 9 * GnuCash is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU Library General Public License as 11 * published by the Free Software Foundation; either version 2 of 12 * the License, or (at your option) any later version. 13 * 14 * Gnucash is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Library General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, contact: 21 * 22 * Free Software Foundation Voice: +1-617-542-5942 23 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 24 * Boston, MA 02110-1301, USA gnu@gnu.org 25 * 26 */ 27 28 /** @addtogroup GUI 29 @{ */ 30 /** @addtogroup GncCurrencyEdit 31 * @{ */ 32 /** @file gnc-currency-edit.h 33 * @brief Currency selection widget. 34 * @author Dave Peticolas <dave@krondo.com> 35 * @author David Hampton <hampton@employees.org> 36 * 37 * This widget is a GtkComboBox that is wrapped with support 38 * functions for building/selecting from a list of ISO4217 currency 39 * names. All data is maintained within the widget itself, which 40 * makes the name/item lookup functions somewhat complicated. The 41 * alternative coding would be to keep an auxiliary list of strings 42 * attacked to the widget for lookup purposes, but that would be 100% 43 * redundant information. 44 * 45 * When the GtkComboCellEntry widget supports completion, this Gnucash 46 * widget should be modified so that it is based upon that widget. 47 * That would give users the capability to select a currency by typing 48 * its ISO 4217 code (e.g. USD, GBP, etc). Moving to that widget 49 * today, however, would cause more problems that its worth. There is 50 * currently no way to get access to the embedded GtkEntry widget, and 51 * therefore no way to implement completion in gnucash or prevent the 52 * user from typing in random data. 53 */ 54 55 #ifndef GNC_CURRENCY_EDIT_H 56 #define GNC_CURRENCY_EDIT_H 57 58 #include "gnc-commodity.h" 59 60 /** @name Basic Object Implementation */ 61 /** @{ */ 62 63 #define GNC_TYPE_CURRENCY_EDIT (gnc_currency_edit_get_type()) 64 #define GNC_CURRENCY_EDIT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_CURRENCY_EDIT, GNCCurrencyEdit)) 65 #define GNC_CURRENCY_EDIT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GNC_TYPE_CURRENCY_EDIT, GNCCurrencyEditClass)) 66 #define GNC_IS_CURRENCY_EDIT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_CURRENCY_EDIT)) 67 68 typedef struct 69 { 70 GtkComboBox combobox; 71 } GNCCurrencyEdit; 72 73 typedef struct 74 { 75 GtkComboBoxClass combobox; 76 } GNCCurrencyEditClass; 77 78 /** Return the GType for the GNCCurrencyEdit currency selection widget. 79 * 80 * @return A GType value. 81 */ 82 GType gnc_currency_edit_get_type (void); 83 84 85 /** Create a new GNCCurrencyEdit widget which can be used to provide 86 * an easy way to enter ISO currency codes. 87 * 88 * @return A GNCCurrencyEdit widget. 89 */ 90 GtkWidget *gnc_currency_edit_new (void); 91 /** @} */ 92 93 94 /** @name Get/Set Functions */ 95 /** @{ */ 96 97 /** Set the widget to display a certain currency name. 98 * 99 * @param gce The currency editor widget to set. 100 * 101 * @param currency The currency to set as the displayed/selected 102 * value of the widget. 103 */ 104 void gnc_currency_edit_set_currency (GNCCurrencyEdit *gce, 105 const gnc_commodity *currency); 106 107 108 /** Retrieve the displayed currency of the widget. 109 * 110 * @param gce The currency editor widget whose values should be retrieved. 111 * 112 * @return A pointer to the selected currency (a gnc_commodity 113 * structure). 114 */ 115 gnc_commodity *gnc_currency_edit_get_currency (GNCCurrencyEdit *gce); 116 117 118 /** Clear the displayed currency of the widget. 119 * 120 * This will clear the currency being displayed just like when first created 121 * but it still returns the default currency as usual 122 * 123 * @param gce The currency editor widget whose values should be retrieved. 124 */ 125 void gnc_currency_edit_clear_display (GNCCurrencyEdit *gce); 126 127 /** @} */ 128 129 #endif 130 131 /** @} */ 132 /** @} */ 133 134