00001 /** $Revision: 1.33 $ 00002 Last updated: $Date: 2002/09/25 21:18:01 $ 00003 00004 Copyright (C) 2000-2002 Vlad Mereuta <dizzy@users.sourceforge.net> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00019 00020 #ifndef __MISC_FUNC__ 00021 #define __MISC_FUNC__ 00022 00023 #include <PalmOS.h> 00024 00025 /// application creator 00026 #define FREE_COINS_CREATOR 'DyCo' 00027 00028 ///version string for os 3.5 00029 #define palmos_3_5 0x03503000 00030 ///version string for os 3.1 00031 #define palmos_3_1 0x03103000 00032 00033 /// section definition for form code 00034 #define FORM_SECTION1 __attribute__ (( section ("forms1"))) 00035 00036 /// section definition for form code 00037 #define FORM_SECTION2 __attribute__ (( section ("forms2"))) 00038 00039 /// section definition for database code 00040 #define DB_SECTION1 __attribute__ (( section ("dbs1"))) 00041 00042 /// section definition for database code 00043 #define DB_SECTION2 __attribute__ (( section ("dbs2"))) 00044 00045 /// contains various functions used throughout the program 00046 namespace MiscFunc { 00047 ///Number format: Thousands separator (currently unused) 00048 extern char cThousandSep; 00049 ///Number format: Decimal separator 00050 extern char cDecimalSep; 00051 ///date format, print day first? 00052 extern Boolean bDayFirst; 00053 ///date format, character between day and month 00054 extern char cDateSep; 00055 00056 /** 00057 checks if the PalmOS version on the current device is greater or equal to the one specified. 00058 for example if(osVerGe(palmos_3_5)) DoSomething(); 00059 00060 @param version_no the version number - pass it one of the variables defined above (palmos_*****) 00061 @return true if the os has a verno greater or equal to the one specified, false otherwise 00062 */ 00063 Boolean osVerGe(UInt32 version_no); 00064 00065 /** 00066 Get a 32bit int containg a sum of money in pence and return a pointer 00067 to a proper formatted string. 00068 00069 the pointer has to be deallocated after use with MemPtrFree 00070 00071 */ 00072 Char* Pence2String(Int32 pence) FORM_SECTION2; 00073 00074 /** 00075 draw right aligned text 00076 @param s string to be drawn 00077 @param bounds rectangle inside which the text will be displayed 00078 */ 00079 void DrawCharsRightAlign(const Char* s, const RectangleType* bounds) FORM_SECTION2; 00080 00081 /** 00082 Get a string containing a sum of money and convert it to pence 00083 @param sum the sting containing the formatted amount 00084 @return the amount of pence in the sum 00085 */ 00086 Int32 String2Pence(Char* sum) FORM_SECTION2; 00087 00088 /** 00089 returns a pointer to a given object in the current form 00090 */ 00091 void* GetObjectPtr(UInt16 objID) FORM_SECTION2; 00092 00093 /** 00094 returns a pointer to a given object in a given form 00095 */ 00096 void* GetObjectPtrByForm(FormPtr frm,UInt16 objID) FORM_SECTION2; 00097 00098 /** 00099 returns pointer to the text in a given field in the current form 00100 */ 00101 Char* GetTextPtr(UInt16 objID) FORM_SECTION2; 00102 00103 /** fills in a text field from a memory handle 00104 @param fieldID id of the field to be filled 00105 @param txtH memory handle to the text to be placed in the field 00106 @return pointer to the field */ 00107 FieldPtr SetFieldTextFromHandle(Int16 fieldID, MemHandle txtH); 00108 00109 /// Allocates new handle and copies incoming string 00110 FieldPtr SetFieldTextFromStr(Int16 fieldID, const Char* str) FORM_SECTION2; 00111 00112 /// Allocates new handle and copies incoming integer 00113 FieldPtr SetFieldTextFromInt(Int16 fieldID, const Int32 i) FORM_SECTION2; 00114 00115 ///clears the text from a field: 00116 void ClearFieldText(Int16 fieldID) FORM_SECTION2; 00117 00118 /** 00119 fills in a date field (pushbutton or selectortrigger) with a date 00120 @param date_field_id ID of the field 00121 @param new_date date to be displayed 00122 @param date_txt pointer to an allocated buffer where the date text can be stored 00123 */ 00124 void updateDateField(UInt16 date_field_id, DateType new_date, Char* date_txt) FORM_SECTION2; 00125 00126 /** 00127 call the system form to choose a new date 00128 @param dest the choosen date will be stored in here 00129 @param date_field_id the date choosen will be displayed in this field 00130 @param date_txt pointer to be passed to updateDateField 00131 */ 00132 void selectDate(DateType& dest, UInt16 date_field_id, Char* date_txt) FORM_SECTION2; 00133 00134 /** 00135 compares two dates 00136 @param date1 1st date 00137 @param date2 2nd date 00138 @return -1 if date1<date2, 0 if date1==date2 and 1 otherwise 00139 */ 00140 Int16 compareDates(DateType date1, DateType date2) DB_SECTION2; 00141 00142 /** 00143 check if a string contains a valid decimal number 00144 @param str the string 00145 @param minus_allowed boolean that indicates if the number may be negative 00146 @return true if the string is valid, false otherwise 00147 */ 00148 Boolean validNumberStr(const Char *str, Boolean allow_minus) DB_SECTION2; 00149 00150 /** 00151 set list selection and update associated popup trigger label 00152 @param listId the ID of the list to set 00153 @param trigId the ID of the associated popup trigger 00154 @param sel_index index of the item to select 00155 */ 00156 void PopupListSetSelection(UInt16 listId, UInt16 trigId, Int16 sel_index) FORM_SECTION2; 00157 00158 }; 00159 00160 ///export by default all the functions/vars in this namespace 00161 using namespace MiscFunc; 00162 00163 #endif