+ /**
+ * Display the drop-down menu represented by {@link TComboBox#list}.
+ */
+ private void displayDropdown() {
+ if (this.list != null) {
+ hideDropdown();
+ }
+
+ int valuesHeight = this.valuesHeight;
+ if (valuesHeight < 0) {
+ valuesHeight = values == null ? 0 : values.size() + 1;
+ }
+
+ TList list = new TList(this, values, 0, 1, getWidth(), valuesHeight,
+ new TAction() {
+ @Override
+ public void DO() {
+ TList list = TComboBox.this.list;
+ if (list == null) {
+ return;
+ }
+
+ field.setText(list.getSelected());
+ hideDropdown();
+
+ if (updateAction != null) {
+ updateAction.DO();
+ }
+ }
+ }
+ );
+
+ int i = -1;
+ if (values != null) {
+ String current = field.getText();
+ for (i = 0 ; i < values.size() ; i++) {
+ String value = values.get(i);
+ if ((caseSensitive && current.equals(value))
+ || (!caseSensitive && current.equalsIgnoreCase(value))) {
+ break;
+ }
+ }
+
+ if (i >= values.size()) {
+ i = -1;
+ }
+ }
+ list.setSelectedIndex(i);
+
+ list.setEnabled(true);
+ list.setVisible(true);
+
+ this.list = list;
+
+ reflowData();
+ activate(list);
+ }
+
+ /**
+ * Hide the drop-down menu represented by {@link TComboBox#list}.
+ */
+ private void hideDropdown() {
+ TList list = this.list;
+
+ if (list != null) {
+ list.setEnabled(false);
+ list.setVisible(false);
+ removeChild(list);
+
+ setHeight(1);
+ if (limitToListValue == false) {
+ activate(field);
+ }
+
+ this.list = null;
+ }
+ }