comparison android/dw.cpp @ 2529:060fdb2d807d

Android: Initial pixmap implmentation using Android Bitmap. Clean up some clang-tidy warnings reported by Android Studio.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 10 May 2021 20:06:50 +0000
parents 03f6870bcfcc
children b9923432cb1f
comparison
equal deleted inserted replaced
2528:03f6870bcfcc 2529:060fdb2d807d
91 dw_event_post(startup); 91 dw_event_post(startup);
92 return; 92 return;
93 } 93 }
94 else 94 else
95 { 95 {
96 char *argv[2] = {arg, NULL}; 96 char *argv[2] = {arg, nullptr};
97 97
98 /* Wait for a short while to see if we get called again... 98 /* Wait for a short while to see if we get called again...
99 * if we get called again we will be posted, if not... 99 * if we get called again we will be posted, if not...
100 * just wait for the timer to expire. 100 * just wait for the timer to expire.
101 */ 101 */
116 * path: The path to the Android app. 116 * path: The path to the Android app.
117 */ 117 */
118 JNIEXPORT void JNICALL 118 JNIEXPORT void JNICALL
119 Java_org_dbsoft_dwindows_DWindows_dwindowsInit(JNIEnv* env, jobject obj, jstring path, jstring appID) 119 Java_org_dbsoft_dwindows_DWindows_dwindowsInit(JNIEnv* env, jobject obj, jstring path, jstring appID)
120 { 120 {
121 char *arg = strdup(env->GetStringUTFChars((jstring)path, NULL)); 121 char *arg = strdup(env->GetStringUTFChars((jstring)path, nullptr));
122 const char *appid = env->GetStringUTFChars((jstring)appID, NULL); 122 const char *appid = env->GetStringUTFChars((jstring)appID, nullptr);
123 123
124 if(!_dw_main_event) 124 if(!_dw_main_event)
125 { 125 {
126 /* Save our class object pointer for later */ 126 /* Save our class object pointer for later */
127 _dw_obj = env->NewGlobalRef(obj); 127 _dw_obj = env->NewGlobalRef(obj);
128 128
129 /* Save the JNIEnv for the main thread */ 129 /* Save the JNIEnv for the main thread */
130 pthread_key_create(&_dw_env_key, NULL); 130 pthread_key_create(&_dw_env_key, nullptr);
131 pthread_setspecific(_dw_env_key, env); 131 pthread_setspecific(_dw_env_key, env);
132 132
133 /* Create the dwmain event */ 133 /* Create the dwmain event */
134 _dw_main_event = dw_event_new(); 134 _dw_main_event = dw_event_new();
135 } 135 }
159 void *discfunction; 159 void *discfunction;
160 void *data; 160 void *data;
161 161
162 } SignalHandler; 162 } SignalHandler;
163 163
164 static SignalHandler *DWRoot = NULL; 164 static SignalHandler *DWRoot = nullptr;
165 165
166 SignalHandler *_dw_get_handler(HWND window, int messageid) 166 SignalHandler *_dw_get_handler(HWND window, int messageid)
167 { 167 {
168 SignalHandler *tmp = DWRoot; 168 SignalHandler *tmp = DWRoot;
169 JNIEnv *env; 169 JNIEnv *env;
175 return tmp; 175 return tmp;
176 } 176 }
177 tmp = tmp->next; 177 tmp = tmp->next;
178 } 178 }
179 } 179 }
180 return NULL; 180 return nullptr;
181 } 181 }
182 182
183 typedef struct 183 typedef struct
184 { 184 {
185 ULONG message; 185 ULONG message;
384 */ 384 */
385 JNIEXPORT jint JNICALL 385 JNIEXPORT jint JNICALL
386 Java_org_dbsoft_dwindows_DWindows_eventHandler(JNIEnv* env, jobject obj, jobject obj1, jobject obj2, 386 Java_org_dbsoft_dwindows_DWindows_eventHandler(JNIEnv* env, jobject obj, jobject obj1, jobject obj2,
387 jint message, jstring str1, jstring str2, 387 jint message, jstring str1, jstring str2,
388 jint inta, jint intb, jint intc, jint intd) { 388 jint inta, jint intb, jint intc, jint intd) {
389 const char *utf81 = str1 ? env->GetStringUTFChars(str1, NULL) : NULL; 389 const char *utf81 = str1 ? env->GetStringUTFChars(str1, nullptr) : nullptr;
390 const char *utf82 = str2 ? env->GetStringUTFChars(str2, NULL) : NULL; 390 const char *utf82 = str2 ? env->GetStringUTFChars(str2, nullptr) : nullptr;
391 void *params[8] = { (void *)obj2, (void *)utf81, (void *)utf82, 391 void *params[8] = { (void *)obj2, (void *)utf81, (void *)utf82,
392 DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb), 392 DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb),
393 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), NULL }; 393 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), nullptr };
394 394
395 return _dw_event_handler(obj1, params, message); 395 return _dw_event_handler(obj1, params, message);
396 } 396 }
397 397
398 /* A more simple method for quicker calls */ 398 /* A more simple method for quicker calls */
399 JNIEXPORT void JNICALL 399 JNIEXPORT void JNICALL
400 Java_org_dbsoft_dwindows_DWindows_eventHandlerSimple(JNIEnv* env, jobject obj, jobject obj1, jint message) { 400 Java_org_dbsoft_dwindows_DWindows_eventHandlerSimple(JNIEnv* env, jobject obj, jobject obj1, jint message) {
401 void *params[8] = { NULL }; 401 void *params[8] = { nullptr };
402 402
403 _dw_event_handler(obj1, params, message); 403 _dw_event_handler(obj1, params, message);
404 } 404 }
405 405
406 /* Handler for notebook page changes */ 406 /* Handler for notebook page changes */
407 JNIEXPORT void JNICALL 407 JNIEXPORT void JNICALL
408 Java_org_dbsoft_dwindows_DWindows_eventHandlerNotebook(JNIEnv* env, jobject obj, jobject obj1, jint message, jlong pageID) { 408 Java_org_dbsoft_dwindows_DWindows_eventHandlerNotebook(JNIEnv* env, jobject obj, jobject obj1, jint message, jlong pageID) {
409 void *params[8] = { NULL }; 409 void *params[8] = { nullptr };
410 410
411 params[3] = DW_INT_TO_POINTER(pageID); 411 params[3] = DW_INT_TO_POINTER(pageID);
412 _dw_event_handler(obj1, params, message); 412 _dw_event_handler(obj1, params, message);
413 } 413 }
414 414
415 /* Handlers for HTML events */ 415 /* Handlers for HTML events */
416 JNIEXPORT void JNICALL 416 JNIEXPORT void JNICALL
417 Java_org_dbsoft_dwindows_DWindows_eventHandlerHTMLResult(JNIEnv* env, jobject obj, jobject obj1, 417 Java_org_dbsoft_dwindows_DWindows_eventHandlerHTMLResult(JNIEnv* env, jobject obj, jobject obj1,
418 jint message, jstring htmlResult, jlong data) { 418 jint message, jstring htmlResult, jlong data) {
419 const char *result = env->GetStringUTFChars(htmlResult, NULL); 419 const char *result = env->GetStringUTFChars(htmlResult, nullptr);
420 void *params[8] = { NULL, DW_POINTER(result), NULL, 0, 0, 0, 0, DW_INT_TO_POINTER(data) }; 420 void *params[8] = { nullptr, DW_POINTER(result), nullptr, 0, 0, 0, 0, DW_INT_TO_POINTER(data) };
421 421
422 _dw_event_handler(obj1, params, message); 422 _dw_event_handler(obj1, params, message);
423 } 423 }
424 424
425 JNIEXPORT void JNICALL 425 JNIEXPORT void JNICALL
426 Java_org_dbsoft_dwindows_DWWebViewClient_eventHandlerHTMLChanged(JNIEnv* env, jobject obj, jobject obj1, 426 Java_org_dbsoft_dwindows_DWWebViewClient_eventHandlerHTMLChanged(JNIEnv* env, jobject obj, jobject obj1,
427 jint message, jstring URI, jint status) { 427 jint message, jstring URI, jint status) {
428 const char *uri = env->GetStringUTFChars(URI, NULL); 428 const char *uri = env->GetStringUTFChars(URI, nullptr);
429 void *params[8] = { NULL, DW_POINTER(uri), NULL, DW_INT_TO_POINTER(status), 0, 0, 0, 0 }; 429 void *params[8] = { nullptr, DW_POINTER(uri), nullptr, DW_INT_TO_POINTER(status), 0, 0, 0, 0 };
430 430
431 _dw_event_handler(obj1, params, message); 431 _dw_event_handler(obj1, params, message);
432 } 432 }
433 433
434 JNIEXPORT void JNICALL 434 JNIEXPORT void JNICALL
435 Java_org_dbsoft_dwindows_DWindows_eventHandlerInt(JNIEnv* env, jobject obj, jobject obj1, jint message, 435 Java_org_dbsoft_dwindows_DWindows_eventHandlerInt(JNIEnv* env, jobject obj, jobject obj1, jint message,
436 jint inta, jint intb, jint intc, jint intd) { 436 jint inta, jint intb, jint intc, jint intd) {
437 void *params[8] = { NULL, NULL, NULL, 437 void *params[8] = { nullptr, nullptr, nullptr,
438 DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb), 438 DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb),
439 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), NULL }; 439 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), nullptr };
440 440
441 _dw_event_handler(obj1, params, message); 441 _dw_event_handler(obj1, params, message);
442 } 442 }
443 443
444 JNIEXPORT void JNICALL 444 JNIEXPORT void JNICALL
445 Java_org_dbsoft_dwindows_DWComboBox_eventHandlerInt(JNIEnv* env, jobject obj, jint message, 445 Java_org_dbsoft_dwindows_DWComboBox_eventHandlerInt(JNIEnv* env, jobject obj, jint message,
446 jint inta, jint intb, jint intc, jint intd) { 446 jint inta, jint intb, jint intc, jint intd) {
447 void *params[8] = { NULL, NULL, NULL, 447 void *params[8] = { nullptr, nullptr, nullptr,
448 DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb), 448 DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb),
449 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), NULL }; 449 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), nullptr };
450 450
451 _dw_event_handler(obj, params, message); 451 _dw_event_handler(obj, params, message);
452 } 452 }
453 453
454 JNIEXPORT void JNICALL 454 JNIEXPORT void JNICALL
455 Java_org_dbsoft_dwindows_DWSpinButton_eventHandlerInt(JNIEnv* env, jobject obj, jint message, 455 Java_org_dbsoft_dwindows_DWSpinButton_eventHandlerInt(JNIEnv* env, jobject obj, jint message,
456 jint inta, jint intb, jint intc, jint intd) { 456 jint inta, jint intb, jint intc, jint intd) {
457 void *params[8] = { NULL, NULL, NULL, 457 void *params[8] = { nullptr, nullptr, nullptr,
458 DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb), 458 DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb),
459 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), NULL }; 459 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), nullptr };
460 460
461 _dw_event_handler(obj, params, message); 461 _dw_event_handler(obj, params, message);
462 } 462 }
463 463
464 JNIEXPORT void JNICALL 464 JNIEXPORT void JNICALL
465 Java_org_dbsoft_dwindows_DWListBox_eventHandlerInt(JNIEnv* env, jobject obj, jint message, 465 Java_org_dbsoft_dwindows_DWListBox_eventHandlerInt(JNIEnv* env, jobject obj, jint message,
466 jint inta, jint intb, jint intc, jint intd) { 466 jint inta, jint intb, jint intc, jint intd) {
467 void *params[8] = { NULL, NULL, NULL, 467 void *params[8] = { nullptr, nullptr, nullptr,
468 DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb), 468 DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb),
469 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), NULL }; 469 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), nullptr };
470 470
471 _dw_event_handler(obj, params, message); 471 _dw_event_handler(obj, params, message);
472 } 472 }
473 473
474 /* Handler for Timer events */ 474 /* Handler for Timer events */
490 newsig->window = window; 490 newsig->window = window;
491 newsig->id = msgid; 491 newsig->id = msgid;
492 newsig->signalfunction = signalfunction; 492 newsig->signalfunction = signalfunction;
493 newsig->discfunction = discfunc; 493 newsig->discfunction = discfunc;
494 newsig->data = data; 494 newsig->data = data;
495 newsig->next = NULL; 495 newsig->next = nullptr;
496 496
497 if (!DWRoot) 497 if (!DWRoot)
498 DWRoot = newsig; 498 DWRoot = newsig;
499 else 499 else
500 { 500 {
501 SignalHandler *prev = NULL, *tmp = DWRoot; 501 SignalHandler *prev = nullptr, *tmp = DWRoot;
502 while(tmp) 502 while(tmp)
503 { 503 {
504 if(tmp->message == message && 504 if(tmp->message == message &&
505 tmp->window == window && 505 tmp->window == window &&
506 tmp->id == msgid && 506 tmp->id == msgid &&
652 652
653 /* 653 /*
654 * Sets the application ID used by this Dynamic Windows application instance. 654 * Sets the application ID used by this Dynamic Windows application instance.
655 * Parameters: 655 * Parameters:
656 * appid: A string typically in the form: com.company.division.application 656 * appid: A string typically in the form: com.company.division.application
657 * appname: The application name used on Windows or NULL. 657 * appname: The application name used on Windows or nullptr.
658 * Returns: 658 * Returns:
659 * DW_ERROR_NONE after successfully setting the application ID. 659 * DW_ERROR_NONE after successfully setting the application ID.
660 * DW_ERROR_UNKNOWN if unsupported on this system. 660 * DW_ERROR_UNKNOWN if unsupported on this system.
661 * DW_ERROR_GENERAL if the application ID is not allowed. 661 * DW_ERROR_GENERAL if the application ID is not allowed.
662 * Remarks: 662 * Remarks:
663 * This must be called before dw_init(). If dw_init() is called first 663 * This must be called before dw_init(). If dw_init() is called first
664 * it will create a unique ID in the form: org.dbsoft.dwindows.application 664 * it will create a unique ID in the form: org.dbsoft.dwindows.application
665 * or if the application name cannot be detected: org.dbsoft.dwindows.pid.# 665 * or if the application name cannot be detected: org.dbsoft.dwindows.pid.#
666 * The appname is used on Windows and Android. If NULL is passed the 666 * The appname is used on Windows and Android. If nullptr is passed the
667 * detected name will be used, but a prettier name may be desired. 667 * detected name will be used, but a prettier name may be desired.
668 */ 668 */
669 int API dw_app_id_set(const char *appid, const char *appname) 669 int API dw_app_id_set(const char *appid, const char *appname)
670 { 670 {
671 if(appid) 671 if(appid)
754 * title: Title bar text for dialog. 754 * title: Title bar text for dialog.
755 * defpath: The default path of the open dialog. 755 * defpath: The default path of the open dialog.
756 * ext: Default file extention. 756 * ext: Default file extention.
757 * flags: DW_FILE_OPEN or DW_FILE_SAVE. 757 * flags: DW_FILE_OPEN or DW_FILE_SAVE.
758 * Returns: 758 * Returns:
759 * NULL on error. A malloced buffer containing 759 * nullptr on error. A malloced buffer containing
760 * the file path on success. 760 * the file path on success.
761 * 761 *
762 */ 762 */
763 char * API dw_file_browse(const char *title, const char *defpath, const char *ext, int flags) 763 char * API dw_file_browse(const char *title, const char *defpath, const char *ext, int flags)
764 { 764 {
766 766
767 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) 767 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
768 { 768 {
769 // Use a long parameter 769 // Use a long parameter
770 jstring jstr = env->NewStringUTF(title); 770 jstring jstr = env->NewStringUTF(title);
771 jstring path = NULL; 771 jstring path = nullptr;
772 jstring jext = NULL; 772 jstring jext = nullptr;
773 if(defpath) 773 if(defpath)
774 path = env->NewStringUTF(defpath); 774 path = env->NewStringUTF(defpath);
775 if(ext) 775 if(ext)
776 jext = env->NewStringUTF(defpath); 776 jext = env->NewStringUTF(defpath);
777 // First get the class that contains the method you need to call 777 // First get the class that contains the method you need to call
782 // Call the method on the object 782 // Call the method on the object
783 jstring jresult = (jstring)env->CallObjectMethod(_dw_obj, fileBrowse, jstr, path, jext, flags); 783 jstring jresult = (jstring)env->CallObjectMethod(_dw_obj, fileBrowse, jstr, path, jext, flags);
784 if(jresult) 784 if(jresult)
785 return strdup(env->GetStringUTFChars(jresult, 0)); 785 return strdup(env->GetStringUTFChars(jresult, 0));
786 } 786 }
787 return NULL; 787 return nullptr;
788 } 788 }
789 789
790 /* 790 /*
791 * Gets the contents of the default clipboard as text. 791 * Gets the contents of the default clipboard as text.
792 * Parameters: 792 * Parameters:
793 * None. 793 * None.
794 * Returns: 794 * Returns:
795 * Pointer to an allocated string of text or NULL if clipboard empty or contents could not 795 * Pointer to an allocated string of text or nullptr if clipboard empty or contents could not
796 * be converted to text. 796 * be converted to text.
797 */ 797 */
798 char * API dw_clipboard_get_text() 798 char * API dw_clipboard_get_text()
799 { 799 {
800 JNIEnv *env; 800 JNIEnv *env;
801 801
802 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) 802 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
803 { 803 {
804 const char *utf8 = NULL; 804 const char *utf8 = nullptr;
805 805
806 // First get the class that contains the method you need to call 806 // First get the class that contains the method you need to call
807 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); 807 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
808 // Get the method that you want to call 808 // Get the method that you want to call
809 jmethodID clipboardGetText = env->GetMethodID(clazz, "clipboardGetText", 809 jmethodID clipboardGetText = env->GetMethodID(clazz, "clipboardGetText",
811 // Call the method on the object 811 // Call the method on the object
812 jstring result = (jstring)env->CallObjectMethod(_dw_obj, clipboardGetText); 812 jstring result = (jstring)env->CallObjectMethod(_dw_obj, clipboardGetText);
813 // Get the UTF8 string result 813 // Get the UTF8 string result
814 if(result) 814 if(result)
815 utf8 = env->GetStringUTFChars(result, 0); 815 utf8 = env->GetStringUTFChars(result, 0);
816 return utf8 ? strdup(utf8) : NULL; 816 return utf8 ? strdup(utf8) : nullptr;
817 } 817 }
818 return NULL; 818 return nullptr;
819 } 819 }
820 820
821 /* 821 /*
822 * Sets the contents of the default clipboard to the supplied text. 822 * Sets the contents of the default clipboard to the supplied text.
823 * Parameters: 823 * Parameters:
845 /* 845 /*
846 * Allocates and initializes a dialog struct. 846 * Allocates and initializes a dialog struct.
847 * Parameters: 847 * Parameters:
848 * data: User defined data to be passed to functions. 848 * data: User defined data to be passed to functions.
849 * Returns: 849 * Returns:
850 * A handle to a dialog or NULL on failure. 850 * A handle to a dialog or nullptr on failure.
851 */ 851 */
852 DWDialog * API dw_dialog_new(void *data) 852 DWDialog * API dw_dialog_new(void *data)
853 { 853 {
854 DWDialog *tmp = (DWDialog *)malloc(sizeof(DWDialog)); 854 DWDialog *tmp = (DWDialog *)malloc(sizeof(DWDialog));
855 855
857 { 857 {
858 tmp->eve = dw_event_new(); 858 tmp->eve = dw_event_new();
859 dw_event_reset(tmp->eve); 859 dw_event_reset(tmp->eve);
860 tmp->data = data; 860 tmp->data = data;
861 tmp->done = FALSE; 861 tmp->done = FALSE;
862 tmp->result = NULL; 862 tmp->result = nullptr;
863 } 863 }
864 return tmp; 864 return tmp;
865 } 865 }
866 866
867 /* 867 /*
889 * Returns: 889 * Returns:
890 * The data passed to dw_dialog_dismiss(). 890 * The data passed to dw_dialog_dismiss().
891 */ 891 */
892 void * API dw_dialog_wait(DWDialog *dialog) 892 void * API dw_dialog_wait(DWDialog *dialog)
893 { 893 {
894 void *tmp = NULL; 894 void *tmp = nullptr;
895 895
896 while(!dialog->done) 896 while(!dialog->done)
897 { 897 {
898 dw_main_iteration(); 898 dw_main_iteration();
899 } 899 }
907 * Create a new Box to be packed. 907 * Create a new Box to be packed.
908 * Parameters: 908 * Parameters:
909 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). 909 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
910 * pad: Number of pixels to pad around the box. 910 * pad: Number of pixels to pad around the box.
911 * Returns: 911 * Returns:
912 * A handle to a box or NULL on failure. 912 * A handle to a box or nullptr on failure.
913 */ 913 */
914 HWND API dw_box_new(int type, int pad) 914 HWND API dw_box_new(int type, int pad)
915 { 915 {
916 JNIEnv *env; 916 JNIEnv *env;
917 917
933 * Parameters: 933 * Parameters:
934 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). 934 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
935 * pad: Number of pixels to pad around the box. 935 * pad: Number of pixels to pad around the box.
936 * title: Text to be displayined in the group outline. 936 * title: Text to be displayined in the group outline.
937 * Returns: 937 * Returns:
938 * A handle to a groupbox window or NULL on failure. 938 * A handle to a groupbox window or nullptr on failure.
939 */ 939 */
940 HWND API dw_groupbox_new(int type, int pad, const char *title) 940 HWND API dw_groupbox_new(int type, int pad, const char *title)
941 { 941 {
942 /* TODO: Just create a normal box for now */ 942 /* TODO: Just create a normal box for now */
943 return dw_box_new(type, pad); 943 return dw_box_new(type, pad);
947 * Create a new scrollable Box to be packed. 947 * Create a new scrollable Box to be packed.
948 * Parameters: 948 * Parameters:
949 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). 949 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
950 * pad: Number of pixels to pad around the box. 950 * pad: Number of pixels to pad around the box.
951 * Returns: 951 * Returns:
952 * A handle to a scrollbox or NULL on failure. 952 * A handle to a scrollbox or nullptr on failure.
953 */ 953 */
954 HWND API dw_scrollbox_new(int type, int pad) 954 HWND API dw_scrollbox_new(int type, int pad)
955 { 955 {
956 JNIEnv *env; 956 JNIEnv *env;
957 957
1116 * Create a new button window (widget) to be packed. 1116 * Create a new button window (widget) to be packed.
1117 * Parameters: 1117 * Parameters:
1118 * text: The text to be display by the static text widget. 1118 * text: The text to be display by the static text widget.
1119 * id: An ID to be used with dw_window_from_id() or 0L. 1119 * id: An ID to be used with dw_window_from_id() or 0L.
1120 * Returns: 1120 * Returns:
1121 * A handle to a button window or NULL on failure. 1121 * A handle to a button window or nullptr on failure.
1122 */ 1122 */
1123 HWND API dw_button_new(const char *text, ULONG cid) 1123 HWND API dw_button_new(const char *text, ULONG cid)
1124 { 1124 {
1125 JNIEnv *env; 1125 JNIEnv *env;
1126 1126
1163 * Create a new Entryfield window (widget) to be packed. 1163 * Create a new Entryfield window (widget) to be packed.
1164 * Parameters: 1164 * Parameters:
1165 * text: The default text to be in the entryfield widget. 1165 * text: The default text to be in the entryfield widget.
1166 * id: An ID to be used with dw_window_from_id() or 0L. 1166 * id: An ID to be used with dw_window_from_id() or 0L.
1167 * Returns: 1167 * Returns:
1168 * A handle to an entryfield window or NULL on failure. 1168 * A handle to an entryfield window or nullptr on failure.
1169 */ 1169 */
1170 HWND API dw_entryfield_new(const char *text, ULONG cid) 1170 HWND API dw_entryfield_new(const char *text, ULONG cid)
1171 { 1171 {
1172 return _dw_entryfield_new(text, cid, FALSE); 1172 return _dw_entryfield_new(text, cid, FALSE);
1173 } 1173 }
1176 * Create a new Entryfield (password) window (widget) to be packed. 1176 * Create a new Entryfield (password) window (widget) to be packed.
1177 * Parameters: 1177 * Parameters:
1178 * text: The default text to be in the entryfield widget. 1178 * text: The default text to be in the entryfield widget.
1179 * id: An ID to be used with dw_window_from_id() or 0L. 1179 * id: An ID to be used with dw_window_from_id() or 0L.
1180 * Returns: 1180 * Returns:
1181 * A handle to an entryfield password window or NULL on failure. 1181 * A handle to an entryfield password window or nullptr on failure.
1182 */ 1182 */
1183 HWND API dw_entryfield_password_new(const char *text, ULONG cid) 1183 HWND API dw_entryfield_password_new(const char *text, ULONG cid)
1184 { 1184 {
1185 return _dw_entryfield_new(text, cid, TRUE); 1185 return _dw_entryfield_new(text, cid, TRUE);
1186 } 1186 }
1211 * Create a new bitmap button window (widget) to be packed. 1211 * Create a new bitmap button window (widget) to be packed.
1212 * Parameters: 1212 * Parameters:
1213 * text: Bubble help text to be displayed. 1213 * text: Bubble help text to be displayed.
1214 * id: An ID of a bitmap in the resource file. 1214 * id: An ID of a bitmap in the resource file.
1215 * Returns: 1215 * Returns:
1216 * A handle to a bitmap button window or NULL on failure. 1216 * A handle to a bitmap button window or nullptr on failure.
1217 */ 1217 */
1218 HWND API dw_bitmapbutton_new(const char *text, ULONG resid) 1218 HWND API dw_bitmapbutton_new(const char *text, ULONG resid)
1219 { 1219 {
1220 JNIEnv *env; 1220 JNIEnv *env;
1221 1221
1242 * id: An ID to be used with dw_window_from_id() or 0L. 1242 * id: An ID to be used with dw_window_from_id() or 0L.
1243 * filename: Name of the file, omit extention to have 1243 * filename: Name of the file, omit extention to have
1244 * DW pick the appropriate file extension. 1244 * DW pick the appropriate file extension.
1245 * (BMP on OS/2 or Windows, XPM on Unix) 1245 * (BMP on OS/2 or Windows, XPM on Unix)
1246 * Returns: 1246 * Returns:
1247 * A handle to a bitmap button window or NULL on failure. 1247 * A handle to a bitmap button window or nullptr on failure.
1248 */ 1248 */
1249 HWND API dw_bitmapbutton_new_from_file(const char *text, unsigned long cid, const char *filename) 1249 HWND API dw_bitmapbutton_new_from_file(const char *text, unsigned long cid, const char *filename)
1250 { 1250 {
1251 JNIEnv *env; 1251 JNIEnv *env;
1252 1252
1274 * id: An ID to be used with dw_window_from_id() or 0L. 1274 * id: An ID to be used with dw_window_from_id() or 0L.
1275 * data: The contents of the image 1275 * data: The contents of the image
1276 * (BMP or ICO on OS/2 or Windows, XPM on Unix) 1276 * (BMP or ICO on OS/2 or Windows, XPM on Unix)
1277 * len: length of str 1277 * len: length of str
1278 * Returns: 1278 * Returns:
1279 * A handle to a bitmap button window or NULL on failure. 1279 * A handle to a bitmap button window or nullptr on failure.
1280 */ 1280 */
1281 HWND API dw_bitmapbutton_new_from_data(const char *text, unsigned long cid, const char *data, int len) 1281 HWND API dw_bitmapbutton_new_from_data(const char *text, unsigned long cid, const char *data, int len)
1282 { 1282 {
1283 JNIEnv *env; 1283 JNIEnv *env;
1284 1284
1307 * Create a new spinbutton window (widget) to be packed. 1307 * Create a new spinbutton window (widget) to be packed.
1308 * Parameters: 1308 * Parameters:
1309 * text: The text to be display by the static text widget. 1309 * text: The text to be display by the static text widget.
1310 * id: An ID to be used with dw_window_from_id() or 0L. 1310 * id: An ID to be used with dw_window_from_id() or 0L.
1311 * Returns: 1311 * Returns:
1312 * A handle to a spinbutton window or NULL on failure. 1312 * A handle to a spinbutton window or nullptr on failure.
1313 */ 1313 */
1314 HWND API dw_spinbutton_new(const char *text, ULONG cid) 1314 HWND API dw_spinbutton_new(const char *text, ULONG cid)
1315 { 1315 {
1316 JNIEnv *env; 1316 JNIEnv *env;
1317 1317
1405 * Create a new radiobutton window (widget) to be packed. 1405 * Create a new radiobutton window (widget) to be packed.
1406 * Parameters: 1406 * Parameters:
1407 * text: The text to be display by the static text widget. 1407 * text: The text to be display by the static text widget.
1408 * id: An ID to be used with dw_window_from_id() or 0L. 1408 * id: An ID to be used with dw_window_from_id() or 0L.
1409 * Returns: 1409 * Returns:
1410 * A handle to a radio button window or NULL on failure. 1410 * A handle to a radio button window or nullptr on failure.
1411 */ 1411 */
1412 HWND API dw_radiobutton_new(const char *text, ULONG cid) 1412 HWND API dw_radiobutton_new(const char *text, ULONG cid)
1413 { 1413 {
1414 JNIEnv *env; 1414 JNIEnv *env;
1415 1415
1434 * Parameters: 1434 * Parameters:
1435 * vertical: TRUE or FALSE if slider is vertical. 1435 * vertical: TRUE or FALSE if slider is vertical.
1436 * increments: Number of increments available. 1436 * increments: Number of increments available.
1437 * id: An ID to be used with dw_window_from_id() or 0L. 1437 * id: An ID to be used with dw_window_from_id() or 0L.
1438 * Returns: 1438 * Returns:
1439 * A handle to a slider window or NULL on failure. 1439 * A handle to a slider window or nullptr on failure.
1440 */ 1440 */
1441 HWND API dw_slider_new(int vertical, int increments, ULONG cid) 1441 HWND API dw_slider_new(int vertical, int increments, ULONG cid)
1442 { 1442 {
1443 JNIEnv *env; 1443 JNIEnv *env;
1444 1444
1494 * Create a new scrollbar window (widget) to be packed. 1494 * Create a new scrollbar window (widget) to be packed.
1495 * Parameters: 1495 * Parameters:
1496 * vertical: TRUE or FALSE if scrollbar is vertical. 1496 * vertical: TRUE or FALSE if scrollbar is vertical.
1497 * id: An ID to be used with dw_window_from_id() or 0L. 1497 * id: An ID to be used with dw_window_from_id() or 0L.
1498 * Returns: 1498 * Returns:
1499 * A handle to a scrollbar window or NULL on failure. 1499 * A handle to a scrollbar window or nullptr on failure.
1500 */ 1500 */
1501 HWND API dw_scrollbar_new(int vertical, ULONG cid) 1501 HWND API dw_scrollbar_new(int vertical, ULONG cid)
1502 { 1502 {
1503 return dw_slider_new(vertical, 100, cid); 1503 return dw_slider_new(vertical, 100, cid);
1504 } 1504 }
1552 /* 1552 /*
1553 * Create a new percent bar window (widget) to be packed. 1553 * Create a new percent bar window (widget) to be packed.
1554 * Parameters: 1554 * Parameters:
1555 * id: An ID to be used with dw_window_from_id() or 0L. 1555 * id: An ID to be used with dw_window_from_id() or 0L.
1556 * Returns: 1556 * Returns:
1557 * A handle to a percent bar window or NULL on failure. 1557 * A handle to a percent bar window or nullptr on failure.
1558 */ 1558 */
1559 HWND API dw_percent_new(ULONG cid) 1559 HWND API dw_percent_new(ULONG cid)
1560 { 1560 {
1561 JNIEnv *env; 1561 JNIEnv *env;
1562 1562
1600 * Create a new checkbox window (widget) to be packed. 1600 * Create a new checkbox window (widget) to be packed.
1601 * Parameters: 1601 * Parameters:
1602 * text: The text to be display by the static text widget. 1602 * text: The text to be display by the static text widget.
1603 * id: An ID to be used with dw_window_from_id() or 0L. 1603 * id: An ID to be used with dw_window_from_id() or 0L.
1604 * Returns: 1604 * Returns:
1605 * A handle to a checkbox window or NULL on failure. 1605 * A handle to a checkbox window or nullptr on failure.
1606 */ 1606 */
1607 HWND API dw_checkbox_new(const char *text, ULONG cid) 1607 HWND API dw_checkbox_new(const char *text, ULONG cid)
1608 { 1608 {
1609 JNIEnv *env; 1609 JNIEnv *env;
1610 1610
1674 * Create a new listbox window (widget) to be packed. 1674 * Create a new listbox window (widget) to be packed.
1675 * Parameters: 1675 * Parameters:
1676 * id: An ID to be used with dw_window_from_id() or 0L. 1676 * id: An ID to be used with dw_window_from_id() or 0L.
1677 * multi: Multiple select TRUE or FALSE. 1677 * multi: Multiple select TRUE or FALSE.
1678 * Returns: 1678 * Returns:
1679 * A handle to a listbox window or NULL on failure. 1679 * A handle to a listbox window or nullptr on failure.
1680 */ 1680 */
1681 HWND API dw_listbox_new(ULONG cid, int multi) 1681 HWND API dw_listbox_new(ULONG cid, int multi)
1682 { 1682 {
1683 JNIEnv *env; 1683 JNIEnv *env;
1684 1684
1833 * Copies the given index item's text into buffer. 1833 * Copies the given index item's text into buffer.
1834 * Parameters: 1834 * Parameters:
1835 * handle: Handle to the listbox to be queried. 1835 * handle: Handle to the listbox to be queried.
1836 * index: Index into the list to be queried. 1836 * index: Index into the list to be queried.
1837 * buffer: Buffer where text will be copied. 1837 * buffer: Buffer where text will be copied.
1838 * length: Length of the buffer (including NULL). 1838 * length: Length of the buffer (including nullptr).
1839 */ 1839 */
1840 void API dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length) 1840 void API dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length)
1841 { 1841 {
1842 JNIEnv *env; 1842 JNIEnv *env;
1843 1843
1985 * Create a new Combobox window (widget) to be packed. 1985 * Create a new Combobox window (widget) to be packed.
1986 * Parameters: 1986 * Parameters:
1987 * text: The default text to be in the combpbox widget. 1987 * text: The default text to be in the combpbox widget.
1988 * id: An ID to be used with dw_window_from_id() or 0L. 1988 * id: An ID to be used with dw_window_from_id() or 0L.
1989 * Returns: 1989 * Returns:
1990 * A handle to a combobox window or NULL on failure. 1990 * A handle to a combobox window or nullptr on failure.
1991 */ 1991 */
1992 HWND API dw_combobox_new(const char *text, ULONG cid) 1992 HWND API dw_combobox_new(const char *text, ULONG cid)
1993 { 1993 {
1994 JNIEnv *env; 1994 JNIEnv *env;
1995 1995
2012 /* 2012 /*
2013 * Create a new Multiline Editbox window (widget) to be packed. 2013 * Create a new Multiline Editbox window (widget) to be packed.
2014 * Parameters: 2014 * Parameters:
2015 * id: An ID to be used with dw_window_from_id() or 0L. 2015 * id: An ID to be used with dw_window_from_id() or 0L.
2016 * Returns: 2016 * Returns:
2017 * A handle to a MLE window or NULL on failure. 2017 * A handle to a MLE window or nullptr on failure.
2018 */ 2018 */
2019 HWND API dw_mle_new(ULONG cid) 2019 HWND API dw_mle_new(ULONG cid)
2020 { 2020 {
2021 JNIEnv *env; 2021 JNIEnv *env;
2022 2022
2311 * Create a new status text window (widget) to be packed. 2311 * Create a new status text window (widget) to be packed.
2312 * Parameters: 2312 * Parameters:
2313 * text: The text to be display by the static text widget. 2313 * text: The text to be display by the static text widget.
2314 * id: An ID to be used with dw_window_from_id() or 0L. 2314 * id: An ID to be used with dw_window_from_id() or 0L.
2315 * Returns: 2315 * Returns:
2316 * A handle to a status text window or NULL on failure. 2316 * A handle to a status text window or nullptr on failure.
2317 */ 2317 */
2318 HWND API dw_status_text_new(const char *text, ULONG cid) 2318 HWND API dw_status_text_new(const char *text, ULONG cid)
2319 { 2319 {
2320 return _dw_text_new(text, cid, TRUE); 2320 return _dw_text_new(text, cid, TRUE);
2321 } 2321 }
2324 * Create a new static text window (widget) to be packed. 2324 * Create a new static text window (widget) to be packed.
2325 * Parameters: 2325 * Parameters:
2326 * text: The text to be display by the static text widget. 2326 * text: The text to be display by the static text widget.
2327 * id: An ID to be used with dw_window_from_id() or 0L. 2327 * id: An ID to be used with dw_window_from_id() or 0L.
2328 * Returns: 2328 * Returns:
2329 * A handle to a text window or NULL on failure. 2329 * A handle to a text window or nullptr on failure.
2330 */ 2330 */
2331 HWND API dw_text_new(const char *text, ULONG cid) 2331 HWND API dw_text_new(const char *text, ULONG cid)
2332 { 2332 {
2333 return _dw_text_new(text, cid, FALSE); 2333 return _dw_text_new(text, cid, FALSE);
2334 } 2334 }
2336 /* 2336 /*
2337 * Creates a rendering context widget (window) to be packed. 2337 * Creates a rendering context widget (window) to be packed.
2338 * Parameters: 2338 * Parameters:
2339 * id: An id to be used with dw_window_from_id. 2339 * id: An id to be used with dw_window_from_id.
2340 * Returns: 2340 * Returns:
2341 * A handle to the widget or NULL on failure. 2341 * A handle to the widget or nullptr on failure.
2342 */ 2342 */
2343 HWND API dw_render_new(unsigned long cid) 2343 HWND API dw_render_new(unsigned long cid)
2344 { 2344 {
2345 return 0; 2345 return 0;
2346 } 2346 }
2481 * Create a tree object to be packed. 2481 * Create a tree object to be packed.
2482 * Parameters: 2482 * Parameters:
2483 * id: An ID to be used for getting the resource from the 2483 * id: An ID to be used for getting the resource from the
2484 * resource file. 2484 * resource file.
2485 * Returns: 2485 * Returns:
2486 * A handle to a tree window or NULL on failure. 2486 * A handle to a tree window or nullptr on failure.
2487 */ 2487 */
2488 HWND API dw_tree_new(ULONG cid) 2488 HWND API dw_tree_new(ULONG cid)
2489 { 2489 {
2490 return 0; 2490 return 0;
2491 } 2491 }
2498 * title: The text title of the entry. 2498 * title: The text title of the entry.
2499 * icon: Handle to coresponding icon. 2499 * icon: Handle to coresponding icon.
2500 * parent: Parent handle or 0 if root. 2500 * parent: Parent handle or 0 if root.
2501 * itemdata: Item specific data. 2501 * itemdata: Item specific data.
2502 * Returns: 2502 * Returns:
2503 * A handle to a tree item or NULL on failure. 2503 * A handle to a tree item or nullptr on failure.
2504 */ 2504 */
2505 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, const char *title, HICN icon, HTREEITEM parent, void *itemdata) 2505 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, const char *title, HICN icon, HTREEITEM parent, void *itemdata)
2506 { 2506 {
2507 return 0; 2507 return 0;
2508 } 2508 }
2514 * title: The text title of the entry. 2514 * title: The text title of the entry.
2515 * icon: Handle to coresponding icon. 2515 * icon: Handle to coresponding icon.
2516 * parent: Parent handle or 0 if root. 2516 * parent: Parent handle or 0 if root.
2517 * itemdata: Item specific data. 2517 * itemdata: Item specific data.
2518 * Returns: 2518 * Returns:
2519 * A handle to a tree item or NULL on failure. 2519 * A handle to a tree item or nullptr on failure.
2520 */ 2520 */
2521 HTREEITEM API dw_tree_insert(HWND handle, const char *title, HICN icon, HTREEITEM parent, void *itemdata) 2521 HTREEITEM API dw_tree_insert(HWND handle, const char *title, HICN icon, HTREEITEM parent, void *itemdata)
2522 { 2522 {
2523 return 0; 2523 return 0;
2524 } 2524 }
2527 * Gets the text an item in a tree window (widget). 2527 * Gets the text an item in a tree window (widget).
2528 * Parameters: 2528 * Parameters:
2529 * handle: Handle to the tree containing the item. 2529 * handle: Handle to the tree containing the item.
2530 * item: Handle of the item to be modified. 2530 * item: Handle of the item to be modified.
2531 * Returns: 2531 * Returns:
2532 * A malloc()ed buffer of item text to be dw_free()ed or NULL on error. 2532 * A malloc()ed buffer of item text to be dw_free()ed or nullptr on error.
2533 */ 2533 */
2534 char * API dw_tree_get_title(HWND handle, HTREEITEM item) 2534 char * API dw_tree_get_title(HWND handle, HTREEITEM item)
2535 { 2535 {
2536 return NULL; 2536 return nullptr;
2537 } 2537 }
2538 2538
2539 /* 2539 /*
2540 * Gets the text an item in a tree window (widget). 2540 * Gets the text an item in a tree window (widget).
2541 * Parameters: 2541 * Parameters:
2542 * handle: Handle to the tree containing the item. 2542 * handle: Handle to the tree containing the item.
2543 * item: Handle of the item to be modified. 2543 * item: Handle of the item to be modified.
2544 * Returns: 2544 * Returns:
2545 * A handle to a tree item or NULL on failure. 2545 * A handle to a tree item or nullptr on failure.
2546 */ 2546 */
2547 HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item) 2547 HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item)
2548 { 2548 {
2549 return 0; 2549 return 0;
2550 } 2550 }
2576 * Gets the item data of a tree item. 2576 * Gets the item data of a tree item.
2577 * Parameters: 2577 * Parameters:
2578 * handle: Handle to the tree containing the item. 2578 * handle: Handle to the tree containing the item.
2579 * item: Handle of the item to be modified. 2579 * item: Handle of the item to be modified.
2580 * Returns: 2580 * Returns:
2581 * A pointer to tree item data or NULL on failure. 2581 * A pointer to tree item data or nullptr on failure.
2582 */ 2582 */
2583 void * API dw_tree_item_get_data(HWND handle, HTREEITEM item) 2583 void * API dw_tree_item_get_data(HWND handle, HTREEITEM item)
2584 { 2584 {
2585 return NULL; 2585 return nullptr;
2586 } 2586 }
2587 2587
2588 /* 2588 /*
2589 * Sets this item as the active selection. 2589 * Sets this item as the active selection.
2590 * Parameters: 2590 * Parameters:
2638 * Create a container object to be packed. 2638 * Create a container object to be packed.
2639 * Parameters: 2639 * Parameters:
2640 * id: An ID to be used for getting the resource from the 2640 * id: An ID to be used for getting the resource from the
2641 * resource file. 2641 * resource file.
2642 * Returns: 2642 * Returns:
2643 * A handle to a container window or NULL on failure. 2643 * A handle to a container window or nullptr on failure.
2644 */ 2644 */
2645 HWND API dw_container_new(ULONG cid, int multi) 2645 HWND API dw_container_new(ULONG cid, int multi)
2646 { 2646 {
2647 return 0; 2647 return 0;
2648 } 2648 }
2693 * Allocates memory used to populate a container. 2693 * Allocates memory used to populate a container.
2694 * Parameters: 2694 * Parameters:
2695 * handle: Handle to the container window (widget). 2695 * handle: Handle to the container window (widget).
2696 * rowcount: The number of items to be populated. 2696 * rowcount: The number of items to be populated.
2697 * Returns: 2697 * Returns:
2698 * Handle to container items allocated or NULL on error. 2698 * Handle to container items allocated or nullptr on error.
2699 */ 2699 */
2700 void * API dw_container_alloc(HWND handle, int rowcount) 2700 void * API dw_container_alloc(HWND handle, int rowcount)
2701 { 2701 {
2702 return NULL; 2702 return nullptr;
2703 } 2703 }
2704 2704
2705 /* 2705 /*
2706 * Sets an item in specified row and column to the given data. 2706 * Sets an item in specified row and column to the given data.
2707 * Parameters: 2707 * Parameters:
2922 * handle: Handle to the window (widget) to be queried. 2922 * handle: Handle to the window (widget) to be queried.
2923 * flags: If this parameter is DW_CRA_SELECTED it will only 2923 * flags: If this parameter is DW_CRA_SELECTED it will only
2924 * return items that are currently selected. Otherwise 2924 * return items that are currently selected. Otherwise
2925 * it will return all records in the container. 2925 * it will return all records in the container.
2926 * Returns: 2926 * Returns:
2927 * Pointer to data associated with first entry or NULL on error. 2927 * Pointer to data associated with first entry or nullptr on error.
2928 */ 2928 */
2929 char * API dw_container_query_start(HWND handle, unsigned long flags) 2929 char * API dw_container_query_start(HWND handle, unsigned long flags)
2930 { 2930 {
2931 return NULL; 2931 return nullptr;
2932 } 2932 }
2933 2933
2934 /* 2934 /*
2935 * Continues an existing query of a container. 2935 * Continues an existing query of a container.
2936 * Parameters: 2936 * Parameters:
2937 * handle: Handle to the window (widget) to be queried. 2937 * handle: Handle to the window (widget) to be queried.
2938 * flags: If this parameter is DW_CRA_SELECTED it will only 2938 * flags: If this parameter is DW_CRA_SELECTED it will only
2939 * return items that are currently selected. Otherwise 2939 * return items that are currently selected. Otherwise
2940 * it will return all records in the container. 2940 * it will return all records in the container.
2941 * Returns: 2941 * Returns:
2942 * Pointer to data associated with next entry or NULL on error or completion. 2942 * Pointer to data associated with next entry or nullptr on error or completion.
2943 */ 2943 */
2944 char * API dw_container_query_next(HWND handle, unsigned long flags) 2944 char * API dw_container_query_next(HWND handle, unsigned long flags)
2945 { 2945 {
2946 return NULL; 2946 return nullptr;
2947 } 2947 }
2948 2948
2949 /* 2949 /*
2950 * Cursors the item with the text speficied, and scrolls to that item. 2950 * Cursors the item with the text speficied, and scrolls to that item.
2951 * Parameters: 2951 * Parameters:
3022 * module: Handle to module (DLL) in OS/2 and Windows. 3022 * module: Handle to module (DLL) in OS/2 and Windows.
3023 * id: A unsigned long id int the resources on OS/2 and 3023 * id: A unsigned long id int the resources on OS/2 and
3024 * Windows, on GTK this is converted to a pointer 3024 * Windows, on GTK this is converted to a pointer
3025 * to an embedded XPM. 3025 * to an embedded XPM.
3026 * Returns: 3026 * Returns:
3027 * Handle to the created icon or NULL on error. 3027 * Handle to the created icon or nullptr on error.
3028 */ 3028 */
3029 HICN API dw_icon_load(unsigned long module, unsigned long resid) 3029 HICN API dw_icon_load(unsigned long module, unsigned long resid)
3030 { 3030 {
3031 return 0; 3031 return 0;
3032 } 3032 }
3036 * Parameters: 3036 * Parameters:
3037 * filename: Name of the file, omit extention to have 3037 * filename: Name of the file, omit extention to have
3038 * DW pick the appropriate file extension. 3038 * DW pick the appropriate file extension.
3039 * (ICO on OS/2 or Windows, XPM on Unix) 3039 * (ICO on OS/2 or Windows, XPM on Unix)
3040 * Returns: 3040 * Returns:
3041 * Handle to the created icon or NULL on error. 3041 * Handle to the created icon or nullptr on error.
3042 */ 3042 */
3043 HICN API dw_icon_load_from_file(const char *filename) 3043 HICN API dw_icon_load_from_file(const char *filename)
3044 { 3044 {
3045 return 0; 3045 return 0;
3046 } 3046 }
3049 * Obtains an icon from data. 3049 * Obtains an icon from data.
3050 * Parameters: 3050 * Parameters:
3051 * data: Data for the icon (ICO on OS/2 or Windows, XPM on Unix, PNG on Mac) 3051 * data: Data for the icon (ICO on OS/2 or Windows, XPM on Unix, PNG on Mac)
3052 * len: Length of the passed in data. 3052 * len: Length of the passed in data.
3053 * Returns: 3053 * Returns:
3054 * Handle to the created icon or NULL on error. 3054 * Handle to the created icon or nullptr on error.
3055 */ 3055 */
3056 HICN API dw_icon_load_from_data(const char *data, int len) 3056 HICN API dw_icon_load_from_data(const char *data, int len)
3057 { 3057 {
3058 return 0; 3058 return 0;
3059 } 3059 }
3070 /* 3070 /*
3071 * Create a new MDI Frame to be packed. 3071 * Create a new MDI Frame to be packed.
3072 * Parameters: 3072 * Parameters:
3073 * id: An ID to be used with dw_window_from_id or 0L. 3073 * id: An ID to be used with dw_window_from_id or 0L.
3074 * Returns: 3074 * Returns:
3075 * Handle to the created MDI widget or NULL on error. 3075 * Handle to the created MDI widget or nullptr on error.
3076 */ 3076 */
3077 HWND API dw_mdi_new(unsigned long cid) 3077 HWND API dw_mdi_new(unsigned long cid)
3078 { 3078 {
3079 return 0; 3079 return nullptr;
3080 } 3080 }
3081 3081
3082 /* 3082 /*
3083 * Creates a splitbar window (widget) with given parameters. 3083 * Creates a splitbar window (widget) with given parameters.
3084 * Parameters: 3084 * Parameters:
3085 * type: Value can be DW_VERT or DW_HORZ. 3085 * type: Value can be DW_VERT or DW_HORZ.
3086 * topleft: Handle to the window to be top or left. 3086 * topleft: Handle to the window to be top or left.
3087 * bottomright: Handle to the window to be bottom or right. 3087 * bottomright: Handle to the window to be bottom or right.
3088 * Returns: 3088 * Returns:
3089 * A handle to a splitbar window or NULL on failure. 3089 * A handle to a splitbar window or nullptr on failure.
3090 */ 3090 */
3091 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long cid) 3091 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long cid)
3092 { 3092 {
3093 return 0; 3093 return nullptr;
3094 } 3094 }
3095 3095
3096 /* 3096 /*
3097 * Sets the position of a splitbar (pecentage). 3097 * Sets the position of a splitbar (pecentage).
3098 * Parameters: 3098 * Parameters:
3118 /* 3118 /*
3119 * Create a bitmap object to be packed. 3119 * Create a bitmap object to be packed.
3120 * Parameters: 3120 * Parameters:
3121 * id: An ID to be used with dw_window_from_id() or 0L. 3121 * id: An ID to be used with dw_window_from_id() or 0L.
3122 * Returns: 3122 * Returns:
3123 * Handle to the created bitmap widget or NULL on error. 3123 * Handle to the created bitmap widget or nullptr on error.
3124 */ 3124 */
3125 HWND API dw_bitmap_new(ULONG cid) 3125 HWND API dw_bitmap_new(ULONG cid)
3126 { 3126 {
3127 JNIEnv *env; 3127 JNIEnv *env;
3128 3128
3135 "(I)Landroid/widget/ImageView;"); 3135 "(I)Landroid/widget/ImageView;");
3136 // Call the method on the object 3136 // Call the method on the object
3137 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, mleNew, (int)cid)); 3137 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, mleNew, (int)cid));
3138 return result; 3138 return result;
3139 } 3139 }
3140 return 0; 3140 return nullptr;
3141 }
3142
3143 /* Unified internal function to create an Android internal Bitmap */
3144 jobject _dw_jbitmap_new(unsigned long width, unsigned long height, const char *filename, const char *data, int len, int resid)
3145 {
3146 JNIEnv *env;
3147
3148 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
3149 {
3150 // Construct a string
3151 jstring file = nullptr;
3152 if(filename)
3153 file = env->NewStringUTF(filename);
3154 // Construct a byte array
3155 jbyteArray bytearray = nullptr;
3156 if(data && len > 0)
3157 {
3158 bytearray = env->NewByteArray(len);
3159 env->SetByteArrayRegion(bytearray, 0, len, reinterpret_cast<const jbyte *>(data));
3160 }
3161 // First get the class that contains the method you need to call
3162 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
3163 // Get the method that you want to call
3164 jmethodID pixmapNew = env->GetMethodID(clazz, "pixmapNew",
3165 "(IILjava/lang/String;[BII)Landroid/graphics/Bitmap;");
3166 // Call the method on the object
3167 jobject result = env->NewGlobalRef(env->CallObjectMethod(_dw_obj, pixmapNew,
3168 (jint)width, (jint)height,
3169 file, bytearray, len, resid));
3170 // Clean up after the array now that we are finished
3171 //if(bytearray)
3172 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0);
3173 return result;
3174 }
3175 return nullptr;
3176 }
3177
3178 void _dw_pixmap_get_dimensions(HPIXMAP pixmap)
3179 {
3180 JNIEnv *env;
3181
3182 if(pixmap && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
3183 {
3184 // First get the class that contains the method you need to call
3185 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
3186 // Get the method that you want to call
3187 jmethodID pixmapGetDimensions = env->GetMethodID(clazz, "pixmapGetDimensions",
3188 "(Landroid/graphics/Bitmap;)J");
3189 // Call the method on the object
3190 jlong dimensions = env->CallLongMethod(_dw_obj, pixmapGetDimensions, pixmap->bitmap);
3191
3192 pixmap->width = dimensions & 0xFFFF;
3193 pixmap->height = dimensions >> 32;
3194 }
3141 } 3195 }
3142 3196
3143 /* 3197 /*
3144 * Creates a pixmap with given parameters. 3198 * Creates a pixmap with given parameters.
3145 * Parameters: 3199 * Parameters:
3146 * handle: Window handle the pixmap is associated with. 3200 * handle: Window handle the pixmap is associated with.
3147 * width: Width of the pixmap in pixels. 3201 * width: Width of the pixmap in pixels.
3148 * height: Height of the pixmap in pixels. 3202 * height: Height of the pixmap in pixels.
3149 * depth: Color depth of the pixmap. 3203 * depth: Color depth of the pixmap.
3150 * Returns: 3204 * Returns:
3151 * A handle to a pixmap or NULL on failure. 3205 * A handle to a pixmap or nullptr on failure.
3152 */ 3206 */
3153 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) 3207 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
3154 { 3208 {
3155 return 0; 3209 jobject jbitmap = _dw_jbitmap_new(width, height, nullptr, nullptr, 0, 0);
3210
3211 if(jbitmap)
3212 {
3213 HPIXMAP pixmap = (HPIXMAP)calloc(1, sizeof(HPIXMAP));
3214
3215 if(pixmap)
3216 {
3217 pixmap->width = width;
3218 pixmap->height = height;
3219 pixmap->bitmap = jbitmap;
3220 pixmap->handle = handle;
3221
3222 return pixmap;
3223 }
3224 }
3225 return nullptr;
3156 } 3226 }
3157 3227
3158 /* 3228 /*
3159 * Creates a pixmap from a file. 3229 * Creates a pixmap from a file.
3160 * Parameters: 3230 * Parameters:
3161 * handle: Window handle the pixmap is associated with. 3231 * handle: Window handle the pixmap is associated with.
3162 * filename: Name of the file, omit extention to have 3232 * filename: Name of the file, omit extention to have
3163 * DW pick the appropriate file extension. 3233 * DW pick the appropriate file extension.
3164 * (BMP on OS/2 or Windows, XPM on Unix) 3234 * (BMP on OS/2 or Windows, XPM on Unix)
3165 * Returns: 3235 * Returns:
3166 * A handle to a pixmap or NULL on failure. 3236 * A handle to a pixmap or nullptr on failure.
3167 */ 3237 */
3168 HPIXMAP API dw_pixmap_new_from_file(HWND handle, const char *filename) 3238 HPIXMAP API dw_pixmap_new_from_file(HWND handle, const char *filename)
3169 { 3239 {
3170 return 0; 3240 jobject jbitmap = _dw_jbitmap_new(0, 0, filename, nullptr, 0, 0);
3241
3242 if(jbitmap)
3243 {
3244 HPIXMAP pixmap = (HPIXMAP)calloc(1, sizeof(HPIXMAP));
3245
3246 if(pixmap)
3247 {
3248 pixmap->bitmap = jbitmap;
3249 pixmap->handle = handle;
3250 _dw_pixmap_get_dimensions(pixmap);
3251
3252 return pixmap;
3253 }
3254 }
3255 return nullptr;
3171 } 3256 }
3172 3257
3173 /* 3258 /*
3174 * Creates a pixmap from data in memory. 3259 * Creates a pixmap from data in memory.
3175 * Parameters: 3260 * Parameters:
3176 * handle: Window handle the pixmap is associated with. 3261 * handle: Window handle the pixmap is associated with.
3177 * data: Source of the image data 3262 * data: Source of the image data
3178 * (BMP on OS/2 or Windows, XPM on Unix) 3263 * (BMP on OS/2 or Windows, XPM on Unix)
3179 * len: Length of data 3264 * len: Length of data
3180 * Returns: 3265 * Returns:
3181 * A handle to a pixmap or NULL on failure. 3266 * A handle to a pixmap or nullptr on failure.
3182 */ 3267 */
3183 HPIXMAP API dw_pixmap_new_from_data(HWND handle, const char *data, int len) 3268 HPIXMAP API dw_pixmap_new_from_data(HWND handle, const char *data, int len)
3184 { 3269 {
3185 return 0; 3270 jobject jbitmap = _dw_jbitmap_new(0, 0, nullptr, data, len, 0);
3271
3272 if(jbitmap)
3273 {
3274 HPIXMAP pixmap = (HPIXMAP)calloc(1, sizeof(HPIXMAP));
3275
3276 if(pixmap)
3277 {
3278 pixmap->bitmap = jbitmap;
3279 pixmap->handle = handle;
3280 _dw_pixmap_get_dimensions(pixmap);
3281
3282 return pixmap;
3283 }
3284 }
3285 return nullptr;
3186 } 3286 }
3187 3287
3188 /* 3288 /*
3189 * Sets the transparent color for a pixmap. 3289 * Sets the transparent color for a pixmap.
3190 * Parameters: 3290 * Parameters:
3202 * Creates a pixmap from internal resource graphic specified by id. 3302 * Creates a pixmap from internal resource graphic specified by id.
3203 * Parameters: 3303 * Parameters:
3204 * handle: Window handle the pixmap is associated with. 3304 * handle: Window handle the pixmap is associated with.
3205 * id: Resource ID associated with requested pixmap. 3305 * id: Resource ID associated with requested pixmap.
3206 * Returns: 3306 * Returns:
3207 * A handle to a pixmap or NULL on failure. 3307 * A handle to a pixmap or nullptr on failure.
3208 */ 3308 */
3209 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG resid) 3309 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG resid)
3210 { 3310 {
3211 return 0; 3311 jobject jbitmap = _dw_jbitmap_new(0, 0, nullptr, nullptr, 0, (int)resid);
3312
3313 if(jbitmap)
3314 {
3315 HPIXMAP pixmap = (HPIXMAP)calloc(1, sizeof(HPIXMAP));
3316
3317 if(pixmap)
3318 {
3319 pixmap->bitmap = jbitmap;
3320 pixmap->handle = handle;
3321 _dw_pixmap_get_dimensions(pixmap);
3322
3323 return pixmap;
3324 }
3325 }
3326 return nullptr;
3212 } 3327 }
3213 3328
3214 /* 3329 /*
3215 * Sets the font used by a specified pixmap. 3330 * Sets the font used by a specified pixmap.
3216 * Normally the pixmap font is obtained from the associated window handle. 3331 * Normally the pixmap font is obtained from the associated window handle.
3233 * pixmap: Handle to a pixmap returned by 3348 * pixmap: Handle to a pixmap returned by
3234 * dw_pixmap_new.. 3349 * dw_pixmap_new..
3235 */ 3350 */
3236 void API dw_pixmap_destroy(HPIXMAP pixmap) 3351 void API dw_pixmap_destroy(HPIXMAP pixmap)
3237 { 3352 {
3353 if(pixmap)
3354 {
3355 JNIEnv *env;
3356
3357 if(pixmap && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
3358 {
3359 env->DeleteGlobalRef(pixmap->bitmap);
3360 free(pixmap);
3361 }
3362 }
3238 } 3363 }
3239 3364
3240 /* 3365 /*
3241 * Copies from one item to another. 3366 * Copies from one item to another.
3242 * Parameters: 3367 * Parameters:
3281 /* 3406 /*
3282 * Create a new calendar window (widget) to be packed. 3407 * Create a new calendar window (widget) to be packed.
3283 * Parameters: 3408 * Parameters:
3284 * id: An ID to be used with dw_window_from_id() or 0L. 3409 * id: An ID to be used with dw_window_from_id() or 0L.
3285 * Returns: 3410 * Returns:
3286 * Handle to the created calendar or NULL on error. 3411 * Handle to the created calendar or nullptr on error.
3287 */ 3412 */
3288 HWND API dw_calendar_new(ULONG cid) 3413 HWND API dw_calendar_new(ULONG cid)
3289 { 3414 {
3290 JNIEnv *env; 3415 JNIEnv *env;
3291 3416
3336 3461
3337 /* 3462 /*
3338 * Gets the year, month and day set in the calendar widget. 3463 * Gets the year, month and day set in the calendar widget.
3339 * Parameters: 3464 * Parameters:
3340 * handle: The handle to the calendar returned by dw_calendar_new(). 3465 * handle: The handle to the calendar returned by dw_calendar_new().
3341 * year: Variable to store the year or NULL. 3466 * year: Variable to store the year or nullptr.
3342 * month: Variable to store the month or NULL. 3467 * month: Variable to store the month or nullptr.
3343 * day: Variable to store the day or NULL. 3468 * day: Variable to store the day or nullptr.
3344 */ 3469 */
3345 void API dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day) 3470 void API dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day)
3346 { 3471 {
3347 JNIEnv *env; 3472 JNIEnv *env;
3348 3473
3481 /* 3606 /*
3482 * Create a new HTML window (widget) to be packed. 3607 * Create a new HTML window (widget) to be packed.
3483 * Parameters: 3608 * Parameters:
3484 * id: An ID to be used with dw_window_from_id() or 0L. 3609 * id: An ID to be used with dw_window_from_id() or 0L.
3485 * Returns: 3610 * Returns:
3486 * Handle to the created html widget or NULL on error. 3611 * Handle to the created html widget or nullptr on error.
3487 */ 3612 */
3488 HWND API dw_html_new(unsigned long cid) 3613 HWND API dw_html_new(unsigned long cid)
3489 { 3614 {
3490 JNIEnv *env; 3615 JNIEnv *env;
3491 3616
3504 } 3629 }
3505 3630
3506 /* 3631 /*
3507 * Returns the current X and Y coordinates of the mouse pointer. 3632 * Returns the current X and Y coordinates of the mouse pointer.
3508 * Parameters: 3633 * Parameters:
3509 * x: Pointer to variable to store X coordinate or NULL. 3634 * x: Pointer to variable to store X coordinate or nullptr.
3510 * y: Pointer to variable to store Y coordinate or NULL. 3635 * y: Pointer to variable to store Y coordinate or nullptr.
3511 */ 3636 */
3512 void API dw_pointer_query_pos(long *x, long *y) 3637 void API dw_pointer_query_pos(long *x, long *y)
3513 { 3638 {
3514 } 3639 }
3515 3640
3526 /* 3651 /*
3527 * Create a menu object to be popped up. 3652 * Create a menu object to be popped up.
3528 * Parameters: 3653 * Parameters:
3529 * id: An ID to be used associated with this menu. 3654 * id: An ID to be used associated with this menu.
3530 * Returns: 3655 * Returns:
3531 * Handle to the created menu or NULL on error. 3656 * Handle to the created menu or nullptr on error.
3532 */ 3657 */
3533 HMENUI API dw_menu_new(ULONG cid) 3658 HMENUI API dw_menu_new(ULONG cid)
3534 { 3659 {
3535 return 0; 3660 return 0;
3536 } 3661 }
3538 /* 3663 /*
3539 * Create a menubar on a window. 3664 * Create a menubar on a window.
3540 * Parameters: 3665 * Parameters:
3541 * location: Handle of a window frame to be attached to. 3666 * location: Handle of a window frame to be attached to.
3542 * Returns: 3667 * Returns:
3543 * Handle to the created menu bar or NULL on error. 3668 * Handle to the created menu bar or nullptr on error.
3544 */ 3669 */
3545 HMENUI API dw_menubar_new(HWND location) 3670 HMENUI API dw_menubar_new(HWND location)
3546 { 3671 {
3547 return 0; 3672 return 0;
3548 } 3673 }
3588 * title: The title text on the menu item to be added. 3713 * title: The title text on the menu item to be added.
3589 * id: An ID to be used for message passing. 3714 * id: An ID to be used for message passing.
3590 * flags: Extended attributes to set on the menu. 3715 * flags: Extended attributes to set on the menu.
3591 * end: If TRUE memu is positioned at the end of the menu. 3716 * end: If TRUE memu is positioned at the end of the menu.
3592 * check: If TRUE menu is "check"able. 3717 * check: If TRUE menu is "check"able.
3593 * submenu: Handle to an existing menu to be a submenu or NULL. 3718 * submenu: Handle to an existing menu to be a submenu or nullptr.
3594 * Returns: 3719 * Returns:
3595 * Handle to the created menu item or NULL on error. 3720 * Handle to the created menu item or nullptr on error.
3596 */ 3721 */
3597 HWND API dw_menu_append_item(HMENUI menux, const char *title, ULONG itemid, ULONG flags, int end, int check, HMENUI submenux) 3722 HWND API dw_menu_append_item(HMENUI menux, const char *title, ULONG itemid, ULONG flags, int end, int check, HMENUI submenux)
3598 { 3723 {
3599 return 0; 3724 return 0;
3600 } 3725 }
3627 * Create a notebook object to be packed. 3752 * Create a notebook object to be packed.
3628 * Parameters: 3753 * Parameters:
3629 * id: An ID to be used for getting the resource from the 3754 * id: An ID to be used for getting the resource from the
3630 * resource file. 3755 * resource file.
3631 * Returns: 3756 * Returns:
3632 * Handle to the created notebook or NULL on error. 3757 * Handle to the created notebook or nullptr on error.
3633 */ 3758 */
3634 HWND API dw_notebook_new(ULONG cid, int top) 3759 HWND API dw_notebook_new(ULONG cid, int top)
3635 { 3760 {
3636 JNIEnv *env; 3761 JNIEnv *env;
3637 3762
3807 * Parameters: 3932 * Parameters:
3808 * owner: The Owner's window handle or HWND_DESKTOP. 3933 * owner: The Owner's window handle or HWND_DESKTOP.
3809 * title: The Window title. 3934 * title: The Window title.
3810 * flStyle: Style flags. 3935 * flStyle: Style flags.
3811 * Returns: 3936 * Returns:
3812 * Handle to the created window or NULL on error. 3937 * Handle to the created window or nullptr on error.
3813 */ 3938 */
3814 HWND API dw_window_new(HWND hwndOwner, const char *title, ULONG flStyle) 3939 HWND API dw_window_new(HWND hwndOwner, const char *title, ULONG flStyle)
3815 { 3940 {
3816 JNIEnv *env; 3941 JNIEnv *env;
3817 3942
4008 /* 4133 /*
4009 * Returns the current font for the specified window. 4134 * Returns the current font for the specified window.
4010 * Parameters: 4135 * Parameters:
4011 * handle: The window handle from which to obtain the font. 4136 * handle: The window handle from which to obtain the font.
4012 * Returns: 4137 * Returns:
4013 * A malloc()ed font name string to be dw_free()ed or NULL on error. 4138 * A malloc()ed font name string to be dw_free()ed or nullptr on error.
4014 */ 4139 */
4015 char * API dw_window_get_font(HWND handle) 4140 char * API dw_window_get_font(HWND handle)
4016 { 4141 {
4017 return NULL; 4142 return nullptr;
4018 } 4143 }
4019 4144
4020 /* Allows the user to choose a font using the system's font chooser dialog. 4145 /* Allows the user to choose a font using the system's font chooser dialog.
4021 * Parameters: 4146 * Parameters:
4022 * currfont: current font 4147 * currfont: current font
4023 * Returns: 4148 * Returns:
4024 * A malloced buffer with the selected font or NULL on error. 4149 * A malloced buffer with the selected font or nullptr on error.
4025 */ 4150 */
4026 char * API dw_font_choose(const char *currfont) 4151 char * API dw_font_choose(const char *currfont)
4027 { 4152 {
4028 return NULL; 4153 return nullptr;
4029 } 4154 }
4030 4155
4031 /* 4156 /*
4032 * Sets the default font used on text based widgets. 4157 * Sets the default font used on text based widgets.
4033 * Parameters: 4158 * Parameters:
4052 /* 4177 /*
4053 * Gets the text used for a given window. 4178 * Gets the text used for a given window.
4054 * Parameters: 4179 * Parameters:
4055 * handle: Handle to the window. 4180 * handle: Handle to the window.
4056 * Returns: 4181 * Returns:
4057 * The text associsated with a given window or NULL on error. 4182 * The text associsated with a given window or nullptr on error.
4058 */ 4183 */
4059 char * API dw_window_get_text(HWND handle) 4184 char * API dw_window_get_text(HWND handle)
4060 { 4185 {
4061 JNIEnv *env; 4186 JNIEnv *env;
4062 4187
4063 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) 4188 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
4064 { 4189 {
4065 const char *utf8 = NULL; 4190 const char *utf8 = nullptr;
4066 4191
4067 // First get the class that contains the method you need to call 4192 // First get the class that contains the method you need to call
4068 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); 4193 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
4069 // Get the method that you want to call 4194 // Get the method that you want to call
4070 jmethodID windowGetText = env->GetMethodID(clazz, "windowGetText", 4195 jmethodID windowGetText = env->GetMethodID(clazz, "windowGetText",
4072 // Call the method on the object 4197 // Call the method on the object
4073 jstring result = (jstring)env->CallObjectMethod(_dw_obj, windowGetText, handle); 4198 jstring result = (jstring)env->CallObjectMethod(_dw_obj, windowGetText, handle);
4074 // Get the UTF8 string result 4199 // Get the UTF8 string result
4075 if(result) 4200 if(result)
4076 utf8 = env->GetStringUTFChars(result, 0); 4201 utf8 = env->GetStringUTFChars(result, 0);
4077 return utf8 ? strdup(utf8) : NULL; 4202 return utf8 ? strdup(utf8) : nullptr;
4078 } 4203 }
4079 return NULL; 4204 return nullptr;
4080 } 4205 }
4081 4206
4082 /* 4207 /*
4083 * Sets the text used for a given window. 4208 * Sets the text used for a given window.
4084 * Parameters: 4209 * Parameters:
4155 * handle: Handle to the window. 4280 * handle: Handle to the window.
4156 * id: An ID to be used to specify the icon, 4281 * id: An ID to be used to specify the icon,
4157 * (pass 0 if you use the filename param) 4282 * (pass 0 if you use the filename param)
4158 * data: memory buffer containing image (Bitmap on OS/2 or 4283 * data: memory buffer containing image (Bitmap on OS/2 or
4159 * Windows and a pixmap on Unix, pass 4284 * Windows and a pixmap on Unix, pass
4160 * NULL if you use the id param) 4285 * nullptr if you use the id param)
4161 * len: Length of data passed 4286 * len: Length of data passed
4162 */ 4287 */
4163 void API dw_window_set_bitmap_from_data(HWND handle, unsigned long cid, const char *data, int len) 4288 void API dw_window_set_bitmap_from_data(HWND handle, unsigned long cid, const char *data, int len)
4164 { 4289 {
4165 JNIEnv *env; 4290 JNIEnv *env;
4166 4291
4167 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) 4292 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
4168 { 4293 {
4169 // Construct a byte array 4294 // Construct a byte array
4170 jbyteArray bytearray = NULL; 4295 jbyteArray bytearray = nullptr;
4171 if(data && len > 0) { 4296 if(data && len > 0)
4297 {
4172 bytearray = env->NewByteArray(len); 4298 bytearray = env->NewByteArray(len);
4173 env->SetByteArrayRegion(bytearray, 0, len, reinterpret_cast<const jbyte *>(data)); 4299 env->SetByteArrayRegion(bytearray, 0, len, reinterpret_cast<const jbyte *>(data));
4174 } 4300 }
4175 // First get the class that contains the method you need to call 4301 // First get the class that contains the method you need to call
4176 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); 4302 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
4178 jmethodID windowSetBitmapFromData = env->GetMethodID(clazz, "windowSetBitmapFromData", 4304 jmethodID windowSetBitmapFromData = env->GetMethodID(clazz, "windowSetBitmapFromData",
4179 "(Landroid/view/View;I[BI)V"); 4305 "(Landroid/view/View;I[BI)V");
4180 // Call the method on the object 4306 // Call the method on the object
4181 env->CallVoidMethod(_dw_obj, windowSetBitmapFromData, handle, (int)cid, bytearray, len); 4307 env->CallVoidMethod(_dw_obj, windowSetBitmapFromData, handle, (int)cid, bytearray, len);
4182 // Clean up after the array now that we are finished 4308 // Clean up after the array now that we are finished
4183 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0); 4309 //if(bytearray)
4310 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0);
4184 } 4311 }
4185 } 4312 }
4186 4313
4187 /* 4314 /*
4188 * Sets the bitmap used for a given static window. 4315 * Sets the bitmap used for a given static window.
4190 * handle: Handle to the window. 4317 * handle: Handle to the window.
4191 * id: An ID to be used to specify the icon, 4318 * id: An ID to be used to specify the icon,
4192 * (pass 0 if you use the filename param) 4319 * (pass 0 if you use the filename param)
4193 * filename: a path to a file (Bitmap on OS/2 or 4320 * filename: a path to a file (Bitmap on OS/2 or
4194 * Windows and a pixmap on Unix, pass 4321 * Windows and a pixmap on Unix, pass
4195 * NULL if you use the id param) 4322 * nullptr if you use the id param)
4196 */ 4323 */
4197 void API dw_window_set_bitmap(HWND handle, unsigned long resid, const char *filename) 4324 void API dw_window_set_bitmap(HWND handle, unsigned long resid, const char *filename)
4198 { 4325 {
4199 JNIEnv *env; 4326 JNIEnv *env;
4200 4327
4201 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) 4328 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
4202 { 4329 {
4203 // Construct a string 4330 // Construct a string
4204 jstring jstr = NULL; 4331 jstring jstr = nullptr;
4205 if(filename) { 4332 if(filename) {
4206 jstr = env->NewStringUTF(filename); 4333 jstr = env->NewStringUTF(filename);
4207 } 4334 }
4208 // First get the class that contains the method you need to call 4335 // First get the class that contains the method you need to call
4209 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); 4336 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
4229 * Gets the child window handle with specified ID. 4356 * Gets the child window handle with specified ID.
4230 * Parameters: 4357 * Parameters:
4231 * handle: Handle to the parent window. 4358 * handle: Handle to the parent window.
4232 * id: Integer ID of the child. 4359 * id: Integer ID of the child.
4233 * Returns: 4360 * Returns:
4234 * HWND of window with ID or NULL on error. 4361 * HWND of window with ID or nullptr on error.
4235 */ 4362 */
4236 HWND API dw_window_from_id(HWND handle, int id) 4363 HWND API dw_window_from_id(HWND handle, int id)
4237 { 4364 {
4238 JNIEnv *env; 4365 JNIEnv *env;
4239 HWND retval = 0; 4366 HWND retval = 0;
4308 4435
4309 /* 4436 /*
4310 * Gets the size the system thinks the widget should be. 4437 * Gets the size the system thinks the widget should be.
4311 * Parameters: 4438 * Parameters:
4312 * handle: Window (widget) handle of the item to query. 4439 * handle: Window (widget) handle of the item to query.
4313 * width: Width in pixels of the item or NULL if not needed. 4440 * width: Width in pixels of the item or nullptr if not needed.
4314 * height: Height in pixels of the item or NULL if not needed. 4441 * height: Height in pixels of the item or nullptr if not needed.
4315 */ 4442 */
4316 void API dw_window_get_preferred_size(HWND handle, int *width, int *height) 4443 void API dw_window_get_preferred_size(HWND handle, int *width, int *height)
4317 { 4444 {
4318 } 4445 }
4319 4446
4355 4482
4356 /* 4483 /*
4357 * Gets the position and size of a given window (widget). 4484 * Gets the position and size of a given window (widget).
4358 * Parameters: 4485 * Parameters:
4359 * handle: Window (widget) handle. 4486 * handle: Window (widget) handle.
4360 * x: X location from the bottom left or NULL. 4487 * x: X location from the bottom left or nullptr.
4361 * y: Y location from the bottom left or NULL. 4488 * y: Y location from the bottom left or nullptr.
4362 * width: Width of the widget or NULL. 4489 * width: Width of the widget or nullptr.
4363 * height: Height of the widget or NULL. 4490 * height: Height of the widget or nullptr.
4364 */ 4491 */
4365 void API dw_window_get_pos_size(HWND handle, LONG *x, LONG *y, ULONG *width, ULONG *height) 4492 void API dw_window_get_pos_size(HWND handle, LONG *x, LONG *y, ULONG *width, ULONG *height)
4366 { 4493 {
4367 } 4494 }
4368 4495
4466 * Gets a named user data item from a window handle. 4593 * Gets a named user data item from a window handle.
4467 * Parameters: 4594 * Parameters:
4468 * window: Window handle to get data from. 4595 * window: Window handle to get data from.
4469 * dataname: A string pointer identifying which data to get. 4596 * dataname: A string pointer identifying which data to get.
4470 * Returns: 4597 * Returns:
4471 * Pointer to data or NULL if no data is available. 4598 * Pointer to data or nullptr if no data is available.
4472 */ 4599 */
4473 void * API dw_window_get_data(HWND window, const char *dataname) 4600 void * API dw_window_get_data(HWND window, const char *dataname)
4474 { 4601 {
4475 JNIEnv *env; 4602 JNIEnv *env;
4476 void *retval = NULL; 4603 void *retval = nullptr;
4477 4604
4478 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) 4605 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
4479 { 4606 {
4480 // Construct a String 4607 // Construct a String
4481 jstring jstr = env->NewStringUTF(dataname); 4608 jstring jstr = env->NewStringUTF(dataname);
4551 * sigfunc: The pointer to the function to be used as the callback. 4678 * sigfunc: The pointer to the function to be used as the callback.
4552 * data: User data to be passed to the handler function. 4679 * data: User data to be passed to the handler function.
4553 */ 4680 */
4554 void API dw_signal_connect(HWND window, const char *signame, void *sigfunc, void *data) 4681 void API dw_signal_connect(HWND window, const char *signame, void *sigfunc, void *data)
4555 { 4682 {
4556 dw_signal_connect_data(window, signame, sigfunc, NULL, data); 4683 dw_signal_connect_data(window, signame, sigfunc, nullptr, data);
4557 } 4684 }
4558 4685
4559 /* 4686 /*
4560 * Add a callback to a window event with a closure callback. 4687 * Add a callback to a window event with a closure callback.
4561 * Parameters: 4688 * Parameters:
4583 * Parameters: 4710 * Parameters:
4584 * window: Window handle of callback to be removed. 4711 * window: Window handle of callback to be removed.
4585 */ 4712 */
4586 void API dw_signal_disconnect_by_name(HWND window, const char *signame) 4713 void API dw_signal_disconnect_by_name(HWND window, const char *signame)
4587 { 4714 {
4588 SignalHandler *prev = NULL, *tmp = DWRoot; 4715 SignalHandler *prev = nullptr, *tmp = DWRoot;
4589 ULONG message; 4716 ULONG message;
4590 4717
4591 if(!window || !signame || (message = _dw_findsigmessage(signame)) == 0) 4718 if(!window || !signame || (message = _dw_findsigmessage(signame)) == 0)
4592 return; 4719 return;
4593 4720
4628 * Parameters: 4755 * Parameters:
4629 * window: Window handle of callback to be removed. 4756 * window: Window handle of callback to be removed.
4630 */ 4757 */
4631 void API dw_signal_disconnect_by_window(HWND window) 4758 void API dw_signal_disconnect_by_window(HWND window)
4632 { 4759 {
4633 SignalHandler *prev = NULL, *tmp = DWRoot; 4760 SignalHandler *prev = nullptr, *tmp = DWRoot;
4634 4761
4635 while(tmp) 4762 while(tmp)
4636 { 4763 {
4637 if(tmp->window == window) 4764 if(tmp->window == window)
4638 { 4765 {
4670 * window: Window handle of callback to be removed. 4797 * window: Window handle of callback to be removed.
4671 * data: Pointer to the data to be compared against. 4798 * data: Pointer to the data to be compared against.
4672 */ 4799 */
4673 void API dw_signal_disconnect_by_data(HWND window, void *data) 4800 void API dw_signal_disconnect_by_data(HWND window, void *data)
4674 { 4801 {
4675 SignalHandler *prev = NULL, *tmp = DWRoot; 4802 SignalHandler *prev = nullptr, *tmp = DWRoot;
4676 4803
4677 while(tmp) 4804 while(tmp)
4678 { 4805 {
4679 if(tmp->window == window && tmp->data == data) 4806 if(tmp->window == window && tmp->data == data)
4680 { 4807 {
4734 return -1; 4861 return -1;
4735 4862
4736 if((len = strlen(name)) == 0) 4863 if((len = strlen(name)) == 0)
4737 return -1; 4864 return -1;
4738 4865
4739 /* Lenth + "lib" + ".so" + NULL */ 4866 /* Lenth + "lib" + ".so" + nullptr */
4740 newname = (char *)malloc(len + 7); 4867 newname = (char *)malloc(len + 7);
4741 4868
4742 if(!newname) 4869 if(!newname)
4743 return -1; 4870 return -1;
4744 4871
4745 sprintf(newname, "lib%s.so", name); 4872 sprintf(newname, "lib%s.so", name);
4746 _dw_strlwr(newname); 4873 _dw_strlwr(newname);
4747 4874
4748 *handle = dlopen(newname, RTLD_NOW); 4875 *handle = dlopen(newname, RTLD_NOW);
4749 if(*handle == NULL) 4876 if(*handle == nullptr)
4750 { 4877 {
4751 strncpy(errorbuf, dlerror(), 1024); 4878 strncpy(errorbuf, dlerror(), 1024);
4752 printf("%s\n", errorbuf); 4879 printf("%s\n", errorbuf);
4753 sprintf(newname, "lib%s.so", name); 4880 sprintf(newname, "lib%s.so", name);
4754 *handle = dlopen(newname, RTLD_NOW); 4881 *handle = dlopen(newname, RTLD_NOW);
4755 } 4882 }
4756 4883
4757 free(newname); 4884 free(newname);
4758 4885
4759 return (NULL == *handle) ? -1 : 0; 4886 return (nullptr == *handle) ? -1 : 0;
4760 } 4887 }
4761 4888
4762 /* Queries the address of a symbol within open handle. 4889 /* Queries the address of a symbol within open handle.
4763 * Parameters: 4890 * Parameters:
4764 * handle: Module handle returned by dw_module_load() 4891 * handle: Module handle returned by dw_module_load()
4773 4900
4774 if(strlen(name) == 0) 4901 if(strlen(name) == 0)
4775 return -1; 4902 return -1;
4776 4903
4777 *func = (void*)dlsym(handle, name); 4904 *func = (void*)dlsym(handle, name);
4778 return (NULL == *func); 4905 return (nullptr == *func);
4779 } 4906 }
4780 4907
4781 /* Frees the shared library previously opened. 4908 /* Frees the shared library previously opened.
4782 * Parameters: 4909 * Parameters:
4783 * handle: Module handle returned by dw_module_load() 4910 * handle: Module handle returned by dw_module_load()
4794 */ 4921 */
4795 HMTX API dw_mutex_new(void) 4922 HMTX API dw_mutex_new(void)
4796 { 4923 {
4797 HMTX mutex = (HMTX)malloc(sizeof(pthread_mutex_t)); 4924 HMTX mutex = (HMTX)malloc(sizeof(pthread_mutex_t));
4798 4925
4799 pthread_mutex_init(mutex, NULL); 4926 pthread_mutex_init(mutex, nullptr);
4800 return mutex; 4927 return mutex;
4801 } 4928 }
4802 4929
4803 /* 4930 /*
4804 * Closes a semaphore created by dw_mutex_new(). 4931 * Closes a semaphore created by dw_mutex_new().
4830 if(_dw_thread == pthread_self()) 4957 if(_dw_thread == pthread_self())
4831 { 4958 {
4832 while(pthread_mutex_trylock(mutex) != 0) 4959 while(pthread_mutex_trylock(mutex) != 0)
4833 { 4960 {
4834 /* Process any pending events */ 4961 /* Process any pending events */
4835 if(g_main_context_pending(NULL)) 4962 if(g_main_context_pending(nullptr))
4836 { 4963 {
4837 do 4964 do
4838 { 4965 {
4839 g_main_context_iteration(NULL, FALSE); 4966 g_main_context_iteration(nullptr, FALSE);
4840 } 4967 }
4841 while(g_main_context_pending(NULL)); 4968 while(g_main_context_pending(nullptr));
4842 } 4969 }
4843 else 4970 else
4844 sched_yield(); 4971 sched_yield();
4845 } 4972 }
4846 } 4973 }
4881 HEV API dw_event_new(void) 5008 HEV API dw_event_new(void)
4882 { 5009 {
4883 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event)); 5010 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event));
4884 5011
4885 if(!eve) 5012 if(!eve)
4886 return NULL; 5013 return nullptr;
4887 5014
4888 /* We need to be careful here, mutexes on Linux are 5015 /* We need to be careful here, mutexes on Linux are
4889 * FAST by default but are error checking on other 5016 * FAST by default but are error checking on other
4890 * systems such as FreeBSD and OS/2, perhaps others. 5017 * systems such as FreeBSD and OS/2, perhaps others.
4891 */ 5018 */
4892 pthread_mutex_init (&(eve->mutex), NULL); 5019 pthread_mutex_init (&(eve->mutex), nullptr);
4893 pthread_mutex_lock (&(eve->mutex)); 5020 pthread_mutex_lock (&(eve->mutex));
4894 pthread_cond_init (&(eve->event), NULL); 5021 pthread_cond_init (&(eve->event), nullptr);
4895 5022
4896 pthread_mutex_unlock (&(eve->mutex)); 5023 pthread_mutex_unlock (&(eve->mutex));
4897 eve->alive = 1; 5024 eve->alive = 1;
4898 eve->posted = 0; 5025 eve->posted = 0;
4899 5026
4910 if(!eve) 5037 if(!eve)
4911 return DW_ERROR_NON_INIT; 5038 return DW_ERROR_NON_INIT;
4912 5039
4913 pthread_mutex_lock (&(eve->mutex)); 5040 pthread_mutex_lock (&(eve->mutex));
4914 pthread_cond_broadcast (&(eve->event)); 5041 pthread_cond_broadcast (&(eve->event));
4915 pthread_cond_init (&(eve->event), NULL); 5042 pthread_cond_init (&(eve->event), nullptr);
4916 eve->posted = 0; 5043 eve->posted = 0;
4917 pthread_mutex_unlock (&(eve->mutex)); 5044 pthread_mutex_unlock (&(eve->mutex));
4918 return DW_ERROR_NONE; 5045 return DW_ERROR_NONE;
4919 } 5046 }
4920 5047
4991 pthread_mutex_lock (&((*eve)->mutex)); 5118 pthread_mutex_lock (&((*eve)->mutex));
4992 pthread_cond_destroy (&((*eve)->event)); 5119 pthread_cond_destroy (&((*eve)->event));
4993 pthread_mutex_unlock (&((*eve)->mutex)); 5120 pthread_mutex_unlock (&((*eve)->mutex));
4994 pthread_mutex_destroy (&((*eve)->mutex)); 5121 pthread_mutex_destroy (&((*eve)->mutex));
4995 free(*eve); 5122 free(*eve);
4996 *eve = NULL; 5123 *eve = nullptr;
4997 5124
4998 return DW_ERROR_NONE; 5125 return DW_ERROR_NONE;
4999 } 5126 }
5000 5127
5001 struct _dw_seminfo { 5128 struct _dw_seminfo {
5011 int bytesread, connectcount = 1, maxfd, z, posted = 0; 5138 int bytesread, connectcount = 1, maxfd, z, posted = 0;
5012 char command; 5139 char command;
5013 sigset_t mask; 5140 sigset_t mask;
5014 5141
5015 sigfillset(&mask); /* Mask all allowed signals */ 5142 sigfillset(&mask); /* Mask all allowed signals */
5016 pthread_sigmask(SIG_BLOCK, &mask, NULL); 5143 pthread_sigmask(SIG_BLOCK, &mask, nullptr);
5017 5144
5018 /* problems */ 5145 /* problems */
5019 if(tmpsock[1] == -1) 5146 if(tmpsock[1] == -1)
5020 { 5147 {
5021 free(array); 5148 free(array);
5043 maxfd = array[z].fd; 5170 maxfd = array[z].fd;
5044 5171
5045 FD_SET(array[z].fd, &rd); 5172 FD_SET(array[z].fd, &rd);
5046 } 5173 }
5047 5174
5048 if(select(maxfd+1, &rd, NULL, NULL, NULL) == -1) 5175 if(select(maxfd+1, &rd, nullptr, nullptr, nullptr) == -1)
5049 { 5176 {
5050 free(array); 5177 free(array);
5051 return; 5178 return;
5052 } 5179 }
5053 5180
5165 struct sockaddr_un un; 5292 struct sockaddr_un un;
5166 int ev, *tmpsock = (int *)malloc(sizeof(int)*2); 5293 int ev, *tmpsock = (int *)malloc(sizeof(int)*2);
5167 DWTID dwthread; 5294 DWTID dwthread;
5168 5295
5169 if(!tmpsock) 5296 if(!tmpsock)
5170 return NULL; 5297 return nullptr;
5171 5298
5172 tmpsock[0] = socket(AF_UNIX, SOCK_STREAM, 0); 5299 tmpsock[0] = socket(AF_UNIX, SOCK_STREAM, 0);
5173 ev = socket(AF_UNIX, SOCK_STREAM, 0); 5300 ev = socket(AF_UNIX, SOCK_STREAM, 0);
5174 memset(&un, 0, sizeof(un)); 5301 memset(&un, 0, sizeof(un));
5175 un.sun_family=AF_UNIX; 5302 un.sun_family=AF_UNIX;
5194 if(tmpsock[1] > -1) 5321 if(tmpsock[1] > -1)
5195 close(tmpsock[1]); 5322 close(tmpsock[1]);
5196 if(ev > -1) 5323 if(ev > -1)
5197 close(ev); 5324 close(ev);
5198 free(tmpsock); 5325 free(tmpsock);
5199 return NULL; 5326 return nullptr;
5200 } 5327 }
5201 5328
5202 /* Create a thread to handle this event semaphore */ 5329 /* Create a thread to handle this event semaphore */
5203 pthread_create(&dwthread, NULL, (void *(*)(void *))_dw_handle_sem, (void *)tmpsock); 5330 pthread_create(&dwthread, nullptr, (void *(*)(void *))_dw_handle_sem, (void *)tmpsock);
5204 return (HEV)DW_INT_TO_POINTER(ev); 5331 return (HEV)DW_INT_TO_POINTER(ev);
5205 } 5332 }
5206 5333
5207 /* Open an already existing named event semaphore. 5334 /* Open an already existing named event semaphore.
5208 * Parameters: 5335 * Parameters:
5213 HEV API dw_named_event_get(const char *name) 5340 HEV API dw_named_event_get(const char *name)
5214 { 5341 {
5215 struct sockaddr_un un; 5342 struct sockaddr_un un;
5216 int ev = socket(AF_UNIX, SOCK_STREAM, 0); 5343 int ev = socket(AF_UNIX, SOCK_STREAM, 0);
5217 if(ev < 0) 5344 if(ev < 0)
5218 return NULL; 5345 return nullptr;
5219 5346
5220 un.sun_family=AF_UNIX; 5347 un.sun_family=AF_UNIX;
5221 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); 5348 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
5222 strcpy(un.sun_path, "/tmp/.dw/"); 5349 strcpy(un.sun_path, "/tmp/.dw/");
5223 strcat(un.sun_path, name); 5350 strcat(un.sun_path, name);
5273 * or -1 if indefinite. 5400 * or -1 if indefinite.
5274 */ 5401 */
5275 int API dw_named_event_wait(HEV eve, unsigned long timeout) 5402 int API dw_named_event_wait(HEV eve, unsigned long timeout)
5276 { 5403 {
5277 fd_set rd; 5404 fd_set rd;
5278 struct timeval tv, *useme = NULL; 5405 struct timeval tv, *useme = nullptr;
5279 int retval = 0; 5406 int retval = 0;
5280 char tmp; 5407 char tmp;
5281 5408
5282 if(DW_POINTER_TO_INT(eve) < 0) 5409 if(DW_POINTER_TO_INT(eve) < 0)
5283 return DW_ERROR_NON_INIT; 5410 return DW_ERROR_NON_INIT;
5297 /* Signal wait */ 5424 /* Signal wait */
5298 tmp = (char)2; 5425 tmp = (char)2;
5299 retval = write(DW_POINTER_TO_INT(eve), &tmp, 1); 5426 retval = write(DW_POINTER_TO_INT(eve), &tmp, 1);
5300 5427
5301 if(retval == 1) 5428 if(retval == 1)
5302 retval = select(DW_POINTER_TO_INT(eve)+1, &rd, NULL, NULL, useme); 5429 retval = select(DW_POINTER_TO_INT(eve)+1, &rd, nullptr, nullptr, useme);
5303 5430
5304 /* Signal done waiting. */ 5431 /* Signal done waiting. */
5305 tmp = (char)3; 5432 tmp = (char)3;
5306 if(retval == 1) 5433 if(retval == 1)
5307 retval = write(DW_POINTER_TO_INT(eve), &tmp, 1); 5434 retval = write(DW_POINTER_TO_INT(eve), &tmp, 1);
5342 */ 5469 */
5343 void API _dw_init_thread(void) 5470 void API _dw_init_thread(void)
5344 { 5471 {
5345 JNIEnv *env; 5472 JNIEnv *env;
5346 5473
5347 _dw_jvm->AttachCurrentThread(&env, NULL); 5474 _dw_jvm->AttachCurrentThread(&env, nullptr);
5348 pthread_setspecific(_dw_env_key, env); 5475 pthread_setspecific(_dw_env_key, env);
5349 } 5476 }
5350 5477
5351 /* 5478 /*
5352 * Generally an internal function called from a terminating 5479 * Generally an internal function called from a terminating
5362 /* 5489 /*
5363 * Setup thread independent color sets. 5490 * Setup thread independent color sets.
5364 */ 5491 */
5365 void _dwthreadstart(void *data) 5492 void _dwthreadstart(void *data)
5366 { 5493 {
5367 void (*threadfunc)(void *) = NULL; 5494 void (*threadfunc)(void *) = nullptr;
5368 void **tmp = (void **)data; 5495 void **tmp = (void **)data;
5369 5496
5370 threadfunc = (void (*)(void *))tmp[0]; 5497 threadfunc = (void (*)(void *))tmp[0];
5371 5498
5372 /* Initialize colors */ 5499 /* Initialize colors */
5396 snprintf(namebuf, 1024, "/tmp/.dw/%s", name); 5523 snprintf(namebuf, 1024, "/tmp/.dw/%s", name);
5397 5524
5398 if((handle->fd = open(namebuf, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0) 5525 if((handle->fd = open(namebuf, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0)
5399 { 5526 {
5400 free(handle); 5527 free(handle);
5401 return NULL; 5528 return nullptr;
5402 } 5529 }
5403 5530
5404 if(ftruncate(handle->fd, size)) 5531 if(ftruncate(handle->fd, size))
5405 { 5532 {
5406 close(handle->fd); 5533 close(handle->fd);
5407 free(handle); 5534 free(handle);
5408 return NULL; 5535 return nullptr;
5409 } 5536 }
5410 5537
5411 /* attach the shared memory segment to our process's address space. */ 5538 /* attach the shared memory segment to our process's address space. */
5412 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); 5539 *dest = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0);
5413 5540
5414 if(*dest == MAP_FAILED) 5541 if(*dest == MAP_FAILED)
5415 { 5542 {
5416 close(handle->fd); 5543 close(handle->fd);
5417 *dest = NULL; 5544 *dest = nullptr;
5418 free(handle); 5545 free(handle);
5419 return NULL; 5546 return nullptr;
5420 } 5547 }
5421 5548
5422 handle->size = size; 5549 handle->size = size;
5423 handle->sid = getsid(0); 5550 handle->sid = getsid(0);
5424 handle->path = strdup(namebuf); 5551 handle->path = strdup(namebuf);
5442 snprintf(namebuf, 1024, "/tmp/.dw/%s", name); 5569 snprintf(namebuf, 1024, "/tmp/.dw/%s", name);
5443 5570
5444 if((handle->fd = open(namebuf, O_RDWR)) < 0) 5571 if((handle->fd = open(namebuf, O_RDWR)) < 0)
5445 { 5572 {
5446 free(handle); 5573 free(handle);
5447 return NULL; 5574 return nullptr;
5448 } 5575 }
5449 5576
5450 /* attach the shared memory segment to our process's address space. */ 5577 /* attach the shared memory segment to our process's address space. */
5451 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); 5578 *dest = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0);
5452 5579
5453 if(*dest == MAP_FAILED) 5580 if(*dest == MAP_FAILED)
5454 { 5581 {
5455 close(handle->fd); 5582 close(handle->fd);
5456 *dest = NULL; 5583 *dest = nullptr;
5457 free(handle); 5584 free(handle);
5458 return NULL; 5585 return nullptr;
5459 } 5586 }
5460 5587
5461 handle->size = size; 5588 handle->size = size;
5462 handle->sid = -1; 5589 handle->sid = -1;
5463 handle->path = NULL; 5590 handle->path = nullptr;
5464 5591
5465 return handle; 5592 return handle;
5466 } 5593 }
5467 5594
5468 /* 5595 /*
5502 int rc; 5629 int rc;
5503 5630
5504 tmp[0] = func; 5631 tmp[0] = func;
5505 tmp[1] = data; 5632 tmp[1] = data;
5506 5633
5507 rc = pthread_create(&dwthread, NULL, (void *(*)(void *))_dwthreadstart, (void *)tmp); 5634 rc = pthread_create(&dwthread, nullptr, (void *(*)(void *))_dwthreadstart, (void *)tmp);
5508 if(rc == 0) 5635 if(rc == 0)
5509 return dwthread; 5636 return dwthread;
5510 return (DWTID)DW_ERROR_UNKNOWN; 5637 return (DWTID)DW_ERROR_UNKNOWN;
5511 } 5638 }
5512 5639
5513 /* 5640 /*
5514 * Ends execution of current thread immediately. 5641 * Ends execution of current thread immediately.
5515 */ 5642 */
5516 void API dw_thread_end(void) 5643 void API dw_thread_end(void)
5517 { 5644 {
5518 pthread_exit(NULL); 5645 pthread_exit(nullptr);
5519 } 5646 }
5520 5647
5521 /* 5648 /*
5522 * Returns the current thread's ID. 5649 * Returns the current thread's ID.
5523 */ 5650 */
5616 * flags: Flags to initially configure the print object. 5743 * flags: Flags to initially configure the print object.
5617 * pages: Number of pages to print. 5744 * pages: Number of pages to print.
5618 * drawfunc: The pointer to the function to be used as the callback. 5745 * drawfunc: The pointer to the function to be used as the callback.
5619 * drawdata: User data to be passed to the handler function. 5746 * drawdata: User data to be passed to the handler function.
5620 * Returns: 5747 * Returns:
5621 * A handle to the print object or NULL on failure. 5748 * A handle to the print object or nullptr on failure.
5622 */ 5749 */
5623 HPRINT API dw_print_new(const char *jobname, unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata) 5750 HPRINT API dw_print_new(const char *jobname, unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata)
5624 { 5751 {
5625 return NULL; 5752 return nullptr;
5626 } 5753 }
5627 5754
5628 /* 5755 /*
5629 * Runs the print job, causing the draw page callbacks to fire. 5756 * Runs the print job, causing the draw page callbacks to fire.
5630 * Parameters: 5757 * Parameters:
5649 5776
5650 /* 5777 /*
5651 * Creates a new system notification if possible. 5778 * Creates a new system notification if possible.
5652 * Parameters: 5779 * Parameters:
5653 * title: The short title of the notification. 5780 * title: The short title of the notification.
5654 * imagepath: Path to an image to display or NULL if none. 5781 * imagepath: Path to an image to display or nullptr if none.
5655 * description: A longer description of the notification, 5782 * description: A longer description of the notification,
5656 * or NULL if none is necessary. 5783 * or nullptr if none is necessary.
5657 * Returns: 5784 * Returns:
5658 * A handle to the notification which can be used to attach a "clicked" event if desired, 5785 * A handle to the notification which can be used to attach a "clicked" event if desired,
5659 * or NULL if it fails or notifications are not supported by the system. 5786 * or nullptr if it fails or notifications are not supported by the system.
5660 * Remarks: 5787 * Remarks:
5661 * This will create a system notification that will show in the notifaction panel 5788 * This will create a system notification that will show in the notifaction panel
5662 * on supported systems, which may be clicked to perform another task. 5789 * on supported systems, which may be clicked to perform another task.
5663 */ 5790 */
5664 HWND API dw_notification_new(const char *title, const char *imagepath, const char *description, ...) 5791 HWND API dw_notification_new(const char *title, const char *imagepath, const char *description, ...)
5668 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) 5795 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
5669 { 5796 {
5670 // Construct a String 5797 // Construct a String
5671 jstring appid = env->NewStringUTF(_dw_app_id); 5798 jstring appid = env->NewStringUTF(_dw_app_id);
5672 jstring ntitle = env->NewStringUTF(title); 5799 jstring ntitle = env->NewStringUTF(title);
5673 jstring ndesc = NULL; 5800 jstring ndesc = nullptr;
5674 jstring image = NULL; 5801 jstring image = nullptr;
5675 5802
5676 if(description) 5803 if(description)
5677 { 5804 {
5678 va_list args; 5805 va_list args;
5679 char outbuf[1025] = {0}; 5806 char outbuf[1025] = {0};
5728 * Converts a UTF-8 encoded string into a wide string. 5855 * Converts a UTF-8 encoded string into a wide string.
5729 * Parameters: 5856 * Parameters:
5730 * utf8string: UTF-8 encoded source string. 5857 * utf8string: UTF-8 encoded source string.
5731 * Returns: 5858 * Returns:
5732 * Wide string that needs to be freed with dw_free() 5859 * Wide string that needs to be freed with dw_free()
5733 * or NULL on failure. 5860 * or nullptr on failure.
5734 */ 5861 */
5735 wchar_t * API dw_utf8_to_wchar(const char *utf8string) 5862 wchar_t * API dw_utf8_to_wchar(const char *utf8string)
5736 { 5863 {
5737 size_t buflen = strlen(utf8string) + 1; 5864 size_t buflen = strlen(utf8string) + 1;
5738 wchar_t *temp = (wchar_t *)malloc(buflen * sizeof(wchar_t)); 5865 wchar_t *temp = (wchar_t *)malloc(buflen * sizeof(wchar_t));
5745 * Converts a wide string into a UTF-8 encoded string. 5872 * Converts a wide string into a UTF-8 encoded string.
5746 * Parameters: 5873 * Parameters:
5747 * wstring: Wide source string. 5874 * wstring: Wide source string.
5748 * Returns: 5875 * Returns:
5749 * UTF-8 encoded string that needs to be freed with dw_free() 5876 * UTF-8 encoded string that needs to be freed with dw_free()
5750 * or NULL on failure. 5877 * or nullptr on failure.
5751 */ 5878 */
5752 char * API dw_wchar_to_utf8(const wchar_t *wstring) 5879 char * API dw_wchar_to_utf8(const wchar_t *wstring)
5753 { 5880 {
5754 size_t bufflen = 8 * wcslen(wstring) + 1; 5881 size_t bufflen = 8 * wcslen(wstring) + 1;
5755 char *temp = (char *)malloc(bufflen); 5882 char *temp = (char *)malloc(bufflen);