1 #include <OcctWindow.h>
3 IMPLEMENT_STANDARD_RTTIEXT(OcctWindow,Aspect_Window)
5 // =======================================================================
6 // function : OcctWindow
8 // =======================================================================
9 OcctWindow::OcctWindow ( QWidget* theWidget, const Quantity_NameOfColor theBackColor )
13 SetBackground (theBackColor);
14 myXLeft = myWidget->rect().left();
15 myYTop = myWidget->rect().top();
16 myXRight = myWidget->rect().right();
17 myYBottom = myWidget->rect().bottom();
20 // =======================================================================
23 // =======================================================================
24 void OcctWindow::Destroy()
29 // =======================================================================
30 // function : NativeParentHandle
32 // =======================================================================
33 Aspect_Drawable OcctWindow::NativeParentHandle() const
35 QWidget* aParentWidget = myWidget->parentWidget();
36 if ( aParentWidget != NULL )
37 return (Aspect_Drawable)aParentWidget->winId();
42 // =======================================================================
43 // function : NativeHandle
45 // =======================================================================
46 Aspect_Drawable OcctWindow::NativeHandle() const
48 return (Aspect_Drawable)myWidget->winId();
51 // =======================================================================
52 // function : IsMapped
54 // =======================================================================
55 Standard_Boolean OcctWindow::IsMapped() const
57 return !( myWidget->isMinimized() || myWidget->isHidden() );
60 // =======================================================================
63 // =======================================================================
64 void OcctWindow::Map() const
70 // =======================================================================
73 // =======================================================================
74 void OcctWindow::Unmap() const
80 // =======================================================================
81 // function : DoResize
83 // =======================================================================
84 Aspect_TypeOfResize OcctWindow::DoResize()
87 Aspect_TypeOfResize aMode = Aspect_TOR_UNKNOWN;
89 if ( !myWidget->isMinimized() )
91 if ( Abs ( myWidget->rect().left() - myXLeft ) > 2 ) aMask |= 1;
92 if ( Abs ( myWidget->rect().right() - myXRight ) > 2 ) aMask |= 2;
93 if ( Abs ( myWidget->rect().top() - myYTop ) > 2 ) aMask |= 4;
94 if ( Abs ( myWidget->rect().bottom() - myYBottom ) > 2 ) aMask |= 8;
99 aMode = Aspect_TOR_NO_BORDER;
102 aMode = Aspect_TOR_LEFT_BORDER;
105 aMode = Aspect_TOR_RIGHT_BORDER;
108 aMode = Aspect_TOR_TOP_BORDER;
111 aMode = Aspect_TOR_LEFT_AND_TOP_BORDER;
114 aMode = Aspect_TOR_TOP_AND_RIGHT_BORDER;
117 aMode = Aspect_TOR_BOTTOM_BORDER;
120 aMode = Aspect_TOR_BOTTOM_AND_LEFT_BORDER;
123 aMode = Aspect_TOR_RIGHT_AND_BOTTOM_BORDER;
129 myXLeft = myWidget->rect().left();
130 myXRight = myWidget->rect().right();
131 myYTop = myWidget->rect().top();
132 myYBottom = myWidget->rect().bottom();
138 // =======================================================================
141 // =======================================================================
142 Standard_Real OcctWindow::Ratio() const
144 QRect aRect = myWidget->rect();
145 return Standard_Real( aRect.right() - aRect.left() ) / Standard_Real( aRect.bottom() - aRect.top() );
148 // =======================================================================
151 // =======================================================================
152 void OcctWindow::Size ( Standard_Integer& theWidth, Standard_Integer& theHeight ) const
154 QRect aRect = myWidget->rect();
155 theWidth = aRect.right();
156 theHeight = aRect.bottom();
159 // =======================================================================
160 // function : Position
162 // =======================================================================
163 void OcctWindow::Position ( Standard_Integer& theX1, Standard_Integer& theY1,
164 Standard_Integer& theX2, Standard_Integer& theY2 ) const
166 theX1 = myWidget->rect().left();
167 theX2 = myWidget->rect().right();
168 theY1 = myWidget->rect().top();
169 theY2 = myWidget->rect().bottom();