Mercurial > projects > dwt-addons
comparison dwtx/jface/action/ToolBarManager.d @ 71:4878bef4a38e
Some fixing
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 22 May 2008 04:03:58 +0200 |
parents | 46a6e0e6ccd4 |
children | 5df4896124c7 |
comparison
equal
deleted
inserted
replaced
70:46a6e0e6ccd4 | 71:4878bef4a38e |
---|---|
195 * the old number of items | 195 * the old number of items |
196 * @param newCount | 196 * @param newCount |
197 * the new number of items | 197 * the new number of items |
198 */ | 198 */ |
199 protected void relayout(ToolBar layoutBar, int oldCount, int newCount) { | 199 protected void relayout(ToolBar layoutBar, int oldCount, int newCount) { |
200 if ((oldCount !is newCount) && (newCount!is0)) { | 200 if ((oldCount !is newCount) && (newCount!is 0)) { |
201 Point beforePack = layoutBar.getSize(); | 201 Point beforePack = layoutBar.getSize(); |
202 layoutBar.pack(true); | 202 layoutBar.pack(true); |
203 Point afterPack = layoutBar.getSize(); | 203 Point afterPack = layoutBar.getSize(); |
204 | 204 |
205 // If the TB didn't change size then we're done | 205 // If the TB didn't change size then we're done |
206 if (beforePack.equals(afterPack)) | 206 if (beforePack.equals(afterPack)) |
207 return; | 207 return; |
208 | 208 |
209 // OK, we need to re-layout the TB | 209 // OK, we need to re-layout the TB |
210 layoutBar.getParent().layout(); | 210 layoutBar.getParent().layout(); |
211 | 211 |
212 // Now, if we're in a CoolBar then change the CoolItem size as well | 212 // Now, if we're in a CoolBar then change the CoolItem size as well |
213 if (layoutBar.getParent() instanceof CoolBar) { | 213 if (null !is cast(CoolBar)layoutBar.getParent() ) { |
214 CoolBar cb = (CoolBar) layoutBar.getParent(); | 214 CoolBar cb = cast(CoolBar) layoutBar.getParent(); |
215 CoolItem[] items = cb.getItems(); | 215 CoolItem[] items = cb.getItems(); |
216 for (int i = 0; i < items.length; i++) { | 216 for (int i = 0; i < items.length; i++) { |
217 if (items[i].getControl() is layoutBar) { | 217 if (items[i].getControl() is layoutBar) { |
218 Point curSize = items[i].getSize(); | 218 Point curSize = items[i].getSize(); |
219 items[i].setSize(curSize.x+ (afterPack.x - beforePack.x), | 219 items[i].setSize(curSize.x+ (afterPack.x - beforePack.x), |
385 toolBar.setRedraw(true); | 385 toolBar.setRedraw(true); |
386 } | 386 } |
387 } | 387 } |
388 | 388 |
389 int newCount = toolBar.getItemCount(); | 389 int newCount = toolBar.getItemCount(); |
390 | 390 |
391 // If we're forcing a change then ensure that we re-layout everything | 391 // If we're forcing a change then ensure that we re-layout everything |
392 if (force) | 392 if (force) |
393 oldCount = newCount+1; | 393 oldCount = newCount+1; |
394 | 394 |
395 relayout(toolBar, oldCount, newCount); | 395 relayout(toolBar, oldCount, newCount); |
396 } | 396 } |
397 | 397 |
398 } | 398 } |
399 | 399 |