entry.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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