1 /******************************************************************************* 2 * Copyright (c) 2000, 2016 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.swt.examples.controlexample; 15 16 17 import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter; 18 19 import org.eclipse.swt.SWT; 20 import org.eclipse.swt.custom.CTabFolder; 21 import org.eclipse.swt.custom.CTabFolder2Listener; 22 import org.eclipse.swt.custom.CTabFolderEvent; 23 import org.eclipse.swt.custom.CTabItem; 24 import org.eclipse.swt.graphics.Color; 25 import org.eclipse.swt.graphics.Font; 26 import org.eclipse.swt.graphics.FontData; 27 import org.eclipse.swt.graphics.Image; 28 import org.eclipse.swt.graphics.RGB; 29 import org.eclipse.swt.layout.GridData; 30 import org.eclipse.swt.layout.GridLayout; 31 import org.eclipse.swt.widgets.Button; 32 import org.eclipse.swt.widgets.Group; 33 import org.eclipse.swt.widgets.Item; 34 import org.eclipse.swt.widgets.TableItem; 35 import org.eclipse.swt.widgets.Text; 36 import org.eclipse.swt.widgets.ToolBar; 37 import org.eclipse.swt.widgets.ToolItem; 38 import org.eclipse.swt.widgets.Widget; 39 40 class CTabFolderTab extends Tab { 41 int lastSelectedTab = 0; 42 43 /* Example widgets and groups that contain them */ 44 CTabFolder tabFolder1; 45 Group tabFolderGroup, itemGroup, tabHeightGroup; 46 47 /* Style widgets added to the "Style" group */ 48 Button topButton, bottomButton, flatButton, closeButton; 49 Button rightButton, fillButton, wrapButton; 50 51 static String [] CTabItems1 = {ControlExample.getResourceString("CTabItem1_0"), 52 ControlExample.getResourceString("CTabItem1_1"), 53 ControlExample.getResourceString("CTabItem1_2")}; 54 55 /* Controls and resources added to the "Fonts" group */ 56 static final int SELECTION_FOREGROUND_COLOR = 3; 57 static final int SELECTION_BACKGROUND_COLOR = 4; 58 static final int ITEM_FONT = 5; 59 static final int ITEM_FOREGROUND_COLOR = 6; 60 static final int ITEM_BACKGROUND_COLOR = 7; 61 Color selectionForegroundColor, selectionBackgroundColor, itemForegroundColor, itemBackgroundColor; 62 Font itemFont; 63 64 /* Other widgets added to the "Other" group */ 65 Button simpleTabButton, singleTabButton, imageButton, showMinButton, showMaxButton, 66 topRightButton, unselectedCloseButton, unselectedImageButton; 67 68 ToolBar topRightControl; 69 70 Button tabHeightDefault, tabHeightSmall, tabHeightMedium, tabHeightLarge; 71 72 /** 73 * Creates the Tab within a given instance of ControlExample. 74 */ CTabFolderTab(ControlExample instance)75 CTabFolderTab(ControlExample instance) { 76 super(instance); 77 } 78 79 @Override createControlGroup()80 void createControlGroup() { 81 super.createControlGroup(); 82 83 /* Create a group for the CTabFolder */ 84 tabHeightGroup = new Group (controlGroup, SWT.NONE); 85 tabHeightGroup.setLayout (new GridLayout ()); 86 tabHeightGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); 87 tabHeightGroup.setText (ControlExample.getResourceString ("Tab_Height")); 88 89 tabHeightDefault = new Button(tabHeightGroup, SWT.RADIO); 90 tabHeightDefault.setText(ControlExample.getResourceString("Preferred")); 91 tabHeightDefault.setSelection(true); 92 tabHeightDefault.addSelectionListener (widgetSelectedAdapter(event -> setTabHeight(SWT.DEFAULT))); 93 94 tabHeightSmall = new Button(tabHeightGroup, SWT.RADIO); 95 tabHeightSmall.setText("8"); 96 tabHeightSmall.addSelectionListener (widgetSelectedAdapter(event -> setTabHeight(Integer.parseInt(tabHeightSmall.getText())))); 97 98 tabHeightMedium = new Button(tabHeightGroup, SWT.RADIO); 99 tabHeightMedium.setText("20"); 100 tabHeightMedium.addSelectionListener (widgetSelectedAdapter(event -> setTabHeight(Integer.parseInt(tabHeightMedium.getText())))); 101 102 tabHeightLarge = new Button(tabHeightGroup, SWT.RADIO); 103 tabHeightLarge.setText("45"); 104 tabHeightLarge.addSelectionListener (widgetSelectedAdapter(event -> setTabHeight(Integer.parseInt(tabHeightLarge.getText())))); 105 } 106 107 /** 108 * Creates the "Colors and Fonts" group. 109 */ 110 @Override createColorAndFontGroup()111 void createColorAndFontGroup () { 112 super.createColorAndFontGroup(); 113 114 TableItem item = new TableItem(colorAndFontTable, SWT.None); 115 item.setText(ControlExample.getResourceString ("Selection_Foreground_Color")); 116 item = new TableItem(colorAndFontTable, SWT.None); 117 item.setText(ControlExample.getResourceString ("Selection_Background_Color")); 118 item = new TableItem(colorAndFontTable, SWT.None); 119 item.setText(ControlExample.getResourceString ("Item_Font")); 120 item = new TableItem(colorAndFontTable, SWT.None); 121 item.setText(ControlExample.getResourceString ("Item_Foreground_Color")); 122 item = new TableItem(colorAndFontTable, SWT.None); 123 item.setText(ControlExample.getResourceString ("Item_Background_Color")); 124 125 shell.addDisposeListener(event -> { 126 if (selectionBackgroundColor != null) selectionBackgroundColor.dispose(); 127 if (selectionForegroundColor != null) selectionForegroundColor.dispose(); 128 if (itemFont != null) itemFont.dispose(); 129 if (itemBackgroundColor != null) itemBackgroundColor.dispose(); 130 if (itemForegroundColor != null) itemForegroundColor.dispose(); 131 selectionBackgroundColor = null; 132 selectionForegroundColor = null; 133 itemFont = null; 134 itemBackgroundColor = null; 135 itemForegroundColor = null; 136 }); 137 } 138 139 @Override changeFontOrColor(int index)140 void changeFontOrColor(int index) { 141 switch (index) { 142 case SELECTION_FOREGROUND_COLOR: { 143 Color oldColor = selectionForegroundColor; 144 if (oldColor == null) oldColor = tabFolder1.getSelectionForeground(); 145 colorDialog.setRGB(oldColor.getRGB()); 146 RGB rgb = colorDialog.open(); 147 if (rgb == null) return; 148 oldColor = selectionForegroundColor; 149 selectionForegroundColor = new Color (display, rgb); 150 setSelectionForeground (); 151 if (oldColor != null) oldColor.dispose (); 152 } 153 break; 154 case SELECTION_BACKGROUND_COLOR: { 155 Color oldColor = selectionBackgroundColor; 156 if (oldColor == null) oldColor = tabFolder1.getSelectionBackground(); 157 colorDialog.setRGB(oldColor.getRGB()); 158 RGB rgb = colorDialog.open(); 159 if (rgb == null) return; 160 oldColor = selectionBackgroundColor; 161 selectionBackgroundColor = new Color (display, rgb); 162 setSelectionBackground (); 163 if (oldColor != null) oldColor.dispose (); 164 } 165 break; 166 case ITEM_FONT: { 167 Font oldFont = itemFont; 168 if (oldFont == null) oldFont = tabFolder1.getItem (0).getFont (); 169 fontDialog.setFontList(oldFont.getFontData()); 170 FontData fontData = fontDialog.open (); 171 if (fontData == null) return; 172 oldFont = itemFont; 173 itemFont = new Font (display, fontData); 174 setItemFont (); 175 setExampleWidgetSize (); 176 if (oldFont != null) oldFont.dispose (); 177 } 178 break; 179 case ITEM_FOREGROUND_COLOR: { 180 Color oldColor = itemForegroundColor; 181 if (oldColor == null) oldColor = tabFolder1.getItem(0).getControl().getForeground(); 182 colorDialog.setRGB(oldColor.getRGB()); 183 RGB rgb = colorDialog.open(); 184 if (rgb == null) return; 185 oldColor = itemForegroundColor; 186 itemForegroundColor = new Color (display, rgb); 187 setItemForeground (); 188 if (oldColor != null) oldColor.dispose (); 189 } 190 break; 191 case ITEM_BACKGROUND_COLOR: { 192 Color oldColor = itemBackgroundColor; 193 if (oldColor == null) oldColor = tabFolder1.getItem(0).getControl().getBackground(); 194 colorDialog.setRGB(oldColor.getRGB()); 195 RGB rgb = colorDialog.open(); 196 if (rgb == null) return; 197 oldColor = itemBackgroundColor; 198 itemBackgroundColor = new Color (display, rgb); 199 setItemBackground (); 200 if (oldColor != null) oldColor.dispose (); 201 } 202 break; 203 default: 204 super.changeFontOrColor(index); 205 } 206 } 207 208 /** 209 * Creates the "Other" group. 210 */ 211 @Override createOtherGroup()212 void createOtherGroup () { 213 super.createOtherGroup (); 214 215 /* Create display controls specific to this example */ 216 simpleTabButton = new Button (otherGroup, SWT.CHECK); 217 simpleTabButton.setText (ControlExample.getResourceString("Set_Simple_Tabs")); 218 simpleTabButton.setSelection(true); 219 simpleTabButton.addSelectionListener (widgetSelectedAdapter(event -> setSimpleTabs())); 220 221 singleTabButton = new Button (otherGroup, SWT.CHECK); 222 singleTabButton.setText (ControlExample.getResourceString("Set_Single_Tabs")); 223 singleTabButton.setSelection(false); 224 singleTabButton.addSelectionListener (widgetSelectedAdapter(event -> setSingleTabs())); 225 226 showMinButton = new Button (otherGroup, SWT.CHECK); 227 showMinButton.setText (ControlExample.getResourceString("Set_Min_Visible")); 228 showMinButton.setSelection(false); 229 showMinButton.addSelectionListener (widgetSelectedAdapter(event -> setMinimizeVisible())); 230 231 showMaxButton = new Button (otherGroup, SWT.CHECK); 232 showMaxButton.setText (ControlExample.getResourceString("Set_Max_Visible")); 233 showMaxButton.setSelection(false); 234 showMaxButton.addSelectionListener (widgetSelectedAdapter(event -> setMaximizeVisible())); 235 236 topRightButton = new Button (otherGroup, SWT.CHECK); 237 topRightButton.setText (ControlExample.getResourceString("Set_Top_Right")); 238 topRightButton.setSelection(false); 239 topRightButton.addSelectionListener (widgetSelectedAdapter(event -> setTopRight())); 240 241 imageButton = new Button (otherGroup, SWT.CHECK); 242 imageButton.setText (ControlExample.getResourceString("Set_Image")); 243 imageButton.addSelectionListener (widgetSelectedAdapter(event -> setImages())); 244 245 unselectedImageButton = new Button (otherGroup, SWT.CHECK); 246 unselectedImageButton.setText (ControlExample.getResourceString("Set_Unselected_Image_Visible")); 247 unselectedImageButton.setSelection(true); 248 unselectedImageButton.addSelectionListener (widgetSelectedAdapter(event -> setUnselectedImageVisible())); 249 unselectedCloseButton = new Button (otherGroup, SWT.CHECK); 250 unselectedCloseButton.setText (ControlExample.getResourceString("Set_Unselected_Close_Visible")); 251 unselectedCloseButton.setSelection(true); 252 unselectedCloseButton.addSelectionListener (widgetSelectedAdapter(event -> setUnselectedCloseVisible())); 253 } 254 255 /** 256 * Creates the "Example" group. 257 */ 258 @Override createExampleGroup()259 void createExampleGroup () { 260 super.createExampleGroup (); 261 262 /* Create a group for the CTabFolder */ 263 tabFolderGroup = new Group (exampleGroup, SWT.NONE); 264 tabFolderGroup.setLayout (new GridLayout ()); 265 tabFolderGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); 266 tabFolderGroup.setText ("CTabFolder"); 267 } 268 269 /** 270 * Creates the "Example" widgets. 271 */ 272 @Override createExampleWidgets()273 void createExampleWidgets () { 274 275 /* Compute the widget style */ 276 int style = getDefaultStyle(); 277 if (topButton.getSelection ()) style |= SWT.TOP; 278 if (bottomButton.getSelection ()) style |= SWT.BOTTOM; 279 if (borderButton.getSelection ()) style |= SWT.BORDER; 280 if (flatButton.getSelection ()) style |= SWT.FLAT; 281 if (closeButton.getSelection ()) style |= SWT.CLOSE; 282 283 /* Create the example widgets */ 284 tabFolder1 = new CTabFolder (tabFolderGroup, style); 285 for (int i = 0; i < CTabItems1.length; i++) { 286 CTabItem item = new CTabItem(tabFolder1, SWT.NONE); 287 item.setText(CTabItems1[i]); 288 Text text = new Text(tabFolder1, SWT.WRAP | SWT.MULTI); 289 text.setText(ControlExample.getResourceString("CTabItem_content") + ": " + i); 290 item.setControl(text); 291 } 292 tabFolder1.addListener(SWT.Selection, event -> lastSelectedTab = tabFolder1.getSelectionIndex()); 293 294 /* If we have saved state, restore it */ 295 tabFolder1.setSelection(lastSelectedTab); 296 setTopRight (); 297 } 298 299 /** 300 * Creates the "Style" group. 301 */ 302 @Override createStyleGroup()303 void createStyleGroup() { 304 super.createStyleGroup (); 305 306 /* Create the extra widgets */ 307 topButton = new Button (styleGroup, SWT.RADIO); 308 topButton.setText ("SWT.TOP"); 309 topButton.setSelection(true); 310 bottomButton = new Button (styleGroup, SWT.RADIO); 311 bottomButton.setText ("SWT.BOTTOM"); 312 borderButton = new Button (styleGroup, SWT.CHECK); 313 borderButton.setText ("SWT.BORDER"); 314 flatButton = new Button (styleGroup, SWT.CHECK); 315 flatButton.setText ("SWT.FLAT"); 316 closeButton = new Button (styleGroup, SWT.CHECK); 317 closeButton.setText ("SWT.CLOSE"); 318 319 Group topRightGroup = new Group(styleGroup, SWT.NONE); 320 topRightGroup.setLayout (new GridLayout ()); 321 topRightGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false)); 322 topRightGroup.setText (ControlExample.getResourceString("Top_Right_Styles")); 323 rightButton = new Button (topRightGroup, SWT.RADIO); 324 rightButton.setText ("SWT.RIGHT"); 325 rightButton.setSelection(true); 326 fillButton = new Button (topRightGroup, SWT.RADIO); 327 fillButton.setText ("SWT.FILL"); 328 wrapButton = new Button (topRightGroup, SWT.RADIO); 329 wrapButton.setText ("SWT.RIGHT | SWT.WRAP"); 330 } 331 332 /** 333 * Gets the list of custom event names. 334 * 335 * @return an array containing custom event names 336 */ 337 @Override getCustomEventNames()338 String [] getCustomEventNames () { 339 return new String [] {"CTabFolderEvent"}; 340 } 341 342 /** 343 * Gets the "Example" widget children's items, if any. 344 * 345 * @return an array containing the example widget children's items 346 */ 347 @Override getExampleWidgetItems()348 Item [] getExampleWidgetItems () { 349 return tabFolder1.getItems(); 350 } 351 352 /** 353 * Gets the "Example" widget children. 354 */ 355 @Override getExampleWidgets()356 Widget [] getExampleWidgets () { 357 return new Widget [] {tabFolder1}; 358 } 359 360 /** 361 * Gets the text for the tab folder item. 362 */ 363 @Override getTabText()364 String getTabText () { 365 return "CTabFolder"; 366 } 367 368 /** 369 * Hooks the custom listener specified by eventName. 370 */ 371 @Override hookCustomListener(final String eventName)372 void hookCustomListener (final String eventName) { 373 if (eventName == "CTabFolderEvent") { 374 tabFolder1.addCTabFolder2Listener (new CTabFolder2Listener () { 375 @Override 376 public void close (CTabFolderEvent event) { 377 log (eventName, event); 378 } 379 @Override 380 public void minimize(CTabFolderEvent event) { 381 log (eventName, event); 382 } 383 @Override 384 public void maximize(CTabFolderEvent event) { 385 log (eventName, event); 386 } 387 @Override 388 public void restore(CTabFolderEvent event) { 389 log (eventName, event); 390 } 391 @Override 392 public void showList(CTabFolderEvent event) { 393 log (eventName, event); 394 } 395 }); 396 } 397 } 398 399 /** 400 * Sets the foreground color, background color, and font 401 * of the "Example" widgets to their default settings. 402 * Also sets foreground and background color of the Node 1 403 * TreeItems to default settings. 404 */ 405 @Override resetColorsAndFonts()406 void resetColorsAndFonts () { 407 super.resetColorsAndFonts (); 408 Color oldColor = selectionForegroundColor; 409 selectionForegroundColor = null; 410 setSelectionForeground (); 411 if (oldColor != null) oldColor.dispose(); 412 oldColor = selectionBackgroundColor; 413 selectionBackgroundColor = null; 414 setSelectionBackground (); 415 if (oldColor != null) oldColor.dispose(); 416 Font oldFont = itemFont; 417 itemFont = null; 418 setItemFont (); 419 if (oldFont != null) oldFont.dispose(); 420 oldColor = itemForegroundColor; 421 itemForegroundColor = null; 422 setItemForeground (); 423 if (oldColor != null) oldColor.dispose(); 424 oldColor = itemBackgroundColor; 425 itemBackgroundColor = null; 426 setItemBackground (); 427 } 428 429 /** 430 * Sets the state of the "Example" widgets. 431 */ 432 @Override setExampleWidgetState()433 void setExampleWidgetState () { 434 super.setExampleWidgetState(); 435 setSimpleTabs(); 436 setSingleTabs(); 437 setImages(); 438 setMinimizeVisible(); 439 setMaximizeVisible(); 440 setUnselectedCloseVisible(); 441 setUnselectedImageVisible(); 442 setSelectionBackground (); 443 setSelectionForeground (); 444 setItemFont (); 445 setItemBackground(); 446 setItemForeground(); 447 setExampleWidgetSize(); 448 } 449 450 /** 451 * Sets the shape that the CTabFolder will use to render itself. 452 */ setSimpleTabs()453 void setSimpleTabs () { 454 tabFolder1.setSimple (simpleTabButton.getSelection ()); 455 setExampleWidgetSize(); 456 } 457 458 /** 459 * Sets the number of tabs that the CTabFolder should display. 460 */ setSingleTabs()461 void setSingleTabs () { 462 tabFolder1.setSingle (singleTabButton.getSelection ()); 463 setExampleWidgetSize(); 464 } 465 /** 466 * Sets an image into each item of the "Example" widgets. 467 */ setImages()468 void setImages () { 469 boolean setImage = imageButton.getSelection (); 470 CTabItem items[] = tabFolder1.getItems (); 471 for (CTabItem item : items) { 472 if (setImage) { 473 item.setImage (instance.images[ControlExample.ciClosedFolder]); 474 } else { 475 item.setImage (null); 476 } 477 } 478 setExampleWidgetSize (); 479 } 480 /** 481 * Sets the visibility of the minimize button 482 */ setMinimizeVisible()483 void setMinimizeVisible () { 484 tabFolder1.setMinimizeVisible(showMinButton.getSelection ()); 485 setExampleWidgetSize(); 486 } 487 /** 488 * Sets the visibility of the maximize button 489 */ setMaximizeVisible()490 void setMaximizeVisible () { 491 tabFolder1.setMaximizeVisible(showMaxButton.getSelection ()); 492 setExampleWidgetSize(); 493 } 494 /** 495 * Sets the top right control to a toolbar 496 */ setTopRight()497 void setTopRight () { 498 if (topRightButton.getSelection ()) { 499 topRightControl = new ToolBar(tabFolder1, SWT.FLAT); 500 ToolItem item = new ToolItem(topRightControl, SWT.PUSH); 501 item.setImage(instance.images[ControlExample.ciClosedFolder]); 502 item = new ToolItem(topRightControl, SWT.PUSH); 503 item.setImage(instance.images[ControlExample.ciOpenFolder]); 504 int topRightStyle = 0; 505 if (rightButton.getSelection ()) topRightStyle |= SWT.RIGHT; 506 if (fillButton.getSelection ()) topRightStyle |= SWT.FILL; 507 if (wrapButton.getSelection ()) topRightStyle |= SWT.RIGHT | SWT.WRAP; 508 tabFolder1.setTopRight(topRightControl, topRightStyle); 509 } else { 510 if (topRightControl != null) { 511 tabFolder1.setTopRight(null); 512 topRightControl.dispose(); 513 } 514 } 515 setExampleWidgetSize(); 516 } 517 /** 518 * Sets the visibility of the close button on unselected tabs 519 */ setUnselectedCloseVisible()520 void setUnselectedCloseVisible () { 521 tabFolder1.setUnselectedCloseVisible(unselectedCloseButton.getSelection ()); 522 setExampleWidgetSize(); 523 } 524 /** 525 * Sets the visibility of the image on unselected tabs 526 */ setUnselectedImageVisible()527 void setUnselectedImageVisible () { 528 tabFolder1.setUnselectedImageVisible(unselectedImageButton.getSelection ()); 529 setExampleWidgetSize(); 530 } 531 /** 532 * Sets the background color of CTabItem 0. 533 */ setSelectionBackground()534 void setSelectionBackground () { 535 if (!instance.startup) { 536 tabFolder1.setSelectionBackground(selectionBackgroundColor); 537 } 538 // Set the selection background item's image to match the background color of the selection. 539 Color color = selectionBackgroundColor; 540 if (color == null) color = tabFolder1.getSelectionBackground (); 541 TableItem item = colorAndFontTable.getItem(SELECTION_BACKGROUND_COLOR); 542 Image oldImage = item.getImage(); 543 if (oldImage != null) oldImage.dispose(); 544 item.setImage (colorImage(color)); 545 } 546 547 /** 548 * Sets the foreground color of CTabItem 0. 549 */ setSelectionForeground()550 void setSelectionForeground () { 551 if (!instance.startup) { 552 tabFolder1.setSelectionForeground(selectionForegroundColor); 553 } 554 // Set the selection foreground item's image to match the foreground color of the selection. 555 Color color = selectionForegroundColor; 556 if (color == null) color = tabFolder1.getSelectionForeground (); 557 TableItem item = colorAndFontTable.getItem(SELECTION_FOREGROUND_COLOR); 558 Image oldImage = item.getImage(); 559 if (oldImage != null) oldImage.dispose(); 560 item.setImage (colorImage(color)); 561 } 562 563 /** 564 * Sets the font of CTabItem 0. 565 */ setItemFont()566 void setItemFont () { 567 if (!instance.startup) { 568 tabFolder1.getItem (0).setFont (itemFont); 569 setExampleWidgetSize(); 570 } 571 /* Set the font item's image to match the font of the item. */ 572 Font ft = itemFont; 573 if (ft == null) ft = tabFolder1.getItem (0).getFont (); 574 TableItem item = colorAndFontTable.getItem(ITEM_FONT); 575 Image oldImage = item.getImage(); 576 if (oldImage != null) oldImage.dispose(); 577 item.setImage (fontImage(ft)); 578 item.setFont(ft); 579 colorAndFontTable.layout (); 580 } 581 582 /** 583 * Sets the background color of the CTabItem 0 content element. 584 */ setItemBackground()585 void setItemBackground () { 586 if (!instance.startup) { 587 tabFolder1.getItem(0).getControl().setBackground(itemBackgroundColor); 588 } 589 /* Set the background color item's image to match the background color of the content. */ 590 Color color = itemBackgroundColor; 591 if (color == null) color = tabFolder1.getItem(0).getControl().getBackground(); 592 TableItem item = colorAndFontTable.getItem(ITEM_BACKGROUND_COLOR); 593 Image oldImage = item.getImage(); 594 if (oldImage != null) oldImage.dispose(); 595 item.setImage (colorImage(color)); 596 } 597 598 /** 599 * Sets the foreground color of the CTabItem 0 content element. 600 */ setItemForeground()601 void setItemForeground () { 602 if (!instance.startup) { 603 tabFolder1.getItem(0).getControl().setForeground(itemForegroundColor); 604 } 605 /* Set the foreground color item's image to match the foreground color of the content. */ 606 Color color = itemForegroundColor; 607 if (color == null) color = tabFolder1.getItem(0).getControl().getForeground(); 608 TableItem item = colorAndFontTable.getItem(ITEM_FOREGROUND_COLOR); 609 Image oldImage = item.getImage(); 610 if (oldImage != null) oldImage.dispose(); 611 item.setImage (colorImage(color)); 612 } 613 614 /** 615 * Set the fixed item height for the CTabFolder 616 * 617 * @param height new fixed header height 618 */ setTabHeight(int height)619 void setTabHeight(int height) { 620 tabFolder1.setTabHeight(height); 621 } 622 } 623