Skip to content

Commit af044d9

Browse files
committed
[GTK] Simplify Tree/Table
This is continuation of #2059 . There is no point in having these extra methods (and double checkWidget method calls for so many things).
1 parent 195a3bf commit af044d9

File tree

6 files changed

+9
-104
lines changed

6 files changed

+9
-104
lines changed

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2022 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -1157,7 +1157,7 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean
11571157
long [] path = new long [1];
11581158
if (GTK.gtk_gesture_drag_get_start_point(dragGesture, startX, startY)) {
11591159
if (getHeaderVisible()) {
1160-
startY[0]-= getHeaderHeightInPixels();
1160+
startY[0]-= getHeaderHeight();
11611161
}
11621162
if (GTK.gtk_tree_view_get_path_at_pos (handle, (int) startX[0], (int) startY[0], path, null, null, null)) {
11631163
if (path [0] != 0) {
@@ -1434,11 +1434,6 @@ TableItem getFocusItem () {
14341434
*/
14351435
public int getGridLineWidth () {
14361436
checkWidget ();
1437-
return getGridLineWidthInPixels ();
1438-
}
1439-
1440-
int getGridLineWidthInPixels () {
1441-
checkWidget();
14421437
return 0;
14431438
}
14441439

@@ -1488,11 +1483,6 @@ public Color getHeaderForeground () {
14881483
*/
14891484
public int getHeaderHeight () {
14901485
checkWidget ();
1491-
return getHeaderHeightInPixels ();
1492-
}
1493-
1494-
int getHeaderHeightInPixels () {
1495-
checkWidget();
14961486
if (!GTK.gtk_tree_view_get_headers_visible(handle)) return 0;
14971487

14981488
int height = 0;
@@ -1598,11 +1588,6 @@ public TableItem getItem (int index) {
15981588
* </ul>
15991589
*/
16001590
public TableItem getItem (Point point) {
1601-
checkWidget();
1602-
return getItemInPixels(point);
1603-
}
1604-
1605-
TableItem getItemInPixels (Point point) {
16061591
checkWidget();
16071592
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
16081593
long [] path = new long [1];
@@ -1657,11 +1642,6 @@ public int getItemCount () {
16571642
*/
16581643
public int getItemHeight () {
16591644
checkWidget ();
1660-
return getItemHeightInPixels ();
1661-
}
1662-
1663-
int getItemHeightInPixels () {
1664-
checkWidget();
16651645
int height = 0;
16661646

16671647
if (itemCount == 0) {

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,6 @@ public String getToolTipText () {
319319
*/
320320
public int getWidth () {
321321
checkWidget ();
322-
return getWidthInPixels();
323-
}
324-
325-
int getWidthInPixels () {
326-
checkWidget();
327322
if (!GTK.gtk_tree_view_column_get_visible (handle)) {
328323
return 0;
329324
}
@@ -507,7 +502,7 @@ public void pack () {
507502
}
508503
OS.g_free (iter);
509504
}
510-
setWidthInPixels(width);
505+
setWidth(width);
511506
}
512507

513508
@Override
@@ -760,11 +755,6 @@ public void setToolTipText(String string) {
760755
*/
761756
public void setWidth (int width) {
762757
checkWidget ();
763-
setWidthInPixels (width);
764-
}
765-
766-
void setWidthInPixels (int width) {
767-
checkWidget();
768758
if (width < 0) return;
769759
if (width == lastWidth) return;
770760
if (width > 0) {

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2019 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -394,11 +394,6 @@ public Color getBackground (int index) {
394394
*/
395395
public Rectangle getBounds (int index) {
396396
checkWidget ();
397-
return getBoundsInPixels (index);
398-
}
399-
400-
Rectangle getBoundsInPixels (int index) {
401-
checkWidget();
402397
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
403398
long parentHandle = parent.handle;
404399
long column = 0;
@@ -601,11 +596,6 @@ public Image getImage (int index) {
601596
* </ul>
602597
*/
603598
public Rectangle getImageBounds (int index) {
604-
checkWidget ();
605-
return getImageBoundsInPixels (index);
606-
}
607-
608-
Rectangle getImageBoundsInPixels (int index) {
609599
checkWidget ();
610600
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
611601
long parentHandle = parent.handle;
@@ -742,11 +732,6 @@ public String getText (int index) {
742732
* @since 3.3
743733
*/
744734
public Rectangle getTextBounds (int index) {
745-
checkWidget ();
746-
return getTextBoundsInPixels (index);
747-
}
748-
749-
Rectangle getTextBoundsInPixels (int index) {
750735
checkWidget ();
751736
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
752737
int count = Math.max (1, parent.getColumnCount ());

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2022 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -645,7 +645,7 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
645645
* the number of items at the root of the tree.
646646
*/
647647
if (hHint == SWT.DEFAULT && size.y == getHeaderHeight()) {
648-
int itemHeight = getItemHeightInPixels();
648+
int itemHeight = getItemHeight();
649649

650650
// Initialize to height of root items & header
651651
size.y = getItemCount() * itemHeight + getHeaderHeight();
@@ -1320,7 +1320,7 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean
13201320
long [] path = new long [1];
13211321
if (GTK.gtk_gesture_drag_get_start_point(dragGesture, startX, startY)) {
13221322
if (getHeaderVisible()) {
1323-
startY[0]-= getHeaderHeightInPixels();
1323+
startY[0]-= getHeaderHeight();
13241324
}
13251325
if (GTK.gtk_tree_view_get_path_at_pos (handle, (int) startX[0], (int) startY[0], path, null, null, null)) {
13261326
if (path [0] != 0) {
@@ -1602,11 +1602,6 @@ TreeItem getFocusItem () {
16021602
*/
16031603
public int getGridLineWidth () {
16041604
checkWidget ();
1605-
return getGridLineWidthInPixels ();
1606-
}
1607-
1608-
int getGridLineWidthInPixels () {
1609-
checkWidget();
16101605
return 0;
16111606
}
16121607

@@ -1656,11 +1651,6 @@ public Color getHeaderForeground () {
16561651
*/
16571652
public int getHeaderHeight () {
16581653
checkWidget ();
1659-
return getHeaderHeightInPixels ();
1660-
}
1661-
1662-
int getHeaderHeightInPixels () {
1663-
checkWidget();
16641654
if (!GTK.gtk_tree_view_get_headers_visible(handle)) return 0;
16651655

16661656
int height = 0;
@@ -1771,11 +1761,6 @@ public TreeItem getItem (int index) {
17711761
*/
17721762
public TreeItem getItem (Point point) {
17731763
checkWidget();
1774-
return getItemInPixels(point);
1775-
}
1776-
1777-
TreeItem getItemInPixels (Point point) {
1778-
checkWidget ();
17791764
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
17801765
long [] path = new long [1];
17811766
GTK.gtk_widget_realize (handle);
@@ -1846,11 +1831,6 @@ public int getItemCount () {
18461831
*/
18471832
public int getItemHeight () {
18481833
checkWidget ();
1849-
return getItemHeightInPixels ();
1850-
}
1851-
1852-
int getItemHeightInPixels () {
1853-
checkWidget();
18541834
int height = 0;
18551835
int itemCount = GTK.gtk_tree_model_iter_n_children(modelHandle, 0);
18561836

@@ -3462,7 +3442,7 @@ public void setInsertMark (TreeItem item, boolean before) {
34623442
}
34633443
if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
34643444
if (item.parent != this) return;
3465-
Rectangle rect = item.getBoundsInPixels();
3445+
Rectangle rect = item.getBounds();
34663446
long [] path = new long [1];
34673447
GTK.gtk_widget_realize (handle);
34683448
if (!GTK.gtk_tree_view_get_path_at_pos(handle, rect.x, rect.y, path, null, null, null)) return;

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,6 @@ public String getToolTipText () {
321321
*/
322322
public int getWidth () {
323323
checkWidget ();
324-
return getWidthInPixels ();
325-
}
326-
327-
int getWidthInPixels () {
328-
checkWidget();
329324
if (!GTK.gtk_tree_view_column_get_visible (handle)) {
330325
return 0;
331326
}
@@ -487,7 +482,7 @@ public void pack () {
487482
}
488483
OS.g_free (iter);
489484
}
490-
setWidthInPixels(width);
485+
setWidth(width);
491486
}
492487

493488
@Override
@@ -736,11 +731,6 @@ public void setToolTipText(String string) {
736731
* </ul>
737732
*/
738733
public void setWidth(int width) {
739-
checkWidget();
740-
setWidthInPixels(width);
741-
}
742-
743-
void setWidthInPixels(int width) {
744734
checkWidget();
745735
if (width < 0) return;
746736
if (width == lastWidth) return;

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,7 @@ public Color getBackground (int index) {
407407
*/
408408
public Rectangle getBounds (int index) {
409409
checkWidget ();
410-
return getBoundsInPixels (index);
411-
}
412-
413-
Rectangle getBoundsInPixels (int index) {
414410
// TODO fully test on early and later versions of GTK
415-
checkWidget();
416411
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
417412
long parentHandle = parent.handle;
418413
long column = 0;
@@ -454,13 +449,8 @@ Rectangle getBoundsInPixels (int index) {
454449
*/
455450
public Rectangle getBounds () {
456451
checkWidget ();
457-
return getBoundsInPixels ();
458-
}
459-
460-
Rectangle getBoundsInPixels () {
461452
// TODO fully test on early and later versions of GTK
462453
// shifted a bit too far right on later versions of GTK - however, old Tree also had this problem
463-
checkWidget ();
464454
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
465455
long parentHandle = parent.handle;
466456
long column = GTK.gtk_tree_view_get_column (parentHandle, 0);
@@ -694,12 +684,7 @@ public Image getImage (int index) {
694684
*/
695685
public Rectangle getImageBounds (int index) {
696686
checkWidget ();
697-
return getImageBoundsInPixels(index);
698-
}
699-
700-
Rectangle getImageBoundsInPixels (int index) {
701687
// TODO fully test on early and later versions of GTK
702-
checkWidget ();
703688
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
704689
long parentHandle = parent.handle;
705690
long column = 0;
@@ -927,11 +912,6 @@ public String getText (int index) {
927912
* @since 3.3
928913
*/
929914
public Rectangle getTextBounds (int index) {
930-
checkWidget ();
931-
return getTextBoundsInPixels(index);
932-
}
933-
934-
Rectangle getTextBoundsInPixels (int index) {
935915
checkWidget ();
936916
if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
937917
int count = Math.max (1, parent.getColumnCount ());

0 commit comments

Comments
 (0)