summaryrefslogtreecommitdiffstats
path: root/scilab
diff options
context:
space:
mode:
authorVincent COUVERT <vincent.couvert@scilab.org>2010-05-20 10:36:13 +0200
committerSylvestre Ledru <sylvestre.ledru@scilab.org>2010-05-20 12:55:30 +0200
commit91f3c686e4440842f629b9016049cf9506397622 (patch)
tree8f2c1d26b07d242fd322983229c2b9413d78d3a0 /scilab
parent45c624ca446c850b80692b58331ad28ae8f9b3b2 (diff)
downloadscilab-91f3c686e4440842f629b9016049cf9506397622.zip
scilab-91f3c686e4440842f629b9016049cf9506397622.tar.gz
Bug 3937 fixed
Change-Id: I4bf3d02a0c5d89da26b53856807a2f998fa2a9cb
Diffstat (limited to 'scilab')
-rw-r--r--scilab/CHANGES_5.3.X2
-rw-r--r--scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/messagebox/SwingScilabMessageBox.java22
-rw-r--r--scilab/modules/gui/tests/nonreg_tests/bug_3937.tst22
3 files changed, 41 insertions, 5 deletions
diff --git a/scilab/CHANGES_5.3.X b/scilab/CHANGES_5.3.X
index ccb8146..4b38ee8 100644
--- a/scilab/CHANGES_5.3.X
+++ b/scilab/CHANGES_5.3.X
@@ -339,6 +339,8 @@ Bug fixes:
339* bug 3811 fixed - Documention about "typeof" and overload prefixes was not 339* bug 3811 fixed - Documention about "typeof" and overload prefixes was not
340 up-to-date (help overloading). 340 up-to-date (help overloading).
341 341
342* bug 3937 fixed - Buttons size in "x_choices" window was related to the labels one.
343
342* bug 4075 fixed - a basic uicontrol example crashed scilab 5.0.3 344* bug 4075 fixed - a basic uicontrol example crashed scilab 5.0.3
343 345
344* bug 4117 fixed - Closing via the user interface a graphics figure which had a 346* bug 4117 fixed - Closing via the user interface a graphics figure which had a
diff --git a/scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/messagebox/SwingScilabMessageBox.java b/scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/messagebox/SwingScilabMessageBox.java
index 6bcad57..eb8ab9f 100644
--- a/scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/messagebox/SwingScilabMessageBox.java
+++ b/scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/messagebox/SwingScilabMessageBox.java
@@ -18,7 +18,6 @@ import java.awt.Dimension;
18import java.awt.Font; 18import java.awt.Font;
19import java.awt.GridBagConstraints; 19import java.awt.GridBagConstraints;
20import java.awt.GridBagLayout; 20import java.awt.GridBagLayout;
21import java.awt.GridLayout;
22import java.awt.Image; 21import java.awt.Image;
23import java.awt.Insets; 22import java.awt.Insets;
24import java.awt.event.ActionEvent; 23import java.awt.event.ActionEvent;
@@ -299,7 +298,11 @@ public class SwingScilabMessageBox extends JDialog implements SimpleMessageBox,
299 numberOfLines++; 298 numberOfLines++;
300 299
301 // Create the panel with button groups 300 // Create the panel with button groups
302 JPanel panel = new JPanel(new GridLayout(numberOfLines, numberOfColumns)); 301 JPanel panel = new JPanel(new GridBagLayout());
302 GridBagConstraints gbc = new GridBagConstraints();
303 gbc.gridx = 0;
304 gbc.gridy = 0;
305 gbc.fill = GridBagConstraints.HORIZONTAL;
303 buttonGroups = new ButtonGroup[numberOfLines]; 306 buttonGroups = new ButtonGroup[numberOfLines];
304 307
305 // Initialize return value 308 // Initialize return value
@@ -310,9 +313,13 @@ public class SwingScilabMessageBox extends JDialog implements SimpleMessageBox,
310 int buttonNumber = 0; 313 int buttonNumber = 0;
311 for (curItemIndex = 0; curItemIndex < lineLabels.length; curItemIndex++) { 314 for (curItemIndex = 0; curItemIndex < lineLabels.length; curItemIndex++) {
312 // Add the label of the line 315 // Add the label of the line
313 panel.add(new JLabel(lineLabels[curItemIndex])); 316 gbc.weightx = 1; // Labels will use remaining space when resizing
317 panel.add(new JLabel(lineLabels[curItemIndex]), gbc);
318 gbc.gridx++; // Increment the column index
319
314 buttonNumber = 0; 320 buttonNumber = 0;
315 curItemIndex++; 321 curItemIndex++;
322
316 // Add the button group 323 // Add the button group
317 ButtonGroup group = new ButtonGroup(); 324 ButtonGroup group = new ButtonGroup();
318 while (curItemIndex < lineLabels.length && !lineLabels[curItemIndex].equals(SEPARATOR)) { 325 while (curItemIndex < lineLabels.length && !lineLabels[curItemIndex].equals(SEPARATOR)) {
@@ -333,7 +340,9 @@ public class SwingScilabMessageBox extends JDialog implements SimpleMessageBox,
333 // Add the button to the group (for toggle) 340 // Add the button to the group (for toggle)
334 // And to the panel (for display) 341 // And to the panel (for display)
335 group.add(button); 342 group.add(button);
336 panel.add(button); 343 gbc.weightx = 0; // Button size will not change when resizing
344 panel.add(button, gbc);
345 gbc.gridx++; // Increment the column index
337 346
338 // Increment item index 347 // Increment item index
339 curItemIndex++; 348 curItemIndex++;
@@ -341,7 +350,8 @@ public class SwingScilabMessageBox extends JDialog implements SimpleMessageBox,
341 } 350 }
342 // Add empty labels if number of buttons in the line is lesser than maximum number of buttons found in a line 351 // Add empty labels if number of buttons in the line is lesser than maximum number of buttons found in a line
343 for (int emptyLabelsIndex = buttonsPerLines.get(lineNumber); emptyLabelsIndex < numberOfColumns; emptyLabelsIndex++) { 352 for (int emptyLabelsIndex = buttonsPerLines.get(lineNumber); emptyLabelsIndex < numberOfColumns; emptyLabelsIndex++) {
344 panel.add(new JLabel()); 353 panel.add(new JLabel(), gbc);
354 gbc.gridx++; // Increment the column index
345 } 355 }
346 356
347 // Store the group to get the user selection when returning 357 // Store the group to get the user selection when returning
@@ -349,6 +359,8 @@ public class SwingScilabMessageBox extends JDialog implements SimpleMessageBox,
349 359
350 // Increment current line number 360 // Increment current line number
351 lineNumber++; 361 lineNumber++;
362 gbc.gridx = 0; // New line --> Back to first column
363 gbc.gridy++; // Increment the row index
352 } 364 }
353 365
354 // Display the panel 366 // Display the panel
diff --git a/scilab/modules/gui/tests/nonreg_tests/bug_3937.tst b/scilab/modules/gui/tests/nonreg_tests/bug_3937.tst
new file mode 100644
index 0000000..bd0fcab
--- /dev/null
+++ b/scilab/modules/gui/tests/nonreg_tests/bug_3937.tst
@@ -0,0 +1,22 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2010 - DIGITEO - Vincent COUVERT
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7
8// <-- Non-regression test for bug 3937 -->
9// <-- INTERACTIVE TEST -->
10//
11// <-- Bugzilla URL -->
12// http://bugzilla.scilab.org/show_bug.cgi?id=3937
13//
14// <-- Short Description -->
15// When we use x_choices, the size of the buttons depends on the largest string of the variable "title". So if the largest title is too long, the size of the buttons will also be too long, whatever the size of the string on these buttons.
16
17option= list(["Very veryyyyyyyyyyyyyyyyyyyyyyy loooooooooooooooonnnnnnnngg label"], 1, ["Yes", "No"]);
18choiceSettings=x_choices('Settings Menu', list(option));
19
20// Check that the buttons width is smaller that the label width
21
22// Resize the window & check that the buttons size does not change \ No newline at end of file