MorePalmOS
A development library for developing Palm OS applications

MoreList.c

Go to the documentation of this file.
00001 /******************************************************************************
00002  * MorePalmOS
00003  * Copyright (c) 2004 Steven Fisher
00004  *
00005  * Distributed under the Boost Software License, Version 1.0. See accompanying
00006  * license file License.txt or <http://www.boost.org/LICENSE_1_0.txt>.
00007  *
00008  * http://morepalmos.sourceforge.net
00009  *
00010  *   MorePalmOS is the humble begining of an attempt to provide a library for
00011  *   Palm OS development which works around system bugs, illustrate how to
00012  *   use system calls, and provide "glue code" for programming Palm OS
00013  *   applications in a more straightforward way while minimally impacting
00014  *   code size.
00015  *****************************************************************************/
00016 
00017 #include "MorePrefix.h"
00018 #include "MoreList.h"
00019 #include "MoreControl.h"
00020 #include "MoreForm.h"
00021 #include "MorePrivate.h"
00022 
00023 //-----------------------------------------------------------------------------
00024 
00025 #if !MOREPALMOS_MACRO_SIMPLE_FUNCS
00026 
00027 ListType* MLstGetPtrByIdxSafely( const FormType* formP, FrmObjectIdx_t idx )
00028 {
00029         return ( ListType* ) MFrmGetObjPtrOfTypeByIdx( formP, idx, frmListObj );
00030 }
00031 
00032 ListType* MLstGetPtrByIDSafely( const FormType* formP, FrmObjectID_t id )
00033 {
00034         return ( ListType* ) MFrmGetObjPtrOfTypeByID( formP, id, frmListObj );
00035 }
00036 
00037 ListType* MLstGetPtrByObjPtrSafely( const FormType* formP, FrmObject_t* objectP )
00038 {
00039         return ( ListType* ) MFrmGetObjPtrOfTypeByPtr( formP, objectP, frmListObj );
00040 }
00041 
00042 #endif
00043 
00044 //-----------------------------------------------------------------------------
00045 
00046 #if !MOREPALMOS_MACRO_SIMPLE_FUNCS
00047 
00048 ListType* MLstGetPtrByIdx( const FormType* formP, FrmObjectIdx_t idx )
00049 {
00050         return ( ListType* ) MFrmGetObjPtrByIdx( formP, idx );
00051 }
00052 
00053 ListType* MLstGetPtrByID( const FormType* formP, FrmObjectID_t ID )
00054 {
00055         return ( ListType* ) MFrmGetObjPtrByID( formP, ID );
00056 }
00057 
00058 ListType* MLstGetPtrByObjPtr( FrmObject_t* ptr )
00059 {
00060         return ( ListType* ) ptr;
00061 }
00062 
00063 #endif
00064 
00065 //-----------------------------------------------------------------------------
00066 
00067 Int16 MLstGetSelectionByID( FormType* formP, FrmObjectID_t listID )
00068 {
00069         _validate_object_id( formP, listID );
00070         return LstGetSelection(
00071                         _validate_object_ptr( MLstGetPtrByID( formP, listID ) ) );
00072 }
00073 
00074 Int16 MLstGetSelectionByIdx( FormType* formP, FrmObjectIdx_t listIdx )
00075 {
00076         _validate_object_idx( formP, listIdx );
00077         return LstGetSelection( MLstGetPtrByIdx( formP, listIdx ) );
00078 }
00079 
00080 //-----------------------------------------------------------------------------
00081 
00082 void MLstSetTriggerAndListValueIdxByIdx( FormType* formP, FrmObjectIdx_t triggerIdx,
00083                 FrmObjectIdx_t listIdx, CtlValue_t item )
00084 {
00085         ControlPtr triggerP;
00086         ListPtr listP;
00087         _validate_object_idx ( formP, triggerIdx );
00088         _validate_object_idx ( formP, listIdx );
00089         triggerP = MCtlGetPtrByIdx( formP, triggerIdx );
00090         listP = MLstGetPtrByIdx( formP, listIdx );
00091         LstSetSelection( listP, item );
00092         CtlSetLabel( triggerP, LstGetSelectionText( listP, item ) );
00093 }
00094 
00095 void MLstSetTriggerAndListValueIdxByID( FormType* formP, FrmObjectID_t triggerID,
00096                 FrmObjectID_t listID, CtlValue_t item )
00097 {
00098         _validate_object_idx ( formP, triggerID );
00099         _validate_object_idx ( formP, listID );
00100         MLstSetTriggerAndListValueIdxByIdx ( formP,
00101                         FrmGetObjectIndex( formP, triggerID ),
00102                         FrmGetObjectIndex( formP, listID ),
00103                         item );
00104 }
00105 
00106 void MLstSetTriggerValueByIdx( FormType* formP, FrmObjectIdx_t triggerIdx,
00107                 FrmObjectIdx_t listIdx, CtlValue_t item )
00108 {
00109         ControlPtr triggerP;
00110         ListPtr listP;
00111         _validate_object_idx ( formP, triggerIdx );
00112         _validate_object_idx ( formP, listIdx );
00113         triggerP = MCtlGetPtrByIdx( formP, triggerIdx );
00114         listP = MLstGetPtrByIdx( formP, listIdx );
00115         CtlSetLabel( triggerP, LstGetSelectionText( listP, item ) );
00116 }
00117 
00118 void MLstSetTriggerValueByID( FormType* formP, FrmObjectID_t triggerID,
00119                 FrmObjectID_t listID, CtlValue_t item )
00120 {
00121         _validate_object_idx ( formP, triggerID );
00122         _validate_object_idx ( formP, listID );
00123         MLstSetTriggerValueByIdx ( formP,
00124                         FrmGetObjectIndex( formP, triggerID ),
00125                         FrmGetObjectIndex( formP, listID ),
00126                         item );
00127 }
00128 
00129 void MLstSetTriggerValueByPtr( FormType* formP, void* triggerP,
00130                 void* listP, CtlValue_t item )
00131 {
00132         _validate_object_ptr ( triggerP );
00133         _validate_object_ptr ( listP );
00134         MLstSetTriggerValueByIdx ( formP,
00135                         FrmGetObjectIndexFromPtr( formP, triggerP ),
00136                         FrmGetObjectIndexFromPtr( formP, listP ),
00137                         item );
00138 }

SourceForge.net Logo