// qapplication.sip generated by MetaSIP on Fri Sep 28 17:07:47 2007 // // This file is part of the QtGui Python extension module. // // Copyright (c) 2007 // Phil Thompson // // This file is part of PyQt. // // This copy of PyQt is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License version 2 as published by // the Free Software Foundation and appearing in the file LICENSE included in the // packaging of this file. // // PyQt is supplied in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // You should have received a copy of the GNU General Public License along with // PyQt; see the file LICENSE. If not, write to the Free Software Foundation, // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void qt_set_sequence_auto_mnemonic(bool enable); %If (WS_X11) void qt_x11_wait_for_window_manager(QWidget *widget); %End %If (WS_MACX) void qt_mac_secure_keyboard(bool enable); %End %If (WS_MACX) void qt_mac_set_dock_menu(QMenu *menu); %End %If (WS_MACX) void qt_mac_set_menubar_icons(bool enable); %End %If (WS_MACX) void qt_mac_set_menubar_merge(bool enable); %End %If (WS_MACX) void qt_mac_set_native_menubar(bool enable); %End %If (WS_MACX) void qt_mac_set_press_and_hold_context(bool enable); %End // QApplication *qApp QApplication *qApp; %AccessCode // Qt implements this has a #define to a function call so we have to handle // it like this. return qApp; %End class QApplication : QCoreApplication { %TypeHeaderCode #include %End %TypeCode // Convert a Python argv list to a conventional C argc count and argv array. static char **qtgui_ArgvToC(PyObject *argvlist, int &argc) { char **argv; argc = PyList_GET_SIZE(argvlist); // Allocate space for two copies of the argument pointers, plus the // terminating NULL. if ((argv = (char **)sipMalloc(2 * (argc + 1) * sizeof (char *))) == NULL) return NULL; // Convert the list. for (int a = 0; a < argc; ++a) { char *arg; // Get the argument and allocate memory for it. if ((arg = PyString_AsString(PyList_GET_ITEM(argvlist, a))) == NULL || (argv[a] = (char *)sipMalloc(strlen(arg) + 1)) == NULL) return NULL; // Copy the argument and save a pointer to it. strcpy(argv[a], arg); argv[a + argc + 1] = argv[a]; } argv[argc + argc + 1] = argv[argc] = NULL; return argv; } // Remove arguments from the Python argv list that have been removed from the // C argv array. static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv) { for (int a = 0, na = 0; a < argc; ++a) { // See if it was removed. if (argv[na] == argv[a + argc + 1]) ++na; else PyList_SetSlice(argvlist, na, na + 1, NULL); } } %End %ConvertToSubClassCode static struct class_graph { char *name; sipWrapperType **type; int yes, no; } graph[] = { {sipName_QTextDocument, &sipClass_QTextDocument, -1, 1}, {sipName_QAbstractProxyModel, &sipClass_QAbstractProxyModel, 34, 2}, {sipName_QApplication, &sipClass_QApplication, -1, 3}, {sipName_QDirModel, &sipClass_QDirModel, -1, 4}, #if QT_VERSION >= 0x040200 {sipName_QGraphicsScene, &sipClass_QGraphicsScene, -1, 5}, #else {0, 0, -1, 5}, #endif #if QT_VERSION >= 0x040200 {sipName_QUndoStack, &sipClass_QUndoStack, -1, 6}, #else {0, 0, -1, 6}, #endif {sipName_QItemSelectionModel, &sipClass_QItemSelectionModel, -1, 7}, {sipName_QInputContext, &sipClass_QInputContext, -1, 8}, {sipName_QStringListModel, &sipClass_QStringListModel, -1, 9}, {sipName_QTextObject, &sipClass_QTextObject, 35, 10}, {sipName_QSyntaxHighlighter, &sipClass_QSyntaxHighlighter, -1, 11}, {sipName_QShortcut, &sipClass_QShortcut, -1, 12}, #if QT_VERSION >= 0x040200 {sipName_QGraphicsTextItem, &sipClass_QGraphicsTextItem, -1, 13}, #else {0, 0, -1, 13}, #endif {sipName_QActionGroup, &sipClass_QActionGroup, -1, 14}, {sipName_QProxyModel, &sipClass_QProxyModel, -1, 15}, {sipName_QSound, &sipClass_QSound, -1, 16}, {sipName_QAction, &sipClass_QAction, 39, 17}, #if QT_VERSION >= 0x040200 {sipName_QGraphicsItemAnimation, &sipClass_QGraphicsItemAnimation, -1, 18}, #else {0, 0, -1, 18}, #endif {sipName_QMovie, &sipClass_QMovie, -1, 19}, #if QT_VERSION >= 0x040200 {sipName_QCompleter, &sipClass_QCompleter, -1, 20}, #else {0, 0, -1, 20}, #endif {sipName_QStyle, &sipClass_QStyle, -1, 21}, #if QT_VERSION >= 0x040200 {sipName_QUndoGroup, &sipClass_QUndoGroup, -1, 22}, #else {0, 0, -1, 22}, #endif #if QT_VERSION >= 0x040200 {sipName_QSystemTrayIcon, &sipClass_QSystemTrayIcon, -1, 23}, #else {0, 0, -1, 23}, #endif {sipName_QStandardItemModel, &sipClass_QStandardItemModel, -1, 24}, {sipName_QValidator, &sipClass_QValidator, 40, 25}, {sipName_QButtonGroup, &sipClass_QButtonGroup, -1, 26}, {sipName_QWidget, &sipClass_QWidget, 43, 27}, #if defined(SIP_FEATURE_PyQt_SessionManager) {sipName_QSessionManager, &sipClass_QSessionManager, -1, 28}, #else {0, 0, -1, 28}, #endif {sipName_QClipboard, &sipClass_QClipboard, -1, 29}, #if QT_VERSION >= 0x040200 {sipName_QDataWidgetMapper, &sipClass_QDataWidgetMapper, -1, 30}, #else {0, 0, -1, 30}, #endif {sipName_QLayout, &sipClass_QLayout, 118, 31}, {sipName_QAbstractTextDocumentLayout, &sipClass_QAbstractTextDocumentLayout, -1, 32}, {sipName_QAbstractItemDelegate, &sipClass_QAbstractItemDelegate, 123, 33}, {sipName_QDrag, &sipClass_QDrag, -1, -1}, {sipName_QSortFilterProxyModel, &sipClass_QSortFilterProxyModel, -1, -1}, {sipName_QTextFrame, &sipClass_QTextFrame, 37, 36}, {sipName_QTextBlockGroup, &sipClass_QTextBlockGroup, 38, -1}, {sipName_QTextTable, &sipClass_QTextTable, -1, -1}, {sipName_QTextList, &sipClass_QTextList, -1, -1}, #if QT_VERSION >= 0x040200 {sipName_QWidgetAction, &sipClass_QWidgetAction, -1, -1}, #else {0, 0, -1, -1}, #endif {sipName_QDoubleValidator, &sipClass_QDoubleValidator, -1, 41}, {sipName_QIntValidator, &sipClass_QIntValidator, -1, 42}, {sipName_QRegExpValidator, &sipClass_QRegExpValidator, -1, -1}, #if QT_VERSION >= 0x040300 {sipName_QWizardPage, &sipClass_QWizardPage, -1, 44}, #else {0, 0, -1, 44}, #endif {sipName_QComboBox, &sipClass_QComboBox, 73, 45}, #if QT_VERSION >= 0x040200 {sipName_QDialogButtonBox, &sipClass_QDialogButtonBox, -1, 46}, #else {0, 0, -1, 46}, #endif {sipName_QLineEdit, &sipClass_QLineEdit, -1, 47}, #if QT_VERSION >= 0x040300 {sipName_QMdiSubWindow, &sipClass_QMdiSubWindow, -1, 48}, #else {0, 0, -1, 48}, #endif {sipName_QAbstractSpinBox, &sipClass_QAbstractSpinBox, 74, 49}, {sipName_QTabBar, &sipClass_QTabBar, -1, 50}, {sipName_QMainWindow, &sipClass_QMainWindow, -1, 51}, {sipName_QRubberBand, &sipClass_QRubberBand, -1, 52}, {sipName_QAbstractButton, &sipClass_QAbstractButton, 79, 53}, {sipName_QStatusBar, &sipClass_QStatusBar, -1, 54}, {sipName_QDockWidget, &sipClass_QDockWidget, -1, 55}, {sipName_QToolBar, &sipClass_QToolBar, -1, 56}, #if defined(Q_WS_X11) {sipName_QX11EmbedWidget, &sipClass_QX11EmbedWidget, -1, 57}, #else {0, 0, -1, 57}, #endif {sipName_QDesktopWidget, &sipClass_QDesktopWidget, -1, 58}, {sipName_QGroupBox, &sipClass_QGroupBox, -1, 59}, {sipName_QProgressBar, &sipClass_QProgressBar, -1, 60}, {sipName_QSplitterHandle, &sipClass_QSplitterHandle, -1, 61}, {sipName_QWorkspace, &sipClass_QWorkspace, -1, 62}, {sipName_QSizeGrip, &sipClass_QSizeGrip, -1, 63}, #if defined(Q_WS_X11) {sipName_QX11EmbedContainer, &sipClass_QX11EmbedContainer, -1, 64}, #else {0, 0, -1, 64}, #endif {sipName_QMenuBar, &sipClass_QMenuBar, -1, 65}, {sipName_QDialog, &sipClass_QDialog, 83, 66}, #if QT_VERSION >= 0x040200 {sipName_QCalendarWidget, &sipClass_QCalendarWidget, -1, 67}, #else {0, 0, -1, 67}, #endif {sipName_QAbstractSlider, &sipClass_QAbstractSlider, 94, 68}, {sipName_QFrame, &sipClass_QFrame, 97, 69}, {sipName_QSplashScreen, &sipClass_QSplashScreen, -1, 70}, {sipName_QMenu, &sipClass_QMenu, -1, 71}, {sipName_QFocusFrame, &sipClass_QFocusFrame, -1, 72}, {sipName_QTabWidget, &sipClass_QTabWidget, -1, -1}, #if QT_VERSION >= 0x040200 {sipName_QFontComboBox, &sipClass_QFontComboBox, -1, -1}, #else {0, 0, -1, -1}, #endif {sipName_QSpinBox, &sipClass_QSpinBox, -1, 75}, {sipName_QDoubleSpinBox, &sipClass_QDoubleSpinBox, -1, 76}, {sipName_QDateTimeEdit, &sipClass_QDateTimeEdit, 77, -1}, {sipName_QTimeEdit, &sipClass_QTimeEdit, -1, 78}, {sipName_QDateEdit, &sipClass_QDateEdit, -1, -1}, {sipName_QCheckBox, &sipClass_QCheckBox, -1, 80}, {sipName_QToolButton, &sipClass_QToolButton, -1, 81}, {sipName_QRadioButton, &sipClass_QRadioButton, -1, 82}, {sipName_QPushButton, &sipClass_QPushButton, -1, -1}, {sipName_QInputDialog, &sipClass_QInputDialog, -1, 84}, {sipName_QColorDialog, &sipClass_QColorDialog, -1, 85}, {sipName_QAbstractPrintDialog, &sipClass_QAbstractPrintDialog, 93, 86}, {sipName_QFontDialog, &sipClass_QFontDialog, -1, 87}, {sipName_QFileDialog, &sipClass_QFileDialog, -1, 88}, {sipName_QPageSetupDialog, &sipClass_QPageSetupDialog, -1, 89}, {sipName_QProgressDialog, &sipClass_QProgressDialog, -1, 90}, {sipName_QMessageBox, &sipClass_QMessageBox, -1, 91}, {sipName_QErrorMessage, &sipClass_QErrorMessage, -1, 92}, #if QT_VERSION >= 0x040300 {sipName_QWizard, &sipClass_QWizard, -1, -1}, #else {0, 0, -1, -1}, #endif {sipName_QPrintDialog, &sipClass_QPrintDialog, -1, -1}, {sipName_QScrollBar, &sipClass_QScrollBar, -1, 95}, {sipName_QSlider, &sipClass_QSlider, -1, 96}, {sipName_QDial, &sipClass_QDial, -1, -1}, {sipName_QToolBox, &sipClass_QToolBox, -1, 98}, {sipName_QAbstractScrollArea, &sipClass_QAbstractScrollArea, 103, 99}, {sipName_QLCDNumber, &sipClass_QLCDNumber, -1, 100}, {sipName_QSplitter, &sipClass_QSplitter, -1, 101}, {sipName_QStackedWidget, &sipClass_QStackedWidget, -1, 102}, {sipName_QLabel, &sipClass_QLabel, -1, -1}, {sipName_QScrollArea, &sipClass_QScrollArea, -1, 104}, #if QT_VERSION >= 0x040300 {sipName_QMdiArea, &sipClass_QMdiArea, -1, 105}, #else {0, 0, -1, 105}, #endif {sipName_QAbstractItemView, &sipClass_QAbstractItemView, 108, 106}, {sipName_QTextEdit, &sipClass_QTextEdit, 117, 107}, #if QT_VERSION >= 0x040200 {sipName_QGraphicsView, &sipClass_QGraphicsView, -1, -1}, #else {0, 0, -1, -1}, #endif #if QT_VERSION >= 0x040300 {sipName_QColumnView, &sipClass_QColumnView, -1, 109}, #else {0, 0, -1, 109}, #endif {sipName_QTreeView, &sipClass_QTreeView, 113, 110}, {sipName_QTableView, &sipClass_QTableView, 114, 111}, {sipName_QHeaderView, &sipClass_QHeaderView, -1, 112}, {sipName_QListView, &sipClass_QListView, 115, -1}, {sipName_QTreeWidget, &sipClass_QTreeWidget, -1, -1}, {sipName_QTableWidget, &sipClass_QTableWidget, -1, -1}, {sipName_QListWidget, &sipClass_QListWidget, -1, 116}, #if QT_VERSION >= 0x040200 {sipName_QUndoView, &sipClass_QUndoView, -1, -1}, #else {0, 0, -1, -1}, #endif {sipName_QTextBrowser, &sipClass_QTextBrowser, -1, -1}, {sipName_QBoxLayout, &sipClass_QBoxLayout, 121, 119}, {sipName_QStackedLayout, &sipClass_QStackedLayout, -1, 120}, {sipName_QGridLayout, &sipClass_QGridLayout, -1, -1}, {sipName_QVBoxLayout, &sipClass_QVBoxLayout, -1, 122}, {sipName_QHBoxLayout, &sipClass_QHBoxLayout, -1, -1}, {sipName_QItemDelegate, &sipClass_QItemDelegate, -1, -1}, }; int i = 0; sipClass = NULL; do { struct class_graph *cg = &graph[i]; if (cg->name != NULL && sipCpp->inherits(cg->name)) { sipClass = *cg->type; i = cg->yes; } else i = cg->no; } while (i >= 0); %End public: QApplication(SIP_PYLIST argv) /PostHook=__pyQtQAppHook__/ [(int &argc, char **argv)]; %MethodCode // The Python interface is a list of argument strings that is modified. int argc; char **argv; // Convert the list. if ((argv = qtgui_ArgvToC(a0, argc)) == NULL) sipIsErr = 1; else { // Create it now the arguments are right. static int nargc; nargc = argc; Py_BEGIN_ALLOW_THREADS sipCpp = new sipQApplication(nargc, argv); Py_END_ALLOW_THREADS // Now modify the original list. qtgui_UpdatePyArgv(a0, argc, argv); } %End QApplication(SIP_PYLIST argv, bool GUIenabled) /PostHook=__pyQtQAppHook__/ [(int &argc, char **argv, bool GUIenabled)]; %MethodCode // The Python interface is a list of argument strings that is modified. int argc; char **argv; // Convert the list. if ((argv = qtgui_ArgvToC(a0, argc)) == NULL) sipIsErr = 1; else { // Create it now the arguments are right. static int nargc; nargc = argc; Py_BEGIN_ALLOW_THREADS sipCpp = new sipQApplication(nargc, argv, a1); Py_END_ALLOW_THREADS // Now modify the original list. qtgui_UpdatePyArgv(a0, argc, argv); } %End enum Type { Tty, GuiClient, GuiServer, }; QApplication(SIP_PYLIST argv, QApplication::Type) /PostHook=__pyQtQAppHook__/ [(int &argc, char **argv, QApplication::Type)]; %MethodCode // The Python interface is a list of argument strings that is modified. int argc; char **argv; // Convert the list. if ((argv = qtgui_ArgvToC(a0, argc)) == NULL) sipIsErr = 1; else { // Create it now the arguments are right. static int nargc; nargc = argc; Py_BEGIN_ALLOW_THREADS sipCpp = new sipQApplication(nargc, argv, a1); Py_END_ALLOW_THREADS // Now modify the original list. qtgui_UpdatePyArgv(a0, argc, argv); } %End %If (WS_X11) QApplication(Display *dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0) /PostHook=__pyQtQAppHook__/; %End %If (WS_X11) QApplication(Display *dpy, SIP_PYLIST argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0) /PostHook=__pyQtQAppHook__/ [(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0)]; %MethodCode // The Python interface is a list of argument strings that is modified. int argc; char **argv; // Convert the list. if ((argv = qtgui_ArgvToC(a1, argc)) == NULL) sipIsErr = 1; else { // Create it now the arguments are right. static int nargc; nargc = argc; Py_BEGIN_ALLOW_THREADS sipCpp = new sipQApplication(a0, nargc, argv, a2, a3); Py_END_ALLOW_THREADS // Now modify the original list. qtgui_UpdatePyArgv(a1, argc, argv); } %End %End virtual ~QApplication(); %MethodCode // Make sure all remaining top level widgets are not owned by Python. When a // PyQt script terminates we have no control over the order in which the // QApplication instance and the top level widgets are destroyed. If the // former happens first then we get a seg. fault. We could take the approach // of only pretending to delete the QApplication instance, but Qt seems to // allow an application to delete the QApplication instance and then create // another one (and it's useful for unit testing). The approach we take is to // transfer ownership of all top level widgets away from Python so that the C++ // dtor is not called if they are destroyed after the QApplication instance. // This might be seen as a memory leak - but if we really are terminating // then it doesn't matter, and if we are just deleting the QApplication // instance then we should have already deleted the top level widgets manually.] // In any event, the X server resources will be freed. QWidgetList tlw = QApplication::topLevelWidgets(); for (int i = 0; i < tlw.count(); ++i) { PyObject *sw; if ((sw = sipGetWrapper(tlw.at(i), sipClass_QWidget)) != NULL) sipTransferTo(sw, NULL); } // Handle all QObject instances that we want to make sure are deleted before // the QApplication is deleted. qtgui_delete_tracked(); %End static QApplication::Type type(); static QStyle *style(); static void setStyle(QStyle * /Transfer/); static QStyle *setStyle(const QString &); enum ColorSpec { NormalColor, CustomColor, ManyColor, }; static int colorSpec(); static void setColorSpec(int); static QCursor *overrideCursor(); static void setOverrideCursor(const QCursor &); static void changeOverrideCursor(const QCursor &); static void restoreOverrideCursor(); static QPalette palette(); static QPalette palette(const QWidget *); static QPalette palette(const char *className); static void setPalette(const QPalette &, const char *className = 0); %If (- Qt_4_2_0) static QFont font(const QWidget * = 0); %End static void setFont(const QFont &, const char *className = 0); static QFontMetrics fontMetrics(); static void setWindowIcon(const QIcon &icon); static QIcon windowIcon(); static QWidgetList allWidgets(); static QWidgetList topLevelWidgets(); static QDesktopWidget *desktop(); static QWidget *activePopupWidget(); static QWidget *activeModalWidget(); static QClipboard *clipboard(); static QWidget *focusWidget(); static QWidget *activeWindow(); static void setActiveWindow(QWidget *act); static QWidget *widgetAt(const QPoint &p); static QWidget *widgetAt(int x, int y); static QWidget *topLevelAt(const QPoint &p); static QWidget *topLevelAt(int x, int y); static void syncX(); static void beep(); static Qt::KeyboardModifiers keyboardModifiers(); static Qt::MouseButtons mouseButtons(); static void setDesktopSettingsAware(bool); static bool desktopSettingsAware(); static void setCursorFlashTime(int); static int cursorFlashTime(); static void setDoubleClickInterval(int); static int doubleClickInterval(); static void setKeyboardInputInterval(int); static int keyboardInputInterval(); static void setWheelScrollLines(int); static int wheelScrollLines(); static void setGlobalStrut(const QSize &); static QSize globalStrut(); static void setStartDragTime(int ms); static int startDragTime(); static void setStartDragDistance(int l); static int startDragDistance(); static void setLayoutDirection(Qt::LayoutDirection direction); static Qt::LayoutDirection layoutDirection(); static bool isRightToLeft(); static bool isLeftToRight(); static bool isEffectEnabled(Qt::UIEffect); static void setEffectEnabled(Qt::UIEffect, bool enable = true); %If (PyQt_SessionManager) bool isSessionRestored() const; %End %If (PyQt_SessionManager) QString sessionId() const; %End %If (PyQt_SessionManager) QString sessionKey() const; %End %If (PyQt_SessionManager) virtual void commitData(QSessionManager &sm); %End %If (PyQt_SessionManager) virtual void saveState(QSessionManager &sm); %End void setInputContext(QInputContext *); QInputContext *inputContext() const; static int exec() /PostHook=__pyQtPostEventLoopHook__,PreHook=__pyQtPreEventLoopHook__,PyName=exec_,ReleaseGIL/; virtual bool notify(QObject *, QEvent *) /ReleaseGIL/; static void setQuitOnLastWindowClosed(bool quit); static bool quitOnLastWindowClosed(); signals: %If (Qt_4_2_0 -) %If (PyQt_SessionManager) void commitDataRequest(QSessionManager &sessionManager); %End %End void focusChanged(QWidget *old, QWidget *now); void lastWindowClosed(); %If (Qt_4_2_0 -) %If (PyQt_SessionManager) void saveStateRequest(QSessionManager &sessionManager); %End %End public slots: static void aboutQt(); static void closeAllWindows(); %If (Qt_4_2_0 -) void setStyleSheet(const QString &sheet); %End protected: virtual bool event(QEvent *); public: %If (Qt_4_2_0 -) static QFont font(); %End %If (Qt_4_2_0 -) static QFont font(const QWidget *); %End %If (Qt_4_2_0 -) static QFont font(const char *className); %End %If (Qt_4_2_0 -) static QLocale keyboardInputLocale(); %End %If (Qt_4_2_0 -) static Qt::LayoutDirection keyboardInputDirection(); %End %If (Qt_4_2_0 -) QString styleSheet() const; %End %If (Qt_4_3_0 -) static void alert(QWidget *widget, int duration = 0) /ReleaseGIL/; %End private: QApplication(const QApplication &); }; %ModuleHeaderCode // Used to track QObject instances that must be explicitly destroyed before the // QApplication instance is destroyed. Typically these are instances that // sometimes don't have a parent (and are not QWidgets). (QGraphicsScene seems // to be the most common, possibly only, example.) void qtgui_track(QObject *o); void qtgui_delete_tracked(); %End %ModuleCode // Forward declarations of the low level exported functions. void qt_set_sequence_auto_mnemonic(bool enable); #if defined(Q_WS_X11) void qt_x11_wait_for_window_manager(QWidget *widget); #endif #if defined(Q_WS_MAC) void qt_mac_secure_keyboard(bool enable); void qt_mac_set_dock_menu(QMenu *menu); void qt_mac_set_menubar_icons(bool enable); void qt_mac_set_menubar_merge(bool enable); void qt_mac_set_native_menubar(bool enable); void qt_mac_set_press_and_hold_context(bool enable); #endif // These are the implementations of the functions that handle object tracking. #include QObjectCleanupHandler qtgui_cleanup_handler; void qtgui_track(QObject *o) { qtgui_cleanup_handler.add(o); } void qtgui_delete_tracked() { qtgui_cleanup_handler.clear(); } %End