From: <si...@us...> - 2010-08-06 13:13:45
|
Revision: 1234 http://qterm.svn.sourceforge.net/qterm/?rev=1234&view=rev Author: sidos Date: 2010-08-06 13:13:38 +0000 (Fri, 06 Aug 2010) Log Message: ----------- chartable test Added Paths: ----------- branches/chartable/ branches/chartable/Makefile branches/chartable/chartable.cpp branches/chartable/chartable.h branches/chartable/chartable.pro branches/chartable/main.cpp Added: branches/chartable/Makefile =================================================================== --- branches/chartable/Makefile (rev 0) +++ branches/chartable/Makefile 2010-08-06 13:13:38 UTC (rev 1234) @@ -0,0 +1,154 @@ +############################################################################# +# Makefile for building: chartable +# Generated by qmake (2.01a) (Qt 4.6.3) on: Fri Aug 6 15:11:55 2010 +# Project: chartable.pro +# Template: app +# Command: c:\Qt\4.6.3\bin\qmake.exe -win32 -o Makefile chartable.pro +############################################################################# + +first: debug +install: debug-install +uninstall: debug-uninstall +MAKEFILE = Makefile +QMAKE = c:\Qt\4.6.3\bin\qmake.exe +DEL_FILE = del +CHK_DIR_EXISTS= if not exist +MKDIR = mkdir +COPY = copy /y +COPY_FILE = $(COPY) +COPY_DIR = xcopy /s /q /y /i +INSTALL_FILE = $(COPY_FILE) +INSTALL_PROGRAM = $(COPY_FILE) +INSTALL_DIR = $(COPY_DIR) +DEL_FILE = del +SYMLINK = +DEL_DIR = rmdir +MOVE = move +CHK_DIR_EXISTS= if not exist +MKDIR = mkdir +SUBTARGETS = \ + debug \ + release + +debug: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug +debug-make_default: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug +debug-make_first: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug first +debug-all: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug all +debug-clean: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug clean +debug-distclean: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug distclean +debug-install: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug install +debug-uninstall: $(MAKEFILE).Debug FORCE + $(MAKE) -f $(MAKEFILE).Debug uninstall +release: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release +release-make_default: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release +release-make_first: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release first +release-all: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release all +release-clean: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release clean +release-distclean: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release distclean +release-install: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release install +release-uninstall: $(MAKEFILE).Release FORCE + $(MAKE) -f $(MAKEFILE).Release uninstall + +Makefile: chartable.pro ..\..\..\Qt\4.6.3\mkspecs\win32-msvc\qmake.conf ..\..\..\Qt\4.6.3\mkspecs\qconfig.pri \ + ..\..\..\Qt\4.6.3\mkspecs\features\qt_functions.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\qt_config.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\exclusive_builds.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\default_pre.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\win32\default_pre.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\debug.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\debug_and_release.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\default_post.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\win32\default_post.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\win32\rtti.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\win32\exceptions.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\win32\stl.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\shared.prf \ + ..\..\..\Qt\4.6.3\mkspecs\win32-msvc\features\incremental.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\warn_on.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\qt.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\win32\thread.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\moc.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\win32\windows.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\resources.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\uic.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\yacc.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\lex.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\incredibuild_xge.prf \ + ..\..\..\Qt\4.6.3\mkspecs\features\include_source_dir.prf \ + c:\Qt\4.6.3\lib\qtmaind.prl + $(QMAKE) -win32 -o Makefile chartable.pro +..\..\..\Qt\4.6.3\mkspecs\qconfig.pri: +..\..\..\Qt\4.6.3\mkspecs\features\qt_functions.prf: +..\..\..\Qt\4.6.3\mkspecs\features\qt_config.prf: +..\..\..\Qt\4.6.3\mkspecs\features\exclusive_builds.prf: +..\..\..\Qt\4.6.3\mkspecs\features\default_pre.prf: +..\..\..\Qt\4.6.3\mkspecs\features\win32\default_pre.prf: +..\..\..\Qt\4.6.3\mkspecs\features\debug.prf: +..\..\..\Qt\4.6.3\mkspecs\features\debug_and_release.prf: +..\..\..\Qt\4.6.3\mkspecs\features\default_post.prf: +..\..\..\Qt\4.6.3\mkspecs\features\win32\default_post.prf: +..\..\..\Qt\4.6.3\mkspecs\features\win32\rtti.prf: +..\..\..\Qt\4.6.3\mkspecs\features\win32\exceptions.prf: +..\..\..\Qt\4.6.3\mkspecs\features\win32\stl.prf: +..\..\..\Qt\4.6.3\mkspecs\features\shared.prf: +..\..\..\Qt\4.6.3\mkspecs\win32-msvc\features\incremental.prf: +..\..\..\Qt\4.6.3\mkspecs\features\warn_on.prf: +..\..\..\Qt\4.6.3\mkspecs\features\qt.prf: +..\..\..\Qt\4.6.3\mkspecs\features\win32\thread.prf: +..\..\..\Qt\4.6.3\mkspecs\features\moc.prf: +..\..\..\Qt\4.6.3\mkspecs\features\win32\windows.prf: +..\..\..\Qt\4.6.3\mkspecs\features\resources.prf: +..\..\..\Qt\4.6.3\mkspecs\features\uic.prf: +..\..\..\Qt\4.6.3\mkspecs\features\yacc.prf: +..\..\..\Qt\4.6.3\mkspecs\features\lex.prf: +..\..\..\Qt\4.6.3\mkspecs\features\incredibuild_xge.prf: +..\..\..\Qt\4.6.3\mkspecs\features\include_source_dir.prf: +c:\Qt\4.6.3\lib\qtmaind.prl: +qmake: qmake_all FORCE + @$(QMAKE) -win32 -o Makefile chartable.pro + +qmake_all: FORCE + +make_default: debug-make_default release-make_default FORCE +make_first: debug-make_first release-make_first FORCE +all: debug-all release-all FORCE +clean: debug-clean release-clean FORCE + -$(DEL_FILE) chartable.exp + -$(DEL_FILE) chartable.pdb + -$(DEL_FILE) chartable.ilk + -$(DEL_FILE) vc*.pdb + -$(DEL_FILE) vc*.idb +distclean: debug-distclean release-distclean FORCE + -$(DEL_FILE) Makefile + +check: first + +debug-mocclean: $(MAKEFILE).Debug + $(MAKE) -f $(MAKEFILE).Debug mocclean +release-mocclean: $(MAKEFILE).Release + $(MAKE) -f $(MAKEFILE).Release mocclean +mocclean: debug-mocclean release-mocclean + +debug-mocables: $(MAKEFILE).Debug + $(MAKE) -f $(MAKEFILE).Debug mocables +release-mocables: $(MAKEFILE).Release + $(MAKE) -f $(MAKEFILE).Release mocables +mocables: debug-mocables release-mocables +FORCE: + +$(MAKEFILE).Debug: Makefile +$(MAKEFILE).Release: Makefile Added: branches/chartable/chartable.cpp =================================================================== --- branches/chartable/chartable.cpp (rev 0) +++ branches/chartable/chartable.cpp 2010-08-06 13:13:38 UTC (rev 1234) @@ -0,0 +1,119 @@ +#include "chartable.h" + +#include <QMouseEvent> +#include <QResizeEvent> +#include <QPainter> + +#include <QtDebug> + +namespace QTerm +{ + +CharTable :: CharTable(QWidget *parent) + : QWidget(parent) +{ + setMouseTracking(true); + maxColumn = 10; + square = 25; + symbols = QString::fromUtf8("+-×÷±∵∴∈≡∝" + "∑∏∪∩∫∮∶∧∨∷" + "≌≈∽\xE2\x89 ≮≯≤≥∞\xE2\x88 " + "〔〕()〈〉《》「」" + "『』〖〗【】[]{}" + "︵︶︹︺︿﹀︽︾﹁﹂" + "﹃﹄︻︼︷︸‘’“”" + "ΑΒΓΔΕΖΗΘΙΚ" + "ΛΜΝΞΟ\xCE ΡΣΤΥ" + "ΦΧΨΩαβγδεζ" + "ηθικλμνξοπ" + "ρστυφχψω㎎" + "℡㎏㎜㎝㎞㎡㏄〾⿰⿱" + "⿲⿳⿴⿵⿶⿷⿸⿹⿺⿻" + "▁▂▃▄▅▆▇█▉▊" + "▋▌▍▎▏▓╱╲╳※" + "─│┌┐└┘├┤┬┴" + "┼↖↗↘↙→←↑↓√" + "▼▽◢◣◥◤╭╮╯╰" + "♂♀☉⊕〇◎〓℉℃㊣" + "☆★◇◆□\xE2\x96 △▲○●" + "⒈⒉⒊⒋⒌⒍⒎⒏⒐⒑" + "⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛" + "⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽" + "\xE2\x91 ②③④⑤⑥⑦⑧⑨⑩" + "\xE3\x88 ㈡㈢㈣㈤㈥㈦㈧㈨㈩" + "ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ" + "\xE2\x85 ⅡⅢⅣⅤⅥⅦⅧⅨⅩ"); +} + +void CharTable ::resizeEvent(QResizeEvent *re) +{ + maxColumn = re->size().width()/square; + setMinimumHeight((symbols.length()/maxColumn + 1)*square); +} + +QSize CharTable :: sizeHint() const +{ + int x = maxColumn*square; + int y = (symbols.length()/maxColumn + 1)*square; + return QSize(x, y); +} + +void CharTable :: mouseMoveEvent(QMouseEvent *me) +{ + int column = me->x()/square; + int row = me->y()/square; + if (hovered == QPoint(column, row)) + return; + QRect oldRect(hovered.x()*square, hovered.y()*square, square, square); + hovered.setX(column); + hovered.setY(row); + QRect newRect(hovered.x()*square, hovered.y()*square, square, square); + update(oldRect.united(newRect)); +} + +void CharTable :: mouseReleaseEvent(QMouseEvent *me) +{ + if (me->button() == Qt::LeftButton) { + int n = (me->y()/square)*maxColumn + me->x()/square; + if (n<symbols.length()) + emit characterSelected(symbols.at(n)); + update(); + } +} + +void CharTable :: paintEvent(QPaintEvent *pe) +{ + QPainter painter(this); + painter.fillRect(pe->rect(), QBrush(Qt::white)); + QRect redrawRect = pe->rect(); + int beginRow = redrawRect.top()/square; + int endRow = redrawRect.bottom()/square; + int beginColumn = redrawRect.left()/square; + int endColumn = redrawRect.right()/square; + QFont font("SimSun",20); + + for (int row = beginRow; row <= endRow; ++row) { + for (int column = beginColumn; column <= endColumn; ++column) { + int n = row*maxColumn + column; + QString text; + if (n < symbols.length()) + text = symbols.at(n); + QRect textRect = QRect(column*square, row*square, square, square); + if (hovered == QPoint(column, row)) { + painter.fillRect(textRect, palette().highlight()); + painter.setPen(palette().highlightedText().color()); + } else { + painter.setPen(QPen(Qt::gray)); + painter.drawRect(textRect); + painter.setPen(QPen(Qt::black)); + } + if (!text.isEmpty()) { + painter.setFont(font); + painter.drawText(textRect, Qt::AlignCenter, text); + } + } + } +} + +} + Added: branches/chartable/chartable.h =================================================================== --- branches/chartable/chartable.h (rev 0) +++ branches/chartable/chartable.h 2010-08-06 13:13:38 UTC (rev 1234) @@ -0,0 +1,36 @@ +#ifndef CHARTABLE_H +#define CHARTABLE_H + +#include <QWidget> + +namespace QTerm +{ + +class CharTable : public QWidget +{ + Q_OBJECT +public: + CharTable (QWidget *parent = 0); + QSize sizeHint() const; + +signals: + void characterSelected(QString); + +protected: + void resizeEvent(QResizeEvent *re); + void mouseMoveEvent(QMouseEvent *me); + void mouseReleaseEvent(QMouseEvent *me); + void paintEvent(QPaintEvent *pe); + +private: + QString symbols; + int maxColumn; + int square; + QPoint hovered; +}; + + + +} + +#endif Added: branches/chartable/chartable.pro =================================================================== --- branches/chartable/chartable.pro (rev 0) +++ branches/chartable/chartable.pro 2010-08-06 13:13:38 UTC (rev 1234) @@ -0,0 +1,12 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Fri Aug 6 15:11:51 2010 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +# Input +HEADERS += chartable.h +SOURCES += chartable.cpp main.cpp Added: branches/chartable/main.cpp =================================================================== --- branches/chartable/main.cpp (rev 0) +++ branches/chartable/main.cpp 2010-08-06 13:13:38 UTC (rev 1234) @@ -0,0 +1,18 @@ +#include "chartable.h" + +#include <QScrollArea> +#include <QApplication> + +int main (int argc, char **argv) +{ + QApplication app(argc, argv); + + QScrollArea scroll; + scroll.setWidgetResizable(true); + QTerm::CharTable table; + scroll.setWidget(&table); + + scroll.show(); + + app.exec(); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |