choice.c

Go to the documentation of this file.
00001 
00011 #include "choice.h"
00012 #include "component.h"
00013 
00014 #ifdef __cplusplus
00015 extern "C" {
00016 #endif
00017 
00025 jobject getChoiceObject(Choice* choice) {
00026    return choice->choice.choice;
00027 }
00028 
00039 void setChoiceSize(Choice* choice, jint width, jint height) {
00040    setSize(choice->choice.choice, width, height);
00041 }
00042 
00053 jint getChoiceWidth(Choice* choice) {
00054    return getWidth(choice->choice.choice);
00055 }
00056 
00067 jint getChoiceHeight(Choice* choice) {
00068    return getHeight(choice->choice.choice);
00069 }
00070 
00081 void setChoiceLocation(Choice* choice, jint x, jint y) {
00082    setLocation(choice->choice.choice, x, y);
00083 }
00084 
00095 jint getChoiceX(Choice* choice) {
00096    return getX(choice->choice.choice);
00097 }
00098 
00109 jint getChoiceY(Choice* choice) {
00110    return getY(choice->choice.choice);
00111 }
00112 
00121 char* getChoiceItem(Choice* choice, jint pos) {
00122    jstring jitem = (jstring)callObjectMethod(choice->choice.choice, choice->choice.mgetItem, pos);
00123    char* item = convertJString(jitem);
00124    deleteLocalReference(jitem);
00125    return item;
00126 }
00127 
00137 void addChoiceItem(Choice* choice, const char* item) {
00138    jstring jitem = createJString(item);
00139    callVoidMethod(choice->choice.choice, choice->choice.maddItem, jitem);
00140    deleteGlobalReference(jitem);
00141 }
00142 
00152 void removeChoiceItem(Choice* choice, const char* item) {
00153    jstring jitem = createJString(item);
00154    callVoidMethod(choice->choice.choice, choice->choice.mremoveItem, jitem);
00155    deleteGlobalReference(jitem);
00156    exception();
00157 }
00158 
00168 void removeChoiceItemAtPos(Choice* choice, jint pos) {
00169    callVoidMethod(choice->choice.choice, choice->choice.mremoveItemAtPos, pos);
00170    exception();
00171 }
00172 
00181 void removeChoiceAll(Choice* choice) {
00182    callVoidMethod(choice->choice.choice, choice->choice.mremoveAll);
00183 }
00184 
00192 jint getChoiceItemCount(Choice* choice) {
00193    return callIntMethod(choice->choice.choice, choice->choice.mgetItemCount);
00194 }
00195 
00203 jint getChoiceSelectedIndex(Choice* choice) {
00204    return callIntMethod(choice->choice.choice, choice->choice.mgetSelectedIndex);
00205 }
00206 
00218 ItemListener addChoiceItemListener(Choice* choice, void (*func)(Component, jboolean, const char*)) {
00219    return addItemListener(choice->choice.choice, func);
00220 }
00221 
00231 void removeChoiceItemListener(Choice* choice, ItemListener il) {
00232    removeItemListener(choice->choice.choice, il);
00233 }
00234 
00243 void selectChoiceItem(Choice* choice, jint item) {
00244    callVoidMethod(choice->choice.choice, choice->choice.mselectItem, item);
00245 }
00246 
00252 void initChoice_(Choice_* choice) {
00253    choice->getObject = &getChoiceObject;
00254    choice->setSize = &setChoiceSize;
00255    choice->getWidth = &getChoiceWidth;
00256    choice->getHeight = &getChoiceHeight;
00257    choice->setLocation = &setChoiceLocation;
00258    choice->getX = &getChoiceX;
00259    choice->getY = &getChoiceY;
00260    choice->getItem = &getChoiceItem;
00261    choice->addItem = &addChoiceItem;
00262    choice->removeItem = &removeChoiceItem;
00263    choice->removeItemAtPos = &removeChoiceItemAtPos;
00264    choice->removeAll = &removeChoiceAll;
00265    choice->getItemCount = &getChoiceItemCount;
00266    choice->getSelectedIndex = &getChoiceSelectedIndex;
00267    choice->addItemListener = &addChoiceItemListener;
00268    choice->removeItemListener = &removeChoiceItemListener;
00269    choice->selectItem = &selectChoiceItem;
00270 }
00271 
00278 void createChoice_(Choice* choice) {
00279    choice->choice.clschoice = findClass(CLS_CHOICE);
00280    choice->choice.mgetItem = findMethod(choice->choice.clschoice, "getItem", "(I)Ljava/lang/String;");
00281    choice->choice.maddItem = findMethod(choice->choice.clschoice, "add", "(Ljava/lang/String;)V");
00282    choice->choice.mremoveItem = findMethod(choice->choice.clschoice, "remove", "(Ljava/lang/String;)V");
00283    choice->choice.mremoveItemAtPos = findMethod(choice->choice.clschoice, "remove", "(I)V");
00284    choice->choice.mremoveAll = findMethod(choice->choice.clschoice, "removeAll", "()V");
00285    choice->choice.mgetItemCount = findMethod(choice->choice.clschoice, "getItemCount", "()I");
00286    choice->choice.mgetSelectedIndex = findMethod(choice->choice.clschoice, "getSelectedIndex", "()I");
00287    choice->choice.mselectItem = findMethod(choice->choice.clschoice, "select", "(I)V");
00288 
00289    choice->choice.choice = newObjectBySignature(choice->choice.clschoice, "()V");
00290 }
00291 
00298 void createChoiceCPP(ChoiceCPP_* choice) {
00299    choice->functions = (Choice_*)malloc(sizeof(Choice_));
00300    initChoice_(choice->functions);
00301    createChoice_((Choice*)choice);
00302 }
00303 
00310 void createChoiceC(Choice_* choice) {
00311    initChoice_(choice);
00312    createChoice_((Choice*)choice);
00313 }
00314 
00320 void deleteChoice_(Choice* choice) {
00321    deleteGlobalReference(choice->choice.choice);
00322    deleteGlobalReference(choice->choice.clschoice);
00323 }
00324 
00330 void deleteChoiceCPP(ChoiceCPP_* choice) {
00331    deleteChoice_((Choice*)choice);
00332    free(choice->functions);
00333 }
00334 
00340 void deleteChoiceC(Choice_* choice) {
00341    deleteChoice_((Choice*)choice);
00342 }
00343 
00344 #ifdef __cplusplus
00345 } /* extern "C" */
00346 #endif
00347 
00348 /* end of file choice.c */

Generated on Sat Nov 19 14:11:10 2005 for GrubC by  doxygen 1.4.4