Mercurial > dwindows
comparison android/dw.cpp @ 2544:dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 13 May 2021 20:46:07 +0000 |
parents | f9367eb9a6e7 |
children | f803f3b164cf |
comparison
equal
deleted
inserted
replaced
2543:f9367eb9a6e7 | 2544:dbfcc0e357d6 |
---|---|
490 | 490 |
491 pthread_setspecific(_dw_env_key, env); | 491 pthread_setspecific(_dw_env_key, env); |
492 return timerfunc((void *)data); | 492 return timerfunc((void *)data); |
493 } | 493 } |
494 | 494 |
495 /* A more simple method for quicker calls */ | |
496 JNIEXPORT void JNICALL | |
497 Java_org_dbsoft_dwindows_DWMenu_eventHandlerSimple(JNIEnv* env, jobject obj, jobject obj1, jint message) { | |
498 void *params[8] = { nullptr }; | |
499 | |
500 _dw_event_handler(obj1, params, message); | |
501 } | |
502 | |
503 | |
495 /* This function adds a signal handler callback into the linked list. | 504 /* This function adds a signal handler callback into the linked list. |
496 */ | 505 */ |
497 void _dw_new_signal(ULONG message, HWND window, int msgid, void *signalfunction, void *discfunc, void *data) | 506 void _dw_new_signal(ULONG message, HWND window, int msgid, void *signalfunction, void *discfunc, void *data) |
498 { | 507 { |
499 SignalHandler *newsig = (SignalHandler *)malloc(sizeof(SignalHandler)); | 508 SignalHandler *newsig = (SignalHandler *)malloc(sizeof(SignalHandler)); |
3982 */ | 3991 */ |
3983 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) | 3992 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) |
3984 { | 3993 { |
3985 } | 3994 } |
3986 | 3995 |
3996 char _dw_removetilde(char *dest, const char *src) | |
3997 { | |
3998 int z, cur=0; | |
3999 char accel = '\0'; | |
4000 | |
4001 for(z=0;z<strlen(src);z++) | |
4002 { | |
4003 if(src[z] != '~') | |
4004 { | |
4005 dest[cur] = src[z]; | |
4006 cur++; | |
4007 } | |
4008 else | |
4009 { | |
4010 accel = src[z+1]; | |
4011 } | |
4012 } | |
4013 dest[cur] = 0; | |
4014 return accel; | |
4015 } | |
4016 | |
3987 /* | 4017 /* |
3988 * Adds a menuitem or submenu to an existing menu. | 4018 * Adds a menuitem or submenu to an existing menu. |
3989 * Parameters: | 4019 * Parameters: |
3990 * menu: The handle the the existing menu. | 4020 * menu: The handle the the existing menu. |
3991 * title: The title text on the menu item to be added. | 4021 * title: The title text on the menu item to be added. |
4001 { | 4031 { |
4002 JNIEnv *env; | 4032 JNIEnv *env; |
4003 | 4033 |
4004 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | 4034 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) |
4005 { | 4035 { |
4036 char *newtitle = (char *)alloca(strlen(title)+1); | |
4037 char accel = _dw_removetilde(newtitle, title); | |
4006 // Create a string | 4038 // Create a string |
4007 jstring jstr = env->NewStringUTF(title); | 4039 jstring jstr = env->NewStringUTF(newtitle); |
4008 // First get the class that contains the method you need to call | 4040 // First get the class that contains the method you need to call |
4009 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 4041 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
4010 // Get the method that you want to call | 4042 // Get the method that you want to call |
4011 jmethodID menuAppendItem = env->GetMethodID(clazz, "menuAppendItem", | 4043 jmethodID menuAppendItem = env->GetMethodID(clazz, "menuAppendItem", |
4012 "(Lorg/dbsoft/dwindows/DWMenu;Ljava/lang/String;IIIILorg/dbsoft/dwindows/DWMenu;)Lorg/dbsoft/dwindows/DWMenuItem;"); | 4044 "(Lorg/dbsoft/dwindows/DWMenu;Ljava/lang/String;IIIILorg/dbsoft/dwindows/DWMenu;)Lorg/dbsoft/dwindows/DWMenuItem;"); |