comparison dwt/widgets/TabFolder.d @ 7:e831403a80a9

Add 'cast' to casts
author Frank Benoit <benoit@tionex.de>
date Wed, 27 Aug 2008 14:30:35 +0200
parents 1a8b3cb347e0
children d8635bb48c7c
comparison
equal deleted inserted replaced
6:b903c16b6f48 7:e831403a80a9
138 } 138 }
139 139
140 public Point computeSize (int wHint, int hHint, bool changed) { 140 public Point computeSize (int wHint, int hHint, bool changed) {
141 Point size = super.computeSize (wHint, hHint, changed); 141 Point size = super.computeSize (wHint, hHint, changed);
142 if (wHint is DWT.DEFAULT && items.length > 0) { 142 if (wHint is DWT.DEFAULT && items.length > 0) {
143 NSSize mimSize = ((NSTabView)view).minimumSize(); 143 NSSize mimSize = (cast(NSTabView)view).minimumSize();
144 Rectangle trim = computeTrim (0, 0, (int)mimSize.width, 0); 144 Rectangle trim = computeTrim (0, 0, cast(int)mimSize.width, 0);
145 size.x = Math.max (trim.width, size.x); 145 size.x = Math.max (trim.width, size.x);
146 } 146 }
147 return size; 147 return size;
148 } 148 }
149 149
164 // OS.HIViewSetFrame (handle, oldBounds); 164 // OS.HIViewSetFrame (handle, oldBounds);
165 // OS.HIViewSetDrawingEnabled (handle, drawCount is 0); 165 // OS.HIViewSetDrawingEnabled (handle, drawCount is 0);
166 // } 166 // }
167 // x -= client.left; 167 // x -= client.left;
168 // y -= client.top; 168 // y -= client.top;
169 // width += (int) bounds.width - (client.right - client.left); 169 // width += cast(int) bounds.width - (client.right - client.left);
170 // height += (int) bounds.height - (client.bottom - client.top); 170 // height += cast(int) bounds.height - (client.bottom - client.top);
171 // Rect inset = getInset (); 171 // Rect inset = getInset ();
172 // x -= inset.left; 172 // x -= inset.left;
173 // y -= inset.top; 173 // y -= inset.top;
174 // width += inset.left + inset.right; 174 // width += inset.left + inset.right;
175 // height += inset.top + inset.bottom; 175 // height += inset.top + inset.bottom;
176 // return new Rectangle (-client.left, -client.top, width, height); 176 // return new Rectangle (-client.left, -client.top, width, height);
177 return super.computeTrim(x, y, width, height); 177 return super.computeTrim(x, y, width, height);
178 } 178 }
179 179
180 void createHandle () { 180 void createHandle () {
181 SWTTabView widget = (SWTTabView)new SWTTabView().alloc(); 181 SWTTabView widget = cast(SWTTabView)new SWTTabView().alloc();
182 widget.initWithFrame (new NSRect()); 182 widget.initWithFrame (new NSRect());
183 widget.setTag(jniRef); 183 widget.setTag(jniRef);
184 widget.setDelegate(widget); 184 widget.setDelegate(widget);
185 if ((style & DWT.BOTTOM) !is 0) { 185 if ((style & DWT.BOTTOM) !is 0) {
186 widget.setTabViewType(OS.NSBottomTabsBezelBorder); 186 widget.setTabViewType(OS.NSBottomTabsBezelBorder);
198 items = newItems; 198 items = newItems;
199 } 199 }
200 System.arraycopy (items, index, items, index + 1, count - index); 200 System.arraycopy (items, index, items, index + 1, count - index);
201 items [index] = item; 201 items [index] = item;
202 itemCount++; 202 itemCount++;
203 NSTabViewItem nsItem = (NSTabViewItem)new NSTabViewItem().alloc().init(); 203 NSTabViewItem nsItem = cast(NSTabViewItem)new NSTabViewItem().alloc().init();
204 item.nsItem = nsItem; 204 item.nsItem = nsItem;
205 ((NSTabView)view).insertTabViewItem(nsItem, index); 205 (cast(NSTabView)view).insertTabViewItem(nsItem, index);
206 } 206 }
207 207
208 void createWidget () { 208 void createWidget () {
209 super.createWidget (); 209 super.createWidget ();
210 items = new TabItem [4]; 210 items = new TabItem [4];
223 items [count] = null; 223 items [count] = null;
224 if (count is 0) { 224 if (count is 0) {
225 items = new TabItem [4]; 225 items = new TabItem [4];
226 } 226 }
227 itemCount = count; 227 itemCount = count;
228 ((NSTabView)view).removeTabViewItem(item.nsItem); 228 (cast(NSTabView)view).removeTabViewItem(item.nsItem);
229 } 229 }
230 230
231 public Rectangle getClientArea () { 231 public Rectangle getClientArea () {
232 checkWidget (); 232 checkWidget ();
233 NSRect rect = ((NSTabView)view).contentRect(); 233 NSRect rect = (cast(NSTabView)view).contentRect();
234 int x = Math.max (0, (int)rect.x); 234 int x = Math.max (0, cast(int)rect.x);
235 int y = Math.max (0, (int)rect.y); 235 int y = Math.max (0, cast(int)rect.y);
236 int width = Math.max (0, (int)rect.width); 236 int width = Math.max (0, cast(int)rect.width);
237 int height = Math.max (0, (int)rect.height); 237 int height = Math.max (0, cast(int)rect.height);
238 return new Rectangle (x, y, width, height); 238 return new Rectangle (x, y, width, height);
239 } 239 }
240 240
241 /** 241 /**
242 * Returns the item at the given, zero-relative index in the 242 * Returns the item at the given, zero-relative index in the
264 checkWidget (); 264 checkWidget ();
265 if (point is null) error (DWT.ERROR_NULL_ARGUMENT); 265 if (point is null) error (DWT.ERROR_NULL_ARGUMENT);
266 NSPoint nsPoint = new NSPoint (); 266 NSPoint nsPoint = new NSPoint ();
267 nsPoint.x = point.x; 267 nsPoint.x = point.x;
268 nsPoint.y = point.y; 268 nsPoint.y = point.y;
269 NSTabView tabView = (NSTabView) view; 269 NSTabView tabView = cast(NSTabView) view;
270 NSTabViewItem tabViewItem = tabView.tabViewItemAtPoint (nsPoint); 270 NSTabViewItem tabViewItem = tabView.tabViewItemAtPoint (nsPoint);
271 for (int i = 0; i < itemCount; i++) { 271 for (int i = 0; i < itemCount; i++) {
272 NSTabViewItem item = items[i].nsItem; 272 NSTabViewItem item = items[i].nsItem;
273 if (item.isEqual (tabViewItem)) { 273 if (item.isEqual (tabViewItem)) {
274 return items [i]; 274 return items [i];
350 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 350 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
351 * </ul> 351 * </ul>
352 */ 352 */
353 public int getSelectionIndex () { 353 public int getSelectionIndex () {
354 checkWidget (); 354 checkWidget ();
355 NSTabViewItem selected = ((NSTabView)view).selectedTabViewItem(); 355 NSTabViewItem selected = (cast(NSTabView)view).selectedTabViewItem();
356 if (selected is null) return -1; 356 if (selected is null) return -1;
357 for (int i = 0; i < itemCount; i++) { 357 for (int i = 0; i < itemCount; i++) {
358 if (items[i].nsItem.id is selected.id) return i; 358 if (items[i].nsItem.id is selected.id) return i;
359 } 359 }
360 return -1; 360 return -1;
472 } 472 }
473 return result; 473 return result;
474 } 474 }
475 475
476 void setFont (NSFont font) { 476 void setFont (NSFont font) {
477 ((NSTabView)view).setFont(font); 477 (cast(NSTabView)view).setFont(font);
478 } 478 }
479 479
480 /** 480 /**
481 * Sets the receiver's selection to the given item. 481 * Sets the receiver's selection to the given item.
482 * The current selected is first cleared, then the new item is 482 * The current selected is first cleared, then the new item is
559 if (control !is null && !control.isDisposed ()) { 559 if (control !is null && !control.isDisposed ()) {
560 control.setVisible (false); 560 control.setVisible (false);
561 } 561 }
562 } 562 }
563 } 563 }
564 ((NSTabView)view).selectTabViewItemAtIndex(index); 564 (cast(NSTabView)view).selectTabViewItemAtIndex(index);
565 index = getSelectionIndex(); 565 index = getSelectionIndex();
566 if (index !is -1) { 566 if (index !is -1) {
567 TabItem item = items [index]; 567 TabItem item = items [index];
568 if (item !is null) { 568 if (item !is null) {
569 Control control = item.control; 569 Control control = item.control;