messagebox.c

Go to the documentation of this file.
00001 
00013 #include "messagebox.h"
00014 
00015 #ifdef __cplusplus
00016 extern "C" {
00017 #endif
00018 
00024 jclass getMessageboxClass() {
00025    static jclass msgboxcls = NULL;
00026 
00027    if (msgboxcls == NULL) {
00028       msgboxcls = findClass(CLS_MESSAGEBOX);
00029    }
00030 
00031    return msgboxcls;
00032 }
00033 
00044 jint showModalConfirmDialog(Frame* frame, const char* msg) {
00045    static jmethodID mid = NULL;
00046    jstring jmsg = createJString(msg);
00047    jint ret;
00048    jobject frameobj = NULL;
00049 
00050    if (mid == NULL) {
00051       mid = findStaticMethod(getMessageboxClass(), "showConfirmDialog", "(Ljava/awt/Component;Ljava/lang/Object;)I");
00052    }
00053 
00054    if (frame != NULL) {
00055       frameobj = frame->frame.frame;
00056    }
00057 
00058    ret = callStaticIntMethod(getMessageboxClass(), mid, frameobj, jmsg);
00059 
00060    exception();
00061 
00062    deleteGlobalReference(jmsg);
00063    
00064    return ret;
00065 }
00066 
00076 jint showConfirmDialog(const char* msg) {
00077    return showModalConfirmDialog(NULL, msg);
00078 }
00079 
00091 char* showModalInputDialog(Frame* frame, const char* msg, const char* defaultValue) {
00092    static jmethodID mid = NULL;
00093    jstring jmsg = createJString(msg);
00094    jstring jdefault = createJString(defaultValue);
00095    jstring userinput;
00096    jobject frameobj = NULL;
00097    char* ret;
00098 
00099    if (mid == NULL) {
00100       mid = findStaticMethod(getMessageboxClass(), "showInputDialog", "(Ljava/awt/Component;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/String;");
00101    }
00102 
00103    if (frame != NULL) {
00104       frameobj = frame->frame.frame;
00105    }
00106 
00107    userinput = (jstring)callStaticObjectMethod(getMessageboxClass(), mid, frameobj, jmsg, jdefault);
00108 
00109    exception();
00110 
00111    ret = convertJString(userinput);
00112 
00113    deleteLocalReference(userinput);
00114    deleteGlobalReference(jmsg);
00115    deleteGlobalReference(jdefault);
00116    
00117    return ret;
00118 }
00119 
00130 char* showInputDialog(const char* msg, const char* defaultValue) {
00131    return showModalInputDialog(NULL, msg, defaultValue);
00132 }
00133 
00142 void showModalMessageDialog(Frame* frame, const char* msg) {
00143    static jmethodID mid = NULL;
00144    jstring jmsg = createJString(msg);
00145    jobject frameobj = NULL;
00146 
00147    if (mid == NULL) {
00148       mid = findStaticMethod(getMessageboxClass(), "showMessageDialog", "(Ljava/awt/Component;Ljava/lang/Object;)V");
00149    }
00150 
00151    if (frame != NULL) {
00152       frameobj = frame->frame.frame;
00153    }
00154 
00155    callStaticVoidMethod(getMessageboxClass(), mid, frameobj, jmsg);
00156 
00157    exception();
00158 
00159    deleteGlobalReference(jmsg);
00160 }
00161 
00169 void showMessageDialog(const char* msg) {
00170    showModalMessageDialog(NULL, msg);
00171 }
00172 
00173 #ifdef __cplusplus
00174 } /* extern "C" */
00175 #endif
00176 
00177 /* end of file messagebox.c */

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