comparison dwt/graphics/Device.d @ 255:5a30aa9820f3

removed tango.stdc.stringz imports and allow null for arrays and string arguments.
author Frank Benoit <benoit@tionex.de>
date Sun, 15 Jun 2008 22:32:20 +0200
parents ce446666f5a2
children c0d810de7093
comparison
equal deleted inserted replaced
254:8bca790583c3 255:5a30aa9820f3
26 import dwt.internal.Compatibility; 26 import dwt.internal.Compatibility;
27 import dwt.internal.gtk.OS; 27 import dwt.internal.gtk.OS;
28 import dwt.dwthelper.utils; 28 import dwt.dwthelper.utils;
29 29
30 import tango.core.Exception; 30 import tango.core.Exception;
31 import tango.stdc.stringz;
32 import tango.io.Stdout; 31 import tango.io.Stdout;
33 32
34 /** 33 /**
35 * This class is the abstract superclass of all device objects, 34 * This class is the abstract superclass of all device objects,
36 * such as the Display device and the Printer device. Devices 35 * such as the Display device and the Printer device. Devices
588 if (xDisplay !is null) { 587 if (xDisplay !is null) {
589 /* Set GTK warning and error handlers */ 588 /* Set GTK warning and error handlers */
590 if (debugging) { 589 if (debugging) {
591 int flags = OS.G_LOG_LEVEL_MASK | OS.G_LOG_FLAG_FATAL | OS.G_LOG_FLAG_RECURSION; 590 int flags = OS.G_LOG_LEVEL_MASK | OS.G_LOG_FLAG_FATAL | OS.G_LOG_FLAG_RECURSION;
592 for (int i=0; i<log_domains.length; i++) { 591 for (int i=0; i<log_domains.length; i++) {
593 handler_ids [i] = OS.g_log_set_handler (toStringz(log_domains [i]), flags, & logFunction, cast(void*)this); 592 handler_ids [i] = OS.g_log_set_handler (log_domains [i].toStringzValidPtr(), flags, & logFunction, cast(void*)this);
594 } 593 }
595 } 594 }
596 } 595 }
597 596
598 /* Create the standard colors */ 597 /* Create the standard colors */
688 * @since 3.3 687 * @since 3.3
689 */ 688 */
690 public bool loadFont (String path) { 689 public bool loadFont (String path) {
691 checkDevice(); 690 checkDevice();
692 if (path is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); 691 if (path is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
693 return cast(bool) OS.FcConfigAppFontAddFile (null, toStringz(path)); 692 return cast(bool) OS.FcConfigAppFontAddFile (null, path.toStringzValidPtr());
694 } 693 }
695 694
696 private static extern(C) void logFunction (char* log_domain, int log_level, char* message, void* user_data) { 695 private static extern(C) void logFunction (char* log_domain, int log_level, char* message, void* user_data) {
697 Device dev = cast(Device)user_data; 696 Device dev = cast(Device)user_data;
698 if (dev.warningLevel is 0) { 697 if (dev.warningLevel is 0) {
789 788
790 /* Free the GTK error and warning handler */ 789 /* Free the GTK error and warning handler */
791 if (xDisplay !is null) { 790 if (xDisplay !is null) {
792 for (int i=0; i<handler_ids.length; i++) { 791 for (int i=0; i<handler_ids.length; i++) {
793 if (handler_ids [i] !is 0 ) { 792 if (handler_ids [i] !is 0 ) {
794 OS.g_log_remove_handler (toStringz(log_domains [i]), handler_ids [i]); 793 OS.g_log_remove_handler (log_domains [i].toStringzValidPtr(), handler_ids [i]);
795 handler_ids [i] = 0; 794 handler_ids [i] = 0;
796 } 795 }
797 } 796 }
798 //logCallback.dispose (); logCallback = null; 797 //logCallback.dispose (); logCallback = null;
799 handler_ids = null; log_domains = null; 798 handler_ids = null; log_domains = null;
818 if (warnings) { 817 if (warnings) {
819 if (--warningLevel is 0) { 818 if (--warningLevel is 0) {
820 if (debugging) return; 819 if (debugging) return;
821 for (int i=0; i<handler_ids.length; i++) { 820 for (int i=0; i<handler_ids.length; i++) {
822 if (handler_ids [i] !is 0) { 821 if (handler_ids [i] !is 0) {
823 OS.g_log_remove_handler (toStringz(log_domains [i]), handler_ids [i]); 822 OS.g_log_remove_handler (log_domains [i].toStringzValidPtr(), handler_ids [i]);
824 handler_ids [i] = 0; 823 handler_ids [i] = 0;
825 } 824 }
826 } 825 }
827 } 826 }
828 } else { 827 } else {
829 if (warningLevel++ is 0) { 828 if (warningLevel++ is 0) {
830 if (debugging) return; 829 if (debugging) return;
831 int flags = OS.G_LOG_LEVEL_MASK | OS.G_LOG_FLAG_FATAL | OS.G_LOG_FLAG_RECURSION; 830 int flags = OS.G_LOG_LEVEL_MASK | OS.G_LOG_FLAG_FATAL | OS.G_LOG_FLAG_RECURSION;
832 for (int i=0; i<log_domains.length; i++) { 831 for (int i=0; i<log_domains.length; i++) {
833 handler_ids [i] = OS.g_log_set_handler (toStringz(log_domains [i]), flags, & logFunction, cast(void*)this ); 832 handler_ids [i] = OS.g_log_set_handler (log_domains [i].toStringzValidPtr(), flags, & logFunction, cast(void*)this );
834 } 833 }
835 } 834 }
836 } 835 }
837 } 836 }
838 837