diff options
author | fluxgen <fluxgen> | 2004-09-01 12:41:11 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2004-09-01 12:41:11 (GMT) |
commit | 2455a350e8bccd930e4a2420028f7c7a0f3dff9e (patch) | |
tree | e5512427fc5953c38651c3e41cc30054ce4e7061 /src | |
parent | b29b4adc4aa78b2be63657a938ca78a45250e204 (diff) | |
download | fluxbox_paul-2455a350e8bccd930e4a2420028f7c7a0f3dff9e.zip fluxbox_paul-2455a350e8bccd930e4a2420028f7c7a0f3dff9e.tar.bz2 |
foreground and background color as argument
Diffstat (limited to 'src')
-rw-r--r-- | src/tests/testFont.cc | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/src/tests/testFont.cc b/src/tests/testFont.cc index c450216..e8a3687 100644 --- a/src/tests/testFont.cc +++ b/src/tests/testFont.cc | |||
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: testFont.cc,v 1.6 2003/09/11 16:51:03 fluxgen Exp $ | 22 | // $Id: testFont.cc,v 1.7 2004/09/01 12:41:11 fluxgen Exp $ |
23 | 23 | ||
24 | #include "App.hh" | 24 | #include "App.hh" |
25 | #include "FbWindow.hh" | 25 | #include "FbWindow.hh" |
@@ -38,13 +38,14 @@ using namespace std; | |||
38 | 38 | ||
39 | class App:public FbTk::App, public FbTk::EventHandler { | 39 | class App:public FbTk::App, public FbTk::EventHandler { |
40 | public: | 40 | public: |
41 | App(const char *displayname): | 41 | App(const char *displayname, const string &foreground, const string background): |
42 | FbTk::App(displayname), | 42 | FbTk::App(displayname), |
43 | m_win(DefaultScreen(display()), | 43 | m_win(DefaultScreen(display()), |
44 | 0, 0, 640, 480, KeyPressMask | ExposureMask) { | 44 | 0, 0, 640, 480, KeyPressMask | ExposureMask) { |
45 | 45 | m_background = background; | |
46 | m_foreground = foreground; | ||
46 | m_win.show(); | 47 | m_win.show(); |
47 | m_win.setBackgroundColor(FbTk::Color("white", m_win.screenNumber())); | 48 | m_win.setBackgroundColor(FbTk::Color(background.c_str(), m_win.screenNumber())); |
48 | FbTk::EventManager::instance()->add(*this, m_win); | 49 | FbTk::EventManager::instance()->add(*this, m_win); |
49 | } | 50 | } |
50 | ~App() { | 51 | ~App() { |
@@ -84,7 +85,8 @@ public: | |||
84 | wingc.setForeground(FbTk::Color("red", m_win.screenNumber())); | 85 | wingc.setForeground(FbTk::Color("red", m_win.screenNumber())); |
85 | m_win.drawLine(wingc.gc(), | 86 | m_win.drawLine(wingc.gc(), |
86 | x, y, x + text_w, y); | 87 | x, y, x + text_w, y); |
87 | wingc.setForeground(FbTk::Color("black", m_win.screenNumber())); | 88 | wingc.setForeground(FbTk::Color(m_foreground.c_str(), m_win.screenNumber())); |
89 | cerr<<"text width: "<<m_font.textWidth(m_text.c_str(), m_text.size())<<endl; | ||
88 | m_font.drawText(m_win.drawable(), | 90 | m_font.drawText(m_win.drawable(), |
89 | 0, wingc.gc(), | 91 | 0, wingc.gc(), |
90 | m_text.c_str(), m_text.size(), | 92 | m_text.c_str(), m_text.size(), |
@@ -96,6 +98,7 @@ public: | |||
96 | void setText(const std::string& text) { m_text = text; } | 98 | void setText(const std::string& text) { m_text = text; } |
97 | 99 | ||
98 | private: | 100 | private: |
101 | string m_foreground, m_background; | ||
99 | FbTk::FbWindow m_win; | 102 | FbTk::FbWindow m_win; |
100 | FbTk::Font m_font; | 103 | FbTk::Font m_font; |
101 | string m_text; | 104 | string m_text; |
@@ -106,6 +109,8 @@ int main(int argc, char **argv) { | |||
106 | bool rotate = false; | 109 | bool rotate = false; |
107 | string fontname("fixed"); | 110 | string fontname("fixed"); |
108 | string displayname(""); | 111 | string displayname(""); |
112 | string background("black"); | ||
113 | string foreground("white"); | ||
109 | string text("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.-_¯åäöÅÄÖ^~+=`\"!#¤%&/()=¡@£$½¥{[]}¶½§±"); | 114 | string text("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.-_¯åäöÅÄÖ^~+=`\"!#¤%&/()=¡@£$½¥{[]}¶½§±"); |
110 | for (int a=1; a<argc; ++a) { | 115 | for (int a=1; a<argc; ++a) { |
111 | if (strcmp("-font", argv[a])==0 && a + 1 < argc) { | 116 | if (strcmp("-font", argv[a])==0 && a + 1 < argc) { |
@@ -116,16 +121,32 @@ int main(int argc, char **argv) { | |||
116 | displayname = argv[++a]; | 121 | displayname = argv[++a]; |
117 | } else if (strcmp("-text", argv[a]) == 0 && a + 1 < argc) { | 122 | } else if (strcmp("-text", argv[a]) == 0 && a + 1 < argc) { |
118 | text = argv[++a]; | 123 | text = argv[++a]; |
119 | } else if (strcmp("-rotate", argv[a]) == 0) | 124 | } else if (strcmp("-rotate", argv[a]) == 0) { |
120 | rotate = true; | 125 | rotate = true; |
121 | 126 | } else if (strcmp("-bg", argv[a]) == 0 && a + 1 < argc) { | |
127 | background = argv[++a]; | ||
128 | } else if (strcmp("-fg", argv[a]) == 0 && a + 1 < argc) { | ||
129 | foreground = argv[++a]; | ||
130 | } else if (strcmp("-h", argv[a]) == 0) { | ||
131 | cerr<<"Arguments: "<<endl; | ||
132 | cerr<<"-font <fontname>"<<endl; | ||
133 | cerr<<"-antialias"<<endl; | ||
134 | cerr<<"-display <display>"<<endl; | ||
135 | cerr<<"-text <text>"<<endl; | ||
136 | cerr<<"-rotate"<<endl; | ||
137 | cerr<<"-fg <foreground color>"<<endl; | ||
138 | cerr<<"-bg <background color>"<<endl; | ||
139 | cerr<<"-h"<<endl; | ||
140 | exit(0); | ||
141 | } | ||
142 | |||
122 | } | 143 | } |
123 | 144 | ||
124 | App app(displayname.c_str()); | 145 | App app(displayname.c_str(), foreground, background); |
125 | app.font().setAntialias(antialias); | 146 | app.font().setAntialias(antialias); |
126 | if (!app.font().load(fontname.c_str())) | 147 | if (!app.font().load(fontname.c_str())) |
127 | cerr<<"Failed to load: "<<fontname<<endl; | 148 | cerr<<"Failed to load: "<<fontname<<endl; |
128 | 149 | cerr<<"Setting text: "<<text<<endl; | |
129 | app.setText(text); | 150 | app.setText(text); |
130 | if (rotate) | 151 | if (rotate) |
131 | app.font().rotate(90); | 152 | app.font().rotate(90); |