#include <qwidgetstack.h>
#include <qapplication.h>
-#include <stream.h>
-
/*!
Class: QtxWorkstack [Public]
Descr:
curWid->setFocus();
}
-// begin: jfa 06.07.2005
+/*!
+* \brief Split workarea of the given widget on two parts.
+* \param wid - widget, belonging to this workstack
+* \param o - orientation of splitting (Qt::Horizontal or Qt::Vertical)
+* \param type - type of splitting, see <VAR>SplitType</VAR> enumeration
+*/
void QtxWorkstack::Split (QWidget* wid, const Qt::Orientation o, const SplitType type)
{
if (!wid) return;
distributeSpace(trg);
}
+/*!
+* \brief Put given widget on top of its workarea
+* \param wid - widget, belonging to this workstack
+*/
+/*
void QtxWorkstack::OnTop (QWidget* wid)
{
- if (!wid) return;
+ if ( !wid )
+ return;
// find area of the given widget
- QtxWorkstackArea* area = NULL;
+ QtxWorkstackArea* area = 0;
QPtrList<QtxWorkstackArea> allAreas;
- areas(mySplit, allAreas, true);
- QPtrListIterator<QtxWorkstackArea> it (allAreas);
- for (; it.current() && !area; ++it) {
- if (it.current()->contains(wid))
+ areas( mySplit, allAreas, true );
+ for ( QPtrListIterator<QtxWorkstackArea> it( allAreas ); it.current() && !area; ++it )
+ {
+ if ( it.current()->contains( wid ) )
area = it.current();
}
- if (!area) return;
- area->setActiveWidget(wid);
+ if ( area )
+ area->setActiveWidget( wid );
}
+*/
-void QtxWorkstack::Attract (QWidget* wid1, QWidget* wid2, const bool all)
+/*!
+* \brief Move widget(s) from source workarea into target workarea
+* or just reorder widgets inside one workarea.
+* \param wid1 - widget from target workarea
+* \param wid2 - widget from source workarea
+* \param all - if this parameter is TRUE, all widgets from source workarea will
+* be moved into the target one, else only the \a wid2 will be moved
+*
+* Move \a wid2 in target workarea. Put it right after \a wid1.
+* If value of boolean argument is TRUE, all widgets from source workarea
+* will be moved together with \a wid2, source workarea will be deleted.
+* If \a wid1 and \a wid2 belongs to one workarea, simple reordering will take place.
+*/
+void QtxWorkstack::Attract ( QWidget* wid1, QWidget* wid2, const bool all )
{
- if (!wid1 || !wid2) return;
+ if ( !wid1 || !wid2 )
+ return;
// find area of the widgets
QtxWorkstackArea *area1 = NULL, *area2 = NULL;
}
}
- /*area2->removeWidget(wid2);
- area1->insertWidget(wid2);
-
- // Reorder widgets
- QWidgetListIt itr( wids1 );
- for ( ; itr.current() && itr.current() != wid1; ++itr )
- {
- }
- ++itr;
- for ( ; itr.current(); ++itr )
- {
- if (itr.current() != wid2) {
- area1->removeWidget( itr.current() );
- area1->insertWidget( itr.current() );
- }
- }*/
-
- area1->setActiveWidget(curWid);
+ area1->setActiveWidget( curWid );
}
static void setSizes (QIntList& szList, const int item_ind,
}
}
+/*!
+* \brief Set position of the widget relatively its splitter.
+* \param wid - widget to set position of
+* \param pos - position relatively splitter. Value in range [0..1].
+*
+* Orientation of positioning will correspond to the splitter orientation.
+*/
void QtxWorkstack::SetRelativePositionInSplitter( QWidget* wid, const double position )
{
if ( position < 0.0 || 1.0 < position)
return;
+
if ( !wid )
return;
split->setSizes(szList);
}
-void QtxWorkstack::SetRelativePosition (QWidget* wid,
- const Qt::Orientation o,
- const double position)
+/*!
+* \brief Set position of the widget relatively the entire workstack.
+* \param wid - widget to set position of
+* \param o - orientation of positioning (Qt::Horizontal or Qt::Vertical).
+* If o = Qt::Horizontal, horizontal position of \a wid will be changed.
+* If o = Qt::Vertical, vertical position of \a wid will be changed.
+* \param pos - position relatively workstack. Value in range [0..1].
+*/
+void QtxWorkstack::SetRelativePosition( QWidget* wid, const Qt::Orientation o,
+ const double position )
{
- if (position < 0.0 || 1.0 < position)
+ if ( position < 0.0 || 1.0 < position )
return;
- if (!wid)
+
+ if ( !wid )
return;
- int splitter_size = (o == Horizontal ? mySplit->width() : mySplit->height());
- int need_pos = int(position * splitter_size);
+ int splitter_size = o == Horizontal ? mySplit->width() : mySplit->height();
+ int need_pos = int( position * splitter_size );
int splitter_pos = 0;
- if (setPosition(wid, mySplit, o, need_pos, splitter_pos) != 0) {
+ if ( setPosition( wid, mySplit, o, need_pos, splitter_pos ) != 0 )
+ {
// impossible to set required position
}
}
-
+/*!
+* \brief Sets the action's accelerator key to accel.
+* \param id - the key of the action in the actions map.
+* \param accel - action's accelerator key.
+*/
void QtxWorkstack::setAccel( const int id, const int accel )
{
- if (!myActionsMap.contains(id))
+ if ( !myActionsMap.contains( id ) )
return;
- myActionsMap[id]->setAccel(accel);
+
+ myActionsMap[id]->setAccel( accel );
}
-int QtxWorkstack::accel (const int id) const
+/*!
+* \brief Returns the action's accelerator key.
+* \param id - the key of the action in the actions map.
+* \retval int - action's accelerator key.
+*/
+int QtxWorkstack::accel( const int id ) const
{
- if (!myActionsMap.contains(id))
- return 0;
- return myActionsMap[id]->accel();
+ int res = 0;
+ if ( myActionsMap.contains( id ) )
+ res = myActionsMap[id]->accel();
+ return res;
}
static int positionSimple (QIntList& szList, const int nb, const int splitter_size,
return delta;
}
-int QtxWorkstack::setPosition (QWidget* wid, QSplitter* split,
- const Qt::Orientation o, const int need_pos,
- const int splitter_pos)
+/*!
+* \brief Set position of given widget.
+* \param wid - widget to be moved
+* \param split - currently processed splitter (goes from more common
+* to more particular splitter in recursion calls)
+* \param o - orientation of positioning
+* \param need_pos - required position of the given widget in pixels
+* (from top/left side of workstack area)
+* \param splitter_pos - position of the splitter \a split
+* (from top/left side of workstack area)
+* \retval int - returns difference between a required and a distinguished position.
+*
+* Internal method. Recursively calls itself.
+* Is called from <VAR>SetRelativePosition</VAR> public method.
+*/
+int QtxWorkstack::setPosition( QWidget* wid, QSplitter* split, const Qt::Orientation o,
+ const int need_pos, const int splitter_pos )
{
- if (!wid || !split)
+ if ( !wid || !split )
return need_pos - splitter_pos;
// Find corresponding sub-splitter.
bool isBottom = false, isFound = false;
QSplitter* sub_split = NULL;
const QObjectList* objs = split->children();
- if (objs)
+ if ( objs )
{
for (QObjectListIt it (*objs); it.current() && !isFound; ++it)
{
return 0;
}
-// end: jfa 06.07.2005
void QtxWorkstack::distributeSpace( QSplitter* split ) const
{
split( Qt::Horizontal );
}
-void QtxWorkstack::onCloseWindow()
-{
- if ( activeWindow() )
- activeWindow()->close();
-}
-
QSplitter* QtxWorkstack::wrapSplitter( QtxWorkstackArea* area )
{
if ( !area )
itr.current()->reparent( pWid, QPoint( 0, 0 ), map.contains( itr.current() ) ? map[itr.current()] : false );
}
+/*!
+* \brief Closes the active window.
+*/
+void QtxWorkstack::onCloseWindow()
+{
+ if ( activeWindow() )
+ activeWindow()->close();
+}
+
void QtxWorkstack::onDestroyed( QObject* obj )
{
QtxWorkstackArea* area = (QtxWorkstackArea*)obj;
class QtxWorkstackChild;
class QtxWorkstackTabBar;
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
class QTX_EXPORT QtxWorkstack : public QWidget
{
Q_OBJECT
-
+
public:
+ enum { SplitVertical, SplitHorizontal, Close };
+
+ enum SplitType {
+ SPLIT_STAY, //!< given widget stays in its workarea, others are moved into a new one
+ SPLIT_AT, //!< widgets before a given widget stays in they workarea, others are moved into a new one
+ SPLIT_MOVE //!< given widget is moved into a new workarea, others stay in an old one
+ };
+public:
QtxWorkstack( QWidget* = 0 );
virtual ~QtxWorkstack();
QWidget* activeWindow() const;
+ int accel( const int ) const;
+ void setAccel( const int, const int );
+
void split( const int );
- enum { SplitVertical, SplitHorizontal, Close };
+ // STV: Useless function. wid->setFocus() should be used instead.
+ // void OnTop( QWidget* wid);
- // begin: jfa 06.07.2005
- enum SplitType {
- SPLIT_STAY, //!< given widget stays in its workarea, others are moved into a new one
- SPLIT_AT, //!< widgets before a given widget stays in they workarea, others are moved into a new one
- SPLIT_MOVE //!< given widget is moved into a new workarea, others stay in an old one
- };
-
- /*!
- * \brief Split workarea of the given widget on two parts.
- * \param wid - widget, belonging to this workstack
- * \param o - orientation of splitting (Qt::Horizontal or Qt::Vertical)
- * \param type - type of splitting, see <VAR>SplitType</VAR> enumeration
- */
- void Split( QWidget* wid, const Qt::Orientation o, const SplitType type);
-
- /*!
- * \brief Put given widget on top of its workarea
- * \param wid - widget, belonging to this workstack
- */
- void OnTop( QWidget* wid);
-
- /*!
- * \brief Move widget(s) from source workarea into target workarea
- * or just reorder widgets inside one workarea.
- * \param wid1 - widget from target workarea
- * \param wid2 - widget from source workarea
- * \param all - if this parameter is TRUE, all widgets from source workarea will
- * be moved into the target one, else only the \a wid2 will be moved
- *
- * Move \a wid2 in target workarea. Put it right after \a wid1.
- * If value of boolean argument is TRUE, all widgets from source workarea
- * will be moved together with \a wid2, source workarea will be deleted.
- * If \a wid1 and \a wid2 belongs to one workarea, simple reordering will take place.
- */
+ void Split( QWidget* wid, const Qt::Orientation o, const SplitType type );
void Attract( QWidget* wid1, QWidget* wid2, const bool all );
-
- /*!
- * \brief Set position of the widget relatively its splitter.
- * \param wid - widget to set position of
- * \param pos - position relatively splitter. Value in range [0..1].
- *
- * Orientation of positioning will correspond to the splitter orientation.
- */
- void SetRelativePositionInSplitter( QWidget* wid, const double pos );
-
- /*!
- * \brief Set position of the widget relatively the entire workstack.
- * \param wid - widget to set position of
- * \param o - orientation of positioning (Qt::Horizontal or Qt::Vertical).
- * If o = Qt::Horizontal, horizontal position of \a wid will be changed.
- * If o = Qt::Vertical, vertical position of \a wid will be changed.
- * \param pos - position relatively workstack. Value in range [0..1].
- */
void SetRelativePosition( QWidget* wid, const Qt::Orientation o, const double pos );
- // end: jfa 06.07.2005
-
- /*!
- * \brief Sets the action's accelerator key to accel.
- * \param id - the key of the action in the actions map.
- * \param accel - action's accelerator key.
- */
- void setAccel( const int id, const int accel );
-
- /*!
- * \brief Returns the action's accelerator key.
- * \param id - the key of the action in the actions map.
- * \retval int - action's accelerator key.
- */
- int accel (const int id) const;
+ void SetRelativePositionInSplitter( QWidget* wid, const double pos );
signals:
void windowActivated( QWidget* );
void splitHorizontal();
private slots:
+ void onCloseWindow();
void onDestroyed( QObject* );
void onWindowActivated( QWidget* );
void onContextMenuRequested( QPoint );
void onDeactivated( QtxWorkstackArea* );
- /*!
- * \brief Closes the active window.
- */
- void onCloseWindow();
protected:
virtual void childEvent( QChildEvent* );
void updateState( QSplitter* );
void distributeSpace( QSplitter* ) const;
-
- // begin: jfa 06.07.2005
- /*!
- * \brief Set position of given widget.
- * \param wid - widget to be moved
- * \param split - currently processed splitter (goes from more common
- * to more particular splitter in recursion calls)
- * \param o - orientation of positioning
- * \param need_pos - required position of the given widget in pixels
- * (from top/left side of workstack area)
- * \param splitter_pos - position of the splitter \a split
- * (from top/left side of workstack area)
- * \retval int - returns difference between a required and a distinguished position.
- *
- * Internal method. Recursively calls itself.
- * Is called from <VAR>SetRelativePosition</VAR> public method.
- */
int setPosition( QWidget* wid, QSplitter* split, const Qt::Orientation o,
- const int need_pos, const int splitter_pos);
- // end: jfa 06.07.2005
+ const int need_pos, const int splitter_pos );
private:
QWidget* myWin;
};
+#ifdef WIN32
+#pragma warning( default:4251 )
+#endif
+
#endif