1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
// ****************************************************************************
// Project: GUYMAGER
// ****************************************************************************
// Programmer: Guy Voncken
// Police Grand-Ducale
// Service de Police Judiciaire
// Section Nouvelles Technologies
// ****************************************************************************
// Module: Different Qt utility functions
// ****************************************************************************
// Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
// 2018, 2019, 2020
// Guy Voncken
//
// This file is part of Guymager.
//
// Guymager is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// Guymager is distributed 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 Guymager. If not, see <http://www.gnu.org/licenses/>.
#ifndef QTUTIL_H
#define QTUTIL_H
#define QTUTIL_DEGREES(x) (16*x)
#define QTUTIL_FULL_CIRCLE QTUTIL_DEGREES(360)
#ifdef QDIALOG_H
// const int QtUtilDefaultDialogFlags = Qt::WStyle_DialogBorder |
// Qt::WStyle_StaysOnTop |
// Qt::WStyle_Dialog;
const int QtUtilDefaultDialogFlags = Qt::WindowTitleHint;
// What QMessageBox::information does:
// : QDialog( parent, name, modal, f | WStyle_Customize | WStyle_DialogBorder | WStyle_Title | WStyle_SysMenu )
#endif
#ifdef QCOLOR_H
extern const QColor QtUtilColorDefault;
#endif
#ifdef CONFIG_H
#define QTUTIL_SET_FONT(pWidget, FontObject) \
{ \
QFont *pFont = CfgGetpFont (FontObject); \
if (pFont) \
(pWidget)->setFont(*pFont); \
}
#endif
// ------------------------------------
// Prototypes
// ------------------------------------
#ifdef QWIDGET_H
APIRET QtUtilSetGeometryCentered (QWidget *pWidget, int Dx, int Dy);
#endif
#if defined QSTRING_H && defined QPAINTER_H && defined QFONT_H
APIRET QtUtilGetTextAscent (QPainter const *pPainter, QFont const *pFont, int *pDy);
APIRET QtUtilGetTextDescent (QPainter const *pPainter, QFont const *pFont, int *pDy);
APIRET QtUtilGetCharHeight (QPainter const *pPainter, QFont const *pFont, int *pDy);
APIRET QtUtilGetLineHeight (QPainter const *pPainter, QFont const *pFont, int *pDy);
APIRET QtUtilGetAvgStrWidth (QPainter const *pPainter, QFont const *pFont, int Chars, int *pAvgWidth);
APIRET QtUtilGetTextSize (QPainter const *pPainter, QFont const *pFont, const QString &Str, int *pDx, int *pDy);
APIRET QtUtilGetNumStrWidth (QPainter const *pPainter, QFont const *pFont, int IntLen, int FrcLen , bool Signed, int *pDx);
#ifdef STRUCT_H
APIRET QtUtilGetNumStrWidth (QPainter const *pPainter, QFont const *pFont, t_pParamUnit pParamUnit, bool Signed, int *pDx);
#endif
#endif
APIRET QtUtilSleep (int MilliSeconds);
#ifdef QLAYOUT_H
APIRET QtUtilAdjustDefaults (QLayout *pLayout, bool TopLevelLayout=true);
APIRET QtUtilAdjustLayout (QLayout *pLayout, bool TopLevelLayout);
#endif
#ifdef QPUSHBUTTON_H
APIRET QtUtilAdjustPushButton (QPushButton *pWidget);
#endif
#ifdef QLABEL_H
APIRET QtUtilAdjustLabel (QLabel *pWidget);
#endif
APIRET QtUtilProcessCommand (const QString &Command, QString *pStandardOutput=NULL);
APIRET QtUtilInit (void);
APIRET QtUtilDeInit (void);
// ------------------------------------
// Error codes
// ------------------------------------
enum
{
ERROR_QTUTIL_DIALOG_STACK_OVERFLOW = ERROR_BASE_QTUTIL + 1,
ERROR_QTUTIL_DIALOG_STACK_UNDERFLOW,
ERROR_QTUTIL_DIALOG_INVALID_CUSTOMEVENT,
ERROR_QTUTIL_DIALOG_UNEXPECTED_EVENT,
ERROR_QTUTIL_INVALID_MESSAGEBOX_TYPE,
ERROR_QTUTIL_UNFREED_MEMORY,
ERROR_QTUTIL_COMMAND_TIMEOUT
};
#endif
|