From a30f5359f03c3017fa19a6770fab32d25d22cb87 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Mon, 15 Jul 2024 19:08:22 +0900 Subject: Rename graphics class nt* related files to equivalent tq* (part 1) Signed-off-by: Michele Calgaro --- src/dialogs/ntqcolordialog.h | 93 --- src/dialogs/ntqfontdialog.h | 112 --- src/dialogs/qcolordialog.cpp | 1673 --------------------------------------- src/dialogs/qfontdialog.cpp | 841 -------------------- src/dialogs/qprogressdialog.cpp | 2 +- src/dialogs/qt_dialogs.pri | 10 +- src/dialogs/qtabdialog.cpp | 2 +- src/dialogs/qwizard.cpp | 2 +- src/dialogs/tqcolordialog.cpp | 1673 +++++++++++++++++++++++++++++++++++++++ src/dialogs/tqcolordialog.h | 93 +++ src/dialogs/tqfiledialog.cpp | 2 +- src/dialogs/tqfontdialog.cpp | 841 ++++++++++++++++++++ src/dialogs/tqfontdialog.h | 112 +++ 13 files changed, 2728 insertions(+), 2728 deletions(-) delete mode 100644 src/dialogs/ntqcolordialog.h delete mode 100644 src/dialogs/ntqfontdialog.h delete mode 100644 src/dialogs/qcolordialog.cpp delete mode 100644 src/dialogs/qfontdialog.cpp create mode 100644 src/dialogs/tqcolordialog.cpp create mode 100644 src/dialogs/tqcolordialog.h create mode 100644 src/dialogs/tqfontdialog.cpp create mode 100644 src/dialogs/tqfontdialog.h (limited to 'src/dialogs') diff --git a/src/dialogs/ntqcolordialog.h b/src/dialogs/ntqcolordialog.h deleted file mode 100644 index 0941a020d..000000000 --- a/src/dialogs/ntqcolordialog.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Definition of TQColorDialog class -** -** Created : 990222 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the dialogs module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQCOLORDIALOG_H -#define TQCOLORDIALOG_H - -#ifndef QT_H -#include "ntqdialog.h" -#endif // QT_H - -#ifndef TQT_NO_COLORDIALOG - -class TQColorDialogPrivate; - -class TQ_EXPORT TQColorDialog : public TQDialog -{ - TQ_OBJECT - -public: - static TQColor getColor( const TQColor& init = white, TQWidget* parent=0, const char* name=0 ); - static TQRgb getRgba( TQRgb, bool* ok = 0, - TQWidget* parent=0, const char* name=0 ); - - static int customCount(); - static TQRgb customColor( int ); - static void setCustomColor( int, TQRgb ); - static void setStandardColor( int, TQRgb ); - -private: - ~TQColorDialog(); - TQColorDialog( TQWidget* parent=0, const char* name=0, bool modal=FALSE ); - - void setColor( const TQColor& ); - TQColor color() const; - - bool selectColor( const TQColor& ); - - void setSelectedAlpha( int ); - int selectedAlpha() const; - - void showCustom( bool=TRUE ); - -private: // Disabled copy constructor and operator= - TQColorDialogPrivate *d; - friend class TQColorDialogPrivate; - friend class TQColorShower; - -#if defined(TQ_DISABLE_COPY) - TQColorDialog( const TQColorDialog & ); - TQColorDialog& operator=( const TQColorDialog & ); -#endif -}; - -#endif - -#endif //TQCOLORDIALOG_H diff --git a/src/dialogs/ntqfontdialog.h b/src/dialogs/ntqfontdialog.h deleted file mode 100644 index 743738170..000000000 --- a/src/dialogs/ntqfontdialog.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Definition of TQFontDialog -** -** Created : 970605 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the dialogs module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQFONTDIALOG_H -#define TQFONTDIALOG_H - -#include "ntqwindowdefs.h" - -#ifndef TQT_NO_FONTDIALOG - -// -// W A R N I N G -// ------------- -// -// This class is under development and has private constructors. -// -// You may use the public static getFont() functions which are guaranteed -// to be available in the future. -// - -#ifndef QT_H -#include "ntqdialog.h" -#include "ntqfont.h" -#endif // QT_H - -class TQFontDialogPrivate; - -class TQ_EXPORT TQFontDialog: public TQDialog -{ - TQ_OBJECT - -public: - static TQFont getFont( bool *ok, const TQFont &def, - TQWidget* parent=0, const char* name=0); - static TQFont getFont( bool *ok, TQWidget* parent=0, const char* name=0); - -private: - static TQFont getFont( bool *ok, const TQFont *def, - TQWidget* parent=0, const char* name=0); - - TQFontDialog( TQWidget* parent=0, const char* name=0, bool modal=FALSE, - WFlags f=0 ); - ~TQFontDialog(); - - TQFont font() const; - void setFont( const TQFont &font ); - - bool eventFilter( TQObject *, TQEvent * ); - - void updateFamilies(); - void updateStyles(); - void updateSizes(); - -private slots: - void sizeChanged( const TQString &); - void familyHighlighted( int ); - void scriptHighlighted( int ); - void styleHighlighted( int ); - void sizeHighlighted( const TQString & ); - void updateSample(); - -private: - friend class TQFontDialogPrivate; - TQFontDialogPrivate * d; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQFontDialog( const TQFontDialog & ); - TQFontDialog& operator=( const TQFontDialog & ); -#endif -}; - -#endif - -#endif // TQFONTDIALOG_H diff --git a/src/dialogs/qcolordialog.cpp b/src/dialogs/qcolordialog.cpp deleted file mode 100644 index 4f82b6350..000000000 --- a/src/dialogs/qcolordialog.cpp +++ /dev/null @@ -1,1673 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQColorDialog class -** -** Created : 990222 -** -** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the dialogs module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "ntqcolordialog.h" - -#ifndef TQT_NO_COLORDIALOG - -#include "ntqpainter.h" -#include "ntqlayout.h" -#include "ntqlabel.h" -#include "ntqpushbutton.h" -#include "ntqlineedit.h" -#include "tqimage.h" -#include "ntqpixmap.h" -#include "ntqdrawutil.h" -#include "ntqvalidator.h" -#include "tqdragobject.h" -#include "ntqgridview.h" -#include "ntqapplication.h" -#include "tqstyle.h" -#include "tqsettings.h" -#include "tqpopupmenu.h" - -#ifdef TQ_WS_MAC -TQRgb macGetRgba( TQRgb initial, bool *ok, TQWidget *parent, const char* name ); -TQColor macGetColor( const TQColor& initial, TQWidget *parent, const char *name ); -#endif - -#ifdef TQ_WS_X11 -#include "private/tqttdeintegration_x11_p.h" -#endif - -//////////// TQWellArray BEGIN - -struct TQWellArrayData; - -class TQWellArray : public TQGridView -{ - TQ_OBJECT - TQ_PROPERTY( int selectedColumn READ selectedColumn ) - TQ_PROPERTY( int selectedRow READ selectedRow ) - -public: - TQWellArray( TQWidget* parent=0, const char* name=0, bool popup = FALSE ); - - ~TQWellArray() {} - TQString cellContent( int row, int col ) const; - // ### Paul !!! virtual void setCellContent( int row, int col, const TQString &); - - int selectedColumn() const { return selCol; } - int selectedRow() const { return selRow; } - - virtual void setCurrent( int row, int col ); - virtual void setSelected( int row, int col ); - - TQSize sizeHint() const; - - virtual void setCellBrush( int row, int col, const TQBrush & ); - TQBrush cellBrush( int row, int col ); - -signals: - void selected( int row, int col ); - -protected: - void dimensionChange( int oldRows, int oldCols ); - - virtual void paintCell( TQPainter *, int row, int col ); - virtual void paintCellContents( TQPainter *, int row, int col, const TQRect& ); - - void mousePressEvent( TQMouseEvent* ); - void mouseReleaseEvent( TQMouseEvent* ); - void mouseMoveEvent( TQMouseEvent* ); - void keyPressEvent( TQKeyEvent* ); - void focusInEvent( TQFocusEvent* ); - void focusOutEvent( TQFocusEvent* ); - -private: - int curRow; - int curCol; - int selRow; - int selCol; - bool smallStyle; - TQWellArrayData *d; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQWellArray( const TQWellArray & ); - TQWellArray& operator=( const TQWellArray & ); -#endif -}; - - - -// non-interface ... - - - -struct TQWellArrayData { - TQBrush *brush; -}; - -/*! - \internal - \class TQWellArray qwellarray_p.h - \brief The TQWellArray class provides a well array. - - - \ingroup advanced -*/ - -TQWellArray::TQWellArray( TQWidget *parent, const char * name, bool popup ) - : TQGridView( parent, name, - (popup ? (WStyle_Customize|WStyle_Tool|WStyle_NoBorder) : 0 ) ) -{ - d = 0; - setFocusPolicy( StrongFocus ); - setVScrollBarMode(AlwaysOff); - setHScrollBarMode(AlwaysOff); - viewport()->setBackgroundMode( PaletteBackground ); - setNumCols( 7 ); - setNumRows( 7 ); - setCellWidth( 24 ); - setCellHeight( 21 ); - smallStyle = popup; - - if ( popup ) { - setCellWidth( 18 ); - setCellHeight( 18 ); - setFrameStyle(TQFrame::StyledPanel | TQFrame::Raised); - setMargin( 1 ); - setLineWidth( 2 ); - } else { - setFrameStyle( TQFrame::NoFrame ); - } - curCol = 0; - curRow = 0; - selCol = -1; - selRow = -1; - - if ( smallStyle ) - setMouseTracking( TRUE ); -} - - -TQSize TQWellArray::sizeHint() const -{ - constPolish(); - TQSize s = gridSize().boundedTo( TQSize(640, 480 ) ); - return TQSize( s.width() + 2*frameWidth(), s.height() + 2*frameWidth() ); -} - - -void TQWellArray::paintCell( TQPainter* p, int row, int col ) -{ - int w = cellWidth(); // width of cell in pixels - int h = cellHeight(); // height of cell in pixels - int b = 1; - - if ( !smallStyle ) - b = 3; - - const TQColorGroup & g = colorGroup(); - p->setPen( TQPen( black, 0, SolidLine ) ); - if ( !smallStyle && row ==selRow && col == selCol && - style().styleHint(TQStyle::SH_GUIStyle) != MotifStyle) { - int n = 2; - p->drawRect( n, n, w-2*n, h-2*n ); - } - - style().drawPrimitive(TQStyle::PE_Panel, p, TQRect(b, b, w-2*b, h-2*b), g, - TQStyle::Style_Enabled | TQStyle::Style_Sunken); - - int t = 0; - if (style().styleHint(TQStyle::SH_GUIStyle) == MotifStyle) - t = ( row == selRow && col == selCol ) ? 2 : 0; - b += 2 + t; - - if ( (row == curRow) && (col == curCol) ) { - if ( smallStyle ) { - p->setPen ( white ); - p->drawRect( 1, 1, w-2, h-2 ); - p->setPen ( black ); - p->drawRect( 0, 0, w, h ); - p->drawRect( 2, 2, w-4, h-4 ); - b = 3; - } else if ( hasFocus() ) { - style().drawPrimitive(TQStyle::PE_FocusRect, p, TQRect(0, 0, w, h), g); - } - } - paintCellContents( p, row, col, TQRect(b, b, w - 2*b, h - 2*b) ); -} - -/*! - Reimplement this function to change the contents of the well array. - */ -void TQWellArray::paintCellContents( TQPainter *p, int row, int col, const TQRect &r ) -{ - - if ( d ) { - p->fillRect( r, d->brush[row*numCols()+col] ); - } else { - p->fillRect( r, white ); - p->setPen( black ); - p->drawLine( r.topLeft(), r.bottomRight() ); - p->drawLine( r.topRight(), r.bottomLeft() ); - } -} - - -/*\reimp -*/ -void TQWellArray::mousePressEvent( TQMouseEvent* e ) -{ - // The current cell marker is set to the cell the mouse is pressed - // in. - TQPoint pos = e->pos(); - setCurrent( rowAt( pos.y() ), columnAt( pos.x() ) ); -} - -/*\reimp -*/ -void TQWellArray::mouseReleaseEvent( TQMouseEvent* ) -{ - // The current cell marker is set to the cell the mouse is clicked - // in. - setSelected( curRow, curCol ); -} - - -/*\reimp -*/ -void TQWellArray::mouseMoveEvent( TQMouseEvent* e ) -{ - // The current cell marker is set to the cell the mouse is - // clicked in. - if ( smallStyle ) { - TQPoint pos = e->pos(); - setCurrent( rowAt( pos.y() ), columnAt( pos.x() ) ); - } -} - -/* - Sets the cell currently having the focus. This is not necessarily - the same as the currently selected cell. -*/ - -void TQWellArray::setCurrent( int row, int col ) -{ - - if ( (curRow == row) && (curCol == col) ) - return; - - if ( row < 0 || col < 0 ) - row = col = -1; - - int oldRow = curRow; - int oldCol = curCol; - - curRow = row; - curCol = col; - - updateCell( oldRow, oldCol ); - updateCell( curRow, curCol ); -} - - -/*! - Sets the currently selected cell to \a row, \a col. If \a row or \a - col are less than zero, the current cell is unselected. - - Does not set the position of the focus indicator. -*/ - -void TQWellArray::setSelected( int row, int col ) -{ - if ( (selRow == row) && (selCol == col) ) - return; - - int oldRow = selRow; - int oldCol = selCol; - - if ( row < 0 || col < 0 ) - row = col = -1; - - selCol = col; - selRow = row; - - updateCell( oldRow, oldCol ); - updateCell( selRow, selCol ); - if ( row >= 0 ) - emit selected( row, col ); - - if ( isVisible() && ::tqt_cast(parentWidget()) ) - parentWidget()->close(); -} - - - -/*!\reimp -*/ -void TQWellArray::focusInEvent( TQFocusEvent* ) -{ - updateCell( curRow, curCol ); -} - - -/*! - Sets the size of the well array to be \a rows cells by \a cols. - Resets any brush information set by setCellBrush(). - */ -void TQWellArray::dimensionChange( int, int ) -{ - if ( d ) { - if ( d->brush ) - delete[] d->brush; - delete d; - d = 0; - } -} - -void TQWellArray::setCellBrush( int row, int col, const TQBrush &b ) -{ - if ( !d ) { - d = new TQWellArrayData; - int i = numRows()*numCols(); - d->brush = new TQBrush[i]; - } - if ( row >= 0 && row < numRows() && col >= 0 && col < numCols() ) - d->brush[row*numCols()+col] = b; -#ifdef QT_CHECK_RANGE - else - tqWarning( "TQWellArray::setCellBrush( %d, %d ) out of range", row, col ); -#endif -} - - - -/*! - Returns the brush set for the cell at \a row, \a col. If no brush is set, - \c NoBrush is returned. -*/ - -TQBrush TQWellArray::cellBrush( int row, int col ) -{ - if ( d && row >= 0 && row < numRows() && col >= 0 && col < numCols() ) - return d->brush[row*numCols()+col]; - return NoBrush; -} - - - -/*!\reimp -*/ - -void TQWellArray::focusOutEvent( TQFocusEvent* ) -{ - updateCell( curRow, curCol ); -} - -/*\reimp -*/ -void TQWellArray::keyPressEvent( TQKeyEvent* e ) -{ - switch( e->key() ) { // Look at the key code - case Key_Left: // If 'left arrow'-key, - if( curCol > 0 ) // and cr't not in leftmost col - setCurrent( curRow, curCol - 1); // set cr't to next left column - break; - case Key_Right: // Correspondingly... - if( curCol < numCols()-1 ) - setCurrent( curRow, curCol + 1); - break; - case Key_Up: - if( curRow > 0 ) - setCurrent( curRow - 1, curCol); - else if ( smallStyle ) - focusNextPrevChild( FALSE ); - break; - case Key_Down: - if( curRow < numRows()-1 ) - setCurrent( curRow + 1, curCol); - else if ( smallStyle ) - focusNextPrevChild( TRUE ); - break; - case Key_Space: - case Key_Return: - case Key_Enter: - setSelected( curRow, curCol ); - break; - default: // If not an interesting key, - e->ignore(); // we don't accept the event - return; - } - -} - -//////////// TQWellArray END - -static bool initrgb = FALSE; -static TQRgb stdrgb[6*8]; -static TQRgb cusrgb[2*8]; -static bool customSet = FALSE; - - -static void initRGB() -{ - if ( initrgb ) - return; - initrgb = TRUE; - int i = 0; - for ( int g = 0; g < 4; g++ ) - for ( int r = 0; r < 4; r++ ) - for ( int b = 0; b < 3; b++ ) - stdrgb[i++] = tqRgb( r*255/3, g*255/3, b*255/2 ); - - for ( i = 0; i < 2*8; i++ ) - cusrgb[i] = tqRgb(0xff,0xff,0xff); -} - -/*! - Returns the number of custom colors supported by TQColorDialog. All - color dialogs share the same custom colors. -*/ -int TQColorDialog::customCount() -{ - return 2*8; -} - -/*! - Returns custom color number \a i as a TQRgb. -*/ -TQRgb TQColorDialog::customColor( int i ) -{ - initRGB(); - if ( i < 0 || i >= customCount() ) { -#ifdef QT_CHECK_RANGE - tqWarning( "TQColorDialog::customColor() index %d out of range", i ); -#endif - i = 0; - } - return cusrgb[i]; -} - -/*! - Sets custom color number \a i to the TQRgb value \a c. -*/ -void TQColorDialog::setCustomColor( int i, TQRgb c ) -{ - initRGB(); - if ( i < 0 || i >= customCount() ) { -#ifdef QT_CHECK_RANGE - tqWarning( "TQColorDialog::setCustomColor() index %d out of range", i ); -#endif - return; - } - customSet = TRUE; - cusrgb[i] = c; -} - -/*! - Sets standard color number \a i to the TQRgb value \a c. -*/ - -void TQColorDialog::setStandardColor( int i, TQRgb c ) -{ - initRGB(); - if ( i < 0 || i >= 6*8 ) { -#ifdef QT_CHECK_RANGE - tqWarning( "TQColorDialog::setStandardColor() index %d out of range", i ); -#endif - return; - } - stdrgb[i] = c; -} - -static inline void rgb2hsv( TQRgb rgb, int&h, int&s, int&v ) -{ - TQColor c; - c.setRgb( rgb ); - c.getHsv(h,s,v); -} - -class TQColorWell : public TQWellArray -{ -public: - TQColorWell( TQWidget *parent, int r, int c, TQRgb *vals ) - :TQWellArray( parent, "" ), values( vals ), mousePressed( FALSE ), oldCurrent( -1, -1 ) - { setNumRows(r), setNumCols(c); setSizePolicy( TQSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Minimum) ); } - -protected: - void paintCellContents( TQPainter *, int row, int col, const TQRect& ); - void mousePressEvent( TQMouseEvent *e ); - void mouseMoveEvent( TQMouseEvent *e ); - void mouseReleaseEvent( TQMouseEvent *e ); -#ifndef TQT_NO_DRAGANDDROP - void dragEnterEvent( TQDragEnterEvent *e ); - void dragLeaveEvent( TQDragLeaveEvent *e ); - void dragMoveEvent( TQDragMoveEvent *e ); - void dropEvent( TQDropEvent *e ); -#endif - -private: - TQRgb *values; - bool mousePressed; - TQPoint pressPos; - TQPoint oldCurrent; - -}; - -void TQColorWell::paintCellContents( TQPainter *p, int row, int col, const TQRect &r ) -{ - int i = row + col*numRows(); - p->fillRect( r, TQColor( values[i] ) ); -} - -void TQColorWell::mousePressEvent( TQMouseEvent *e ) -{ - oldCurrent = TQPoint( selectedRow(), selectedColumn() ); - TQWellArray::mousePressEvent( e ); - mousePressed = TRUE; - pressPos = e->pos(); -} - -void TQColorWell::mouseMoveEvent( TQMouseEvent *e ) -{ - TQWellArray::mouseMoveEvent( e ); -#ifndef TQT_NO_DRAGANDDROP - if ( !mousePressed ) - return; - if ( ( pressPos - e->pos() ).manhattanLength() > TQApplication::startDragDistance() ) { - setCurrent( oldCurrent.x(), oldCurrent.y() ); - int i = rowAt(pressPos.y()) + columnAt(pressPos.x()) * numRows(); - TQColor col( values[ i ] ); - TQColorDrag *drg = new TQColorDrag( col, this ); - TQPixmap pix( cellWidth(), cellHeight() ); - pix.fill( col ); - TQPainter p( &pix ); - p.drawRect( 0, 0, pix.width(), pix.height() ); - p.end(); - drg->setPixmap( pix ); - mousePressed = FALSE; - drg->dragCopy(); - } -#endif -} - -#ifndef TQT_NO_DRAGANDDROP -void TQColorWell::dragEnterEvent( TQDragEnterEvent *e ) -{ - setFocus(); - if ( TQColorDrag::canDecode( e ) ) - e->accept(); - else - e->ignore(); -} - -void TQColorWell::dragLeaveEvent( TQDragLeaveEvent * ) -{ - if ( hasFocus() ) - parentWidget()->setFocus(); -} - -void TQColorWell::dragMoveEvent( TQDragMoveEvent *e ) -{ - if ( TQColorDrag::canDecode( e ) ) { - setCurrent( rowAt( e->pos().y() ), columnAt( e->pos().x() ) ); - e->accept(); - } else - e->ignore(); -} - -void TQColorWell::dropEvent( TQDropEvent *e ) -{ - if ( TQColorDrag::canDecode( e ) ) { - int i = rowAt( e->pos().y() ) + columnAt( e->pos().x() ) * numRows(); - TQColor col; - TQColorDrag::decode( e, col ); - values[ i ] = col.rgb(); - repaintContents( FALSE ); - e->accept(); - } else { - e->ignore(); - } -} - -#endif // TQT_NO_DRAGANDDROP - -void TQColorWell::mouseReleaseEvent( TQMouseEvent *e ) -{ - if ( !mousePressed ) - return; - TQWellArray::mouseReleaseEvent( e ); - mousePressed = FALSE; -} - -class TQColorPicker : public TQFrame -{ - TQ_OBJECT -public: - TQColorPicker(TQWidget* parent=0, const char* name=0); - ~TQColorPicker(); - -public slots: - void setCol( int h, int s ); - -signals: - void newCol( int h, int s ); - -protected: - TQSize sizeHint() const; - void drawContents(TQPainter* p); - void mouseMoveEvent( TQMouseEvent * ); - void mousePressEvent( TQMouseEvent * ); - -private: - int hue; - int sat; - - TQPoint colPt(); - int huePt( const TQPoint &pt ); - int satPt( const TQPoint &pt ); - void setCol( const TQPoint &pt ); - - TQPixmap *pix; -}; - -static int pWidth = 200; -static int pHeight = 200; - -class TQColorLuminancePicker : public TQWidget -{ - TQ_OBJECT -public: - TQColorLuminancePicker(TQWidget* parent=0, const char* name=0); - ~TQColorLuminancePicker(); - -public slots: - void setCol( int h, int s, int v ); - void setCol( int h, int s ); - -signals: - void newHsv( int h, int s, int v ); - -protected: - void paintEvent( TQPaintEvent*); - void mouseMoveEvent( TQMouseEvent * ); - void mousePressEvent( TQMouseEvent * ); - -private: - enum { foff = 3, coff = 4 }; //frame and contents offset - int val; - int hue; - int sat; - - int y2val( int y ); - int val2y( int val ); - void setVal( int v ); - - TQPixmap *pix; -}; - - -int TQColorLuminancePicker::y2val( int y ) -{ - int d = height() - 2*coff - 1; - return 255 - (y - coff)*255/d; -} - -int TQColorLuminancePicker::val2y( int v ) -{ - int d = height() - 2*coff - 1; - return coff + (255-v)*d/255; -} - -TQColorLuminancePicker::TQColorLuminancePicker(TQWidget* parent, - const char* name) - :TQWidget( parent, name ) -{ - hue = 100; val = 100; sat = 100; - pix = 0; - // setBackgroundMode( NoBackground ); -} - -TQColorLuminancePicker::~TQColorLuminancePicker() -{ - delete pix; -} - -void TQColorLuminancePicker::mouseMoveEvent( TQMouseEvent *m ) -{ - setVal( y2val(m->y()) ); -} -void TQColorLuminancePicker::mousePressEvent( TQMouseEvent *m ) -{ - setVal( y2val(m->y()) ); -} - -void TQColorLuminancePicker::setVal( int v ) -{ - if ( val == v ) - return; - val = TQMAX( 0, TQMIN(v,255)); - delete pix; pix=0; - repaint( FALSE ); //### - emit newHsv( hue, sat, val ); -} - -//receives from a hue,sat chooser and relays. -void TQColorLuminancePicker::setCol( int h, int s ) -{ - setCol( h, s, val ); - emit newHsv( h, s, val ); -} - -void TQColorLuminancePicker::paintEvent( TQPaintEvent * ) -{ - int w = width() - 5; - - TQRect r( 0, foff, w, height() - 2*foff ); - int wi = r.width() - 2; - int hi = r.height() - 2; - if ( !pix || pix->height() != hi || pix->width() != wi ) { - delete pix; - TQImage img( wi, hi, 32 ); - int y; - for ( y = 0; y < hi; y++ ) { - TQColor c( hue, sat, y2val(y+coff), TQColor::Hsv ); - TQRgb r = c.rgb(); - int x; - for ( x = 0; x < wi; x++ ) - img.setPixel( x, y, r ); - } - pix = new TQPixmap; - pix->convertFromImage(img); - } - TQPainter p(this); - p.drawPixmap( 1, coff, *pix ); - const TQColorGroup &g = colorGroup(); - qDrawShadePanel( &p, r, g, TRUE ); - p.setPen( g.foreground() ); - p.setBrush( g.foreground() ); - TQPointArray a; - int y = val2y(val); - a.setPoints( 3, w, y, w+5, y+5, w+5, y-5 ); - erase( w, 0, 5, height() ); - p.drawPolygon( a ); -} - -void TQColorLuminancePicker::setCol( int h, int s , int v ) -{ - val = v; - hue = h; - sat = s; - delete pix; pix=0; - repaint( FALSE );//#### -} - -TQPoint TQColorPicker::colPt() -{ return TQPoint( (360-hue)*(pWidth-1)/360, (255-sat)*(pHeight-1)/255 ); } -int TQColorPicker::huePt( const TQPoint &pt ) -{ return 360 - pt.x()*360/(pWidth-1); } -int TQColorPicker::satPt( const TQPoint &pt ) -{ return 255 - pt.y()*255/(pHeight-1) ; } -void TQColorPicker::setCol( const TQPoint &pt ) -{ setCol( huePt(pt), satPt(pt) ); } - -TQColorPicker::TQColorPicker(TQWidget* parent, const char* name ) - : TQFrame( parent, name ) -{ - hue = 0; sat = 0; - setCol( 150, 255 ); - - TQImage img( pWidth, pHeight, 32 ); - int x,y; - for ( y = 0; y < pHeight; y++ ) - for ( x = 0; x < pWidth; x++ ) { - TQPoint p( x, y ); - img.setPixel( x, y, TQColor(huePt(p), satPt(p), - 200, TQColor::Hsv).rgb() ); - } - pix = new TQPixmap; - pix->convertFromImage(img); - setBackgroundMode( NoBackground ); - setSizePolicy( TQSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed ) ); -} - -TQColorPicker::~TQColorPicker() -{ - delete pix; -} - -TQSize TQColorPicker::sizeHint() const -{ - return TQSize( pWidth + 2*frameWidth(), pHeight + 2*frameWidth() ); -} - -void TQColorPicker::setCol( int h, int s ) -{ - int nhue = TQMIN( TQMAX(0,h), 360 ); - int nsat = TQMIN( TQMAX(0,s), 255); - if ( nhue == hue && nsat == sat ) - return; - TQRect r( colPt(), TQSize(20,20) ); - hue = nhue; sat = nsat; - r = r.unite( TQRect( colPt(), TQSize(20,20) ) ); - r.moveBy( contentsRect().x()-9, contentsRect().y()-9 ); - // update( r ); - repaint( r, FALSE ); -} - -void TQColorPicker::mouseMoveEvent( TQMouseEvent *m ) -{ - TQPoint p = m->pos() - contentsRect().topLeft(); - setCol( p ); - emit newCol( hue, sat ); -} - -void TQColorPicker::mousePressEvent( TQMouseEvent *m ) -{ - TQPoint p = m->pos() - contentsRect().topLeft(); - setCol( p ); - emit newCol( hue, sat ); -} - -void TQColorPicker::drawContents(TQPainter* p) -{ - TQRect r = contentsRect(); - - p->drawPixmap( r.topLeft(), *pix ); - TQPoint pt = colPt() + r.topLeft(); - p->setPen( TQPen(black) ); - - p->fillRect( pt.x()-9, pt.y(), 20, 2, black ); - p->fillRect( pt.x(), pt.y()-9, 2, 20, black ); - -} - -class TQColorShowLabel; - - - -class TQColIntValidator: public TQIntValidator -{ -public: - TQColIntValidator( int bottom, int top, - TQWidget * parent, const char *name = 0 ) - :TQIntValidator( bottom, top, parent, name ) {} - - TQValidator::State validate( TQString &, int & ) const; -}; - -TQValidator::State TQColIntValidator::validate( TQString &s, int &pos ) const -{ - State state = TQIntValidator::validate(s,pos); - if ( state == Valid ) { - long int val = s.toLong(); - // This is not a general solution, assumes that top() > 0 and - // bottom >= 0 - if ( val < 0 ) { - s = "0"; - pos = 1; - } else if ( val > top() ) { - s.setNum( top() ); - pos = s.length(); - } - } - return state; -} - - - -class TQColNumLineEdit : public TQLineEdit -{ -public: - TQColNumLineEdit( TQWidget *parent, const char* name=0 ) - : TQLineEdit( parent, name ) { setMaxLength( 3 );} - TQSize sizeHint() const { - return TQSize( fontMetrics().width( "999" ) + 2 * ( margin() + frameWidth() ), - TQLineEdit::sizeHint().height() ); } - void setNum( int i ) { - TQString s; - s.setNum(i); - bool block = signalsBlocked(); - blockSignals(TRUE); - setText( s ); - blockSignals(block); - } - int val() const { return text().toInt(); } -}; - - -class TQColorShower : public TQWidget -{ - TQ_OBJECT -public: - TQColorShower( TQWidget *parent, const char *name=0 ); - - //things that don't emit signals - void setHsv( int h, int s, int v ); - - int currentAlpha() const { return alphaEd->val(); } - void setCurrentAlpha( int a ) { alphaEd->setNum( a ); } - void showAlpha( bool b ); - - - TQRgb currentColor() const { return curCol; } - -public slots: - void setRgb( TQRgb rgb ); - -signals: - void newCol( TQRgb rgb ); -private slots: - void rgbEd(); - void hsvEd(); -private: - void showCurrentColor(); - int hue, sat, val; - TQRgb curCol; - TQColNumLineEdit *hEd; - TQColNumLineEdit *sEd; - TQColNumLineEdit *vEd; - TQColNumLineEdit *rEd; - TQColNumLineEdit *gEd; - TQColNumLineEdit *bEd; - TQColNumLineEdit *alphaEd; - TQLabel *alphaLab; - TQColorShowLabel *lab; - bool rgbOriginal; -}; - -class TQColorShowLabel : public TQFrame -{ - TQ_OBJECT - -public: - TQColorShowLabel( TQWidget *parent ) : TQFrame( parent, "qt_colorshow_lbl" ) { - setFrameStyle( TQFrame::Panel|TQFrame::Sunken ); - setBackgroundMode( PaletteBackground ); - setAcceptDrops( TRUE ); - mousePressed = FALSE; - } - void setColor( TQColor c ) { col = c; } - -signals: - void colorDropped( TQRgb ); - -protected: - void drawContents( TQPainter *p ); - void mousePressEvent( TQMouseEvent *e ); - void mouseMoveEvent( TQMouseEvent *e ); - void mouseReleaseEvent( TQMouseEvent *e ); -#ifndef TQT_NO_DRAGANDDROP - void dragEnterEvent( TQDragEnterEvent *e ); - void dragLeaveEvent( TQDragLeaveEvent *e ); - void dropEvent( TQDropEvent *e ); -#endif - -private: - TQColor col; - bool mousePressed; - TQPoint pressPos; - -}; - -void TQColorShowLabel::drawContents( TQPainter *p ) -{ - p->fillRect( contentsRect(), col ); -} - -void TQColorShower::showAlpha( bool b ) -{ - if ( b ) { - alphaLab->show(); - alphaEd->show(); - } else { - alphaLab->hide(); - alphaEd->hide(); - } -} - -void TQColorShowLabel::mousePressEvent( TQMouseEvent *e ) -{ - mousePressed = TRUE; - pressPos = e->pos(); -} - -void TQColorShowLabel::mouseMoveEvent( TQMouseEvent *e ) -{ -#ifndef TQT_NO_DRAGANDDROP - if ( !mousePressed ) - return; - if ( ( pressPos - e->pos() ).manhattanLength() > TQApplication::startDragDistance() ) { - TQColorDrag *drg = new TQColorDrag( col, this ); - TQPixmap pix( 30, 20 ); - pix.fill( col ); - TQPainter p( &pix ); - p.drawRect( 0, 0, pix.width(), pix.height() ); - p.end(); - drg->setPixmap( pix ); - mousePressed = FALSE; - drg->dragCopy(); - } -#endif -} - -#ifndef TQT_NO_DRAGANDDROP -void TQColorShowLabel::dragEnterEvent( TQDragEnterEvent *e ) -{ - if ( TQColorDrag::canDecode( e ) ) - e->accept(); - else - e->ignore(); -} - -void TQColorShowLabel::dragLeaveEvent( TQDragLeaveEvent * ) -{ -} - -void TQColorShowLabel::dropEvent( TQDropEvent *e ) -{ - if ( TQColorDrag::canDecode( e ) ) { - TQColorDrag::decode( e, col ); - repaint( FALSE ); - emit colorDropped( col.rgb() ); - e->accept(); - } else { - e->ignore(); - } -} -#endif // TQT_NO_DRAGANDDROP - -void TQColorShowLabel::mouseReleaseEvent( TQMouseEvent * ) -{ - if ( !mousePressed ) - return; - mousePressed = FALSE; -} - -TQColorShower::TQColorShower( TQWidget *parent, const char *name ) - :TQWidget( parent, name) -{ - curCol = tqRgb( -1, -1, -1 ); - TQColIntValidator *val256 = new TQColIntValidator( 0, 255, this ); - TQColIntValidator *val360 = new TQColIntValidator( 0, 360, this ); - - TQGridLayout *gl = new TQGridLayout( this, 1, 1, 6 ); - lab = new TQColorShowLabel( this ); - lab->setMinimumWidth( 60 ); //### - gl->addMultiCellWidget(lab, 0,-1,0,0); - connect( lab, TQ_SIGNAL( colorDropped(TQRgb) ), - this, TQ_SIGNAL( newCol(TQRgb) ) ); - connect( lab, TQ_SIGNAL( colorDropped(TQRgb) ), - this, TQ_SLOT( setRgb(TQRgb) ) ); - - hEd = new TQColNumLineEdit( this, "qt_hue_edit" ); - hEd->setValidator( val360 ); - TQLabel *l = new TQLabel( hEd, TQColorDialog::tr("Hu&e:"), this, "qt_hue_lbl" ); - l->setAlignment( AlignRight|AlignVCenter ); - gl->addWidget( l, 0, 1 ); - gl->addWidget( hEd, 0, 2 ); - - sEd = new TQColNumLineEdit( this, "qt_sat_edit" ); - sEd->setValidator( val256 ); - l = new TQLabel( sEd, TQColorDialog::tr("&Sat:"), this, "qt_sat_lbl" ); - l->setAlignment( AlignRight|AlignVCenter ); - gl->addWidget( l, 1, 1 ); - gl->addWidget( sEd, 1, 2 ); - - vEd = new TQColNumLineEdit( this, "qt_val_edit" ); - vEd->setValidator( val256 ); - l = new TQLabel( vEd, TQColorDialog::tr("&Val:"), this, "qt_val_lbl" ); - l->setAlignment( AlignRight|AlignVCenter ); - gl->addWidget( l, 2, 1 ); - gl->addWidget( vEd, 2, 2 ); - - rEd = new TQColNumLineEdit( this, "qt_red_edit" ); - rEd->setValidator( val256 ); - l = new TQLabel( rEd, TQColorDialog::tr("&Red:"), this, "qt_red_lbl" ); - l->setAlignment( AlignRight|AlignVCenter ); - gl->addWidget( l, 0, 3 ); - gl->addWidget( rEd, 0, 4 ); - - gEd = new TQColNumLineEdit( this, "qt_grn_edit" ); - gEd->setValidator( val256 ); - l = new TQLabel( gEd, TQColorDialog::tr("&Green:"), this, "qt_grn_lbl" ); - l->setAlignment( AlignRight|AlignVCenter ); - gl->addWidget( l, 1, 3 ); - gl->addWidget( gEd, 1, 4 ); - - bEd = new TQColNumLineEdit( this, "qt_blue_edit" ); - bEd->setValidator( val256 ); - l = new TQLabel( bEd, TQColorDialog::tr("Bl&ue:"), this, "qt_blue_lbl" ); - l->setAlignment( AlignRight|AlignVCenter ); - gl->addWidget( l, 2, 3 ); - gl->addWidget( bEd, 2, 4 ); - - alphaEd = new TQColNumLineEdit( this, "qt_aplha_edit" ); - alphaEd->setValidator( val256 ); - alphaLab = new TQLabel( alphaEd, TQColorDialog::tr("A&lpha channel:"), this, "qt_alpha_lbl" ); - alphaLab->setAlignment( AlignRight|AlignVCenter ); - gl->addMultiCellWidget( alphaLab, 3, 3, 1, 3 ); - gl->addWidget( alphaEd, 3, 4 ); - alphaEd->hide(); - alphaLab->hide(); - - connect( hEd, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(hsvEd()) ); - connect( sEd, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(hsvEd()) ); - connect( vEd, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(hsvEd()) ); - - connect( rEd, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(rgbEd()) ); - connect( gEd, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(rgbEd()) ); - connect( bEd, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(rgbEd()) ); - connect( alphaEd, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(rgbEd()) ); -} - -void TQColorShower::showCurrentColor() -{ - lab->setColor( currentColor() ); - lab->repaint(FALSE); //### -} - -void TQColorShower::rgbEd() -{ - rgbOriginal = TRUE; - if ( alphaEd->isVisible() ) - curCol = tqRgba( rEd->val(), gEd->val(), bEd->val(), currentAlpha() ); - else - curCol = tqRgb( rEd->val(), gEd->val(), bEd->val() ); - - rgb2hsv(currentColor(), hue, sat, val ); - - hEd->setNum( hue ); - sEd->setNum( sat ); - vEd->setNum( val ); - - showCurrentColor(); - emit newCol( currentColor() ); -} - -void TQColorShower::hsvEd() -{ - rgbOriginal = FALSE; - hue = hEd->val(); - sat = sEd->val(); - val = vEd->val(); - - curCol = TQColor( hue, sat, val, TQColor::Hsv ).rgb(); - - rEd->setNum( tqRed(currentColor()) ); - gEd->setNum( tqGreen(currentColor()) ); - bEd->setNum( tqBlue(currentColor()) ); - - showCurrentColor(); - emit newCol( currentColor() ); -} - -void TQColorShower::setRgb( TQRgb rgb ) -{ - rgbOriginal = TRUE; - curCol = rgb; - - rgb2hsv( currentColor(), hue, sat, val ); - - hEd->setNum( hue ); - sEd->setNum( sat ); - vEd->setNum( val ); - - rEd->setNum( tqRed(currentColor()) ); - gEd->setNum( tqGreen(currentColor()) ); - bEd->setNum( tqBlue(currentColor()) ); - - showCurrentColor(); -} - -void TQColorShower::setHsv( int h, int s, int v ) -{ - rgbOriginal = FALSE; - hue = h; val = v; sat = s; //Range check### - curCol = TQColor( hue, sat, val, TQColor::Hsv ).rgb(); - - hEd->setNum( hue ); - sEd->setNum( sat ); - vEd->setNum( val ); - - rEd->setNum( tqRed(currentColor()) ); - gEd->setNum( tqGreen(currentColor()) ); - bEd->setNum( tqBlue(currentColor()) ); - - showCurrentColor(); -} - -class TQColorDialogPrivate : public TQObject -{ -TQ_OBJECT -public: - TQColorDialogPrivate( TQColorDialog *p ); - TQRgb currentColor() const { return cs->currentColor(); } - void setCurrentColor( TQRgb rgb ); - - int currentAlpha() const { return cs->currentAlpha(); } - void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); } - void showAlpha( bool b ) { cs->showAlpha( b ); } - -public slots: - void addCustom(); - - void newHsv( int h, int s, int v ); - void newColorTypedIn( TQRgb rgb ); - void newCustom( int, int ); - void newStandard( int, int ); -public: - TQWellArray *custom; - TQWellArray *standard; - - TQColorPicker *cp; - TQColorLuminancePicker *lp; - TQColorShower *cs; - int nextCust; - bool compact; -}; - -//sets all widgets to display h,s,v -void TQColorDialogPrivate::newHsv( int h, int s, int v ) -{ - cs->setHsv( h, s, v ); - cp->setCol( h, s ); - lp->setCol( h, s, v ); -} - -//sets all widgets to display rgb -void TQColorDialogPrivate::setCurrentColor( TQRgb rgb ) -{ - cs->setRgb( rgb ); - newColorTypedIn( rgb ); -} - -//sets all widgets exept cs to display rgb -void TQColorDialogPrivate::newColorTypedIn( TQRgb rgb ) -{ - int h, s, v; - rgb2hsv(rgb, h, s, v ); - cp->setCol( h, s ); - lp->setCol( h, s, v); -} - -void TQColorDialogPrivate::newCustom( int r, int c ) -{ - int i = r+2*c; - setCurrentColor( cusrgb[i] ); - nextCust = i; - if (standard) - standard->setSelected(-1,-1); -} - -void TQColorDialogPrivate::newStandard( int r, int c ) -{ - setCurrentColor( stdrgb[r+c*6] ); - if (custom) - custom->setSelected(-1,-1); -} - -TQColorDialogPrivate::TQColorDialogPrivate( TQColorDialog *dialog ) : - TQObject(dialog) -{ - compact = FALSE; - // small displays (e.g. PDAs cannot fit the full color dialog, - // so just use the color picker. - if ( tqApp->desktop()->width() < 480 || tqApp->desktop()->height() < 350 ) - compact = TRUE; - - nextCust = 0; - const int lumSpace = 3; - int border = 12; - if ( compact ) - border = 6; - TQHBoxLayout *topLay = new TQHBoxLayout( dialog, border, 6 ); - TQVBoxLayout *leftLay = 0; - - if ( !compact ) - leftLay = new TQVBoxLayout( topLay ); - - initRGB(); - - if ( !compact ) { - standard = new TQColorWell( dialog, 6, 8, stdrgb ); - standard->setCellWidth( 28 ); - standard->setCellHeight( 24 ); - TQLabel * lab = new TQLabel( standard, - TQColorDialog::tr( "&Basic colors"), dialog, "qt_basiccolors_lbl" ); - connect( standard, TQ_SIGNAL(selected(int,int)), TQ_SLOT(newStandard(int,int))); - leftLay->addWidget( lab ); - leftLay->addWidget( standard ); - - - leftLay->addStretch(); - - custom = new TQColorWell( dialog, 2, 8, cusrgb ); - custom->setCellWidth( 28 ); - custom->setCellHeight( 24 ); - custom->setAcceptDrops( TRUE ); - - connect( custom, TQ_SIGNAL(selected(int,int)), TQ_SLOT(newCustom(int,int))); - lab = new TQLabel( custom, TQColorDialog::tr( "&Custom colors") , dialog, "qt_custcolors_lbl" ); - leftLay->addWidget( lab ); - leftLay->addWidget( custom ); - - TQPushButton *custbut = - new TQPushButton( TQColorDialog::tr("&Define Custom Colors >>"), - dialog, "qt_def_custcolors_lbl" ); - custbut->setEnabled( FALSE ); - leftLay->addWidget( custbut ); - } else { - // better color picker size for small displays - pWidth = 150; - pHeight = 100; - - custom = 0; - standard = 0; - } - - TQVBoxLayout *rightLay = new TQVBoxLayout( topLay ); - - TQHBoxLayout *pickLay = new TQHBoxLayout( rightLay ); - - - TQVBoxLayout *cLay = new TQVBoxLayout( pickLay ); - cp = new TQColorPicker( dialog, "qt_colorpicker" ); - cp->setFrameStyle( TQFrame::Panel + TQFrame::Sunken ); - cLay->addSpacing( lumSpace ); - cLay->addWidget( cp ); - cLay->addSpacing( lumSpace ); - - lp = new TQColorLuminancePicker( dialog, "qt_luminance_picker" ); - lp->setFixedWidth( 20 ); //### - pickLay->addWidget( lp ); - - connect( cp, TQ_SIGNAL(newCol(int,int)), lp, TQ_SLOT(setCol(int,int)) ); - connect( lp, TQ_SIGNAL(newHsv(int,int,int)), this, TQ_SLOT(newHsv(int,int,int)) ); - - rightLay->addStretch(); - - cs = new TQColorShower( dialog, "qt_colorshower" ); - connect( cs, TQ_SIGNAL(newCol(TQRgb)), this, TQ_SLOT(newColorTypedIn(TQRgb))); - rightLay->addWidget( cs ); - - TQHBoxLayout *buttons; - if ( compact ) - buttons = new TQHBoxLayout( rightLay ); - else - buttons = new TQHBoxLayout( leftLay ); - - TQPushButton *ok, *cancel; - ok = new TQPushButton( TQColorDialog::tr("OK"), dialog, "qt_ok_btn" ); - connect( ok, TQ_SIGNAL(clicked()), dialog, TQ_SLOT(accept()) ); - ok->setDefault(TRUE); - cancel = new TQPushButton( TQColorDialog::tr("Cancel"), dialog, "qt_cancel_btn" ); - connect( cancel, TQ_SIGNAL(clicked()), dialog, TQ_SLOT(reject()) ); - buttons->addWidget( ok ); - buttons->addWidget( cancel ); - buttons->addStretch(); - - if ( !compact ) { - TQPushButton *addCusBt = new TQPushButton( - TQColorDialog::tr("&Add to Custom Colors"), - dialog, "qt_add_btn" ); - rightLay->addWidget( addCusBt ); - connect( addCusBt, TQ_SIGNAL(clicked()), this, TQ_SLOT(addCustom()) ); - } -} - -void TQColorDialogPrivate::addCustom() -{ - cusrgb[nextCust] = cs->currentColor(); - if (custom) - custom->repaintContents( FALSE ); - nextCust = (nextCust+1) % 16; -} - - -/*! - \class TQColorDialog ntqcolordialog.h - \brief The TQColorDialog class provides a dialog widget for specifying colors. - \mainclass - \ingroup dialogs - \ingroup graphics - - The color dialog's function is to allow users to choose colors. - For example, you might use this in a drawing program to allow the - user to set the brush color. - - The static functions provide modal color dialogs. - \omit - If you require a modeless dialog, use the TQColorDialog constructor. - \endomit - - The static getColor() function shows the dialog and allows the - user to specify a color. The getRgba() function does the same but - also allows the user to specify a color with an alpha channel - (transparency) value. - - The user can store customCount() different custom colors. The - custom colors are shared by all color dialogs, and remembered - during the execution of the program. Use setCustomColor() to set - the custom colors, and use customColor() to get them. - - \img qcolordlg-w.png -*/ - -/*! - Constructs a default color dialog with parent \a parent and called - \a name. If \a modal is TRUE the dialog will be modal. Use - setColor() to set an initial value. - - \sa getColor() -*/ - -TQColorDialog::TQColorDialog(TQWidget* parent, const char* name, bool modal) : - TQDialog(parent, name, modal, ( WType_Dialog | WStyle_Customize | WStyle_Title | - WStyle_DialogBorder | WStyle_SysMenu ) ) -{ - setSizeGripEnabled( FALSE ); - d = new TQColorDialogPrivate( this ); - -#ifndef TQT_NO_SETTINGS - if ( !customSet ) { - TQSettings settings; - settings.insertSearchPath( TQSettings::Windows, "/Trolltech" ); - for ( int i = 0; i < 2*8; ++i ) { - bool ok = FALSE; - TQRgb rgb = (TQRgb)settings.readNumEntry( "/TQt/customColors/" + TQString::number( i ), 0, &ok ); - if ( ok ) - cusrgb[i] = rgb; - } - } -#endif -} - -/*! - Pops up a modal color dialog, lets the user choose a color, and - returns that color. The color is initially set to \a initial. The - dialog is a child of \a parent and is called \a name. It returns - an invalid (see TQColor::isValid()) color if the user cancels the - dialog. All colors allocated by the dialog will be deallocated - before this function returns. -*/ - -TQColor TQColorDialog::getColor( const TQColor& initial, TQWidget *parent, - const char *name ) -{ -#if defined(TQ_WS_X11) - if( TQTDEIntegration::enabled()) - return TQTDEIntegration::getColor( initial, parent, name ); -#elif defined(TQ_WS_MAC) - return macGetColor(initial, parent, name); -#endif - - int allocContext = TQColor::enterAllocContext(); - TQColorDialog *dlg = new TQColorDialog( parent, name, TRUE ); //modal -#ifndef TQT_NO_WIDGET_TOPEXTRA - dlg->setCaption( TQColorDialog::tr( "Select color" ) ); -#endif - dlg->setColor( initial ); - dlg->selectColor( initial ); - int resultCode = dlg->exec(); - TQColor::leaveAllocContext(); - TQColor result; - if ( resultCode == TQDialog::Accepted ) - result = dlg->color(); - TQColor::destroyAllocContext(allocContext); - delete dlg; - return result; -} - - -/*! - Pops up a modal color dialog to allow the user to choose a color - and an alpha channel (transparency) value. The color+alpha is - initially set to \a initial. The dialog is a child of \a parent - and called \a name. - - If \a ok is non-null, \e *\a ok is set to TRUE if the user clicked - OK, and to FALSE if the user clicked Cancel. - - If the user clicks Cancel, the \a initial value is returned. -*/ - -TQRgb TQColorDialog::getRgba( TQRgb initial, bool *ok, - TQWidget *parent, const char* name ) -{ -#if defined(TQ_WS_MAC) - if( TQTDEIntegration::enabled()) { - TQColor color = TQTDEIntegration::getColor( TQColor( initial ), parent, name ); - if( ok ) - *ok = color.isValid(); - return color.rgba(); - } -#elif defined(TQ_WS_MAC) - return macGetRgba(initial, ok, parent, name); -#endif - - int allocContext = TQColor::enterAllocContext(); - TQColorDialog *dlg = new TQColorDialog( parent, name, TRUE ); //modal - - TQ_CHECK_PTR( dlg ); -#ifndef TQT_NO_WIDGET_TOPEXTRA - dlg->setCaption( TQColorDialog::tr( "Select color" ) ); -#endif - dlg->setColor( initial ); - dlg->selectColor( initial ); - dlg->setSelectedAlpha( tqAlpha(initial) ); - int resultCode = dlg->exec(); - TQColor::leaveAllocContext(); - TQRgb result = initial; - if ( resultCode == TQDialog::Accepted ) { - TQRgb c = dlg->color().rgb(); - int alpha = dlg->selectedAlpha(); - result = tqRgba( tqRed(c), tqGreen(c), tqBlue(c), alpha ); - } - if ( ok ) - *ok = resultCode == TQDialog::Accepted; - - TQColor::destroyAllocContext(allocContext); - delete dlg; - return result; -} - - - - - -/*! - Returns the color currently selected in the dialog. - - \sa setColor() -*/ - -TQColor TQColorDialog::color() const -{ - return TQColor(d->currentColor()); -} - - -/*! - Destroys the dialog and frees any memory it allocated. -*/ - -TQColorDialog::~TQColorDialog() -{ -#ifndef TQT_NO_SETTINGS - if ( !customSet ) { - TQSettings settings; - settings.insertSearchPath( TQSettings::Windows, "/Trolltech" ); - for ( int i = 0; i < 2*8; ++i ) - settings.writeEntry( "/TQt/customColors/" + TQString::number( i ), (int)cusrgb[i] ); - } -#endif -} - - -/*! - Sets the color shown in the dialog to \a c. - - \sa color() -*/ - -void TQColorDialog::setColor( const TQColor& c ) -{ - d->setCurrentColor( c.rgb() ); -} - - - - -/*! - Sets the initial alpha channel value to \a a, and shows the alpha - channel entry box. -*/ - -void TQColorDialog::setSelectedAlpha( int a ) -{ - d->showAlpha( TRUE ); - d->setCurrentAlpha( a ); -} - - -/*! - Returns the value selected for the alpha channel. -*/ - -int TQColorDialog::selectedAlpha() const -{ - return d->currentAlpha(); -} - -/*! - Sets focus to the corresponding button, if any. -*/ -bool TQColorDialog::selectColor( const TQColor& col ) -{ - TQRgb color = col.rgb(); - int i = 0, j = 0; - // Check standard colors - if (d->standard) { - for ( i = 0; i < 6; i++ ) { - for ( j = 0; j < 8; j++ ) { - if ( color == stdrgb[i + j*6] ) { - d->newStandard( i, j ); - d->standard->setCurrent( i, j ); - d->standard->setSelected( i, j ); - d->standard->setFocus(); - return TRUE; - } - } - } - } - // Check custom colors - if (d->custom) { - for ( i = 0; i < 2; i++ ) { - for ( j = 0; j < 8; j++ ) { - if ( color == cusrgb[i + j*2] ) { - d->newCustom( i, j ); - d->custom->setCurrent( i, j ); - d->custom->setSelected( i, j ); - d->custom->setFocus(); - return TRUE; - } - } - } - } - return FALSE; -} - -#include "qcolordialog.moc" - -#endif diff --git a/src/dialogs/qfontdialog.cpp b/src/dialogs/qfontdialog.cpp deleted file mode 100644 index dfb9731e1..000000000 --- a/src/dialogs/qfontdialog.cpp +++ /dev/null @@ -1,841 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQFontDialog -** -** Created : 970605 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the dialogs module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "ntqwindowdefs.h" - -#ifndef TQT_NO_FONTDIALOG - -#include "ntqfontdialog.h" - -#include "ntqlineedit.h" -#include "ntqlistbox.h" -#include "ntqpushbutton.h" -#include "ntqcheckbox.h" -#include "ntqcombobox.h" -#include "ntqlayout.h" -#include "ntqvgroupbox.h" -#include "ntqhgroupbox.h" -#include "ntqlabel.h" -#include "ntqapplication.h" -#include "ntqfontdatabase.h" -#include "tqstyle.h" -#include -#include - -#ifdef TQ_WS_X11 -#include "private/tqttdeintegration_x11_p.h" -#endif - -/*! - \class TQFontDialog ntqfontdialog.h - \ingroup dialogs - \mainclass - \brief The TQFontDialog class provides a dialog widget for selecting a font. - - The usual way to use this class is to call one of the static convenience - functions, e.g. getFont(). - - Examples: - - \code - bool ok; - TQFont font = TQFontDialog::getFont( - &ok, TQFont( "Helvetica [Cronyx]", 10 ), this ); - if ( ok ) { - // font is set to the font the user selected - } else { - // the user canceled the dialog; font is set to the initial - // value, in this case Helvetica [Cronyx], 10 - } - \endcode - - The dialog can also be used to set a widget's font directly: - \code - myWidget.setFont( TQFontDialog::getFont( 0, myWidget.font() ) ); - \endcode - If the user clicks OK the font they chose will be used for myWidget, - and if they click Cancel the original font is used. - - \sa TQFont TQFontInfo TQFontMetrics - - -*/ - -class TQFontDialogPrivate -{ -public: - TQFontDialogPrivate() : script( TQFontPrivate::defaultScript ) {}; - TQLabel * familyAccel; - TQLineEdit * familyEdit; - TQListBox * familyList; - - TQLabel * styleAccel; - TQLineEdit * styleEdit; - TQListBox * styleList; - - TQLabel * sizeAccel; - TQLineEdit * sizeEdit; - TQListBox * sizeList; - - TQVGroupBox * effects; - TQCheckBox * strikeout; - TQCheckBox * underline; - TQComboBox * color; - - TQHGroupBox * sample; - TQLineEdit * sampleEdit; - - TQLabel * scriptAccel; - TQComboBox * scriptCombo; - - TQPushButton * ok; - TQPushButton * cancel; - - TQBoxLayout * buttonLayout; - TQBoxLayout * effectsLayout; - TQBoxLayout * sampleLayout; - TQBoxLayout * sampleEditLayout; - - TQFontDatabase fdb; - - TQString family; - TQFont::Script script; - TQString style; - int size; - - bool smoothScalable; -}; - - -/*! - \internal - Constructs a standard font dialog. - - Use setFont() to set the initial font attributes. - - The \a parent, \a name, \a modal and \a f parameters are passed to - the TQDialog constructor. - - \sa getFont() -*/ - -TQFontDialog::TQFontDialog( TQWidget *parent, const char *name, - bool modal, WFlags f ) - : TQDialog( parent, name, modal, f ) -{ - setSizeGripEnabled( TRUE ); - d = new TQFontDialogPrivate; - // grid - d->familyEdit = new TQLineEdit( this, "font family I" ); - d->familyEdit->setReadOnly( TRUE ); - d->familyList = new TQListBox( this, "font family II" ); - d->familyEdit->setFocusProxy( d->familyList ); - - d->familyAccel - = new TQLabel( d->familyList, tr("&Font"), this, "family accelerator" ); - d->familyAccel->setIndent( 2 ); - - d->styleEdit = new TQLineEdit( this, "font style I" ); - d->styleEdit->setReadOnly( TRUE ); - d->styleList = new TQListBox( this, "font style II" ); - d->styleEdit->setFocusProxy( d->styleList ); - - d->styleAccel - = new TQLabel( d->styleList, tr("Font st&yle"), this, "style accelerator" ); - d->styleAccel->setIndent( 2 ); - - d->sizeEdit = new TQLineEdit( this, "font size I" ); - d->sizeEdit->setFocusPolicy( ClickFocus ); - TQIntValidator *validator = new TQIntValidator( 1, 512, this ); - d->sizeEdit->setValidator( validator ); - d->sizeList = new TQListBox( this, "font size II" ); - - d->sizeAccel - = new TQLabel ( d->sizeEdit, tr("&Size"), this, "size accelerator" ); - d->sizeAccel->setIndent( 2 ); - - // effects box - d->effects = new TQVGroupBox( tr("Effects"), this, "font effects" ); - d->strikeout = new TQCheckBox( d->effects, "strikeout on/off" ); - d->strikeout->setText( tr("Stri&keout") ); - d->underline = new TQCheckBox( d->effects, "underline on/off" ); - d->underline->setText( tr("&Underline") ); - - d->sample = new TQHGroupBox( tr("Sample"), this, "sample text" ); - d->sampleEdit = new TQLineEdit( d->sample, "r/w sample text" ); - d->sampleEdit->setSizePolicy( TQSizePolicy( TQSizePolicy::Ignored, TQSizePolicy::Ignored) ); - d->sampleEdit->setAlignment( AlignCenter ); - // Note that the sample text is *not* translated with tr(), as the - // characters used depend on the charset encoding. - d->sampleEdit->setText( "AaBbYyZz" ); - - d->scriptCombo = new TQComboBox( FALSE, this, "font encoding" ); - - d->scriptAccel - = new TQLabel( d->scriptCombo, tr("Scr&ipt"), this,"encoding label"); - d->scriptAccel->setIndent( 2 ); - - d->size = 0; - d->smoothScalable = FALSE; - - connect( d->scriptCombo, TQ_SIGNAL(activated(int)), - TQ_SLOT(scriptHighlighted(int)) ); - connect( d->familyList, TQ_SIGNAL(highlighted(int)), - TQ_SLOT(familyHighlighted(int)) ); - connect( d->styleList, TQ_SIGNAL(highlighted(int)), - TQ_SLOT(styleHighlighted(int)) ); - connect( d->sizeList, TQ_SIGNAL(highlighted(const TQString&)), - TQ_SLOT(sizeHighlighted(const TQString&)) ); - connect( d->sizeEdit, TQ_SIGNAL(textChanged(const TQString&)), - TQ_SLOT(sizeChanged(const TQString&)) ); - - connect( d->strikeout, TQ_SIGNAL(clicked()), - TQ_SLOT(updateSample()) ); - connect( d->underline, TQ_SIGNAL(clicked()), - TQ_SLOT(updateSample()) ); - - (void)d->familyList->sizeHint(); - (void)d->styleList->sizeHint(); - (void)d->sizeList->sizeHint(); - - for (int i = 0; i < TQFont::NScripts; i++) { - TQString scriptname = TQFontDatabase::scriptName((TQFont::Script) i); - if ( !scriptname.isEmpty() ) - d->scriptCombo->insertItem( scriptname ); - } - - updateFamilies(); - if ( d->familyList->count() != 0 ) - d->familyList->setCurrentItem( 0 ); - - // grid layout - TQGridLayout * mainGrid = new TQGridLayout( this, 9, 6, 12, 0 ); - - mainGrid->addWidget( d->familyAccel, 0, 0 ); - mainGrid->addWidget( d->familyEdit, 1, 0 ); - mainGrid->addWidget( d->familyList, 2, 0 ); - - mainGrid->addWidget( d->styleAccel, 0, 2 ); - mainGrid->addWidget( d->styleEdit, 1, 2 ); - mainGrid->addWidget( d->styleList, 2, 2 ); - - mainGrid->addWidget( d->sizeAccel, 0, 4 ); - mainGrid->addWidget( d->sizeEdit, 1, 4 ); - mainGrid->addWidget( d->sizeList, 2, 4 ); - - mainGrid->setColStretch( 0, 38 ); - mainGrid->setColStretch( 2, 24 ); - mainGrid->setColStretch( 4, 10 ); - - mainGrid->addColSpacing( 1, 6 ); - mainGrid->addColSpacing( 3, 6 ); - mainGrid->addColSpacing( 5, 6 ); - - mainGrid->addRowSpacing( 3, 12 ); - - mainGrid->addWidget( d->effects, 4, 0 ); - - mainGrid->addMultiCellWidget( d->sample, 4, 7, 2, 4 ); - - mainGrid->addWidget( d->scriptAccel, 5, 0 ); - mainGrid->addRowSpacing( 6, 2 ); - mainGrid->addWidget( d->scriptCombo, 7, 0 ); - - mainGrid->addRowSpacing( 8, 12 ); - - TQHBoxLayout *buttonBox = new TQHBoxLayout; - mainGrid->addMultiCell( buttonBox, 9, 9, 0, 4 ); - - buttonBox->addStretch( 1 ); - TQString okt = modal ? tr("OK") : tr("Apply"); - d->ok = new TQPushButton( okt, this, "accept font selection" ); - buttonBox->addWidget( d->ok ); - if ( modal ) - connect( d->ok, TQ_SIGNAL(clicked()), TQ_SLOT(accept()) ); - d->ok->setDefault( TRUE ); - - buttonBox->addSpacing( 12 ); - - TQString cancelt = modal ? tr("Cancel") : tr("Close"); - d->cancel = new TQPushButton( cancelt, this, "cancel/close" ); - buttonBox->addWidget( d->cancel ); - connect( d->cancel, TQ_SIGNAL(clicked()), TQ_SLOT(reject()) ); - - resize( 500, 360 ); - - d->sizeEdit->installEventFilter( this ); - d->familyList->installEventFilter( this ); - d->styleList->installEventFilter( this ); - d->sizeList->installEventFilter( this ); - - d->familyList->setFocus(); -} - -/*! - \internal - Destroys the font dialog and frees up its storage. -*/ - -TQFontDialog::~TQFontDialog() -{ - delete d; - d = 0; -} - -/*! - Executes a modal font dialog and returns a font. - - If the user clicks OK, the selected font is returned. If the user - clicks Cancel, the \a initial font is returned. - - The dialog is called \a name, with the parent \a parent. - \a initial is the initially selected font. - If the \a ok parameter is not-null, \e *\a ok is set to TRUE if the - user clicked OK, and set to FALSE if the user clicked Cancel. - - This static function is less flexible than the full TQFontDialog - object, but is convenient and easy to use. - - Examples: - \code - bool ok; - TQFont font = TQFontDialog::getFont( &ok, TQFont( "Times", 12 ), this ); - if ( ok ) { - // font is set to the font the user selected - } else { - // the user canceled the dialog; font is set to the initial - // value, in this case Times, 12. - } - \endcode - - The dialog can also be used to set a widget's font directly: - \code - myWidget.setFont( TQFontDialog::getFont( 0, myWidget.font() ) ); - \endcode - In this example, if the user clicks OK the font they chose will be - used, and if they click Cancel the original font is used. -*/ -TQFont TQFontDialog::getFont( bool *ok, const TQFont &initial, - TQWidget *parent, const char* name) -{ - return getFont( ok, &initial, parent, name ); -} - -/*! - \overload - - Executes a modal font dialog and returns a font. - - If the user clicks OK, the selected font is returned. If the user - clicks Cancel, the TQt default font is returned. - - The dialog is called \a name, with parent \a parent. - If the \a ok parameter is not-null, \e *\a ok is set to TRUE if the - user clicked OK, and FALSE if the user clicked Cancel. - - This static function is less functional than the full TQFontDialog - object, but is convenient and easy to use. - - Example: - \code - bool ok; - TQFont font = TQFontDialog::getFont( &ok, this ); - if ( ok ) { - // font is set to the font the user selected - } else { - // the user canceled the dialog; font is set to the default - // application font, TQApplication::font() - } - \endcode - -*/ -TQFont TQFontDialog::getFont( bool *ok, TQWidget *parent,const char* name) -{ - return getFont( ok, 0, parent, name ); -} - -extern bool tqt_use_native_dialogs; - -TQFont TQFontDialog::getFont( bool *ok, const TQFont *def, - TQWidget *parent, const char* name) -{ -#if defined(TQ_WS_X11) - if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) - return TQTDEIntegration::getFont( ok, def, parent, name ); -#endif - TQFont result; - if ( def ) - result = *def; - - TQFontDialog *dlg = new TQFontDialog( parent, name, TRUE ); - - dlg->setFont( ( def ? *def : TQFont() ) ); -#ifndef TQT_NO_WIDGET_TOPEXTRA - dlg->setCaption( tr("Select Font") ); -#endif - - bool res = (dlg->exec() == TQDialog::Accepted); - if ( res ) - result = dlg->font(); - if ( ok ) - *ok = res; - delete dlg; - return result; -} - - -/*! - \internal - An event filter to make the Up, Down, PageUp and PageDown keys work - correctly in the line edits. The source of the event is the object - \a o and the event is \a e. -*/ - -bool TQFontDialog::eventFilter( TQObject * o , TQEvent * e ) -{ - if ( e->type() == TQEvent::KeyPress) { - TQKeyEvent * k = (TQKeyEvent *)e; - if ( o == d->sizeEdit && - (k->key() == Key_Up || - k->key() == Key_Down || - k->key() == Key_Prior || - k->key() == Key_Next) ) { - - int ci = d->sizeList->currentItem(); - (void)TQApplication::sendEvent( d->sizeList, k ); - - if ( ci != d->sizeList->currentItem() && - style().styleHint(TQStyle::SH_FontDialog_SelectAssociatedText, this)) - d->sizeEdit->selectAll(); - return TRUE; - } else if ( ( o == d->familyList || o == d->styleList ) && - ( k->key() == Key_Return || k->key() == Key_Enter) ) { - k->accept(); - accept(); - return TRUE; - } - } else if ( e->type() == TQEvent::FocusIn && - style().styleHint(TQStyle::SH_FontDialog_SelectAssociatedText, this) ) { - if ( o == d->familyList ) - d->familyEdit->selectAll(); - else if ( o == d->styleList ) - d->styleEdit->selectAll(); - else if ( o == d->sizeList ) - d->sizeEdit->selectAll(); - } else if ( e->type() == TQEvent::MouseButtonPress && o == d->sizeList ) { - d->sizeEdit->setFocus(); - } - return TQDialog::eventFilter( o, e ); -} - -#ifdef TQ_WS_MAC -// #define SHOW_FONTS_IN_FAMILIES -#endif - -#ifdef SHOW_FONTS_IN_FAMILIES -#include "ntqpainter.h" -#include - -class TQListBoxFontText : public TQListBoxText -{ - TQFont cfont; -public: - TQListBoxFontText( const TQString & text ); - ~TQListBoxFontText() { } - - int height( const TQListBox * ) const; - int width( const TQListBox * ) const; - -protected: - void paint( TQPainter * ); -}; - -TQListBoxFontText::TQListBoxFontText( const TQString & text ) - : TQListBoxText(text), cfont(text) -{ -} - -int TQListBoxFontText::height( const TQListBox * ) const -{ - TQFontMetrics fm(cfont); - return TQMAX( fm.lineSpacing() + 2, TQApplication::globalStrut().height() ); -} - -int TQListBoxFontText::width( const TQListBox * ) const -{ - TQFontMetrics fm(cfont); - return TQMAX( fm.width( text() ) + 6, TQApplication::globalStrut().width() ); -} - -void TQListBoxFontText::paint( TQPainter *painter ) -{ - painter->save(); - painter->setFont(cfont); - TQListBoxText::paint(painter); - painter->restore(); -} - -#endif - -/*! - \internal - Updates the contents of the "font family" list box. This - function can be reimplemented if you have special requirements. -*/ - -void TQFontDialog::updateFamilies() -{ - d->familyList->blockSignals( TRUE ); - - enum match_t { MATCH_NONE=0, MATCH_LAST_RESORT=1, MATCH_APP=2, MATCH_FALLBACK, MATCH_FAMILY=3 }; - - TQStringList familyNames = d->fdb.families(d->script); - { - // merge the unicode/unknown family list with the above list. - TQStringList l = d->fdb.families(TQFont::Unicode) + - d->fdb.families(TQFont::UnknownScript); - TQStringList::ConstIterator it = l.begin(), end = l.end(); - for (; it != end; ++it) { - if (! familyNames.contains(*it)) - familyNames << *it; - } - } - - familyNames.sort(); - - d->familyList->clear(); -#ifdef SHOW_FONTS_IN_FAMILIES - TQStringList::Iterator it = familyNames.begin(); - int idx = 0; - for( ; it != familyNames.end() ; ++it ) - d->familyList->insertItem(new TQListBoxFontText(*it), idx++); -#else - d->familyList->insertStringList( familyNames ); -#endif - - TQString foundryName1, familyName1, foundryName2, familyName2; - int bestFamilyMatch = -1; - match_t bestFamilyType = MATCH_NONE; - - TQFont f; - - // ##### do the right thing for a list of family names in the font. - TQFontDatabase::parseFontName(d->family, foundryName1, familyName1); - - TQStringList::Iterator it = familyNames.begin(); - int i = 0; - for( ; it != familyNames.end(); ++it, ++i ) { - - TQFontDatabase::parseFontName(*it, foundryName2, familyName2); - - //try to match.. - if ( familyName1 == familyName2 ) { - bestFamilyType = MATCH_FAMILY; - if ( foundryName1 == foundryName2 ) { - bestFamilyMatch = i; - break; - } - if ( bestFamilyMatch < MATCH_FAMILY ) - bestFamilyMatch = i; - } - - //and try some fall backs - match_t type = MATCH_NONE; - if ( bestFamilyType <= MATCH_NONE && familyName2 == f.lastResortFamily() ) - type = MATCH_LAST_RESORT; - if ( bestFamilyType <= MATCH_LAST_RESORT && familyName2 == f.family() ) - type = MATCH_APP; - // ### add fallback for script - if ( type != MATCH_NONE ) { - bestFamilyType = type; - bestFamilyMatch = i; - } - } - - if (i != -1 && bestFamilyType != MATCH_NONE) - d->familyList->setCurrentItem(bestFamilyMatch); - else - d->familyList->setCurrentItem( 0 ); - d->familyEdit->setText( d->familyList->currentText() ); - if ( style().styleHint(TQStyle::SH_FontDialog_SelectAssociatedText, this) && - d->familyList->hasFocus() ) - d->familyEdit->selectAll(); - - d->familyList->blockSignals( FALSE ); - updateStyles(); -} - -/*! - \internal - Updates the contents of the "font style" list box. This - function can be reimplemented if you have special requirements. -*/ - -void TQFontDialog::updateStyles() -{ - d->styleList->blockSignals( TRUE ); - - d->styleList->clear(); - - TQStringList styles = d->fdb.styles( d->familyList->currentText() ); - - if ( styles.isEmpty() ) { - d->styleEdit->clear(); - d->smoothScalable = FALSE; - } else { - d->styleList->insertStringList( styles ); - - if ( !d->style.isEmpty() ) { - bool found = FALSE; - bool first = TRUE; - TQString cstyle = d->style; - redo: - for ( int i = 0 ; i < (int)d->styleList->count() ; i++ ) { - if ( cstyle == d->styleList->text(i) ) { - d->styleList->setCurrentItem( i ); - found = TRUE; - break; - } - } - if (!found && first) { - if (cstyle.contains("Italic")) { - cstyle.replace("Italic", "Oblique"); - first = FALSE; - goto redo; - } else if (cstyle.contains("Oblique")) { - cstyle.replace("Oblique", "Italic"); - first = FALSE; - goto redo; - } - } - if ( !found ) - d->styleList->setCurrentItem( 0 ); - } - - d->styleEdit->setText( d->styleList->currentText() ); - if ( style().styleHint(TQStyle::SH_FontDialog_SelectAssociatedText, this) && - d->styleList->hasFocus() ) - d->styleEdit->selectAll(); - - d->smoothScalable = d->fdb.isSmoothlyScalable( d->familyList->currentText(), d->styleList->currentText() ); - } - - d->styleList->blockSignals( FALSE ); - - updateSizes(); -} - -/*! - \internal - Updates the contents of the "font size" list box. This - function can be reimplemented if you have special requirements. -*/ - -void TQFontDialog::updateSizes() -{ - d->sizeList->blockSignals( TRUE ); - - d->sizeList->clear(); - - if ( !d->familyList->currentText().isEmpty() ) { - TQValueList sizes = d->fdb.pointSizes( d->familyList->currentText(), d->styleList->currentText() ); - - int i = 0; - bool found = FALSE; - for( TQValueList::iterator it = sizes.begin() ; it != sizes.end(); ++it ) { - d->sizeList->insertItem( TQString::number( *it ) ); - if ( !found && *it >= d->size ) { - d->sizeList->setCurrentItem( i ); - found = TRUE; - } - ++i; - } - if ( !found ) { - // we request a size bigger than the ones in the list, select the biggest one - d->sizeList->setCurrentItem( d->sizeList->count() - 1 ); - } - - d->sizeEdit->blockSignals( TRUE ); - d->sizeEdit->setText( ( d->smoothScalable ? TQString::number( d->size ) : d->sizeList->currentText() ) ); - if ( style().styleHint(TQStyle::SH_FontDialog_SelectAssociatedText, this) && - d->sizeList->hasFocus() ) - d->sizeEdit->selectAll(); - d->sizeEdit->blockSignals( FALSE ); - } else { - d->sizeEdit->clear(); - } - - d->sizeList->blockSignals( FALSE ); - updateSample(); -} - -void TQFontDialog::updateSample() -{ - if ( d->familyList->currentText().isEmpty() ) - d->sampleEdit->clear(); - else - d->sampleEdit->setFont( font() ); -} - -/*! - \internal -*/ -void TQFontDialog::scriptHighlighted( int index ) -{ - d->script = (TQFont::Script)index; - d->sampleEdit->setText( d->fdb.scriptSample( d->script ) ); - updateFamilies(); -} - -/*! - \internal -*/ -void TQFontDialog::familyHighlighted( int i ) -{ - d->family = d->familyList->text( i ); - d->familyEdit->setText( d->family ); - if ( style().styleHint(TQStyle::SH_FontDialog_SelectAssociatedText, this) && - d->familyList->hasFocus() ) - d->familyEdit->selectAll(); - - updateStyles(); -} - - -/*! - \internal -*/ - -void TQFontDialog::styleHighlighted( int index ) -{ - TQString s = d->styleList->text( index ); - d->styleEdit->setText( s ); - if ( style().styleHint(TQStyle::SH_FontDialog_SelectAssociatedText, this) && - d->styleList->hasFocus() ) - d->styleEdit->selectAll(); - - d->style = s; - - updateSizes(); -} - - -/*! - \internal -*/ - -void TQFontDialog::sizeHighlighted( const TQString &s ) -{ - d->sizeEdit->setText( s ); - if ( style().styleHint(TQStyle::SH_FontDialog_SelectAssociatedText, this) && - d->sizeEdit->hasFocus() ) - d->sizeEdit->selectAll(); - - d->size = s.toInt(); - updateSample(); -} - -/*! - \internal - This slot is called if the user changes the font size. - The size is passed in the \a s argument as a \e string. -*/ - -void TQFontDialog::sizeChanged( const TQString &s ) -{ - // no need to check if the conversion is valid, since we have an TQIntValidator in the size edit - int size = s.toInt(); - if ( d->size == size ) - return; - - d->size = size; - if ( d->sizeList->count() != 0 ) { - int i; - for ( i = 0 ; i < (int)d->sizeList->count() - 1 ; i++ ) { - if ( d->sizeList->text(i).toInt() >= d->size ) - break; - } - d->sizeList->blockSignals( TRUE ); - d->sizeList->setCurrentItem( i ); - d->sizeList->blockSignals( FALSE ); - } - updateSample(); -} - -/*! - \internal - Sets the font highlighted in the TQFontDialog to font \a f. - - \sa font() -*/ - -void TQFontDialog::setFont( const TQFont &f ) -{ - d->family = f.family(); - d->style = d->fdb.styleString( f ); - d->size = f.pointSize(); - if ( d->size == -1 ) { - TQFontInfo fi( f ); - d->size = fi.pointSize(); - } - d->strikeout->setChecked( f.strikeOut() ); - d->underline->setChecked( f.underline() ); - - updateFamilies(); -} - -/*! - \internal - Returns the font which the user has chosen. - - \sa setFont() -*/ - -TQFont TQFontDialog::font() const -{ - int pSize = d->sizeEdit->text().toInt(); - - TQFont f = d->fdb.font( d->familyList->currentText(), d->style, pSize ); - f.setStrikeOut( d->strikeout->isChecked() ); - f.setUnderline( d->underline->isChecked() ); - return f; -} - -#endif diff --git a/src/dialogs/qprogressdialog.cpp b/src/dialogs/qprogressdialog.cpp index 1202d4b76..0527f17d2 100644 --- a/src/dialogs/qprogressdialog.cpp +++ b/src/dialogs/qprogressdialog.cpp @@ -43,7 +43,7 @@ #ifndef TQT_NO_PROGRESSDIALOG #include "ntqaccel.h" -#include "ntqpainter.h" +#include "tqpainter.h" #include "ntqdrawutil.h" #include "tqdatetime.h" #include "ntqapplication.h" diff --git a/src/dialogs/qt_dialogs.pri b/src/dialogs/qt_dialogs.pri index cfd0f5b06..669dd70a4 100644 --- a/src/dialogs/qt_dialogs.pri +++ b/src/dialogs/qt_dialogs.pri @@ -3,27 +3,27 @@ dialogs { DIALOGS_P = dialogs - HEADERS += $$DIALOGS_H/ntqcolordialog.h \ + HEADERS += $$DIALOGS_H/tqcolordialog.h \ $$DIALOGS_H/ntqdialog.h \ $$DIALOGS_H/ntqerrormessage.h \ $$DIALOGS_H/tqfiledialog.h \ - $$DIALOGS_H/ntqfontdialog.h \ + $$DIALOGS_H/tqfontdialog.h \ $$DIALOGS_H/ntqmessagebox.h \ $$DIALOGS_H/ntqprogressdialog.h \ $$DIALOGS_H/ntqtabdialog.h \ $$DIALOGS_H/ntqwizard.h \ $$DIALOGS_H/ntqinputdialog.h - !embedded:mac:SOURCES += $$DIALOGS_CPP/tqfiledialog_mac.cpp $$DIALOGS_CPP/qcolordialog_mac.cpp + !embedded:mac:SOURCES += $$DIALOGS_CPP/tqfiledialog_mac.cpp $$DIALOGS_CPP/tqcolordialog_mac.cpp win32:SOURCES += $$DIALOGS_CPP/tqfiledialog_win.cpp unix:SOURCES += $$DIALOGS_CPP/qprintdialog.cpp unix:HEADERS += $$DIALOGS_H/ntqprintdialog.h - SOURCES += $$DIALOGS_CPP/qcolordialog.cpp \ + SOURCES += $$DIALOGS_CPP/tqcolordialog.cpp \ $$DIALOGS_CPP/qdialog.cpp \ $$DIALOGS_CPP/qerrormessage.cpp \ $$DIALOGS_CPP/tqfiledialog.cpp \ - $$DIALOGS_CPP/qfontdialog.cpp \ + $$DIALOGS_CPP/tqfontdialog.cpp \ $$DIALOGS_CPP/qmessagebox.cpp \ $$DIALOGS_CPP/qprogressdialog.cpp \ $$DIALOGS_CPP/qtabdialog.cpp \ diff --git a/src/dialogs/qtabdialog.cpp b/src/dialogs/qtabdialog.cpp index f2601cca2..d0aa11e05 100644 --- a/src/dialogs/qtabdialog.cpp +++ b/src/dialogs/qtabdialog.cpp @@ -46,7 +46,7 @@ #include "ntqtabbar.h" #include "ntqtabwidget.h" #include "ntqpushbutton.h" -#include "ntqpainter.h" +#include "tqpainter.h" #include "ntqpixmap.h" #include "ntqapplication.h" #include "ntqtabwidget.h" diff --git a/src/dialogs/qwizard.cpp b/src/dialogs/qwizard.cpp index e5b3f8f46..3f8371ea7 100644 --- a/src/dialogs/qwizard.cpp +++ b/src/dialogs/qwizard.cpp @@ -49,7 +49,7 @@ #include "tqwidgetstack.h" #include "ntqapplication.h" #include "tqptrlist.h" -#include "ntqpainter.h" +#include "tqpainter.h" #include "ntqaccel.h" /*! \file wizard/wizard.cpp */ diff --git a/src/dialogs/tqcolordialog.cpp b/src/dialogs/tqcolordialog.cpp new file mode 100644 index 000000000..09040eef3 --- /dev/null +++ b/src/dialogs/tqcolordialog.cpp @@ -0,0 +1,1673 @@ +/**************************************************************************** +** +** Implementation of TQColorDialog class +** +** Created : 990222 +** +** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the dialogs module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tqcolordialog.h" + +#ifndef TQT_NO_COLORDIALOG + +#include "tqpainter.h" +#include "ntqlayout.h" +#include "ntqlabel.h" +#include "ntqpushbutton.h" +#include "ntqlineedit.h" +#include "tqimage.h" +#include "ntqpixmap.h" +#include "ntqdrawutil.h" +#include "ntqvalidator.h" +#include "tqdragobject.h" +#include "ntqgridview.h" +#include "ntqapplication.h" +#include "tqstyle.h" +#include "tqsettings.h" +#include "tqpopupmenu.h" + +#ifdef TQ_WS_MAC +TQRgb macGetRgba( TQRgb initial, bool *ok, TQWidget *parent, const char* name ); +TQColor macGetColor( const TQColor& initial, TQWidget *parent, const char *name ); +#endif + +#ifdef TQ_WS_X11 +#include "private/tqttdeintegration_x11_p.h" +#endif + +//////////// TQWellArray BEGIN + +struct TQWellArrayData; + +class TQWellArray : public TQGridView +{ + TQ_OBJECT + TQ_PROPERTY( int selectedColumn READ selectedColumn ) + TQ_PROPERTY( int selectedRow READ selectedRow ) + +public: + TQWellArray( TQWidget* parent=0, const char* name=0, bool popup = FALSE ); + + ~TQWellArray() {} + TQString cellContent( int row, int col ) const; + // ### Paul !!! virtual void setCellContent( int row, int col, const TQString &); + + int selectedColumn() const { return selCol; } + int selectedRow() const { return selRow; } + + virtual void setCurrent( int row, int col ); + virtual void setSelected( int row, int col ); + + TQSize sizeHint() const; + + virtual void setCellBrush( int row, int col, const TQBrush & ); + TQBrush cellBrush( int row, int col ); + +signals: + void selected( int row, int col ); + +protected: + void dimensionChange( int oldRows, int oldCols ); + + virtual void paintCell( TQPainter *, int row, int col ); + virtual void paintCellContents( TQPainter *, int row, int col, const TQRect& ); + + void mousePressEvent( TQMouseEvent* ); + void mouseReleaseEvent( TQMouseEvent* ); + void mouseMoveEvent( TQMouseEvent* ); + void keyPressEvent( TQKeyEvent* ); + void focusInEvent( TQFocusEvent* ); + void focusOutEvent( TQFocusEvent* ); + +private: + int curRow; + int curCol; + int selRow; + int selCol; + bool smallStyle; + TQWellArrayData *d; + +private: // Disabled copy constructor and operator= +#if defined(TQ_DISABLE_COPY) + TQWellArray( const TQWellArray & ); + TQWellArray& operator=( const TQWellArray & ); +#endif +}; + + + +// non-interface ... + + + +struct TQWellArrayData { + TQBrush *brush; +}; + +/*! + \internal + \class TQWellArray qwellarray_p.h + \brief The TQWellArray class provides a well array. + + + \ingroup advanced +*/ + +TQWellArray::TQWellArray( TQWidget *parent, const char * name, bool popup ) + : TQGridView( parent, name, + (popup ? (WStyle_Customize|WStyle_Tool|WStyle_NoBorder) : 0 ) ) +{ + d = 0; + setFocusPolicy( StrongFocus ); + setVScrollBarMode(AlwaysOff); + setHScrollBarMode(AlwaysOff); + viewport()->setBackgroundMode( PaletteBackground ); + setNumCols( 7 ); + setNumRows( 7 ); + setCellWidth( 24 ); + setCellHeight( 21 ); + smallStyle = popup; + + if ( popup ) { + setCellWidth( 18 ); + setCellHeight( 18 ); + setFrameStyle(TQFrame::StyledPanel | TQFrame::Raised); + setMargin( 1 ); + setLineWidth( 2 ); + } else { + setFrameStyle( TQFrame::NoFrame ); + } + curCol = 0; + curRow = 0; + selCol = -1; + selRow = -1; + + if ( smallStyle ) + setMouseTracking( TRUE ); +} + + +TQSize TQWellArray::sizeHint() const +{ + constPolish(); + TQSize s = gridSize().boundedTo( TQSize(640, 480 ) ); + return TQSize( s.width() + 2*frameWidth(), s.height() + 2*frameWidth() ); +} + + +void TQWellArray::paintCell( TQPainter* p, int row, int col ) +{ + int w = cellWidth(); // width of cell in pixels + int h = cellHeight(); // height of cell in pixels + int b = 1; + + if ( !smallStyle ) + b = 3; + + const TQColorGroup & g = colorGroup(); + p->setPen( TQPen( black, 0, SolidLine ) ); + if ( !smallStyle && row ==selRow && col == selCol && + style().styleHint(TQStyle::SH_GUIStyle) != MotifStyle) { + int n = 2; + p->drawRect( n, n, w-2*n, h-2*n ); + } + + style().drawPrimitive(TQStyle::PE_Panel, p, TQRect(b, b, w-2*b, h-2*b), g, + TQStyle::Style_Enabled | TQStyle::Style_Sunken); + + int t = 0; + if (style().styleHint(TQStyle::SH_GUIStyle) == MotifStyle) + t = ( row == selRow && col == selCol ) ? 2 : 0; + b += 2 + t; + + if ( (row == curRow) && (col == curCol) ) { + if ( smallStyle ) { + p->setPen ( white ); + p->drawRect( 1, 1, w-2, h-2 ); + p->setPen ( black ); + p->drawRect( 0, 0, w, h ); + p->drawRect( 2, 2, w-4, h-4 ); + b = 3; + } else if ( hasFocus() ) { + style().drawPrimitive(TQStyle::PE_FocusRect, p, TQRect(0, 0, w, h), g); + } + } + paintCellContents( p, row, col, TQRect(b, b, w - 2*b, h - 2*b) ); +} + +/*! + Reimplement this function to change the contents of the well array. + */ +void TQWellArray::paintCellContents( TQPainter *p, int row, int col, const TQRect &r ) +{ + + if ( d ) { + p->fillRect( r, d->brush[row*numCols()+col] ); + } else { + p->fillRect( r, white ); + p->setPen( black ); + p->drawLine( r.topLeft(), r.bottomRight() ); + p->drawLine( r.topRight(), r.bottomLeft() ); + } +} + + +/*\reimp +*/ +void TQWellArray::mousePressEvent( TQMouseEvent* e ) +{ + // The current cell marker is set to the cell the mouse is pressed + // in. + TQPoint pos = e->pos(); + setCurrent( rowAt( pos.y() ), columnAt( pos.x() ) ); +} + +/*\reimp +*/ +void TQWellArray::mouseReleaseEvent( TQMouseEvent* ) +{ + // The current cell marker is set to the cell the mouse is clicked + // in. + setSelected( curRow, curCol ); +} + + +/*\reimp +*/ +void TQWellArray::mouseMoveEvent( TQMouseEvent* e ) +{ + // The current cell marker is set to the cell the mouse is + // clicked in. + if ( smallStyle ) { + TQPoint pos = e->pos(); + setCurrent( rowAt( pos.y() ), columnAt( pos.x() ) ); + } +} + +/* + Sets the cell currently having the focus. This is not necessarily + the same as the currently selected cell. +*/ + +void TQWellArray::setCurrent( int row, int col ) +{ + + if ( (curRow == row) && (curCol == col) ) + return; + + if ( row < 0 || col < 0 ) + row = col = -1; + + int oldRow = curRow; + int oldCol = curCol; + + curRow = row; + curCol = col; + + updateCell( oldRow, oldCol ); + updateCell( curRow, curCol ); +} + + +/*! + Sets the currently selected cell to \a row, \a col. If \a row or \a + col are less than zero, the current cell is unselected. + + Does not set the position of the focus indicator. +*/ + +void TQWellArray::setSelected( int row, int col ) +{ + if ( (selRow == row) && (selCol == col) ) + return; + + int oldRow = selRow; + int oldCol = selCol; + + if ( row < 0 || col < 0 ) + row = col = -1; + + selCol = col; + selRow = row; + + updateCell( oldRow, oldCol ); + updateCell( selRow, selCol ); + if ( row >= 0 ) + emit selected( row, col ); + + if ( isVisible() && ::tqt_cast(parentWidget()) ) + parentWidget()->close(); +} + + + +/*!\reimp +*/ +void TQWellArray::focusInEvent( TQFocusEvent* ) +{ + updateCell( curRow, curCol ); +} + + +/*! + Sets the size of the well array to be \a rows cells by \a cols. + Resets any brush information set by setCellBrush(). + */ +void TQWellArray::dimensionChange( int, int ) +{ + if ( d ) { + if ( d->brush ) + delete[] d->brush; + delete d; + d = 0; + } +} + +void TQWellArray::setCellBrush( int row, int col, const TQBrush &b ) +{ + if ( !d ) { + d = new TQWellArrayData; + int i = numRows()*numCols(); + d->brush = new TQBrush[i]; + } + if ( row >= 0 && row < numRows() && col >= 0 && col < numCols() ) + d->brush[row*numCols()+col] = b; +#ifdef QT_CHECK_RANGE + else + tqWarning( "TQWellArray::setCellBrush( %d, %d ) out of range", row, col ); +#endif +} + + + +/*! + Returns the brush set for the cell at \a row, \a col. If no brush is set, + \c NoBrush is returned. +*/ + +TQBrush TQWellArray::cellBrush( int row, int col ) +{ + if ( d && row >= 0 && row < numRows() && col >= 0 && col < numCols() ) + return d->brush[row*numCols()+col]; + return NoBrush; +} + + + +/*!\reimp +*/ + +void TQWellArray::focusOutEvent( TQFocusEvent* ) +{ + updateCell( curRow, curCol ); +} + +/*\reimp +*/ +void TQWellArray::keyPressEvent( TQKeyEvent* e ) +{ + switch( e->key() ) { // Look at the key code + case Key_Left: // If 'left arrow'-key, + if( curCol > 0 ) // and cr't not in leftmost col + setCurrent( curRow, curCol - 1); // set cr't to next left column + break; + case Key_Right: // Correspondingly... + if( curCol < numCols()-1 ) + setCurrent( curRow, curCol + 1); + break; + case Key_Up: + if( curRow > 0 ) + setCurrent( curRow - 1, curCol); + else if ( smallStyle ) + focusNextPrevChild( FALSE ); + break; + case Key_Down: + if( curRow < numRows()-1 ) + setCurrent( curRow + 1, curCol); + else if ( smallStyle ) + focusNextPrevChild( TRUE ); + break; + case Key_Space: + case Key_Return: + case Key_Enter: + setSelected( curRow, curCol ); + break; + default: // If not an interesting key, + e->ignore(); // we don't accept the event + return; + } + +} + +//////////// TQWellArray END + +static bool initrgb = FALSE; +static TQRgb stdrgb[6*8]; +static TQRgb cusrgb[2*8]; +static bool customSet = FALSE; + + +static void initRGB() +{ + if ( initrgb ) + return; + initrgb = TRUE; + int i = 0; + for ( int g = 0; g < 4; g++ ) + for ( int r = 0; r < 4; r++ ) + for ( int b = 0; b < 3; b++ ) + stdrgb[i++] = tqRgb( r*255/3, g*255/3, b*255/2 ); + + for ( i = 0; i < 2*8; i++ ) + cusrgb[i] = tqRgb(0xff,0xff,0xff); +} + +/*! + Returns the number of custom colors supported by TQColorDialog. All + color dialogs share the same custom colors. +*/ +int TQColorDialog::customCount() +{ + return 2*8; +} + +/*! + Returns custom color number \a i as a TQRgb. +*/ +TQRgb TQColorDialog::customColor( int i ) +{ + initRGB(); + if ( i < 0 || i >= customCount() ) { +#ifdef QT_CHECK_RANGE + tqWarning( "TQColorDialog::customColor() index %d out of range", i ); +#endif + i = 0; + } + return cusrgb[i]; +} + +/*! + Sets custom color number \a i to the TQRgb value \a c. +*/ +void TQColorDialog::setCustomColor( int i, TQRgb c ) +{ + initRGB(); + if ( i < 0 || i >= customCount() ) { +#ifdef QT_CHECK_RANGE + tqWarning( "TQColorDialog::setCustomColor() index %d out of range", i ); +#endif + return; + } + customSet = TRUE; + cusrgb[i] = c; +} + +/*! + Sets standard color number \a i to the TQRgb value \a c. +*/ + +void TQColorDialog::setStandardColor( int i, TQRgb c ) +{ + initRGB(); + if ( i < 0 || i >= 6*8 ) { +#ifdef QT_CHECK_RANGE + tqWarning( "TQColorDialog::setStandardColor() index %d out of range", i ); +#endif + return; + } + stdrgb[i] = c; +} + +static inline void rgb2hsv( TQRgb rgb, int&h, int&s, int&v ) +{ + TQColor c; + c.setRgb( rgb ); + c.getHsv(h,s,v); +} + +class TQColorWell : public TQWellArray +{ +public: + TQColorWell( TQWidget *parent, int r, int c, TQRgb *vals ) + :TQWellArray( parent, "" ), values( vals ), mousePressed( FALSE ), oldCurrent( -1, -1 ) + { setNumRows(r), setNumCols(c); setSizePolicy( TQSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Minimum) ); } + +protected: + void paintCellContents( TQPainter *, int row, int col, const TQRect& ); + void mousePressEvent( TQMouseEvent *e ); + void mouseMoveEvent( TQMouseEvent *e ); + void mouseReleaseEvent( TQMouseEvent *e ); +#ifndef TQT_NO_DRAGANDDROP + void dragEnterEvent( TQDragEnterEvent *e ); + void dragLeaveEvent( TQDragLeaveEvent *e ); + void dragMoveEvent( TQDragMoveEvent *e ); + void dropEvent( TQDropEvent *e ); +#endif + +private: + TQRgb *values; + bool mousePressed; + TQPoint pressPos; + TQPoint oldCurrent; + +}; + +void TQColorWell::paintCellContents( TQPainter *p, int row, int col, const TQRect &r ) +{ + int i = row + col*numRows(); + p->fillRect( r, TQColor( values[i] ) ); +} + +void TQColorWell::mousePressEvent( TQMouseEvent *e ) +{ + oldCurrent = TQPoint( selectedRow(), selectedColumn() ); + TQWellArray::mousePressEvent( e ); + mousePressed = TRUE; + pressPos = e->pos(); +} + +void TQColorWell::mouseMoveEvent( TQMouseEvent *e ) +{ + TQWellArray::mouseMoveEvent( e ); +#ifndef TQT_NO_DRAGANDDROP + if ( !mousePressed ) + return; + if ( ( pressPos - e->pos() ).manhattanLength() > TQApplication::startDragDistance() ) { + setCurrent( oldCurrent.x(), oldCurrent.y() ); + int i = rowAt(pressPos.y()) + columnAt(pressPos.x()) * numRows(); + TQColor col( values[ i ] ); + TQColorDrag *drg = new TQColorDrag( col, this ); + TQPixmap pix( cellWidth(), cellHeight() ); + pix.fill( col ); + TQPainter p( &pix ); + p.drawRect( 0, 0, pix.width(), pix.height() ); + p.end(); + drg->setPixmap( pix ); + mousePressed = FALSE; + drg->dragCopy(); + } +#endif +} + +#ifndef TQT_NO_DRAGANDDROP +void TQColorWell::dragEnterEvent( TQDragEnterEvent *e ) +{ + setFocus(); + if ( TQColorDrag::canDecode( e ) ) + e->accept(); + else + e->ignore(); +} + +void TQColorWell::dragLeaveEvent( TQDragLeaveEvent * ) +{ + if ( hasFocus() ) + parentWidget()->setFocus(); +} + +void TQColorWell::dragMoveEvent( TQDragMoveEvent *e ) +{ + if ( TQColorDrag::canDecode( e ) ) { + setCurrent( rowAt( e->pos().y() ), columnAt( e->pos().x() ) ); + e->accept(); + } else + e->ignore(); +} + +void TQColorWell::dropEvent( TQDropEvent *e ) +{ + if ( TQColorDrag::canDecode( e ) ) { + int i = rowAt( e->pos().y() ) + columnAt( e->pos().x() ) * numRows(); + TQColor col; + TQColorDrag::decode( e, col ); + values[ i ] = col.rgb(); + repaintContents( FALSE ); + e->accept(); + } else { + e->ignore(); + } +} + +#endif // TQT_NO_DRAGANDDROP + +void TQColorWell::mouseReleaseEvent( TQMouseEvent *e ) +{ + if ( !mousePressed ) + return; + TQWellArray::mouseReleaseEvent( e ); + mousePressed = FALSE; +} + +class TQColorPicker : public TQFrame +{ + TQ_OBJECT +public: + TQColorPicker(TQWidget* parent=0, const char* name=0); + ~TQColorPicker(); + +public slots: + void setCol( int h, int s ); + +signals: + void newCol( int h, int s ); + +protected: + TQSize sizeHint() const; + void drawContents(TQPainter* p); + void mouseMoveEvent( TQMouseEvent * ); + void mousePressEvent( TQMouseEvent * ); + +private: + int hue; + int sat; + + TQPoint colPt(); + int huePt( const TQPoint &pt ); + int satPt( const TQPoint &pt ); + void setCol( const TQPoint &pt ); + + TQPixmap *pix; +}; + +static int pWidth = 200; +static int pHeight = 200; + +class TQColorLuminancePicker : public TQWidget +{ + TQ_OBJECT +public: + TQColorLuminancePicker(TQWidget* parent=0, const char* name=0); + ~TQColorLuminancePicker(); + +public slots: + void setCol( int h, int s, int v ); + void setCol( int h, int s ); + +signals: + void newHsv( int h, int s, int v ); + +protected: + void paintEvent( TQPaintEvent*); + void mouseMoveEvent( TQMouseEvent * ); + void mousePressEvent( TQMouseEvent * ); + +private: + enum { foff = 3, coff = 4 }; //frame and contents offset + int val; + int hue; + int sat; + + int y2val( int y ); + int val2y( int val ); + void setVal( int v ); + + TQPixmap *pix; +}; + + +int TQColorLuminancePicker::y2val( int y ) +{ + int d = height() - 2*coff - 1; + return 255 - (y - coff)*255/d; +} + +int TQColorLuminancePicker::val2y( int v ) +{ + int d = height() - 2*coff - 1; + return coff + (255-v)*d/255; +} + +TQColorLuminancePicker::TQColorLuminancePicker(TQWidget* parent, + const char* name) + :TQWidget( parent, name ) +{ + hue = 100; val = 100; sat = 100; + pix = 0; + // setBackgroundMode( NoBackground ); +} + +TQColorLuminancePicker::~TQColorLuminancePicker() +{ + delete pix; +} + +void TQColorLuminancePicker::mouseMoveEvent( TQMouseEvent *m ) +{ + setVal( y2val(m->y()) ); +} +void TQColorLuminancePicker::mousePressEvent( TQMouseEvent *m ) +{ + setVal( y2val(m->y()) ); +} + +void TQColorLuminancePicker::setVal( int v ) +{ + if ( val == v ) + return; + val = TQMAX( 0, TQMIN(v,255)); + delete pix; pix=0; + repaint( FALSE ); //### + emit newHsv( hue, sat, val ); +} + +//receives from a hue,sat chooser and relays. +void TQColorLuminancePicker::setCol( int h, int s ) +{ + setCol( h, s, val ); + emit newHsv( h, s, val ); +} + +void TQColorLuminancePicker::paintEvent( TQPaintEvent * ) +{ + int w = width() - 5; + + TQRect r( 0, foff, w, height() - 2*foff ); + int wi = r.width() - 2; + int hi = r.height() - 2; + if ( !pix || pix->height() != hi || pix->width() != wi ) { + delete pix; + TQImage img( wi, hi, 32 ); + int y; + for ( y = 0; y < hi; y++ ) { + TQColor c( hue, sat, y2val(y+coff), TQColor::Hsv ); + TQRgb r = c.rgb(); + int x; + for ( x = 0; x < wi; x++ ) + img.setPixel( x, y, r ); + } + pix = new TQPixmap; + pix->convertFromImage(img); + } + TQPainter p(this); + p.drawPixmap( 1, coff, *pix ); + const TQColorGroup &g = colorGroup(); + qDrawShadePanel( &p, r, g, TRUE ); + p.setPen( g.foreground() ); + p.setBrush( g.foreground() ); + TQPointArray a; + int y = val2y(val); + a.setPoints( 3, w, y, w+5, y+5, w+5, y-5 ); + erase( w, 0, 5, height() ); + p.drawPolygon( a ); +} + +void TQColorLuminancePicker::setCol( int h, int s , int v ) +{ + val = v; + hue = h; + sat = s; + delete pix; pix=0; + repaint( FALSE );//#### +} + +TQPoint TQColorPicker::colPt() +{ return TQPoint( (360-hue)*(pWidth-1)/360, (255-sat)*(pHeight-1)/255 ); } +int TQColorPicker::huePt( const TQPoint &pt ) +{ return 360 - pt.x()*360/(pWidth-1); } +int TQColorPicker::satPt( const TQPoint &pt ) +{ return 255 - pt.y()*255/(pHeight-1) ; } +void TQColorPicker::setCol( const TQPoint &pt ) +{ setCol( huePt(pt), satPt(pt) ); } + +TQColorPicker::TQColorPicker(TQWidget* parent, const char* name ) + : TQFrame( parent, name ) +{ + hue = 0; sat = 0; + setCol( 150, 255 ); + + TQImage img( pWidth, pHeight, 32 ); + int x,y; + for ( y = 0; y < pHeight; y++ ) + for ( x = 0; x < pWidth; x++ ) { + TQPoint p( x, y ); + img.setPixel( x, y, TQColor(huePt(p), satPt(p), + 200, TQColor::Hsv).rgb() ); + } + pix = new TQPixmap; + pix->convertFromImage(img); + setBackgroundMode( NoBackground ); + setSizePolicy( TQSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed ) ); +} + +TQColorPicker::~TQColorPicker() +{ + delete pix; +} + +TQSize TQColorPicker::sizeHint() const +{ + return TQSize( pWidth + 2*frameWidth(), pHeight + 2*frameWidth() ); +} + +void TQColorPicker::setCol( int h, int s ) +{ + int nhue = TQMIN( TQMAX(0,h), 360 ); + int nsat = TQMIN( TQMAX(0,s), 255); + if ( nhue == hue && nsat == sat ) + return; + TQRect r( colPt(), TQSize(20,20) ); + hue = nhue; sat = nsat; + r = r.unite( TQRect( colPt(), TQSize(20,20) ) ); + r.moveBy( contentsRect().x()-9, contentsRect().y()-9 ); + // update( r ); + repaint( r, FALSE ); +} + +void TQColorPicker::mouseMoveEvent( TQMouseEvent *m ) +{ + TQPoint p = m->pos() - contentsRect().topLeft(); + setCol( p ); + emit newCol( hue, sat ); +} + +void TQColorPicker::mousePressEvent( TQMouseEvent *m ) +{ + TQPoint p = m->pos() - contentsRect().topLeft(); + setCol( p ); + emit newCol( hue, sat ); +} + +void TQColorPicker::drawContents(TQPainter* p) +{ + TQRect r = contentsRect(); + + p->drawPixmap( r.topLeft(), *pix ); + TQPoint pt = colPt() + r.topLeft(); + p->setPen( TQPen(black) ); + + p->fillRect( pt.x()-9, pt.y(), 20, 2, black ); + p->fillRect( pt.x(), pt.y()-9, 2, 20, black ); + +} + +class TQColorShowLabel; + + + +class TQColIntValidator: public TQIntValidator +{ +public: + TQColIntValidator( int bottom, int top, + TQWidget * parent, const char *name = 0 ) + :TQIntValidator( bottom, top, parent, name ) {} + + TQValidator::State validate( TQString &, int & ) const; +}; + +TQValidator::State TQColIntValidator::validate( TQString &s, int &pos ) const +{ + State state = TQIntValidator::validate(s,pos); + if ( state == Valid ) { + long int val = s.toLong(); + // This is not a general solution, assumes that top() > 0 and + // bottom >= 0 + if ( val < 0 ) { + s = "0"; + pos = 1; + } else if ( val > top() ) { + s.setNum( top() ); + pos = s.length(); + } + } + return state; +} + + + +class TQColNumLineEdit : public TQLineEdit +{ +public: + TQColNumLineEdit( TQWidget *parent, const char* name=0 ) + : TQLineEdit( parent, name ) { setMaxLength( 3 );} + TQSize sizeHint() const { + return TQSize( fontMetrics().width( "999" ) + 2 * ( margin() + frameWidth() ), + TQLineEdit::sizeHint().height() ); } + void setNum( int i ) { + TQString s; + s.setNum(i); + bool block = signalsBlocked(); + blockSignals(TRUE); + setText( s ); + blockSignals(block); + } + int val() const { return text().toInt(); } +}; + + +class TQColorShower : public TQWidget +{ + TQ_OBJECT +public: + TQColorShower( TQWidget *parent, const char *name=0 ); + + //things that don't emit signals + void setHsv( int h, int s, int v ); + + int currentAlpha() const { return alphaEd->val(); } + void setCurrentAlpha( int a ) { alphaEd->setNum( a ); } + void showAlpha( bool b ); + + + TQRgb currentColor() const { return curCol; } + +public slots: + void setRgb( TQRgb rgb ); + +signals: + void newCol( TQRgb rgb ); +private slots: + void rgbEd(); + void hsvEd(); +private: + void showCurrentColor(); + int hue, sat, val; + TQRgb curCol; + TQColNumLineEdit *hEd; + TQColNumLineEdit *sEd; + TQColNumLineEdit *vEd; + TQColNumLineEdit *rEd; + TQColNumLineEdit *gEd; + TQColNumLineEdit *bEd; + TQColNumLineEdit *alphaEd; + TQLabel *alphaLab; + TQColorShowLabel *lab; + bool rgbOriginal; +}; + +class TQColorShowLabel : public TQFrame +{ + TQ_OBJECT + +public: + TQColorShowLabel( TQWidget *parent ) : TQFrame( parent, "qt_colorshow_lbl" ) { + setFrameStyle( TQFrame::Panel|TQFrame::Sunken ); + setBackgroundMode( PaletteBackground ); + setAcceptDrops( TRUE ); + mousePressed = FALSE; + } + void setColor( TQColor c ) { col = c; } + +signals: + void colorDropped( TQRgb ); + +protected: + void drawContents( TQPainter *p ); + void mousePressEvent( TQMouseEvent *e ); + void mouseMoveEvent( TQMouseEvent *e ); + void mouseReleaseEvent( TQMouseEvent *e ); +#ifndef TQT_NO_DRAGANDDROP + void dragEnterEvent( TQDragEnterEvent *e ); + void dragLeaveEvent( TQDragLeaveEvent *e ); + void dropEvent( TQDropEvent *e ); +#endif + +private: + TQColor col; + bool mousePressed; + TQPoint pressPos; + +}; + +void TQColorShowLabel::drawContents( TQPainter *p ) +{ + p->fillRect( contentsRect(), col ); +} + +void TQColorShower::showAlpha( bool b ) +{ + if ( b ) { + alphaLab->show(); + alphaEd->show(); + } else { + alphaLab->hide(); + alphaEd->hide(); + } +} + +void TQColorShowLabel::mousePressEvent( TQMouseEvent *e ) +{ + mousePressed = TRUE; + pressPos = e->pos(); +} + +void TQColorShowLabel::mouseMoveEvent( TQMouseEvent *e ) +{ +#ifndef TQT_NO_DRAGANDDROP + if ( !mousePressed ) + return; + if ( ( pressPos - e->pos() ).manhattanLength() > TQApplication::startDragDistance() ) { + TQColorDrag *drg = new TQColorDrag( col, this ); + TQPixmap pix( 30, 20 ); + pix.fill( col ); + TQPainter p( &pix ); + p.drawRect( 0, 0, pix.width(), pix.height() ); + p.end(); + drg->setPixmap( pix ); + mousePressed = FALSE; + drg->dragCopy(); + } +#endif +} + +#ifndef TQT_NO_DRAGANDDROP +void TQColorShowLabel::dragEnterEvent( TQDragEnterEvent *e ) +{ + if ( TQColorDrag::canDecode( e ) ) + e->accept(); + else + e->ignore(); +} + +void TQColorShowLabel::dragLeaveEvent( TQDragLeaveEvent * ) +{ +} + +void TQColorShowLabel::dropEvent( TQDropEvent *e ) +{ + if ( TQColorDrag::canDecode( e ) ) { + TQColorDrag::decode( e, col ); + repaint( FALSE ); + emit colorDropped( col.rgb() ); + e->accept(); + } else { + e->ignore(); + } +} +#endif // TQT_NO_DRAGANDDROP + +void TQColorShowLabel::mouseReleaseEvent( TQMouseEvent * ) +{ + if ( !mousePressed ) + return; + mousePressed = FALSE; +} + +TQColorShower::TQColorShower( TQWidget *parent, const char *name ) + :TQWidget( parent, name) +{ + curCol = tqRgb( -1, -1, -1 ); + TQColIntValidator *val256 = new TQColIntValidator( 0, 255, this ); + TQColIntValidator *val360 = new TQColIntValidator( 0, 360, this ); + + TQGridLayout *gl = new TQGridLayout( this, 1, 1, 6 ); + lab = new TQColorShowLabel( this ); + lab->setMinimumWidth( 60 ); //### + gl->addMultiCellWidget(lab, 0,-1,0,0); + connect( lab, TQ_SIGNAL( colorDropped(TQRgb) ), + this, TQ_SIGNAL( newCol(TQRgb) ) ); + connect( lab, TQ_SIGNAL( colorDropped(TQRgb) ), + this, TQ_SLOT( setRgb(TQRgb) ) ); + + hEd = new TQColNumLineEdit( this, "qt_hue_edit" ); + hEd->setValidator( val360 ); + TQLabel *l = new TQLabel( hEd, TQColorDialog::tr("Hu&e:"), this, "qt_hue_lbl" ); + l->setAlignment( AlignRight|AlignVCenter ); + gl->addWidget( l, 0, 1 ); + gl->addWidget( hEd, 0, 2 ); + + sEd = new TQColNumLineEdit( this, "qt_sat_edit" ); + sEd->setValidator( val256 ); + l = new TQLabel( sEd, TQColorDialog::tr("&Sat:"), this, "qt_sat_lbl" ); + l->setAlignment( AlignRight|AlignVCenter ); + gl->addWidget( l, 1, 1 ); + gl->addWidget( sEd, 1, 2 ); + + vEd = new TQColNumLineEdit( this, "qt_val_edit" ); + vEd->setValidator( val256 ); + l = new TQLabel( vEd, TQColorDialog::tr("&Val:"), this, "qt_val_lbl" ); + l->setAlignment( AlignRight|AlignVCenter ); + gl->addWidget( l, 2, 1 ); + gl->addWidget( vEd, 2, 2 ); + + rEd = new TQColNumLineEdit( this, "qt_red_edit" ); + rEd->setValidator( val256 ); + l = new TQLabel( rEd, TQColorDialog::tr("&Red:"), this, "qt_red_lbl" ); + l->setAlignment( AlignRight|AlignVCenter ); + gl->addWidget( l, 0, 3 ); + gl->addWidget( rEd, 0, 4 ); + + gEd = new TQColNumLineEdit( this, "qt_grn_edit" ); + gEd->setValidator( val256 ); + l = new TQLabel( gEd, TQColorDialog::tr("&Green:"), this, "qt_grn_lbl" ); + l->setAlignment( AlignRight|AlignVCenter ); + gl->addWidget( l, 1, 3 ); + gl->addWidget( gEd, 1, 4 ); + + bEd = new TQColNumLineEdit( this, "qt_blue_edit" ); + bEd->setValidator( val256 ); + l = new TQLabel( bEd, TQColorDialog::tr("Bl&ue:"), this, "qt_blue_lbl" ); + l->setAlignment( AlignRight|AlignVCenter ); + gl->addWidget( l, 2, 3 ); + gl->addWidget( bEd, 2, 4 ); + + alphaEd = new TQColNumLineEdit( this, "qt_aplha_edit" ); + alphaEd->setValidator( val256 ); + alphaLab = new TQLabel( alphaEd, TQColorDialog::tr("A&lpha channel:"), this, "qt_alpha_lbl" ); + alphaLab->setAlignment( AlignRight|AlignVCenter ); + gl->addMultiCellWidget( alphaLab, 3, 3, 1, 3 ); + gl->addWidget( alphaEd, 3, 4 ); + alphaEd->hide(); + alphaLab->hide(); + + connect( hEd, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(hsvEd()) ); + connect( sEd, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(hsvEd()) ); + connect( vEd, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(hsvEd()) ); + + connect( rEd, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(rgbEd()) ); + connect( gEd, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(rgbEd()) ); + connect( bEd, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(rgbEd()) ); + connect( alphaEd, TQ_SIGNAL(textChanged(const TQString&)), this, TQ_SLOT(rgbEd()) ); +} + +void TQColorShower::showCurrentColor() +{ + lab->setColor( currentColor() ); + lab->repaint(FALSE); //### +} + +void TQColorShower::rgbEd() +{ + rgbOriginal = TRUE; + if ( alphaEd->isVisible() ) + curCol = tqRgba( rEd->val(), gEd->val(), bEd->val(), currentAlpha() ); + else + curCol = tqRgb( rEd->val(), gEd->val(), bEd->val() ); + + rgb2hsv(currentColor(), hue, sat, val ); + + hEd->setNum( hue ); + sEd->setNum( sat ); + vEd->setNum( val ); + + showCurrentColor(); + emit newCol( currentColor() ); +} + +void TQColorShower::hsvEd() +{ + rgbOriginal = FALSE; + hue = hEd->val(); + sat = sEd->val(); + val = vEd->val(); + + curCol = TQColor( hue, sat, val, TQColor::Hsv ).rgb(); + + rEd->setNum( tqRed(currentColor()) ); + gEd->setNum( tqGreen(currentColor()) ); + bEd->setNum( tqBlue(currentColor()) ); + + showCurrentColor(); + emit newCol( currentColor() ); +} + +void TQColorShower::setRgb( TQRgb rgb ) +{ + rgbOriginal = TRUE; + curCol = rgb; + + rgb2hsv( currentColor(), hue, sat, val ); + + hEd->setNum( hue ); + sEd->setNum( sat ); + vEd->setNum( val ); + + rEd->setNum( tqRed(currentColor()) ); + gEd->setNum( tqGreen(currentColor()) ); + bEd->setNum( tqBlue(currentColor()) ); + + showCurrentColor(); +} + +void TQColorShower::setHsv( int h, int s, int v ) +{ + rgbOriginal = FALSE; + hue = h; val = v; sat = s; //Range check### + curCol = TQColor( hue, sat, val, TQColor::Hsv ).rgb(); + + hEd->setNum( hue ); + sEd->setNum( sat ); + vEd->setNum( val ); + + rEd->setNum( tqRed(currentColor()) ); + gEd->setNum( tqGreen(currentColor()) ); + bEd->setNum( tqBlue(currentColor()) ); + + showCurrentColor(); +} + +class TQColorDialogPrivate : public TQObject +{ +TQ_OBJECT +public: + TQColorDialogPrivate( TQColorDialog *p ); + TQRgb currentColor() const { return cs->currentColor(); } + void setCurrentColor( TQRgb rgb ); + + int currentAlpha() const { return cs->currentAlpha(); } + void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); } + void showAlpha( bool b ) { cs->showAlpha( b ); } + +public slots: + void addCustom(); + + void newHsv( int h, int s, int v ); + void newColorTypedIn( TQRgb rgb ); + void newCustom( int, int ); + void newStandard( int, int ); +public: + TQWellArray *custom; + TQWellArray *standard; + + TQColorPicker *cp; + TQColorLuminancePicker *lp; + TQColorShower *cs; + int nextCust; + bool compact; +}; + +//sets all widgets to display h,s,v +void TQColorDialogPrivate::newHsv( int h, int s, int v ) +{ + cs->setHsv( h, s, v ); + cp->setCol( h, s ); + lp->setCol( h, s, v ); +} + +//sets all widgets to display rgb +void TQColorDialogPrivate::setCurrentColor( TQRgb rgb ) +{ + cs->setRgb( rgb ); + newColorTypedIn( rgb ); +} + +//sets all widgets exept cs to display rgb +void TQColorDialogPrivate::newColorTypedIn( TQRgb rgb ) +{ + int h, s, v; + rgb2hsv(rgb, h, s, v ); + cp->setCol( h, s ); + lp->setCol( h, s, v); +} + +void TQColorDialogPrivate::newCustom( int r, int c ) +{ + int i = r+2*c; + setCurrentColor( cusrgb[i] ); + nextCust = i; + if (standard) + standard->setSelected(-1,-1); +} + +void TQColorDialogPrivate::newStandard( int r, int c ) +{ + setCurrentColor( stdrgb[r+c*6] ); + if (custom) + custom->setSelected(-1,-1); +} + +TQColorDialogPrivate::TQColorDialogPrivate( TQColorDialog *dialog ) : + TQObject(dialog) +{ + compact = FALSE; + // small displays (e.g. PDAs cannot fit the full color dialog, + // so just use the color picker. + if ( tqApp->desktop()->width() < 480 || tqApp->desktop()->height() < 350 ) + compact = TRUE; + + nextCust = 0; + const int lumSpace = 3; + int border = 12; + if ( compact ) + border = 6; + TQHBoxLayout *topLay = new TQHBoxLayout( dialog, border, 6 ); + TQVBoxLayout *leftLay = 0; + + if ( !compact ) + leftLay = new TQVBoxLayout( topLay ); + + initRGB(); + + if ( !compact ) { + standard = new TQColorWell( dialog, 6, 8, stdrgb ); + standard->setCellWidth( 28 ); + standard->setCellHeight( 24 ); + TQLabel * lab = new TQLabel( standard, + TQColorDialog::tr( "&Basic colors"), dialog, "qt_basiccolors_lbl" ); + connect( standard, TQ_SIGNAL(selected(int,int)), TQ_SLOT(newStandard(int,int))); + leftLay->addWidget( lab ); + leftLay->addWidget( standard ); + + + leftLay->addStretch(); + + custom = new TQColorWell( dialog, 2, 8, cusrgb ); + custom->setCellWidth( 28 ); + custom->setCellHeight( 24 ); + custom->setAcceptDrops( TRUE ); + + connect( custom, TQ_SIGNAL(selected(int,int)), TQ_SLOT(newCustom(int,int))); + lab = new TQLabel( custom, TQColorDialog::tr( "&Custom colors") , dialog, "qt_custcolors_lbl" ); + leftLay->addWidget( lab ); + leftLay->addWidget( custom ); + + TQPushButton *custbut = + new TQPushButton( TQColorDialog::tr("&Define Custom Colors >>"), + dialog, "qt_def_custcolors_lbl" ); + custbut->setEnabled( FALSE ); + leftLay->addWidget( custbut ); + } else { + // better color picker size for small displays + pWidth = 150; + pHeight = 100; + + custom = 0; + standard = 0; + } + + TQVBoxLayout *rightLay = new TQVBoxLayout( topLay ); + + TQHBoxLayout *pickLay = new TQHBoxLayout( rightLay ); + + + TQVBoxLayout *cLay = new TQVBoxLayout( pickLay ); + cp = new TQColorPicker( dialog, "qt_colorpicker" ); + cp->setFrameStyle( TQFrame::Panel + TQFrame::Sunken ); + cLay->addSpacing( lumSpace ); + cLay->addWidget( cp ); + cLay->addSpacing( lumSpace ); + + lp = new TQColorLuminancePicker( dialog, "qt_luminance_picker" ); + lp->setFixedWidth( 20 ); //### + pickLay->addWidget( lp ); + + connect( cp, TQ_SIGNAL(newCol(int,int)), lp, TQ_SLOT(setCol(int,int)) ); + connect( lp, TQ_SIGNAL(newHsv(int,int,int)), this, TQ_SLOT(newHsv(int,int,int)) ); + + rightLay->addStretch(); + + cs = new TQColorShower( dialog, "qt_colorshower" ); + connect( cs, TQ_SIGNAL(newCol(TQRgb)), this, TQ_SLOT(newColorTypedIn(TQRgb))); + rightLay->addWidget( cs ); + + TQHBoxLayout *buttons; + if ( compact ) + buttons = new TQHBoxLayout( rightLay ); + else + buttons = new TQHBoxLayout( leftLay ); + + TQPushButton *ok, *cancel; + ok = new TQPushButton( TQColorDialog::tr("OK"), dialog, "qt_ok_btn" ); + connect( ok, TQ_SIGNAL(clicked()), dialog, TQ_SLOT(accept()) ); + ok->setDefault(TRUE); + cancel = new TQPushButton( TQColorDialog::tr("Cancel"), dialog, "qt_cancel_btn" ); + connect( cancel, TQ_SIGNAL(clicked()), dialog, TQ_SLOT(reject()) ); + buttons->addWidget( ok ); + buttons->addWidget( cancel ); + buttons->addStretch(); + + if ( !compact ) { + TQPushButton *addCusBt = new TQPushButton( + TQColorDialog::tr("&Add to Custom Colors"), + dialog, "qt_add_btn" ); + rightLay->addWidget( addCusBt ); + connect( addCusBt, TQ_SIGNAL(clicked()), this, TQ_SLOT(addCustom()) ); + } +} + +void TQColorDialogPrivate::addCustom() +{ + cusrgb[nextCust] = cs->currentColor(); + if (custom) + custom->repaintContents( FALSE ); + nextCust = (nextCust+1) % 16; +} + + +/*! + \class TQColorDialog tqcolordialog.h + \brief The TQColorDialog class provides a dialog widget for specifying colors. + \mainclass + \ingroup dialogs + \ingroup graphics + + The color dialog's function is to allow users to choose colors. + For example, you might use this in a drawing program to allow the + user to set the brush color. + + The static functions provide modal color dialogs. + \omit + If you require a modeless dialog, use the TQColorDialog constructor. + \endomit + + The static getColor() function shows the dialog and allows the + user to specify a color. The getRgba() function does the same but + also allows the user to specify a color with an alpha channel + (transparency) value. + + The user can store customCount() different custom colors. The + custom colors are shared by all color dialogs, and remembered + during the execution of the program. Use setCustomColor() to set + the custom colors, and use customColor() to get them. + + \img tqcolordlg-w.png +*/ + +/*! + Constructs a default color dialog with parent \a parent and called + \a name. If \a modal is TRUE the dialog will be modal. Use + setColor() to set an initial value. + + \sa getColor() +*/ + +TQColorDialog::TQColorDialog(TQWidget* parent, const char* name, bool modal) : + TQDialog(parent, name, modal, ( WType_Dialog | WStyle_Customize | WStyle_Title | + WStyle_DialogBorder | WStyle_SysMenu ) ) +{ + setSizeGripEnabled( FALSE ); + d = new TQColorDialogPrivate( this ); + +#ifndef TQT_NO_SETTINGS + if ( !customSet ) { + TQSettings settings; + settings.insertSearchPath( TQSettings::Windows, "/Trolltech" ); + for ( int i = 0; i < 2*8; ++i ) { + bool ok = FALSE; + TQRgb rgb = (TQRgb)settings.readNumEntry( "/TQt/customColors/" + TQString::number( i ), 0, &ok ); + if ( ok ) + cusrgb[i] = rgb; + } + } +#endif +} + +/*! + Pops up a modal color dialog, lets the user choose a color, and + returns that color. The color is initially set to \a initial. The + dialog is a child of \a parent and is called \a name. It returns + an invalid (see TQColor::isValid()) color if the user cancels the + dialog. All colors allocated by the dialog will be deallocated + before this function returns. +*/ + +TQColor TQColorDialog::getColor( const TQColor& initial, TQWidget *parent, + const char *name ) +{ +#if defined(TQ_WS_X11) + if( TQTDEIntegration::enabled()) + return TQTDEIntegration::getColor( initial, parent, name ); +#elif defined(TQ_WS_MAC) + return macGetColor(initial, parent, name); +#endif + + int allocContext = TQColor::enterAllocContext(); + TQColorDialog *dlg = new TQColorDialog( parent, name, TRUE ); //modal +#ifndef TQT_NO_WIDGET_TOPEXTRA + dlg->setCaption( TQColorDialog::tr( "Select color" ) ); +#endif + dlg->setColor( initial ); + dlg->selectColor( initial ); + int resultCode = dlg->exec(); + TQColor::leaveAllocContext(); + TQColor result; + if ( resultCode == TQDialog::Accepted ) + result = dlg->color(); + TQColor::destroyAllocContext(allocContext); + delete dlg; + return result; +} + + +/*! + Pops up a modal color dialog to allow the user to choose a color + and an alpha channel (transparency) value. The color+alpha is + initially set to \a initial. The dialog is a child of \a parent + and called \a name. + + If \a ok is non-null, \e *\a ok is set to TRUE if the user clicked + OK, and to FALSE if the user clicked Cancel. + + If the user clicks Cancel, the \a initial value is returned. +*/ + +TQRgb TQColorDialog::getRgba( TQRgb initial, bool *ok, + TQWidget *parent, const char* name ) +{ +#if defined(TQ_WS_MAC) + if( TQTDEIntegration::enabled()) { + TQColor color = TQTDEIntegration::getColor( TQColor( initial ), parent, name ); + if( ok ) + *ok = color.isValid(); + return color.rgba(); + } +#elif defined(TQ_WS_MAC) + return macGetRgba(initial, ok, parent, name); +#endif + + int allocContext = TQColor::enterAllocContext(); + TQColorDialog *dlg = new TQColorDialog( parent, name, TRUE ); //modal + + TQ_CHECK_PTR( dlg ); +#ifndef TQT_NO_WIDGET_TOPEXTRA + dlg->setCaption( TQColorDialog::tr( "Select color" ) ); +#endif + dlg->setColor( initial ); + dlg->selectColor( initial ); + dlg->setSelectedAlpha( tqAlpha(initial) ); + int resultCode = dlg->exec(); + TQColor::leaveAllocContext(); + TQRgb result = initial; + if ( resultCode == TQDialog::Accepted ) { + TQRgb c = dlg->color().rgb(); + int alpha = dlg->selectedAlpha(); + result = tqRgba( tqRed(c), tqGreen(c), tqBlue(c), alpha ); + } + if ( ok ) + *ok = resultCode == TQDialog::Accepted; + + TQColor::destroyAllocContext(allocContext); + delete dlg; + return result; +} + + + + + +/*! + Returns the color currently selected in the dialog. + + \sa setColor() +*/ + +TQColor TQColorDialog::color() const +{ + return TQColor(d->currentColor()); +} + + +/*! + Destroys the dialog and frees any memory it allocated. +*/ + +TQColorDialog::~TQColorDialog() +{ +#ifndef TQT_NO_SETTINGS + if ( !customSet ) { + TQSettings settings; + settings.insertSearchPath( TQSettings::Windows, "/Trolltech" ); + for ( int i = 0; i < 2*8; ++i ) + settings.writeEntry( "/TQt/customColors/" + TQString::number( i ), (int)cusrgb[i] ); + } +#endif +} + + +/*! + Sets the color shown in the dialog to \a c. + + \sa color() +*/ + +void TQColorDialog::setColor( const TQColor& c ) +{ + d->setCurrentColor( c.rgb() ); +} + + + + +/*! + Sets the initial alpha channel value to \a a, and shows the alpha + channel entry box. +*/ + +void TQColorDialog::setSelectedAlpha( int a ) +{ + d->showAlpha( TRUE ); + d->setCurrentAlpha( a ); +} + + +/*! + Returns the value selected for the alpha channel. +*/ + +int TQColorDialog::selectedAlpha() const +{ + return d->currentAlpha(); +} + +/*! + Sets focus to the corresponding button, if any. +*/ +bool TQColorDialog::selectColor( const TQColor& col ) +{ + TQRgb color = col.rgb(); + int i = 0, j = 0; + // Check standard colors + if (d->standard) { + for ( i = 0; i < 6; i++ ) { + for ( j = 0; j < 8; j++ ) { + if ( color == stdrgb[i + j*6] ) { + d->newStandard( i, j ); + d->standard->setCurrent( i, j ); + d->standard->setSelected( i, j ); + d->standard->setFocus(); + return TRUE; + } + } + } + } + // Check custom colors + if (d->custom) { + for ( i = 0; i < 2; i++ ) { + for ( j = 0; j < 8; j++ ) { + if ( color == cusrgb[i + j*2] ) { + d->newCustom( i, j ); + d->custom->setCurrent( i, j ); + d->custom->setSelected( i, j ); + d->custom->setFocus(); + return TRUE; + } + } + } + } + return FALSE; +} + +#include "tqcolordialog.moc" + +#endif diff --git a/src/dialogs/tqcolordialog.h b/src/dialogs/tqcolordialog.h new file mode 100644 index 000000000..0941a020d --- /dev/null +++ b/src/dialogs/tqcolordialog.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Definition of TQColorDialog class +** +** Created : 990222 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the dialogs module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQCOLORDIALOG_H +#define TQCOLORDIALOG_H + +#ifndef QT_H +#include "ntqdialog.h" +#endif // QT_H + +#ifndef TQT_NO_COLORDIALOG + +class TQColorDialogPrivate; + +class TQ_EXPORT TQColorDialog : public TQDialog +{ + TQ_OBJECT + +public: + static TQColor getColor( const TQColor& init = white, TQWidget* parent=0, const char* name=0 ); + static TQRgb getRgba( TQRgb, bool* ok = 0, + TQWidget* parent=0, const char* name=0 ); + + static int customCount(); + static TQRgb customColor( int ); + static void setCustomColor( int, TQRgb ); + static void setStandardColor( int, TQRgb ); + +private: + ~TQColorDialog(); + TQColorDialog( TQWidget* parent=0, const char* name=0, bool modal=FALSE ); + + void setColor( const TQColor& ); + TQColor color() const; + + bool selectColor( const TQColor& ); + + void setSelectedAlpha( int ); + int selectedAlpha() const; + + void showCustom( bool=TRUE ); + +private: // Disabled copy constructor and operator= + TQColorDialogPrivate *d; + friend class TQColorDialogPrivate; + friend class TQColorShower; + +#if defined(TQ_DISABLE_COPY) + TQColorDialog( const TQColorDialog & ); + TQColorDialog& operator=( const TQColorDialog & ); +#endif +}; + +#endif + +#endif //TQCOLORDIALOG_H diff --git a/src/dialogs/tqfiledialog.cpp b/src/dialogs/tqfiledialog.cpp index 711ce2a73..194d7478a 100644 --- a/src/dialogs/tqfiledialog.cpp +++ b/src/dialogs/tqfiledialog.cpp @@ -79,7 +79,7 @@ #include "tqmime.h" #include "tqnetworkprotocol.h" #include "tqobjectlist.h" -#include "ntqpainter.h" +#include "tqpainter.h" #include "tqpopupmenu.h" #include "ntqprogressbar.h" #include "tqptrvector.h" diff --git a/src/dialogs/tqfontdialog.cpp b/src/dialogs/tqfontdialog.cpp new file mode 100644 index 000000000..8e7999a2b --- /dev/null +++ b/src/dialogs/tqfontdialog.cpp @@ -0,0 +1,841 @@ +/**************************************************************************** +** +** Implementation of TQFontDialog +** +** Created : 970605 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the dialogs module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "ntqwindowdefs.h" + +#ifndef TQT_NO_FONTDIALOG + +#include "tqfontdialog.h" + +#include "ntqlineedit.h" +#include "ntqlistbox.h" +#include "ntqpushbutton.h" +#include "ntqcheckbox.h" +#include "ntqcombobox.h" +#include "ntqlayout.h" +#include "ntqvgroupbox.h" +#include "ntqhgroupbox.h" +#include "ntqlabel.h" +#include "ntqapplication.h" +#include "tqfontdatabase.h" +#include "tqstyle.h" +#include +#include + +#ifdef TQ_WS_X11 +#include "private/tqttdeintegration_x11_p.h" +#endif + +/*! + \class TQFontDialog tqfontdialog.h + \ingroup dialogs + \mainclass + \brief The TQFontDialog class provides a dialog widget for selecting a font. + + The usual way to use this class is to call one of the static convenience + functions, e.g. getFont(). + + Examples: + + \code + bool ok; + TQFont font = TQFontDialog::getFont( + &ok, TQFont( "Helvetica [Cronyx]", 10 ), this ); + if ( ok ) { + // font is set to the font the user selected + } else { + // the user canceled the dialog; font is set to the initial + // value, in this case Helvetica [Cronyx], 10 + } + \endcode + + The dialog can also be used to set a widget's font directly: + \code + myWidget.setFont( TQFontDialog::getFont( 0, myWidget.font() ) ); + \endcode + If the user clicks OK the font they chose will be used for myWidget, + and if they click Cancel the original font is used. + + \sa TQFont TQFontInfo TQFontMetrics + + +*/ + +class TQFontDialogPrivate +{ +public: + TQFontDialogPrivate() : script( TQFontPrivate::defaultScript ) {}; + TQLabel * familyAccel; + TQLineEdit * familyEdit; + TQListBox * familyList; + + TQLabel * styleAccel; + TQLineEdit * styleEdit; + TQListBox * styleList; + + TQLabel * sizeAccel; + TQLineEdit * sizeEdit; + TQListBox * sizeList; + + TQVGroupBox * effects; + TQCheckBox * strikeout; + TQCheckBox * underline; + TQComboBox * color; + + TQHGroupBox * sample; + TQLineEdit * sampleEdit; + + TQLabel * scriptAccel; + TQComboBox * scriptCombo; + + TQPushButton * ok; + TQPushButton * cancel; + + TQBoxLayout * buttonLayout; + TQBoxLayout * effectsLayout; + TQBoxLayout * sampleLayout; + TQBoxLayout * sampleEditLayout; + + TQFontDatabase fdb; + + TQString family; + TQFont::Script script; + TQString style; + int size; + + bool smoothScalable; +}; + + +/*! + \internal + Constructs a standard font dialog. + + Use setFont() to set the initial font attributes. + + The \a parent, \a name, \a modal and \a f parameters are passed to + the TQDialog constructor. + + \sa getFont() +*/ + +TQFontDialog::TQFontDialog( TQWidget *parent, const char *name, + bool modal, WFlags f ) + : TQDialog( parent, name, modal, f ) +{ + setSizeGripEnabled( TRUE ); + d = new TQFontDialogPrivate; + // grid + d->familyEdit = new TQLineEdit( this, "font family I" ); + d->familyEdit->setReadOnly( TRUE ); + d->familyList = new TQListBox( this, "font family II" ); + d->familyEdit->setFocusProxy( d->familyList ); + + d->familyAccel + = new TQLabel( d->familyList, tr("&Font"), this, "family accelerator" ); + d->familyAccel->setIndent( 2 ); + + d->styleEdit = new TQLineEdit( this, "font style I" ); + d->styleEdit->setReadOnly( TRUE ); + d->styleList = new TQListBox( this, "font style II" ); + d->styleEdit->setFocusProxy( d->styleList ); + + d->styleAccel + = new TQLabel( d->styleList, tr("Font st&yle"), this, "style accelerator" ); + d->styleAccel->setIndent( 2 ); + + d->sizeEdit = new TQLineEdit( this, "font size I" ); + d->sizeEdit->setFocusPolicy( ClickFocus ); + TQIntValidator *validator = new TQIntValidator( 1, 512, this ); + d->sizeEdit->setValidator( validator ); + d->sizeList = new TQListBox( this, "font size II" ); + + d->sizeAccel + = new TQLabel ( d->sizeEdit, tr("&Size"), this, "size accelerator" ); + d->sizeAccel->setIndent( 2 ); + + // effects box + d->effects = new TQVGroupBox( tr("Effects"), this, "font effects" ); + d->strikeout = new TQCheckBox( d->effects, "strikeout on/off" ); + d->strikeout->setText( tr("Stri&keout") ); + d->underline = new TQCheckBox( d->effects, "underline on/off" ); + d->underline->setText( tr("&Underline") ); + + d->sample = new TQHGroupBox( tr("Sample"), this, "sample text" ); + d->sampleEdit = new TQLineEdit( d->sample, "r/w sample text" ); + d->sampleEdit->setSizePolicy( TQSizePolicy( TQSizePolicy::Ignored, TQSizePolicy::Ignored) ); + d->sampleEdit->setAlignment( AlignCenter ); + // Note that the sample text is *not* translated with tr(), as the + // characters used depend on the charset encoding. + d->sampleEdit->setText( "AaBbYyZz" ); + + d->scriptCombo = new TQComboBox( FALSE, this, "font encoding" ); + + d->scriptAccel + = new TQLabel( d->scriptCombo, tr("Scr&ipt"), this,"encoding label"); + d->scriptAccel->setIndent( 2 ); + + d->size = 0; + d->smoothScalable = FALSE; + + connect( d->scriptCombo, TQ_SIGNAL(activated(int)), + TQ_SLOT(scriptHighlighted(int)) ); + connect( d->familyList, TQ_SIGNAL(highlighted(int)), + TQ_SLOT(familyHighlighted(int)) ); + connect( d->styleList, TQ_SIGNAL(highlighted(int)), + TQ_SLOT(styleHighlighted(int)) ); + connect( d->sizeList, TQ_SIGNAL(highlighted(const TQString&)), + TQ_SLOT(sizeHighlighted(const TQString&)) ); + connect( d->sizeEdit, TQ_SIGNAL(textChanged(const TQString&)), + TQ_SLOT(sizeChanged(const TQString&)) ); + + connect( d->strikeout, TQ_SIGNAL(clicked()), + TQ_SLOT(updateSample()) ); + connect( d->underline, TQ_SIGNAL(clicked()), + TQ_SLOT(updateSample()) ); + + (void)d->familyList->sizeHint(); + (void)d->styleList->sizeHint(); + (void)d->sizeList->sizeHint(); + + for (int i = 0; i < TQFont::NScripts; i++) { + TQString scriptname = TQFontDatabase::scriptName((TQFont::Script) i); + if ( !scriptname.isEmpty() ) + d->scriptCombo->insertItem( scriptname ); + } + + updateFamilies(); + if ( d->familyList->count() != 0 ) + d->familyList->setCurrentItem( 0 ); + + // grid layout + TQGridLayout * mainGrid = new TQGridLayout( this, 9, 6, 12, 0 ); + + mainGrid->addWidget( d->familyAccel, 0, 0 ); + mainGrid->addWidget( d->familyEdit, 1, 0 ); + mainGrid->addWidget( d->familyList, 2, 0 ); + + mainGrid->addWidget( d->styleAccel, 0, 2 ); + mainGrid->addWidget( d->styleEdit, 1, 2 ); + mainGrid->addWidget( d->styleList, 2, 2 ); + + mainGrid->addWidget( d->sizeAccel, 0, 4 ); + mainGrid->addWidget( d->sizeEdit, 1, 4 ); + mainGrid->addWidget( d->sizeList, 2, 4 ); + + mainGrid->setColStretch( 0, 38 ); + mainGrid->setColStretch( 2, 24 ); + mainGrid->setColStretch( 4, 10 ); + + mainGrid->addColSpacing( 1, 6 ); + mainGrid->addColSpacing( 3, 6 ); + mainGrid->addColSpacing( 5, 6 ); + + mainGrid->addRowSpacing( 3, 12 ); + + mainGrid->addWidget( d->effects, 4, 0 ); + + mainGrid->addMultiCellWidget( d->sample, 4, 7, 2, 4 ); + + mainGrid->addWidget( d->scriptAccel, 5, 0 ); + mainGrid->addRowSpacing( 6, 2 ); + mainGrid->addWidget( d->scriptCombo, 7, 0 ); + + mainGrid->addRowSpacing( 8, 12 ); + + TQHBoxLayout *buttonBox = new TQHBoxLayout; + mainGrid->addMultiCell( buttonBox, 9, 9, 0, 4 ); + + buttonBox->addStretch( 1 ); + TQString okt = modal ? tr("OK") : tr("Apply"); + d->ok = new TQPushButton( okt, this, "accept font selection" ); + buttonBox->addWidget( d->ok ); + if ( modal ) + connect( d->ok, TQ_SIGNAL(clicked()), TQ_SLOT(accept()) ); + d->ok->setDefault( TRUE ); + + buttonBox->addSpacing( 12 ); + + TQString cancelt = modal ? tr("Cancel") : tr("Close"); + d->cancel = new TQPushButton( cancelt, this, "cancel/close" ); + buttonBox->addWidget( d->cancel ); + connect( d->cancel, TQ_SIGNAL(clicked()), TQ_SLOT(reject()) ); + + resize( 500, 360 ); + + d->sizeEdit->installEventFilter( this ); + d->familyList->installEventFilter( this ); + d->styleList->installEventFilter( this ); + d->sizeList->installEventFilter( this ); + + d->familyList->setFocus(); +} + +/*! + \internal + Destroys the font dialog and frees up its storage. +*/ + +TQFontDialog::~TQFontDialog() +{ + delete d; + d = 0; +} + +/*! + Executes a modal font dialog and returns a font. + + If the user clicks OK, the selected font is returned. If the user + clicks Cancel, the \a initial font is returned. + + The dialog is called \a name, with the parent \a parent. + \a initial is the initially selected font. + If the \a ok parameter is not-null, \e *\a ok is set to TRUE if the + user clicked OK, and set to FALSE if the user clicked Cancel. + + This static function is less flexible than the full TQFontDialog + object, but is convenient and easy to use. + + Examples: + \code + bool ok; + TQFont font = TQFontDialog::getFont( &ok, TQFont( "Times", 12 ), this ); + if ( ok ) { + // font is set to the font the user selected + } else { + // the user canceled the dialog; font is set to the initial + // value, in this case Times, 12. + } + \endcode + + The dialog can also be used to set a widget's font directly: + \code + myWidget.setFont( TQFontDialog::getFont( 0, myWidget.font() ) ); + \endcode + In this example, if the user clicks OK the font they chose will be + used, and if they click Cancel the original font is used. +*/ +TQFont TQFontDialog::getFont( bool *ok, const TQFont &initial, + TQWidget *parent, const char* name) +{ + return getFont( ok, &initial, parent, name ); +} + +/*! + \overload + + Executes a modal font dialog and returns a font. + + If the user clicks OK, the selected font is returned. If the user + clicks Cancel, the TQt default font is returned. + + The dialog is called \a name, with parent \a parent. + If the \a ok parameter is not-null, \e *\a ok is set to TRUE if the + user clicked OK, and FALSE if the user clicked Cancel. + + This static function is less functional than the full TQFontDialog + object, but is convenient and easy to use. + + Example: + \code + bool ok; + TQFont font = TQFontDialog::getFont( &ok, this ); + if ( ok ) { + // font is set to the font the user selected + } else { + // the user canceled the dialog; font is set to the default + // application font, TQApplication::font() + } + \endcode + +*/ +TQFont TQFontDialog::getFont( bool *ok, TQWidget *parent,const char* name) +{ + return getFont( ok, 0, parent, name ); +} + +extern bool tqt_use_native_dialogs; + +TQFont TQFontDialog::getFont( bool *ok, const TQFont *def, + TQWidget *parent, const char* name) +{ +#if defined(TQ_WS_X11) + if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) + return TQTDEIntegration::getFont( ok, def, parent, name ); +#endif + TQFont result; + if ( def ) + result = *def; + + TQFontDialog *dlg = new TQFontDialog( parent, name, TRUE ); + + dlg->setFont( ( def ? *def : TQFont() ) ); +#ifndef TQT_NO_WIDGET_TOPEXTRA + dlg->setCaption( tr("Select Font") ); +#endif + + bool res = (dlg->exec() == TQDialog::Accepted); + if ( res ) + result = dlg->font(); + if ( ok ) + *ok = res; + delete dlg; + return result; +} + + +/*! + \internal + An event filter to make the Up, Down, PageUp and PageDown keys work + correctly in the line edits. The source of the event is the object + \a o and the event is \a e. +*/ + +bool TQFontDialog::eventFilter( TQObject * o , TQEvent * e ) +{ + if ( e->type() == TQEvent::KeyPress) { + TQKeyEvent * k = (TQKeyEvent *)e; + if ( o == d->sizeEdit && + (k->key() == Key_Up || + k->key() == Key_Down || + k->key() == Key_Prior || + k->key() == Key_Next) ) { + + int ci = d->sizeList->currentItem(); + (void)TQApplication::sendEvent( d->sizeList, k ); + + if ( ci != d->sizeList->currentItem() && + style().styleHint(TQStyle::SH_FontDialog_SelectAssociatedText, this)) + d->sizeEdit->selectAll(); + return TRUE; + } else if ( ( o == d->familyList || o == d->styleList ) && + ( k->key() == Key_Return || k->key() == Key_Enter) ) { + k->accept(); + accept(); + return TRUE; + } + } else if ( e->type() == TQEvent::FocusIn && + style().styleHint(TQStyle::SH_FontDialog_SelectAssociatedText, this) ) { + if ( o == d->familyList ) + d->familyEdit->selectAll(); + else if ( o == d->styleList ) + d->styleEdit->selectAll(); + else if ( o == d->sizeList ) + d->sizeEdit->selectAll(); + } else if ( e->type() == TQEvent::MouseButtonPress && o == d->sizeList ) { + d->sizeEdit->setFocus(); + } + return TQDialog::eventFilter( o, e ); +} + +#ifdef TQ_WS_MAC +// #define SHOW_FONTS_IN_FAMILIES +#endif + +#ifdef SHOW_FONTS_IN_FAMILIES +#include "tqpainter.h" +#include + +class TQListBoxFontText : public TQListBoxText +{ + TQFont cfont; +public: + TQListBoxFontText( const TQString & text ); + ~TQListBoxFontText() { } + + int height( const TQListBox * ) const; + int width( const TQListBox * ) const; + +protected: + void paint( TQPainter * ); +}; + +TQListBoxFontText::TQListBoxFontText( const TQString & text ) + : TQListBoxText(text), cfont(text) +{ +} + +int TQListBoxFontText::height( const TQListBox * ) const +{ + TQFontMetrics fm(cfont); + return TQMAX( fm.lineSpacing() + 2, TQApplication::globalStrut().height() ); +} + +int TQListBoxFontText::width( const TQListBox * ) const +{ + TQFontMetrics fm(cfont); + return TQMAX( fm.width( text() ) + 6, TQApplication::globalStrut().width() ); +} + +void TQListBoxFontText::paint( TQPainter *painter ) +{ + painter->save(); + painter->setFont(cfont); + TQListBoxText::paint(painter); + painter->restore(); +} + +#endif + +/*! + \internal + Updates the contents of the "font family" list box. This + function can be reimplemented if you have special requirements. +*/ + +void TQFontDialog::updateFamilies() +{ + d->familyList->blockSignals( TRUE ); + + enum match_t { MATCH_NONE=0, MATCH_LAST_RESORT=1, MATCH_APP=2, MATCH_FALLBACK, MATCH_FAMILY=3 }; + + TQStringList familyNames = d->fdb.families(d->script); + { + // merge the unicode/unknown family list with the above list. + TQStringList l = d->fdb.families(TQFont::Unicode) + + d->fdb.families(TQFont::UnknownScript); + TQStringList::ConstIterator it = l.begin(), end = l.end(); + for (; it != end; ++it) { + if (! familyNames.contains(*it)) + familyNames << *it; + } + } + + familyNames.sort(); + + d->familyList->clear(); +#ifdef SHOW_FONTS_IN_FAMILIES + TQStringList::Iterator it = familyNames.begin(); + int idx = 0; + for( ; it != familyNames.end() ; ++it ) + d->familyList->insertItem(new TQListBoxFontText(*it), idx++); +#else + d->familyList->insertStringList( familyNames ); +#endif + + TQString foundryName1, familyName1, foundryName2, familyName2; + int bestFamilyMatch = -1; + match_t bestFamilyType = MATCH_NONE; + + TQFont f; + + // ##### do the right thing for a list of family names in the font. + TQFontDatabase::parseFontName(d->family, foundryName1, familyName1); + + TQStringList::Iterator it = familyNames.begin(); + int i = 0; + for( ; it != familyNames.end(); ++it, ++i ) { + + TQFontDatabase::parseFontName(*it, foundryName2, familyName2); + + //try to match.. + if ( familyName1 == familyName2 ) { + bestFamilyType = MATCH_FAMILY; + if ( foundryName1 == foundryName2 ) { + bestFamilyMatch = i; + break; + } + if ( bestFamilyMatch < MATCH_FAMILY ) + bestFamilyMatch = i; + } + + //and try some fall backs + match_t type = MATCH_NONE; + if ( bestFamilyType <= MATCH_NONE && familyName2 == f.lastResortFamily() ) + type = MATCH_LAST_RESORT; + if ( bestFamilyType <= MATCH_LAST_RESORT && familyName2 == f.family() ) + type = MATCH_APP; + // ### add fallback for script + if ( type != MATCH_NONE ) { + bestFamilyType = type; + bestFamilyMatch = i; + } + } + + if (i != -1 && bestFamilyType != MATCH_NONE) + d->familyList->setCurrentItem(bestFamilyMatch); + else + d->familyList->setCurrentItem( 0 ); + d->familyEdit->setText( d->familyList->currentText() ); + if ( style().styleHint(TQStyle::SH_FontDialog_SelectAssociatedText, this) && + d->familyList->hasFocus() ) + d->familyEdit->selectAll(); + + d->familyList->blockSignals( FALSE ); + updateStyles(); +} + +/*! + \internal + Updates the contents of the "font style" list box. This + function can be reimplemented if you have special requirements. +*/ + +void TQFontDialog::updateStyles() +{ + d->styleList->blockSignals( TRUE ); + + d->styleList->clear(); + + TQStringList styles = d->fdb.styles( d->familyList->currentText() ); + + if ( styles.isEmpty() ) { + d->styleEdit->clear(); + d->smoothScalable = FALSE; + } else { + d->styleList->insertStringList( styles ); + + if ( !d->style.isEmpty() ) { + bool found = FALSE; + bool first = TRUE; + TQString cstyle = d->style; + redo: + for ( int i = 0 ; i < (int)d->styleList->count() ; i++ ) { + if ( cstyle == d->styleList->text(i) ) { + d->styleList->setCurrentItem( i ); + found = TRUE; + break; + } + } + if (!found && first) { + if (cstyle.contains("Italic")) { + cstyle.replace("Italic", "Oblique"); + first = FALSE; + goto redo; + } else if (cstyle.contains("Oblique")) { + cstyle.replace("Oblique", "Italic"); + first = FALSE; + goto redo; + } + } + if ( !found ) + d->styleList->setCurrentItem( 0 ); + } + + d->styleEdit->setText( d->styleList->currentText() ); + if ( style().styleHint(TQStyle::SH_FontDialog_SelectAssociatedText, this) && + d->styleList->hasFocus() ) + d->styleEdit->selectAll(); + + d->smoothScalable = d->fdb.isSmoothlyScalable( d->familyList->currentText(), d->styleList->currentText() ); + } + + d->styleList->blockSignals( FALSE ); + + updateSizes(); +} + +/*! + \internal + Updates the contents of the "font size" list box. This + function can be reimplemented if you have special requirements. +*/ + +void TQFontDialog::updateSizes() +{ + d->sizeList->blockSignals( TRUE ); + + d->sizeList->clear(); + + if ( !d->familyList->currentText().isEmpty() ) { + TQValueList sizes = d->fdb.pointSizes( d->familyList->currentText(), d->styleList->currentText() ); + + int i = 0; + bool found = FALSE; + for( TQValueList::iterator it = sizes.begin() ; it != sizes.end(); ++it ) { + d->sizeList->insertItem( TQString::number( *it ) ); + if ( !found && *it >= d->size ) { + d->sizeList->setCurrentItem( i ); + found = TRUE; + } + ++i; + } + if ( !found ) { + // we request a size bigger than the ones in the list, select the biggest one + d->sizeList->setCurrentItem( d->sizeList->count() - 1 ); + } + + d->sizeEdit->blockSignals( TRUE ); + d->sizeEdit->setText( ( d->smoothScalable ? TQString::number( d->size ) : d->sizeList->currentText() ) ); + if ( style().styleHint(TQStyle::SH_FontDialog_SelectAssociatedText, this) && + d->sizeList->hasFocus() ) + d->sizeEdit->selectAll(); + d->sizeEdit->blockSignals( FALSE ); + } else { + d->sizeEdit->clear(); + } + + d->sizeList->blockSignals( FALSE ); + updateSample(); +} + +void TQFontDialog::updateSample() +{ + if ( d->familyList->currentText().isEmpty() ) + d->sampleEdit->clear(); + else + d->sampleEdit->setFont( font() ); +} + +/*! + \internal +*/ +void TQFontDialog::scriptHighlighted( int index ) +{ + d->script = (TQFont::Script)index; + d->sampleEdit->setText( d->fdb.scriptSample( d->script ) ); + updateFamilies(); +} + +/*! + \internal +*/ +void TQFontDialog::familyHighlighted( int i ) +{ + d->family = d->familyList->text( i ); + d->familyEdit->setText( d->family ); + if ( style().styleHint(TQStyle::SH_FontDialog_SelectAssociatedText, this) && + d->familyList->hasFocus() ) + d->familyEdit->selectAll(); + + updateStyles(); +} + + +/*! + \internal +*/ + +void TQFontDialog::styleHighlighted( int index ) +{ + TQString s = d->styleList->text( index ); + d->styleEdit->setText( s ); + if ( style().styleHint(TQStyle::SH_FontDialog_SelectAssociatedText, this) && + d->styleList->hasFocus() ) + d->styleEdit->selectAll(); + + d->style = s; + + updateSizes(); +} + + +/*! + \internal +*/ + +void TQFontDialog::sizeHighlighted( const TQString &s ) +{ + d->sizeEdit->setText( s ); + if ( style().styleHint(TQStyle::SH_FontDialog_SelectAssociatedText, this) && + d->sizeEdit->hasFocus() ) + d->sizeEdit->selectAll(); + + d->size = s.toInt(); + updateSample(); +} + +/*! + \internal + This slot is called if the user changes the font size. + The size is passed in the \a s argument as a \e string. +*/ + +void TQFontDialog::sizeChanged( const TQString &s ) +{ + // no need to check if the conversion is valid, since we have an TQIntValidator in the size edit + int size = s.toInt(); + if ( d->size == size ) + return; + + d->size = size; + if ( d->sizeList->count() != 0 ) { + int i; + for ( i = 0 ; i < (int)d->sizeList->count() - 1 ; i++ ) { + if ( d->sizeList->text(i).toInt() >= d->size ) + break; + } + d->sizeList->blockSignals( TRUE ); + d->sizeList->setCurrentItem( i ); + d->sizeList->blockSignals( FALSE ); + } + updateSample(); +} + +/*! + \internal + Sets the font highlighted in the TQFontDialog to font \a f. + + \sa font() +*/ + +void TQFontDialog::setFont( const TQFont &f ) +{ + d->family = f.family(); + d->style = d->fdb.styleString( f ); + d->size = f.pointSize(); + if ( d->size == -1 ) { + TQFontInfo fi( f ); + d->size = fi.pointSize(); + } + d->strikeout->setChecked( f.strikeOut() ); + d->underline->setChecked( f.underline() ); + + updateFamilies(); +} + +/*! + \internal + Returns the font which the user has chosen. + + \sa setFont() +*/ + +TQFont TQFontDialog::font() const +{ + int pSize = d->sizeEdit->text().toInt(); + + TQFont f = d->fdb.font( d->familyList->currentText(), d->style, pSize ); + f.setStrikeOut( d->strikeout->isChecked() ); + f.setUnderline( d->underline->isChecked() ); + return f; +} + +#endif diff --git a/src/dialogs/tqfontdialog.h b/src/dialogs/tqfontdialog.h new file mode 100644 index 000000000..2c7d3f9d4 --- /dev/null +++ b/src/dialogs/tqfontdialog.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Definition of TQFontDialog +** +** Created : 970605 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the dialogs module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQFONTDIALOG_H +#define TQFONTDIALOG_H + +#include "ntqwindowdefs.h" + +#ifndef TQT_NO_FONTDIALOG + +// +// W A R N I N G +// ------------- +// +// This class is under development and has private constructors. +// +// You may use the public static getFont() functions which are guaranteed +// to be available in the future. +// + +#ifndef QT_H +#include "ntqdialog.h" +#include "tqfont.h" +#endif // QT_H + +class TQFontDialogPrivate; + +class TQ_EXPORT TQFontDialog: public TQDialog +{ + TQ_OBJECT + +public: + static TQFont getFont( bool *ok, const TQFont &def, + TQWidget* parent=0, const char* name=0); + static TQFont getFont( bool *ok, TQWidget* parent=0, const char* name=0); + +private: + static TQFont getFont( bool *ok, const TQFont *def, + TQWidget* parent=0, const char* name=0); + + TQFontDialog( TQWidget* parent=0, const char* name=0, bool modal=FALSE, + WFlags f=0 ); + ~TQFontDialog(); + + TQFont font() const; + void setFont( const TQFont &font ); + + bool eventFilter( TQObject *, TQEvent * ); + + void updateFamilies(); + void updateStyles(); + void updateSizes(); + +private slots: + void sizeChanged( const TQString &); + void familyHighlighted( int ); + void scriptHighlighted( int ); + void styleHighlighted( int ); + void sizeHighlighted( const TQString & ); + void updateSample(); + +private: + friend class TQFontDialogPrivate; + TQFontDialogPrivate * d; + +private: // Disabled copy constructor and operator= +#if defined(TQ_DISABLE_COPY) + TQFontDialog( const TQFontDialog & ); + TQFontDialog& operator=( const TQFontDialog & ); +#endif +}; + +#endif + +#endif // TQFONTDIALOG_H -- cgit v1.2.3