entry.h

Go to the documentation of this file.
00001 /*
00002  Copyright (C) 2001-2006, William Joseph.
00003  All Rights Reserved.
00004 
00005  This file is part of GtkRadiant.
00006 
00007  GtkRadiant is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU General Public License as published by
00009  the Free Software Foundation; either version 2 of the License, or
00010  (at your option) any later version.
00011 
00012  GtkRadiant is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU General Public License for more details.
00016 
00017  You should have received a copy of the GNU General Public License
00018  along with GtkRadiant; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020  */
00021 
00022 #if !defined(INCLUDED_GTKUTIL_ENTRY_H)
00023 #define INCLUDED_GTKUTIL_ENTRY_H
00024 
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027 #include <gtk/gtkentry.h>
00028 #include <string>
00029 
00030 inline void entry_set_string (GtkEntry* entry, const std::string& string)
00031 {
00032     gtk_entry_set_text(entry, string.c_str());
00033 }
00034 
00035 inline void entry_set_int (GtkEntry* entry, int i)
00036 {
00037     char buf[32];
00038     sprintf(buf, "%d", i);
00039     entry_set_string(entry, buf);
00040 }
00041 
00042 inline void entry_set_float (GtkEntry* entry, float f)
00043 {
00044     char buf[32];
00045     sprintf(buf, "%g", f);
00046     entry_set_string(entry, buf);
00047 }
00048 
00049 inline const char* entry_get_string (GtkEntry* entry)
00050 {
00051     return gtk_entry_get_text(entry);
00052 }
00053 
00054 inline int entry_get_int (GtkEntry* entry)
00055 {
00056     return atoi(entry_get_string(entry));
00057 }
00058 
00059 inline double entry_get_float (GtkEntry* entry)
00060 {
00061     return atof(entry_get_string(entry));
00062 }
00063 
00064 #endif

Generated by  doxygen 1.6.2