author | zecke <zecke> | 2002-10-14 22:58:11 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-14 22:58:11 (UTC) |
commit | d7290c6b24266303abd95e7f38c0fecae395f355 (patch) (unidiff) | |
tree | f8202b056d9ae8de1cfa818de60ff2929c520f90 /noncore/apps/opie-console/emulation_handler.cpp | |
parent | f5d1ce4b3887e0f09704abad5b9414c9cd90be4b (diff) | |
download | opie-d7290c6b24266303abd95e7f38c0fecae395f355.zip opie-d7290c6b24266303abd95e7f38c0fecae395f355.tar.gz opie-d7290c6b24266303abd95e7f38c0fecae395f355.tar.bz2 |
A small console emulation layer...
And some configuration stuff
fonts are working colors are not fully working
BackGround and ForeGround both are black :(
Diffstat (limited to 'noncore/apps/opie-console/emulation_handler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 89 |
1 files changed, 84 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index 9e7f56c..48218e6 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp | |||
@@ -5,2 +5,3 @@ | |||
5 | 5 | ||
6 | #include "profile.h" | ||
6 | #include "emulation_handler.h" | 7 | #include "emulation_handler.h" |
@@ -31,7 +32,7 @@ EmulationHandler::~EmulationHandler() { | |||
31 | } | 32 | } |
32 | void EmulationHandler::load( const Profile& ) { | 33 | void EmulationHandler::load( const Profile& prof) { |
33 | QFont font = QFont("Fixed", 12, QFont::Normal ); | 34 | m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); |
34 | font.setFixedPitch(TRUE); | 35 | int num = prof.readNumEntry("Color"); |
35 | m_teWid->setVTFont( font ); | 36 | setColor( foreColor(num), backColor(num) ); |
36 | m_teWid->setBackgroundColor(Qt::gray ); | 37 | m_teWid->setBackgroundColor(backColor(num) ); |
37 | } | 38 | } |
@@ -52 +53,79 @@ QWidget* EmulationHandler::widget() { | |||
52 | } | 53 | } |
54 | /* | ||
55 | * allocate a new table of colors | ||
56 | */ | ||
57 | void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { | ||
58 | ColorEntry table[TABLE_COLORS]; | ||
59 | const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); | ||
60 | |||
61 | for (int i = 0; i < TABLE_COLORS; i++ ) { | ||
62 | if ( i == 0 || i == 10 ) { | ||
63 | table[i].color = fore; | ||
64 | }else if ( i == 1 || i == 11 ) { | ||
65 | table[i].color = back; | ||
66 | table[i].transparent = 0; | ||
67 | }else { | ||
68 | table[i].color = defaultCt[i].color; | ||
69 | } | ||
70 | } | ||
71 | // m_teWid->setColorTable(table ); | ||
72 | m_teWid->update(); | ||
73 | } | ||
74 | QFont EmulationHandler::font( int id ) { | ||
75 | QString name; | ||
76 | int size = 0; | ||
77 | switch(id ) { | ||
78 | default: // fall through | ||
79 | case 0: | ||
80 | name = QString::fromLatin1("Micro"); | ||
81 | size = 4; | ||
82 | break; | ||
83 | case 1: | ||
84 | name = QString::fromLatin1("Fixed"); | ||
85 | size = 7; | ||
86 | break; | ||
87 | case 2: | ||
88 | name = QString::fromLatin1("Fixed"); | ||
89 | size = 12; | ||
90 | break; | ||
91 | } | ||
92 | QFont font(name, size, QFont::Normal ); | ||
93 | font.setFixedPitch(TRUE ); | ||
94 | return font; | ||
95 | } | ||
96 | QColor EmulationHandler::foreColor(int col) { | ||
97 | QColor co; | ||
98 | /* we need to switch it */ | ||
99 | switch( col ) { | ||
100 | default: | ||
101 | case Profile::White: | ||
102 | qWarning("Foreground black"); | ||
103 | /* color is black */ | ||
104 | co = Qt::black; | ||
105 | break; | ||
106 | case Profile::Black: | ||
107 | qWarning("Foreground white"); | ||
108 | co = Qt::white; | ||
109 | break; | ||
110 | } | ||
111 | |||
112 | return co; | ||
113 | } | ||
114 | QColor EmulationHandler::backColor(int col ) { | ||
115 | QColor co; | ||
116 | /* we need to switch it */ | ||
117 | switch( col ) { | ||
118 | default: | ||
119 | case Profile::White: | ||
120 | qWarning("Background white"); | ||
121 | /* color is white */ | ||
122 | co = Qt::white; | ||
123 | break; | ||
124 | case Profile::Black: | ||
125 | qWarning("Background black"); | ||
126 | co = Qt::black; | ||
127 | break; | ||
128 | } | ||
129 | |||
130 | return co; | ||
131 | } | ||