Mercurial > projects > dwt-linux
diff dwt/widgets/Label.d @ 259:c0d810de7093
Update SWT 3.4M7 to 3.4
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 29 Jun 2008 14:33:38 +0200 |
parents | 5a30aa9820f3 |
children | bfafc891369e |
line wrap: on
line diff
--- a/dwt/widgets/Label.d Tue Jun 24 22:12:18 2008 +0200 +++ b/dwt/widgets/Label.d Sun Jun 29 14:33:38 2008 +0200 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,6 +28,12 @@ * user interface object that displays a string or image. * When SEPARATOR is specified, displays a single * vertical or horizontal line. + * <p> + * Shadow styles are hints and may not be honoured + * by the platform. To create a separator label + * with the default shadow style for the platform, + * do not specify a shadow style. + * </p> * <dl> * <dt><b>Styles:</b></dt> * <dd>SEPARATOR, HORIZONTAL, VERTICAL</dd> @@ -44,6 +50,10 @@ * IMPORTANT: This class is intended to be subclassed <em>only</em> * within the DWT implementation. * </p> + * + * @see <a href="http://www.eclipse.org/swt/snippets/#label">Label snippets</a> + * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ControlExample</a> + * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> */ public class Label : Control { @@ -220,24 +230,7 @@ OS.gtk_label_set_line_wrap_mode (labelHandle, OS.PANGO_WRAP_WORD_CHAR); } } - if ((style & DWT.LEFT) !is 0) { - OS.gtk_misc_set_alignment (cast(GtkMisc*)labelHandle, 0.0f, 0.0f); - OS.gtk_label_set_justify (cast(GtkLabel*)labelHandle, OS.GTK_JUSTIFY_LEFT); - OS.gtk_misc_set_alignment (cast(GtkMisc*)imageHandle, 0.0f, 0.5f); - return; - } - if ((style & DWT.CENTER) !is 0) { - OS.gtk_misc_set_alignment (cast(GtkMisc*)labelHandle, 0.5f, 0.0f); - OS.gtk_label_set_justify (cast(GtkLabel*)labelHandle, OS.GTK_JUSTIFY_CENTER); - OS.gtk_misc_set_alignment (cast(GtkMisc*)imageHandle, 0.5f, 0.5f); - return; - } - if ((style & DWT.RIGHT) !is 0) { - OS.gtk_misc_set_alignment (cast(GtkMisc*)labelHandle, 1.0f, 0.0f); - OS.gtk_label_set_justify (cast(GtkLabel*)labelHandle, OS.GTK_JUSTIFY_RIGHT); - OS.gtk_misc_set_alignment (cast(GtkMisc*)imageHandle, 1.0f, 0.5f); - return; - } + setAlignment (); } override void createWidget (int index) { @@ -407,7 +400,21 @@ if ((alignment & (DWT.LEFT | DWT.RIGHT | DWT.CENTER)) is 0) return; style &= ~(DWT.LEFT | DWT.RIGHT | DWT.CENTER); style |= alignment & (DWT.LEFT | DWT.RIGHT | DWT.CENTER); + setAlignment (); +} + +void setAlignment () { bool isRTL = (style & DWT.RIGHT_TO_LEFT) !is 0; + if (text !is null && text.length () !is 0) { + if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0)) { + auto layout = OS.gtk_label_get_layout (labelHandle); + auto linePtr = OS.pango_layout_get_line (layout, 0); + int resolved_dir = OS.pango_layout_line_get_resolved_dir (linePtr); + if (resolved_dir is OS.PANGO_DIRECTION_RTL) { + isRTL = !isRTL; + } + } + } if ((style & DWT.LEFT) !is 0) { OS.gtk_misc_set_alignment (cast(GtkMisc*)labelHandle, 0.0f, 0.0f); OS.gtk_label_set_justify (cast(GtkLabel*)labelHandle, isRTL ? OS.GTK_JUSTIFY_RIGHT : OS.GTK_JUSTIFY_LEFT); @@ -500,12 +507,6 @@ if ((style & DWT.RIGHT_TO_LEFT) !is 0) { if (labelHandle !is null) OS.gtk_widget_set_direction (labelHandle, OS.GTK_TEXT_DIR_RTL); if (imageHandle !is null) OS.gtk_widget_set_direction (imageHandle, OS.GTK_TEXT_DIR_RTL); - if ((style & DWT.LEAD) !is 0) { - if (labelHandle !is null) OS.gtk_label_set_justify (cast(GtkLabel*)labelHandle, OS.GTK_JUSTIFY_RIGHT); - } - if ((style & DWT.TRAIL) !is 0) { - if (labelHandle !is null) OS.gtk_label_set_justify (cast(GtkLabel*)labelHandle, OS.GTK_JUSTIFY_LEFT); - } } } @@ -577,6 +578,7 @@ OS.gtk_label_set_text_with_mnemonic (cast(GtkLabel*)labelHandle, chars.toStringzValidPtr()); OS.gtk_widget_hide (imageHandle); OS.gtk_widget_show (labelHandle); + setAlignment (); } override void showWidget () {