diff options
Diffstat (limited to 'qt/PlatQt.cpp')
-rw-r--r-- | qt/PlatQt.cpp | 212 |
1 files changed, 106 insertions, 106 deletions
diff --git a/qt/PlatQt.cpp b/qt/PlatQt.cpp index 160ef70..4f63082 100644 --- a/qt/PlatQt.cpp +++ b/qt/PlatQt.cpp @@ -1,22 +1,22 @@ -// This module implements the portability layer for the Qt port of Scintilla. +// This module implements the portability layer for the TQt port of Scintilla. // // Copyright (c) 2006 // Riverbank Computing Limited <[email protected]> // -// This file is part of QScintilla. +// This file is part of TQScintilla. // -// This copy of QScintilla is free software; you can redistribute it and/or +// This copy of TQScintilla is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) any // later version. // -// QScintilla is supplied in the hope that it will be useful, but WITHOUT ANY +// TQScintilla is supplied in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // You should have received a copy of the GNU General Public License along with -// QScintilla; see the file LICENSE. If not, write to the Free Software +// TQScintilla; see the file LICENSE. If not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -24,44 +24,44 @@ #include <stdarg.h> #include <string.h> -#include <qapplication.h> -#include <qwidget.h> -#include <qfont.h> -#include <qpixmap.h> -#include <qimage.h> -#include <qstring.h> -#include <qlistbox.h> -#include <qpopupmenu.h> -#include <qdatetime.h> -#include <qpainter.h> -#include <qcursor.h> -#include <qlibrary.h> +#include <tqapplication.h> +#include <tqwidget.h> +#include <tqfont.h> +#include <tqpixmap.h> +#include <tqimage.h> +#include <tqstring.h> +#include <tqlistbox.h> +#include <tqpopupmenu.h> +#include <tqdatetime.h> +#include <tqpainter.h> +#include <tqcursor.h> +#include <tqlibrary.h> #include "Platform.h" #include "XPM.h" -#include "qextscintillabase.h" +#include "tqextscintillabase.h" // Type convertors. -static QFont *PFont(FontID id) +static TQFont *PFont(FontID id) { - return reinterpret_cast<QFont *>(id); + return reinterpret_cast<TQFont *>(id); } -static QPainter *PSurface(SurfaceID id) +static TQPainter *PSurface(SurfaceID id) { - return reinterpret_cast<QPainter *>(id); + return reinterpret_cast<TQPainter *>(id); } -static QWidget *PWindow(WindowID id) +static TQWidget *PWindow(WindowID id) { - return reinterpret_cast<QWidget *>(id); + return reinterpret_cast<TQWidget *>(id); } -static QPopupMenu *PMenu(MenuID id) +static TQPopupMenu *PMenu(MenuID id) { - return reinterpret_cast<QPopupMenu *>(id); + return reinterpret_cast<TQPopupMenu *>(id); } @@ -73,7 +73,7 @@ Point Point::FromLong(long lpoint) } -// Colour palette management. The Qt interface to colours means this class +// Colour palette management. The TQt interface to colours means this class // doesn't have to do anything. Palette::Palette() { @@ -115,7 +115,7 @@ void Font::Create(const char *faceName,int,int size,bool bold,bool italic,bool) { Release(); - QFont *f = new QFont(); + TQFont *f = new TQFont(); // If name of the font begins with a '-', assume, that it is an XLFD. if (faceName[0] == '-') @@ -194,22 +194,22 @@ public: void SetClip(PRectangle rc); void FlushCachedState() {painter -> flush();} - void SetUnicodeMode(bool unicodeMode_) {unicodeMode = unicodeMode_;} + void SetUnicodeMode(bool tqunicodeMode_) {tqunicodeMode = tqunicodeMode_;} void SetDBCSMode(int codePage) {} void DrawXPM(PRectangle rc,const XPM *xpm); private: - void commonInit(QPainter *painter_,bool mypainter_); + void commonInit(TQPainter *painter_,bool mypainter_); bool setFont(Font &font_); - QString convertText(const char *s,int len); - static QRgb convertQRgb(const ColourAllocated &col, unsigned alpha); - static QColor convertQColor(const ColourAllocated &col, + TQString convertText(const char *s,int len); + static TQRgb convertTQRgb(const ColourAllocated &col, unsigned alpha); + static TQColor convertTQColor(const ColourAllocated &col, unsigned alpha = 0xff); - bool unicodeMode; + bool tqunicodeMode; bool mypainter; - QPainter *painter; + TQPainter *painter; }; Surface *Surface::Allocate() @@ -217,7 +217,7 @@ Surface *Surface::Allocate() return new SurfaceImpl; } -SurfaceImpl::SurfaceImpl() : unicodeMode(false), mypainter(false), painter(0) +SurfaceImpl::SurfaceImpl() : tqunicodeMode(false), mypainter(false), painter(0) { } @@ -226,7 +226,7 @@ SurfaceImpl::~SurfaceImpl() Release(); } -void SurfaceImpl::commonInit(QPainter *painter_,bool mypainter_) +void SurfaceImpl::commonInit(TQPainter *painter_,bool mypainter_) { Release(); @@ -236,7 +236,7 @@ void SurfaceImpl::commonInit(QPainter *painter_,bool mypainter_) void SurfaceImpl::Init(WindowID) { - commonInit(new QPainter(new QWidget()),true); + commonInit(new TQPainter(new TQWidget()),true); } void SurfaceImpl::Init(SurfaceID sid,WindowID) @@ -246,14 +246,14 @@ void SurfaceImpl::Init(SurfaceID sid,WindowID) void SurfaceImpl::InitPixMap(int width,int height,Surface *,WindowID) { - commonInit(new QPainter(new QPixmap(width,height)),true); + commonInit(new TQPainter(new TQPixmap(width,height)),true); } void SurfaceImpl::Release() { if (painter && mypainter) { - QPaintDevice *pd = painter -> device(); + TQPaintDevice *pd = painter -> device(); delete painter; @@ -265,35 +265,35 @@ void SurfaceImpl::Release() void SurfaceImpl::PenColour(ColourAllocated fore) { - painter -> setPen(convertQColor(fore)); + painter -> setPen(convertTQColor(fore)); } void SurfaceImpl::Polygon(Point *pts,int npts,ColourAllocated fore, ColourAllocated back) { - QPointArray qpts(npts); + TQPointArray qpts(npts); for (int i = 0; i < npts; ++i) qpts.setPoint(i,pts[i].x,pts[i].y); - painter -> setPen(convertQColor(fore)); - painter -> setBrush(convertQColor(back)); + painter -> setPen(convertTQColor(fore)); + painter -> setBrush(convertTQColor(back)); painter -> drawPolygon(qpts); } void SurfaceImpl::RectangleDraw(PRectangle rc,ColourAllocated fore, ColourAllocated back) { - painter -> setPen(convertQColor(fore)); - painter -> setBrush(convertQColor(back)); + painter -> setPen(convertTQColor(fore)); + painter -> setBrush(convertTQColor(back)); painter -> drawRect(rc.left,rc.top, rc.right - rc.left,rc.bottom - rc.top); } void SurfaceImpl::FillRectangle(PRectangle rc,ColourAllocated back) { - painter -> setPen(Qt::NoPen); - painter -> setBrush(convertQColor(back)); + painter -> setPen(TQt::NoPen); + painter -> setBrush(convertTQColor(back)); painter -> drawRect(rc.left,rc.top, rc.right - rc.left,rc.bottom - rc.top); } @@ -301,13 +301,13 @@ void SurfaceImpl::FillRectangle(PRectangle rc,ColourAllocated back) void SurfaceImpl::FillRectangle(PRectangle rc,Surface &surfacePattern) { SurfaceImpl &si = static_cast<SurfaceImpl &>(surfacePattern); - QPixmap *pm = static_cast<QPixmap *>(si.painter -> device()); + TQPixmap *pm = static_cast<TQPixmap *>(si.painter -> device()); if (pm) { - QBrush brsh(Qt::black,*pm); + TQBrush brsh(TQt::black,*pm); - painter -> setPen(Qt::NoPen); + painter -> setPen(TQt::NoPen); painter -> setBrush(brsh); painter -> drawRect(rc.left,rc.top, rc.right - rc.left,rc.bottom - rc.top); @@ -319,8 +319,8 @@ void SurfaceImpl::FillRectangle(PRectangle rc,Surface &surfacePattern) void SurfaceImpl::RoundedRectangle(PRectangle rc,ColourAllocated fore, ColourAllocated back) { - painter -> setPen(convertQColor(fore)); - painter -> setBrush(convertQColor(back)); + painter -> setPen(convertTQColor(fore)); + painter -> setBrush(convertTQColor(back)); painter -> drawRoundRect(rc.left,rc.top, rc.right - rc.left,rc.bottom - rc.top); } @@ -332,15 +332,15 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, int w = rc.right - rc.left; int h = rc.bottom - rc.top; - QImage img(w, h, 32); + TQImage img(w, h, 32); - img.fill(convertQRgb(fill, alphaFill)); + img.fill(convertTQRgb(fill, alphaFill)); img.setAlphaBuffer(TRUE); // Assume that "cornerSize" means outline width. if (cornerSize > 0) { - QRgb oline = convertQRgb(outline, alphaOutline); + TQRgb oline = convertTQRgb(outline, alphaOutline); int linew = cornerSize; @@ -371,8 +371,8 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, void SurfaceImpl::Ellipse(PRectangle rc,ColourAllocated fore, ColourAllocated back) { - painter -> setPen(convertQColor(fore)); - painter -> setBrush(convertQColor(back)); + painter -> setPen(convertTQColor(fore)); + painter -> setBrush(convertTQColor(back)); painter -> drawEllipse(rc.left,rc.top, rc.right - rc.left,rc.bottom - rc.top); } @@ -380,8 +380,8 @@ void SurfaceImpl::Ellipse(PRectangle rc,ColourAllocated fore, void SurfaceImpl::Copy(PRectangle rc,Point from,Surface &surfaceSource) { SurfaceImpl &si = static_cast<SurfaceImpl &>(surfaceSource); - QPaintDevice *spd = si.painter -> device(); - QPaintDevice *dpd = painter -> device(); + TQPaintDevice *spd = si.painter -> device(); + TQPaintDevice *dpd = painter -> device(); if (spd && dpd) { @@ -417,17 +417,17 @@ void SurfaceImpl::DrawTextTransparent(PRectangle rc,Font &font_,int ybase, const char *s,int len, ColourAllocated fore) { - QString qs = convertText(s,len); + TQString qs = convertText(s,len); setFont(font_); - painter -> setPen(convertQColor(fore)); + painter -> setPen(convertTQColor(fore)); painter -> drawText(rc.left,ybase,qs); } void SurfaceImpl::DrawXPM(PRectangle rc,const XPM *xpm) { int x, y; - const QPixmap &qpm = xpm -> Pixmap(); + const TQPixmap &qpm = xpm -> Pixmap(); x = rc.left + (rc.Width() - qpm.width()) / 2; y = rc.top + (rc.Height() - qpm.height()) / 2; @@ -441,14 +441,14 @@ void SurfaceImpl::MeasureWidths(Font &font_,const char *s,int len, if (setFont(font_)) { int totalWidth = 0, ui = 0; - QString qs = convertText(s,len); - QFontMetrics fm = painter -> fontMetrics(); + TQString qs = convertText(s,len); + TQFontMetrics fm = painter -> fontMetrics(); for (int i = 0; i < qs.length(); ++i) { totalWidth += fm.width(qs[i]); - int l = (unicodeMode ? QString(qs[i]).utf8().length() : 1); + int l = (tqunicodeMode ? TQString(qs[i]).utf8().length() : 1); while (l--) positions[ui++] = totalWidth; @@ -463,7 +463,7 @@ int SurfaceImpl::WidthText(Font &font_,const char *s,int len) { if (setFont(font_)) { - QString qs = convertText(s,len); + TQString qs = convertText(s,len); return painter -> fontMetrics().width(qs,qs.length()); } @@ -489,7 +489,7 @@ int SurfaceImpl::Ascent(Font &font_) int SurfaceImpl::Descent(Font &font_) { - // Qt doesn't include the baseline in the descent, so add it. + // TQt doesn't include the baseline in the descent, so add it. if (setFont(font_)) return painter -> fontMetrics().descent() + 1; @@ -522,7 +522,7 @@ void SurfaceImpl::SetClip(PRectangle rc) // Set the painter font if there is one. Return true if it was set. bool SurfaceImpl::setFont(Font &font_) { - QFont *f = PFont(font_.GetID()); + TQFont *f = PFont(font_.GetID()); if (f) painter -> setFont(*f); @@ -530,21 +530,21 @@ bool SurfaceImpl::setFont(Font &font_) return f; } -// Convert a Scintilla string to a Qt Unicode string. -QString SurfaceImpl::convertText(const char *s,int len) +// Convert a Scintilla string to a TQt Unicode string. +TQString SurfaceImpl::convertText(const char *s,int len) { - if (unicodeMode) - return QString::fromUtf8(s,len); + if (tqunicodeMode) + return TQString::fromUtf8(s,len); - QString qs; + TQString qs; qs.setLatin1(s,len); return qs; } -// Convert a Scintilla colour and alpha component to a Qt QRgb. -QRgb SurfaceImpl::convertQRgb(const ColourAllocated &col, unsigned alpha) +// Convert a Scintilla colour and alpha component to a TQt TQRgb. +TQRgb SurfaceImpl::convertTQRgb(const ColourAllocated &col, unsigned alpha) { long c = col.AsLong(); @@ -552,15 +552,15 @@ QRgb SurfaceImpl::convertQRgb(const ColourAllocated &col, unsigned alpha) unsigned g = (c >> 8) & 0xff; unsigned b = (c >> 16) & 0xff; - QRgb rgba = (alpha << 24) | (r << 16) | (g << 8) | b; + TQRgb rgba = (alpha << 24) | (r << 16) | (g << 8) | b; return rgba; } -// Convert a Scintilla colour, and optional alpha component, to a Qt QColor. -QColor SurfaceImpl::convertQColor(const ColourAllocated &col, unsigned alpha) +// Convert a Scintilla colour, and optional alpha component, to a TQt TQColor. +TQColor SurfaceImpl::convertTQColor(const ColourAllocated &col, unsigned alpha) { - return QColor(convertQRgb(col, alpha)); + return TQColor(convertTQRgb(col, alpha)); } @@ -571,7 +571,7 @@ Window::~Window() void Window::Destroy() { - QWidget *w = PWindow(id); + TQWidget *w = PWindow(id); if (w) { @@ -587,14 +587,14 @@ bool Window::HasFocus() PRectangle Window::GetPosition() { - QWidget *w = PWindow(id); + TQWidget *w = PWindow(id); // Before any size allocated pretend its big enough not to be scrolled. PRectangle rc(0,0,5000,5000); if (w) { - const QRect &r = w -> geometry(); + const TQRect &r = w -> tqgeometry(); rc.left = r.left(); rc.top = r.top(); @@ -613,8 +613,8 @@ void Window::SetPosition(PRectangle rc) void Window::SetPositionRelative(PRectangle rc,Window relativeTo) { - QWidget *rel = PWindow(relativeTo.id); - QPoint pos = rel -> mapToGlobal(rel -> pos()); + TQWidget *rel = PWindow(relativeTo.id); + TQPoint pos = rel -> mapToGlobal(rel -> pos()); int x = pos.x() + rc.left; int y = pos.y() + rc.top; @@ -629,7 +629,7 @@ PRectangle Window::GetClientPosition() void Window::Show(bool show) { - QWidget *w = PWindow(id); + TQWidget *w = PWindow(id); if (show) w -> show(); @@ -639,7 +639,7 @@ void Window::Show(bool show) void Window::InvalidateAll() { - QWidget *w = PWindow(id); + TQWidget *w = PWindow(id); if (w) w -> update(); @@ -647,7 +647,7 @@ void Window::InvalidateAll() void Window::InvalidateRectangle(PRectangle rc) { - QWidget *w = PWindow(id); + TQWidget *w = PWindow(id); if (w) w -> update(rc.left,rc.top, @@ -661,36 +661,36 @@ void Window::SetFont(Font &font) void Window::SetCursor(Cursor curs) { - Qt::CursorShape qc; + TQt::tqCursorShape qc; switch (curs) { case cursorText: - qc = Qt::IbeamCursor; + qc = TQt::IbeamCursor; break; case cursorUp: - qc = Qt::UpArrowCursor; + qc = TQt::UpArrowCursor; break; case cursorWait: - qc = Qt::WaitCursor; + qc = TQt::WaitCursor; break; case cursorHoriz: - qc = Qt::SizeHorCursor; + qc = TQt::SizeHorCursor; break; case cursorVert: - qc = Qt::SizeVerCursor; + qc = TQt::SizeVerCursor; break; case cursorHand: - qc = Qt::PointingHandCursor; + qc = TQt::PointingHandCursor; break; default: - qc = Qt::ArrowCursor; + qc = TQt::ArrowCursor; } PWindow(id) -> setCursor(qc); @@ -710,12 +710,12 @@ Menu::Menu() : id(0) void Menu::CreatePopUp() { Destroy(); - id = new QPopupMenu(); + id = new TQPopupMenu(); } void Menu::Destroy() { - QPopupMenu *m = PMenu(id); + TQPopupMenu *m = PMenu(id); if (m) { @@ -726,7 +726,7 @@ void Menu::Destroy() void Menu::Show(Point pt,Window &) { - PMenu(id) -> popup(QPoint(pt.x,pt.y)); + PMenu(id) -> popup(TQPoint(pt.x,pt.y)); } @@ -735,7 +735,7 @@ class DynamicLibraryImpl : public DynamicLibrary public: DynamicLibraryImpl(const char *modulePath) { - m = new QLibrary(modulePath); + m = new TQLibrary(modulePath); m -> load(); } @@ -759,7 +759,7 @@ public: } private: - QLibrary* m; + TQLibrary* m; }; DynamicLibrary *DynamicLibrary::Load(const char *modulePath) @@ -772,7 +772,7 @@ DynamicLibrary *DynamicLibrary::Load(const char *modulePath) // less than 48 hours. ElapsedTime::ElapsedTime() { - QTime now = QTime::currentTime(); + TQTime now = TQTime::currentTime(); bigBit = now.hour() * 60 * 60 + now.minute() * 60 + now.second(); littleBit = now.msec(); @@ -781,7 +781,7 @@ ElapsedTime::ElapsedTime() double ElapsedTime::Duration(bool reset) { long endBigBit, endLittleBit; - QTime now = QTime::currentTime(); + TQTime now = TQTime::currentTime(); endBigBit = now.hour() * 60 * 60 + now.minute() * 60 + now.second(); endLittleBit = now.msec(); @@ -816,17 +816,17 @@ ColourDesired Platform::ChromeHighlight() const char *Platform::DefaultFont() { - return QApplication::font().family(); + return TQApplication::font().family(); } int Platform::DefaultFontSize() { - return QApplication::font().pointSize(); + return TQApplication::font().pointSize(); } unsigned int Platform::DoubleClickTime() { - return QApplication::doubleClickInterval(); + return TQApplication::doubleClickInterval(); } bool Platform::MouseButtonBounce() |