aboutsummaryrefslogtreecommitdiff
path: root/util/fbrun/FbRun.hh
diff options
context:
space:
mode:
Diffstat (limited to 'util/fbrun/FbRun.hh')
-rw-r--r--util/fbrun/FbRun.hh89
1 files changed, 89 insertions, 0 deletions
diff --git a/util/fbrun/FbRun.hh b/util/fbrun/FbRun.hh
new file mode 100644
index 0000000..efcd54f
--- /dev/null
+++ b/util/fbrun/FbRun.hh
@@ -0,0 +1,89 @@
1// FbRun.hh
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22// $Id: FbRun.hh,v 1.6 2002/11/15 14:03:14 fluxgen Exp $
23
24#ifndef FBRUN_HH
25#define FBRUN_HH
26
27#include "EventHandler.hh"
28#include "Font.hh"
29
30#include <string>
31#include <vector>
32
33/**
34 Creates and managed a run window
35*/
36class FbRun: public FbTk::EventHandler<XEvent> {
37public:
38 FbRun(int x = 0, int y = 0, size_t width = 200);
39 ~FbRun();
40 void handleEvent(XEvent * const ev);
41 void setText(const std::string &text);
42 void setTitle(const std::string &title);
43 void move(int x, int y);
44 void resize(size_t width, size_t height);
45 size_t height() const { return m_height; }
46 size_t width() const { return m_width; }
47 /// hide window
48 void hide();
49 /// show window
50 void show();
51 /// load and reconfigure for new font
52 bool loadFont(const std::string &fontname);
53 void setForeground(const XColor &color);
54 void setBackground(const XColor &color);
55 void setAntialias(bool val) { m_font.setAntialias(val); }
56 const FbTk::Font &font() const { return m_font; }
57 /// execute command and exit
58 void run(const std::string &execstring);
59 /// is this application done?
60 bool end() const { return m_end; }
61 /**
62 loads history file.
63 @return true on success, else false
64 */
65 bool loadHistory(const char *filename);
66private:
67 void nextHistoryItem();
68 void prevHistoryItem();
69 void drawString(int x, int y, const char *text, size_t len);
70 void getSize(size_t &width, size_t &height);
71 void createWindow(int x, int y, size_t width, size_t height);
72 void redrawLabel();
73 /// set no maximizable for this window
74 void setNoMaximize();
75
76 FbTk::Font m_font; ///< font used to draw command text
77 Window m_win; ///< toplevel window
78 Display *m_display; ///< display connection
79 std::string m_runtext; ///< command to execute
80 size_t m_width, m_height; ///< size of window
81 int m_bevel; ///< distance to window edge from font in pixels
82 GC m_gc; ///< graphic context
83 bool m_end; ///< marks when this object is done
84 std::vector<std::string> m_history; ///< history list of commands
85 size_t m_current_history_item; ///< holds current position in command history
86 std::string m_history_file; ///< holds filename for command history file
87};
88
89#endif // FBRUN_HH