@@ -115,10 +115,14 @@ public class CTabFolder extends Composite {
115115
116116 /* sizing, positioning */
117117 boolean onBottom = false ;
118+ boolean onSide = false ;
119+ boolean onRight = false ;
118120 boolean single = false ;
119121 boolean simple = true ;
120122 int fixedTabHeight = SWT .DEFAULT ;
123+ int fixedTabWidth = SWT .DEFAULT ;
121124 int tabHeight ;
125+ int tabWidth ;
122126 int minChars = 20 ;
123127 boolean borderVisible = false ;
124128
@@ -238,6 +242,7 @@ public class CTabFolder extends Composite {
238242 final static int REDRAW = 1 << 1 ;
239243 final static int REDRAW_TABS = 1 << 2 ;
240244 final static int UPDATE_TAB_HEIGHT = 1 << 3 ;
245+ final static int UPDATE_TAB_WIDTH = 1 << 4 ;
241246 Runnable updateRun ;
242247
243248 // when disposing CTabFolder, don't try to layout the items or
@@ -301,7 +306,19 @@ void init(int style) {
301306 super .setLayout (new CTabFolderLayout ());
302307 int style2 = super .getStyle ();
303308 oldFont = getFont ();
304- onBottom = (style2 & SWT .BOTTOM ) != 0 ;
309+ switch (style2 & (SWT .TOP | SWT .BOTTOM | SWT .LEFT | SWT .RIGHT )) {
310+ case SWT .BOTTOM :
311+ onBottom = true ;
312+ break ;
313+ case SWT .LEFT :
314+ onSide = true ;
315+ break ;
316+ case SWT .RIGHT :
317+ onSide = true ;
318+ onRight = true ;
319+ break ;
320+ // SWT.TOP is the default
321+ }
305322 showClose = (style2 & SWT .CLOSE ) != 0 ;
306323// showMin = (style2 & SWT.MIN) != 0; - conflicts with SWT.TOP
307324// showMax = (style2 & SWT.MAX) != 0; - conflicts with SWT.BOTTOM
@@ -394,11 +411,19 @@ void onActivate(Event event) {
394411}
395412
396413static int checkStyle (Composite parent , int style ) {
397- int mask = SWT .CLOSE | SWT .TOP | SWT .BOTTOM | SWT .FLAT | SWT .LEFT_TO_RIGHT | SWT .RIGHT_TO_LEFT | SWT .SINGLE | SWT .MULTI ;
414+ int mask = SWT .CLOSE | SWT .TOP | SWT .BOTTOM | SWT .LEFT | SWT . RIGHT | SWT . FLAT | SWT .LEFT_TO_RIGHT | SWT .RIGHT_TO_LEFT | SWT .SINGLE | SWT .MULTI ;
398415 style = style & mask ;
399- // TOP and BOTTOM are mutually exclusive.
416+ // TOP, BOTTOM, LEFT and RIGHT are mutually exclusive.
400417 // TOP is the default
401- if ((style & SWT .TOP ) != 0 ) style = style & ~SWT .BOTTOM ;
418+ if ((style & SWT .TOP ) != 0 ) {
419+ style = style & ~SWT .BOTTOM & ~SWT .LEFT & ~SWT .RIGHT ;
420+ }
421+ else if ((style & SWT .BOTTOM ) != 0 ) {
422+ style = style & ~SWT .LEFT & ~SWT .RIGHT ;
423+ }
424+ else if ((style & SWT .LEFT ) != 0 ) {
425+ style = style & ~SWT .RIGHT ;
426+ }
402427 // SINGLE and MULTI are mutually exclusive.
403428 // MULTI is the default
404429 if ((style & SWT .MULTI ) != 0 ) style = style & ~SWT .SINGLE ;
@@ -1295,6 +1320,22 @@ public int getTabHeight(){
12951320 if (fixedTabHeight != SWT .DEFAULT ) return fixedTabHeight ;
12961321 return tabHeight - 1 ; // -1 for line drawn across top of tab //TODO: replace w/ computeTrim of tab area?
12971322}
1323+ /**
1324+ * Returns the width of the tab
1325+ *
1326+ * @return the width of the tab
1327+ *
1328+ * @exception SWTException <ul>
1329+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
1330+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
1331+ * </ul>
1332+ * @since 3.130
1333+ */
1334+ public int getTabWidth (){
1335+ checkWidget ();
1336+ if (fixedTabWidth != SWT .DEFAULT ) return fixedTabWidth ;
1337+ return tabWidth ;
1338+ }
12981339/**
12991340 * Returns the position of the tab. Possible values are SWT.TOP or SWT.BOTTOM.
13001341 *
@@ -1307,7 +1348,7 @@ public int getTabHeight(){
13071348 */
13081349public int getTabPosition (){
13091350 checkWidget ();
1310- return onBottom ? SWT .BOTTOM : SWT .TOP ;
1351+ return onSide ? ( onRight ? SWT . RIGHT : SWT . LEFT ) : ( onBottom ? SWT .BOTTOM : SWT .TOP ) ;
13111352}
13121353/**
13131354 * Returns the control in the top right corner of the tab folder.
@@ -3580,6 +3621,28 @@ public void setTabHeight(int height) {
35803621 fixedTabHeight = height ;
35813622 updateFolder (UPDATE_TAB_HEIGHT );
35823623}
3624+ /**
3625+ * Specify a fixed width for the tab items. If no width is specified,
3626+ * the default height is the width of the text or the image, whichever
3627+ * is greater. Specifying a width of -1 will revert to the default width.
3628+ *
3629+ * @param width the point value of the width or -1
3630+ *
3631+ * @exception SWTException <ul>
3632+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
3633+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
3634+ * <li>ERROR_INVALID_ARGUMENT - if called with a height of less than 0</li>
3635+ * </ul>
3636+ * @since 3.130
3637+ */
3638+ public void setTabWidth (int width ) {
3639+ checkWidget ();
3640+ if (width < -1 ) {
3641+ SWT .error (SWT .ERROR_INVALID_ARGUMENT );
3642+ }
3643+ fixedTabWidth = width ;
3644+ updateFolder (UPDATE_TAB_WIDTH );
3645+ }
35833646/**
35843647 * Specify whether the tabs should appear along the top of the folder
35853648 * or along the bottom of the folder.
@@ -3596,11 +3659,27 @@ public void setTabHeight(int height) {
35963659 */
35973660public void setTabPosition (int position ) {
35983661 checkWidget ();
3599- if (position != SWT .TOP && position != SWT .BOTTOM ) {
3662+ if (position != SWT .TOP && position != SWT .BOTTOM && position != SWT . LEFT && position != SWT . RIGHT ) {
36003663 SWT .error (SWT .ERROR_INVALID_ARGUMENT );
36013664 }
3602- if (onBottom != (position == SWT .BOTTOM )) {
3603- onBottom = position == SWT .BOTTOM ;
3665+ int tabPosition = onSide ? (onRight ? SWT .RIGHT : SWT .LEFT ) : (onBottom ? SWT .BOTTOM : SWT .TOP );
3666+ if (tabPosition != position ) {
3667+ onBottom = false ;
3668+ onSide = false ;
3669+ onRight = false ;
3670+ switch (position ) {
3671+ case SWT .BOTTOM :
3672+ onBottom = true ;
3673+ break ;
3674+ case SWT .LEFT :
3675+ onSide = true ;
3676+ break ;
3677+ case SWT .RIGHT :
3678+ onSide = true ;
3679+ onRight = true ;
3680+ break ;
3681+ // SWT.TOP is the default
3682+ }
36043683 updateFolder (REDRAW );
36053684 }
36063685}
0 commit comments