download qmenu_p.h
Language: C++
License: GPL
Copyright: (C) 1992-2006 Trolltech ASA. All rights reserved.
LOC: 128
Project Info
qt-copy
Server: KDE Repo
Type: svn
...py\qt‑copy\src\gui\widgets\
   qabstractbutton.cpp
   qabstractbutton.h
   qabstractbutton_p.h
   qabstractscrollarea.cpp
   qabstractscrollarea.h
   qabstractscrollarea_p.h
   qabstractslider.cpp
   qabstractslider.h
   qabstractslider_p.h
   qabstractspinbox.cpp
   qabstractspinbox.h
   qabstractspinbox_p.h
   qbuttongroup.cpp
   qbuttongroup.h
   qcalendarwidget.cpp
   qcalendarwidget.h
   qcheckbox.cpp
   qcheckbox.h
   qcombobox.cpp
   qcombobox.h
   qcombobox_p.h
   qdatetimeedit.cpp
   qdatetimeedit.h
   qdatetimeedit_p.h
   qdial.cpp
   qdial.h
   qdialogbuttonbox.cpp
   qdialogbuttonbox.h
   qdockwidget.cpp
   qdockwidget.h
   qdockwidget_p.h
   qdockwidgetlayout.cpp
   qdockwidgetlayout_p.h
   qeffects.cpp
   qeffects_p.h
   qfocusframe.cpp
   qfocusframe.h
   qfontcombobox.cpp
   qfontcombobox.h
   qframe.cpp
   qframe.h
   qframe_p.h
   qgroupbox.cpp
   qgroupbox.h
   qlabel.cpp
   qlabel.h
   qlabel_p.h
   qlcdnumber.cpp
   qlcdnumber.h
   qlineedit.cpp
   qlineedit.h
   qlineedit_p.h
   qmainwindow.cpp
   qmainwindow.h
   qmainwindowlayout.cpp
   qmainwindowlayout_p.h
   qmenu.cpp
   qmenu.h
   qmenu_p.h
   qmenubar.cpp
   qmenubar.h
   qmenubar_p.h
   qmenudata.cpp
   qmenudata.h
   qprogressbar.cpp
   qprogressbar.h
   qpushbutton.cpp
   qpushbutton.h
   qradiobutton.cpp
   qradiobutton.h
   qrubberband.cpp
   qrubberband.h
   qscrollarea.cpp
   qscrollarea.h
   qscrollarea_p.h
   qscrollbar.cpp
   qscrollbar.h
   qsizegrip.cpp
   qsizegrip.h
   qslider.cpp
   qslider.h
   qspinbox.cpp
   qspinbox.h
   qsplashscreen.cpp
   qsplashscreen.h
   qsplitter.cpp
   qsplitter.h
   qsplitter_p.h
   qstackedwidget.cpp
   qstackedwidget.h
   qstatusbar.cpp
   qstatusbar.h
   qtabbar.cpp
   qtabbar.h
   qtabbar_p.h
   qtabwidget.cpp
   qtabwidget.h
   qtextbrowser.cpp
   qtextbrowser.h
   qtextedit.cpp
   qtextedit.h
   qtextedit_p.h
   qtoolbar.cpp
   qtoolbar.h
   qtoolbar_p.h
   qtoolbarextension.cpp
   qtoolbarextension_p.h
   qtoolbarhandle.cpp
   qtoolbarhandle_p.h
   qtoolbarseparator.cpp
   qtoolbarseparator_p.h
   qtoolbox.cpp
   qtoolbox.h
   qtoolbutton.cpp
   qtoolbutton.h
   qvalidator.cpp
   qvalidator.h
   qwidgetanimator.cpp
   qwidgetanimator_p.h
   qwidgetresizehandler.cpp
   qwidgetresizehandler_p.h
   qworkspace.cpp
   qworkspace.h
   widgets.pri

/****************************************************************************
**
** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** This file may be used under the terms of the GNU General Public
** License version 2.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of
** this file.  Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
** http://www.trolltech.com/products/qt/opensource.html
**
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://www.trolltech.com/products/qt/licensing.html or contact the
** sales department at sales@trolltech.com.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/

#ifndef QMENU_P_H
#define QMENU_P_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#include "QtGui/qmenubar.h"
#include "QtGui/qstyleoption.h"
#include "QtCore/qdatetime.h"
#include "QtCore/qmap.h"
#include "QtCore/qhash.h"
#include "QtCore/qbasictimer.h"
#include "private/qwidget_p.h"

#ifndef QT_NO_MENU

class QTornOffMenu;

#ifdef Q_WS_MAC
struct QMacMenuAction {
    uint command;
    uchar ignore_accel : 1;
    uchar merged : 1;
    QPointer<QAction> action;
    MenuRef menu;
};
#endif

class QMenuPrivate : public QWidgetPrivate
{
    Q_DECLARE_PUBLIC(QMenu)
public:
    QMenuPrivate() : itemsDirty(0), maxIconWidth(0), tabWidth(0), ncols(0), collapsibleSeparators(true), mouseDown(0), hasHadMouse(0), motions(0),
                      currentAction(0), scroll(0), eventLoop(0), tearoff(0), tornoff(0), tearoffHighlighted(0),
                      hasCheckableItems(0), sloppyAction(0)
#ifdef Q_WS_MAC
                      ,mac_menu(0)
#endif
    { }
    ~QMenuPrivate()
    {
        delete scroll;
#ifdef Q_WS_MAC
        delete mac_menu;
#endif
    }

    //item calculations
    mutable uint itemsDirty : 1;
    mutable uint maxIconWidth, tabWidth;
    QRect actionRect(QAction *) const;
    mutable QMap<QAction*, QRect> actionRects;
    mutable QList<QAction*> actionList;
    mutable QHash<QAction *, QWidget *> widgetItems;
    void calcActionRects(QMap<QAction*, QRect> &actionRects, QList<QAction*> &actionList) const;
    void updateActions();
    const QRect popupGeometry(int screen) const;
    QList<QAction *> filterActions(const QList<QAction *> &actions) const;
    uint ncols : 4; //4 bits is probably plenty
    uint collapsibleSeparators : 1;

    //selection
    uint mouseDown : 1, hasHadMouse : 1;
    int motions;
    QAction *currentAction;
    static QBasicTimer menuDelayTimer;
    enum SelectionReason {
        SelectedFromKeyboard,
        SelectedFromElsewhere
    };
    QAction *actionAt(QPoint p) const;
    void setFirstActionActive();
    void setCurrentAction(QAction *, int popup = -1, SelectionReason reason = SelectedFromElsewhere, bool activateFirst = false);
    void popupAction(QAction *, int, bool);

    //scrolling support
    struct QMenuScroller {
        enum ScrollLocation { ScrollStay, ScrollBottom, ScrollTop, ScrollCenter };
        enum ScrollDirection { ScrollNone=0, ScrollUp=0x01, ScrollDown=0x02 };
        uint scrollFlags : 2, scrollDirection : 2;
        int scrollOffset;
        QBasicTimer *scrollTimer;

        QMenuScroller() : scrollFlags(ScrollNone), scrollDirection(ScrollNone), scrollOffset(0), scrollTimer(0) { }
        ~QMenuScroller() { delete scrollTimer; }
    } *scroll;
    void scrollMenu(QMenuScroller::ScrollDirection direction, bool page=false, bool active=false);
    void scrollMenu(QAction *action, QMenuScroller::ScrollLocation location, bool active=false);

    //syncronous operation (ie exec())
    QEventLoop *eventLoop;
    QPointer<QAction> syncAction;
    QStyleOptionMenuItem getStyleOption(const QAction *action) const;

    //search buffer
    QString searchBuffer;
    QBasicTimer searchBufferTimer;

    //passing of mouse events up the parent heirarchy
    QPointer<QMenu> activeMenu;
    bool mouseEventTaken(QMouseEvent *);

    //used to walk up the popup list
    struct QMenuCaused {
        QPointer<QWidget> widget;
        QPointer<QAction> action;
    };
    QMenuCaused causedPopup;
    void hideUpToMenuBar();

    //index mappings
    inline QAction *actionAt(int i) const { return q_func()->actions().at(i); }
    inline int indexOf(QAction *act) const { return q_func()->actions().indexOf(act); }

    //tear off support
    uint tearoff : 1, tornoff : 1, tearoffHighlighted : 1;
    QPointer<QTornOffMenu> tornPopup;

    mutable bool hasCheckableItems;

    //sloppy selection
    static QBasicTimer sloppyDelayTimer;
    QAction *sloppyAction;
    QRegion sloppyRegion;

    //default action
    QPointer<QAction> defaultAction;

    QAction *menuAction;

    //firing of events
    void activateAction(QAction *, QAction::ActionEvent);

    void _q_actionTriggered();
    void _q_actionHovered();

    //menu fading/scrolling effects
    bool doChildEffects;

#ifdef Q_WS_MAC
    //mac menu binding
    struct QMacMenuPrivate {
        QList<QMacMenuAction*> actionItems;
        MenuRef menu;
        QMacMenuPrivate();
        ~QMacMenuPrivate();

        bool merged(const QAction *action) const;
        void addAction(QAction *, QMacMenuAction* =0, QMenuPrivate *qmenu = 0);
        void addAction(QMacMenuAction *, QMacMenuAction* =0, QMenuPrivate *qmenu = 0);
        void syncAction(QMacMenuAction *);
        inline void syncAction(QAction *a) { syncAction(findAction(a)); }
        void removeAction(QMacMenuAction *);
        inline void removeAction(QAction *a) { removeAction(findAction(a)); }
        inline QMacMenuAction *findAction(QAction *a) {
            for(int i = 0; i < actionItems.size(); i++) {
                QMacMenuAction *act = actionItems[i];
                if(a == act->action)
                    return act;
            }
            return 0;
        }
    } *mac_menu;
    MenuRef macMenu(MenuRef merge);
#endif

    QPointer<QWidget> noReplayFor;
};

#endif // QT_NO_MENU

#endif // QMENU_P_H

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us