Medical Imaging Interaction Toolkit  2018.4.99-4c24e3cb
Medical Imaging Interaction Toolkit
berryWindow.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef BERRYWINDOW_H_
14 #define BERRYWINDOW_H_
15 
17 
18 #include "berryIShellProvider.h"
19 #include "berryIShellListener.h"
20 
21 #include "internal/berryWindowManager.h"
23 
24 #include <berryMacros.h>
25 #include <vector>
26 
27 namespace berry
28 {
29 
30 //struct IToolBarManager;
31 
32 class MenuManager;
33 //class StatusLineManager;
34 
83 {
84 
85 public:
86 
88 
89 
95  static const int OK; // = 0;
96 
103  static const int CANCEL; // = 1;
104 
109  static QList<QIcon> defaultImages;
110 
115  struct IExceptionHandler: public Object
116  {
117 
119 
120 
126  virtual void HandleException(const std::exception& t) = 0;
127  };
128 
129 private:
130 
131  struct WindowShellListener : public IShellListener
132  {
133  WindowShellListener(Window* wnd);
134 
135  void ShellClosed(const ShellEvent::Pointer& event) override;
136 
137  private:
138  Window* window;
139  };
140 
141  QScopedPointer<IShellListener> windowShellListener;
142 
146  struct DefaultExceptionHandler: public IExceptionHandler
147  {
148  /*
149  * (non-Javadoc)
150  *
151  * @see org.blueberry.jface.window.Window.IExceptionHandler#handleException(java.lang.Throwable)
152  */
153  void HandleException(const std::exception& t) override;
154  };
155 
161  SmartPointer<MenuManager> menuBarManager;
162 
168  //SmartPointer<IToolBarManager> toolBarManager;
169 
175  //SmartPointer<StatusLineManager> statusLineManager;
176 
180  static IExceptionHandler::Pointer exceptionHandler;
181 
185  struct DefaultModalParent: public IShellProvider
186  {
187  Shell::Pointer GetShell() const override;
188  };
189 
190  friend struct DefaultModalParent;
191 
192  static IShellProvider::Pointer defaultModalParent;
193 
197  IShellProvider::Pointer parentShell;
198 
204  int shellStyle; // = Constants::SHELL_TRIM;
205 
211  WindowManager* windowManager;
212 
216  Shell::Pointer shell;
217 
221  QWidget* contents;
222 
228  int returnCode; // = OK;
229 
238  bool block; // = false;
239 
240  // /**
241  // * Internal class for informing this window when fonts change.
242  // */
243  // class FontChangeListener implements IPropertyChangeListener {
244  // public void propertyChange(PropertyChangeEvent event) {
245  // handleFontChange(event);
246  // }
247  // }
248 
249  // /**
250  // * Internal font change listener.
251  // */
252  // private FontChangeListener fontChangeListener;
253 
257  //bool resizeHasOccurred = false;
258 
259  //Listener resizeListener;
260 
261 
270  static Shell::Pointer GetModalChild(
271  const QList<Shell::Pointer>& toSearch);
272 
279  //void RunEventLoop();
280 
281 protected:
282 
295  Window(Shell::Pointer parentShell);
296 
304  Window(IShellProvider::Pointer shellProvider);
305 
306  ~Window() override;
307 
321  QRect GetConstrainedShellBounds(const QRect& preferredSize);
322 
326  virtual void Init();
327 
339  virtual bool CanHandleShellCloseEvent();
340 
351  virtual void ConfigureShell(Shell::Pointer newShell);
352 
358  //void ConstrainShellSize();
359 
384  virtual QWidget* CreateContents(Shell::Pointer parent);
385 
397  virtual Shell::Pointer CreateShell();
398 
406  virtual QWidget* GetContents();
407 
420  virtual QPoint GetInitialLocation(const QPoint& initialSize);
421 
429  virtual QPoint GetInitialSize();
430 
437  Shell::Pointer GetParentShell();
438 
452  virtual IShellListener* GetShellListener();
453 
464  int GetShellStyle();
465 
475  virtual void HandleShellCloseEvent();
476 
489  virtual void InitializeBounds();
490 
501  void SetParentShell(Shell::Pointer newParentShell);
502 
512  void SetReturnCode(int code);
513 
525  void SetShellStyle(int newShellStyle);
526 
532  void AddMenuBar();
533 
541  virtual SmartPointer<MenuManager> CreateMenuManager();
542 
548  virtual void CreateTrimWidgets(SmartPointer<Shell> shell);
549 
550 public:
551 
568  virtual bool Close();
569 
579  virtual void Create();
580 
589  static QIcon GetDefaultImage();
590 
602  static QList<QIcon> GetDefaultImages();
603 
611  int GetReturnCode();
612 
619  Shell::Pointer GetShell() const override;
620 
626  WindowManager* GetWindowManager();
627 
635  MenuManager* GetMenuBarManager() const;
636 
652  int Open();
653 
663  void SetBlockOnOpen(bool shouldBlock);
664 
673  static void SetDefaultImage(const QIcon& image);
674 
686  static void SetDefaultImages(const QList<QIcon>& images);
687 
698  void SetWindowManager(WindowManager* manager);
699 
710  static void SetExceptionHandler(IExceptionHandler::Pointer handler);
711 
720  static void SetDefaultModalParent(IShellProvider::Pointer provider);
721 
722 };
723 
724 }
725 
726 
727 #endif /* BERRYWINDOW_H_ */
static MsgHandler handler
Definition: usUtils.cpp:261
ImageVectorType images
Light weight base class for most BlueBerry classes.
Definition: berryObject.h:72
static const int CANCEL
Definition: berryWindow.h:103
#define OK
berry::SmartPointer< Self > Pointer
Definition: berryObject.h:82
#define berryObjectMacro(...)
Definition: berryMacros.h:33
mitk::Image::Pointer image
static QList< QIcon > defaultImages
Definition: berryWindow.h:109
#define BERRY_UI_QT