1 #include "STD_TabDesktop.h"
3 #include <SUIT_Session.h>
4 #include <SUIT_ViewWindow.h>
5 #include <SUIT_ResourceMgr.h>
8 #include <QtxWorkstack.h>
9 #include <QtxActionMenuMgr.h>
10 #include <QtxWorkstackAction.h>
14 #include <qworkspace.h>
15 #include <qobjectlist.h>
19 /*!Constructor.Create new instances of QVBox and QtxWorkstack.*/
20 STD_TabDesktop::STD_TabDesktop()
23 myWorkstackAction( 0 )
25 QVBox* base = new QVBox( this );
26 base->setFrameStyle( QFrame::Panel | QFrame::Sunken );
28 setCentralWidget( base );
30 myWorkstack = new QtxWorkstack( base );
32 myWorkstack->setAccel(QtxWorkstack::SplitVertical, SHIFT + Key_V);
33 myWorkstack->setAccel(QtxWorkstack::SplitHorizontal, SHIFT + Key_H);
34 myWorkstack->setAccel(QtxWorkstack::Close, SHIFT + Key_C);
36 connect( myWorkstack, SIGNAL( windowActivated( QWidget* ) ),
37 this, SLOT( onWindowActivated( QWidget* ) ) );
43 STD_TabDesktop::~STD_TabDesktop()
47 /*!\retval SUIT_ViewWindow - return const active window.*/
48 SUIT_ViewWindow* STD_TabDesktop::activeWindow() const
50 SUIT_ViewWindow* wnd = 0;
52 QWidget* wid = myWorkstack->activeWindow();
53 if ( wid && wid->inherits( "SUIT_ViewWindow" ) )
54 wnd = (SUIT_ViewWindow*)wid;
59 /*!\retval QPtrList<SUIT_ViewWindow> - return const active window list.*/
60 QPtrList<SUIT_ViewWindow> STD_TabDesktop::windows() const
62 QPtrList<SUIT_ViewWindow> winList;
64 QWidgetList children = myWorkstack->windowList();
65 for ( QWidgetListIt it( children ); it.current(); ++it )
67 if ( it.current()->inherits( "SUIT_ViewWindow" ) )
68 winList.append( (SUIT_ViewWindow*)it.current() );
74 /*!\retval QWidget pointer - QT work stack.*/
75 QWidget* STD_TabDesktop::parentArea() const
80 /*!Call method perform for operation \a type.*/
81 void STD_TabDesktop::windowOperation( const int type )
83 myWorkstackAction->perform( operationFlag( type ) );
86 /*!Sets window operations by \a first ... parameters.*/
87 void STD_TabDesktop::setWindowOperations( const int first, ... )
90 va_start( ints, first );
92 QValueList<int> typeList;
97 typeList.append( cur );
98 cur = va_arg( ints, int );
101 setWindowOperations( typeList );
104 /*!Sets window operations by variable \a opList - operation list.*/
105 void STD_TabDesktop::setWindowOperations( const QValueList<int>& opList )
109 for ( QValueList<int>::const_iterator it = opList.begin(); it != opList.end(); ++it )
110 flags = flags | operationFlag( *it );
112 myWorkstackAction->setItems( flags );
115 /*!\retval QtxWorkstack pointer - QT work stack.*/
116 QtxWorkstack* STD_TabDesktop::workstack() const
121 /*!Emit window activated.*/
122 void STD_TabDesktop::onWindowActivated( QWidget* w )
124 if ( w && w->inherits( "SUIT_ViewWindow" ) )
125 emit windowActivated( (SUIT_ViewWindow*)w );
128 /*!Create actions for window.*/
129 void STD_TabDesktop::createActions()
131 if ( myWorkstackAction )
134 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
138 myWorkstackAction = new QtxWorkstackAction( workstack(), this );
140 myWorkstackAction->setItems( QtxWorkstackAction::Split | QtxWorkstackAction::Windows );
143 myWorkstackAction->setIconSet( QtxWorkstackAction::HSplit,
144 resMgr->loadPixmap( "STD", tr( "ICON_DESK_WINDOW_HSPLIT" ) ) );
145 myWorkstackAction->setMenuText( QtxWorkstackAction::HSplit, tr( "MEN_DESK_WINDOW_HSPLIT" ) );
146 myWorkstackAction->setStatusTip( QtxWorkstackAction::HSplit, tr( "PRP_DESK_WINDOW_HSPLIT" ) );
149 myWorkstackAction->setIconSet( QtxWorkstackAction::VSplit,
150 resMgr->loadPixmap( "STD", tr( "ICON_DESK_WINDOW_VSPLIT" ) ) );
151 myWorkstackAction->setMenuText( QtxWorkstackAction::VSplit, tr( "MEN_DESK_WINDOW_VSPLIT" ) );
152 myWorkstackAction->setStatusTip( QtxWorkstackAction::VSplit, tr( "PRP_DESK_WINDOW_VSPLIT" ) );
154 QtxActionMenuMgr* mMgr = menuMgr();
158 int winMenuId = mMgr->insert( tr( "MEN_DESK_WINDOW" ), -1, 100 );
159 mMgr->insert( myWorkstackAction, winMenuId, -1 );
160 mMgr->insert( QtxActionMenuMgr::separator(), winMenuId, -1 );
163 /*!Convert STD_TabDesktop enumerations to QtxWorkstackAction*/
164 int STD_TabDesktop::operationFlag( const int type ) const
170 res = QtxWorkstackAction::VSplit;
173 res = QtxWorkstackAction::HSplit;