00001 /** $Revision: 1.7 $ 00002 Last updated: $Date: 2002/09/24 19:46:42 $ 00003 00004 Copyright (C) 2000-2001 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 00021 #ifndef __TABLE__ 00022 #define __TABLE__ 00023 00024 #include <PalmOS.h> 00025 #include "MiscFunc.h" 00026 00027 /** A wrapper for the Table functions; its main function is to set a few standard functions 00028 which are to be overloaded in derived classes 00029 */ 00030 class Table 00031 { 00032 public: 00033 /// the id of the top visible item 00034 UInt16 top_visible_item; 00035 /// the max no of rows that can be displayed at once in this table 00036 UInt16 rows; 00037 /// no of elements that could be loaded in the table 00038 UInt16 total_items; 00039 00040 /** initialises the table pointer. this code is not in the constructor because delayed initialisation 00041 might be desired (after the form was initialised) 00042 When finished this function calls the loadData method in orded to populate the table. */ 00043 void initTable(); 00044 /** initialises the table 00045 @param table_resource id of the resource associated with this table 00046 @param up id of the resource associeted with the 'up' scroll arrow 00047 @param down id of the resource associeted with the 'down' scroll arrow */ 00048 Table(UInt32 table_resource, UInt32 up, UInt32 down); 00049 00050 /// destructor: by default it hides the scroll arrows 00051 virtual ~Table(); 00052 00053 00054 /** set part of the table rows to unusable 00055 @param start row from which all other rows will be unusable */ 00056 void setRowsUnusable(UInt16 start); 00057 00058 ///unhilights the curent selection 00059 void unhighlight(); 00060 00061 /** scroll a page up (if possible) 00062 @return true if the operation was executed, false otherwise */ 00063 Boolean pageUp(); 00064 00065 /** scroll a page down (if possible) 00066 @return true if the operation was executed, false otherwise */ 00067 Boolean pageDown(); 00068 00069 /** hide the scroll arrows */ 00070 void hideScrollArrows(); 00071 00072 /** displays scroll arrows for the table (if needed) */ 00073 void showScrollArrows(); 00074 00075 ///initialises the columns 00076 virtual void initColumns()=0; 00077 00078 ///loads date into the table 00079 virtual void loadData()=0; 00080 00081 /** this function should be used to check whether a record belongs in this table or not 00082 @param id the id of the record to be checked 00083 @return true if the record is valid and false otherwise */ 00084 virtual Boolean recordIsValid(UInt16 id)=0; 00085 00086 protected: 00087 ///pointer to the table managed by the object 00088 TablePtr _table; 00089 ///resource for the table 00090 UInt32 _table_resource; 00091 ///resource for the up arrow 00092 UInt32 _up_arrow; 00093 ///resource for the down arrow 00094 UInt32 _down_arrow; 00095 ///pointer to the form hosting the table 00096 FormPtr _form; 00097 }; 00098 00099 #endif