Commit 9ea636e5642af91c5164934cac1dbceeb58b46d5

Authored by tatiana
1 parent ed221684

FIX: Back to normal toolbar

Showing 1 changed file with 124 additions and 69 deletions   Show diff stats
invesalius/gui/frame.py
... ... @@ -22,7 +22,6 @@ import sys
22 22  
23 23 import wx
24 24 import wx.aui
25   -import wx.lib.agw.aui as aui
26 25 import wx.lib.pubsub as ps
27 26  
28 27 import constants as const
... ... @@ -316,12 +315,13 @@ class TaskBarIcon(wx.TaskBarIcon):
316 315  
317 316 # ------------------------------------------------------------------
318 317  
319   -class ProjectToolBar(aui.AuiToolBar):
  318 +class ProjectToolBar(wx.ToolBar):
320 319 def __init__(self, parent):
321   - aui.AuiToolBar.__init__(self, parent, -1, wx.DefaultPosition,
322   - wx.DefaultSize, aui.AUI_TB_DEFAULT_STYLE)
  320 + wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition,
  321 + wx.DefaultSize,
  322 + wx.TB_FLAT|wx.TB_NODIVIDER | wx.TB_DOCKABLE)
323 323  
324   - self.SetToolBitmapSize(wx.Size(16,16))
  324 + self.SetToolBitmapSize(wx.Size(32,32))
325 325  
326 326 self.parent = parent
327 327  
... ... @@ -342,19 +342,42 @@ class ProjectToolBar(aui.AuiToolBar):
342 342 BMP_PHOTO = wx.Bitmap("../icons/tool_photo.png",
343 343 wx.BITMAP_TYPE_PNG)
344 344  
345   - self.AddSimpleTool(ID_FILE_IMPORT,
  345 + if sys.platform == 'darwin':
  346 + BMP_IMPORT = wx.Bitmap("../icons/file_import_original.png",
  347 + wx.BITMAP_TYPE_PNG)
  348 + BMP_NET = wx.Bitmap("../icons/file_from_internet_original.png",
  349 + wx.BITMAP_TYPE_PNG)
  350 + BMP_SAVE = wx.Bitmap("../icons/file_save_original.png",
  351 + wx.BITMAP_TYPE_PNG)
  352 + BMP_PRINT = wx.Bitmap("../icons/print_original.png",
  353 + wx.BITMAP_TYPE_PNG)
  354 + BMP_PHOTO = wx.Bitmap("../icons/tool_photo_original.png",
  355 + wx.BITMAP_TYPE_PNG)
  356 + else:
  357 + BMP_IMPORT = wx.Bitmap("../icons/file_import.png",
  358 + wx.BITMAP_TYPE_PNG)
  359 + BMP_NET = wx.Bitmap("../icons/file_from_internet.png",
  360 + wx.BITMAP_TYPE_PNG)
  361 + BMP_SAVE = wx.Bitmap("../icons/file_save.png",
  362 + wx.BITMAP_TYPE_PNG)
  363 + BMP_PRINT = wx.Bitmap("../icons/print.png",
  364 + wx.BITMAP_TYPE_PNG)
  365 + BMP_PHOTO = wx.Bitmap("../icons/tool_photo.png",
  366 + wx.BITMAP_TYPE_PNG)
  367 +
  368 + self.AddLabelTool(ID_FILE_IMPORT,
346 369 "Import medical image...",
347 370 BMP_IMPORT)
348   - self.AddSimpleTool(ID_FILE_LOAD_INTERNET,
  371 + self.AddLabelTool(ID_FILE_LOAD_INTERNET,
349 372 "Load medical image...",
350 373 BMP_NET)
351   - self.AddSimpleTool(ID_FILE_SAVE,
  374 + self.AddLabelTool(ID_FILE_SAVE,
352 375 "Save InVesalius project",
353 376 BMP_SAVE)
354   - self.AddSimpleTool(ID_FILE_PHOTO,
  377 + self.AddLabelTool(ID_FILE_PHOTO,
355 378 "Take photo of screen",
356 379 BMP_PHOTO)
357   - self.AddSimpleTool(ID_FILE_PRINT,
  380 + self.AddLabelTool(ID_FILE_PRINT,
358 381 "Print medical image...",
359 382 BMP_PRINT)
360 383  
... ... @@ -365,12 +388,13 @@ class ProjectToolBar(aui.AuiToolBar):
365 388  
366 389 # ------------------------------------------------------------------
367 390  
368   -class ObjectToolBar(aui.AuiToolBar):
  391 +class ObjectToolBar(wx.ToolBar):
369 392 def __init__(self, parent):
370   - aui.AuiToolBar.__init__(self, parent, -1, wx.DefaultPosition,
371   - wx.DefaultSize, aui.AUI_TB_DEFAULT_STYLE)
372   - self.SetToolBitmapSize(wx.Size(16,16))
  393 + wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition,
  394 + wx.DefaultSize,
  395 + wx.TB_FLAT|wx.TB_NODIVIDER | wx.TB_DOCKABLE)
373 396  
  397 + self.SetToolBitmapSize(wx.Size(32,32))
374 398 self.parent = parent
375 399  
376 400 self.__init_items()
... ... @@ -379,40 +403,51 @@ class ObjectToolBar(aui.AuiToolBar):
379 403  
380 404 def __init_items(self):
381 405  
382   -
383   - BMP_ROTATE = wx.Bitmap("../icons/tool_rotate.gif",
384   - wx.BITMAP_TYPE_GIF)
385   - BMP_MOVE = wx.Bitmap("../icons/tool_translate.gif",
386   - wx.BITMAP_TYPE_GIF)
387   - BMP_ZOOM = wx.Bitmap("../icons/tool_zoom.png",
388   - wx.BITMAP_TYPE_PNG)
389   - BMP_ZOOM_SELECT = wx.Bitmap("../icons/tool_zoom_select.png",
390   - wx.BITMAP_TYPE_PNG)
391   - BMP_CONTRAST = wx.Bitmap("../icons/tool_contrast.png",
  406 + if sys.platform == 'darwin':
  407 + BMP_ROTATE = wx.Bitmap("../icons/tool_rotate_original.gif",
  408 + wx.BITMAP_TYPE_GIF)
  409 + BMP_MOVE =wx.Bitmap("../icons/tool_translate_original.png",
  410 + wx.BITMAP_TYPE_PNG)
  411 + BMP_ZOOM = wx.Bitmap("../icons/tool_zoom_original.png",
392 412 wx.BITMAP_TYPE_PNG)
393   -
  413 + BMP_ZOOM_SELECT = wx.Bitmap("../icons/tool_zoom_select_original.png",
  414 + wx.BITMAP_TYPE_PNG)
  415 + BMP_CONTRAST = wx.Bitmap("../icons/tool_contrast.png",
  416 + wx.BITMAP_TYPE_PNG)
  417 + else:
  418 +
  419 + BMP_ROTATE = wx.Bitmap("../icons/tool_rotate.gif",
  420 + wx.BITMAP_TYPE_GIF)
  421 + BMP_MOVE = wx.Bitmap("../icons/tool_translate.gif",
  422 + wx.BITMAP_TYPE_GIF)
  423 + BMP_ZOOM = wx.Bitmap("../icons/tool_zoom.png",
  424 + wx.BITMAP_TYPE_PNG)
  425 + BMP_ZOOM_SELECT = wx.Bitmap("../icons/tool_zoom_select.png",
  426 + wx.BITMAP_TYPE_PNG)
  427 + BMP_CONTRAST = wx.Bitmap("../icons/tool_contrast.png",
  428 + wx.BITMAP_TYPE_PNG)
394 429  
395   - self.AddSimpleTool(ID_ZOOM,
  430 + self.AddLabelTool(ID_ZOOM,
396 431 "Zoom",
397 432 BMP_ZOOM,
398   - kind = aui.ITEM_RADIO)
  433 + kind = wx.ITEM_CHECK)
399 434  
400   - self.AddSimpleTool(ID_ZOOM_SELECT,
  435 + self.AddLabelTool(ID_ZOOM_SELECT,
401 436 "Zoom based on selection",
402 437 BMP_ZOOM_SELECT,
403   - kind = aui.ITEM_RADIO)
  438 + kind = wx.ITEM_CHECK)
404 439  
405   - self.AddSimpleTool(ID_ROTATE,
  440 + self.AddLabelTool(ID_ROTATE,
406 441 "Rotate", BMP_ROTATE,
407   - kind = aui.ITEM_RADIO)
  442 + kind = wx.ITEM_CHECK)
408 443  
409   - self.AddSimpleTool(ID_MOVE,
  444 + self.AddLabelTool(ID_MOVE,
410 445 "Move", BMP_MOVE,
411   - kind = aui.ITEM_RADIO)
  446 + kind = wx.ITEM_CHECK)
412 447  
413   - self.AddSimpleTool(ID_CONTRAST,
  448 + self.AddLabelTool(ID_CONTRAST,
414 449 "Window and Level", BMP_CONTRAST,
415   - kind = aui.ITEM_RADIO)
  450 + kind = wx.ITEM_CHECK)
416 451 self.Realize()
417 452  
418 453  
... ... @@ -424,42 +459,41 @@ class ObjectToolBar(aui.AuiToolBar):
424 459 'Untoggle object toolbar items')
425 460  
426 461 def OnClick(self, evt):
427   - print "OnClick", evt.GetId()
428 462 id = evt.GetId()
429   - state = self.GetToolToggled(id)
430   - label = self.GetToolLabel(id)
431   -
432   - #if id != ID_ZOOM:
433   - # print "Toggled zoom off"
434   - # self.ToggleTool(ID_ZOOM, 0)
  463 + state = self.GetToolState(id)
435 464  
436 465 if state:
437 466 ps.Publisher().sendMessage(('Set interaction mode',
438 467 MODE_BY_ID[id]))
  468 + ps.Publisher().sendMessage('Untoggle slice toolbar items')
439 469 else:
440 470 ps.Publisher().sendMessage(('Set interaction mode',
441   - MODE_SLICE_EDITOR))
442   - ps.Publisher().sendMessage('Untoggle slice toolbar items')
  471 + const.MODE_SLICE_EDITOR))
  472 +
443 473  
444   - for id in OBJ_TOOLS:
445   - print "-- id: %d, state: %d", id, self.GetToolToggled(id)
446 474  
447   -
  475 + for item in OBJ_TOOLS:
  476 + state = self.GetToolState(item)
  477 + if state and (item != id):
  478 + self.ToggleTool(item, False)
  479 +
448 480 evt.Skip()
449 481  
450   - def UntoggleAllItems(self, pubsub_evt):
  482 + def UntoggleAllItems(self, pubsub_evt=None):
451 483 for id in OBJ_TOOLS:
452   - state = self.GetToolToggled(id)
  484 + state = self.GetToolState(id)
453 485 if state:
454 486 self.ToggleTool(id, False)
455 487  
456 488 # -------------------------------------------------------------------
457 489  
458   -class SliceToolBar(aui.AuiToolBar):
  490 +class SliceToolBar(wx.ToolBar):
459 491 def __init__(self, parent):
460   - aui.AuiToolBar.__init__(self, parent, -1, wx.DefaultPosition,
461   - wx.DefaultSize, aui.AUI_TB_DEFAULT_STYLE)
462   - self.SetToolBitmapSize(wx.Size(16,16))
  492 + wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition,
  493 + wx.DefaultSize,
  494 + wx.TB_FLAT|wx.TB_NODIVIDER | wx.TB_DOCKABLE)
  495 +
  496 + self.SetToolBitmapSize(wx.Size(32,32))
463 497  
464 498 self.parent = parent
465 499 self.__init_items()
... ... @@ -467,10 +501,15 @@ class SliceToolBar(aui.AuiToolBar):
467 501 self.__bind_events_wx()
468 502  
469 503 def __init_items(self):
470   - BMP_SLICE = wx.Bitmap("../icons/slice.png",
471   - wx.BITMAP_TYPE_PNG)
472   - self.AddSimpleTool(ID_SLICE_SCROLL, "Scroll slice",
473   - BMP_SLICE, kind = aui.ITEM_RADIO)
  504 + if sys.platform == 'darwin':
  505 + BMP_SLICE = wx.Bitmap("../icons/slice_original.png",
  506 + wx.BITMAP_TYPE_PNG)
  507 + else:
  508 + BMP_SLICE = wx.Bitmap("../icons/slice.png",
  509 + wx.BITMAP_TYPE_PNG)
  510 +
  511 + self.AddLabelTool(ID_SLICE_SCROLL, "Scroll slice",
  512 + BMP_SLICE, kind = wx.ITEM_CHECK)
474 513  
475 514 self.Realize()
476 515  
... ... @@ -484,47 +523,63 @@ class SliceToolBar(aui.AuiToolBar):
484 523 def OnClick(self, evt):
485 524  
486 525 id = evt.GetId()
487   - state = self.GetToolToggled(id)
488   - label = self.GetToolLabel(id)
  526 + state = self.GetToolState(id)
489 527  
490 528 if state:
491 529 ps.Publisher().sendMessage(('Set interaction mode',
492 530 SLICE_MODE_BY_ID[id]))
  531 + ps.Publisher().sendMessage('Untoggle object toolbar items')
493 532 else:
494 533 ps.Publisher().sendMessage(('Set interaction mode',
495 534 const.MODE_SLICE_EDITOR))
496   - ps.Publisher().sendMessage('Untoggle object toolbar items')
  535 +
  536 +
  537 + for item in SLICE_TOOLS:
  538 + state = self.GetToolState(item)
  539 + if state and (item != id):
  540 + self.ToggleTool(item, False)
497 541  
498 542 evt.Skip()
499 543  
500 544  
501 545 def UntoggleAllItem(self, pubsub_evt):
502 546 for id in SLICE_TOOLS:
503   - state = self.GetToolToggled(id)
  547 + state = self.GetToolState(id)
504 548 if state:
505 549 self.ToggleTool(id, False)
506 550  
507 551 # ---------------------------------------------------------------------
508 552  
509   -class LayoutToolBar(aui.AuiToolBar):
  553 +class LayoutToolBar(wx.ToolBar):
510 554 # TODO: what will appear in menubar?
511 555 def __init__(self, parent):
512   - aui.AuiToolBar.__init__(self, parent, -1, wx.DefaultPosition,
513   - wx.DefaultSize, aui.AUI_TB_DEFAULT_STYLE)
  556 + wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition,
  557 + wx.DefaultSize,
  558 + wx.TB_FLAT|wx.TB_NODIVIDER | wx.TB_DOCKABLE)
514 559  
515   - self.SetToolBitmapSize(wx.Size(16,16))
  560 + self.SetToolBitmapSize(wx.Size(32,32))
516 561  
517 562 self.parent = parent
518 563 self.__init_items()
519 564 self.__bind_events()
520 565  
521 566 def __init_items(self):
522   - BMP_ROTATE = wx.Bitmap("../icons/layout_data_only.gif",
  567 +
  568 + if sys.platform == 'darwin':
  569 + BMP_WITHOUT_MENU =\
  570 + wx.Bitmap("../icons/layout_data_only_original.gif",
523 571 wx.BITMAP_TYPE_GIF)
524   - BMP_TRANSLATE = wx.Bitmap("../icons/layout_full.gif",
  572 + BMP_WITH_MENU = wx.Bitmap("../icons/layout_full_original.gif",
525 573 wx.BITMAP_TYPE_GIF)
526   - self.AddSimpleTool(101, "Rotate image", BMP_ROTATE)
527   - self.AddSimpleTool(101, "Translate image", BMP_TRANSLATE)
  574 +
  575 + else:
  576 + BMP_WITHOUT_MENU = wx.Bitmap("../icons/layout_data_only.gif",
  577 + wx.BITMAP_TYPE_GIF)
  578 + BMP_WITH_MENU = wx.Bitmap("../icons/layout_full.gif",
  579 + wx.BITMAP_TYPE_GIF)
  580 +
  581 + self.AddLabelTool(101, "Rotate image", BMP_WITHOUT_MENU)
  582 + self.AddLabelTool(101, "Translate image", BMP_WITH_MENU)
528 583  
529 584 self.Realize()
530 585  
... ...