From 84c9a6a804814b46dec0c0d56e586d4edfa8ed12 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Wed, 27 Aug 2003 18:05:12 +0000 Subject: using FbTk GContext --- src/SetWorkspaceName.cc | 18 +++++++----------- src/SetWorkspaceName.hh | 5 +++-- src/TextTheme.cc | 14 ++++---------- src/TextTheme.hh | 7 ++++--- 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/SetWorkspaceName.cc b/src/SetWorkspaceName.cc index 1127c3b..32187bb 100644 --- a/src/SetWorkspaceName.cc +++ b/src/SetWorkspaceName.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: SetWorkspaceName.cc,v 1.1 2003/08/26 23:48:19 fluxgen Exp $ +// $Id: SetWorkspaceName.cc,v 1.2 2003/08/27 18:05:12 fluxgen Exp $ #include "SetWorkspaceName.hh" @@ -43,8 +43,7 @@ SetWorkspaceName::SetWorkspaceName(BScreen &screen): m_textbox(*this, m_font, screen.currentWorkspace()->name()), m_label(*this, m_font, "Set workspace name:"), m_font("fixed"), - m_gc(XCreateGC(FbTk::App::instance()->display(), m_textbox.window(), - 0, 0)), + m_gc(m_textbox), m_screen(screen), m_move_x(0), m_move_y(0) { @@ -58,12 +57,12 @@ SetWorkspaceName::SetWorkspaceName(BScreen &screen): m_label.show(); m_textbox.setBackgroundColor(FbTk::Color("white", m_textbox.screenNumber())); - XGCValues gc_val; + FbTk::Color black("black", m_textbox.screenNumber()); - gc_val.foreground = black.pixel(); - XChangeGC(FbTk::App::instance()->display(), m_gc, - GCForeground, &gc_val); - m_textbox.setGC(m_gc); + m_gc.setForeground(black); + + m_textbox.setGC(m_gc.gc()); + m_textbox.moveResize(0, m_label.height(), 200, m_font.height() + 2); m_textbox.show(); @@ -80,9 +79,6 @@ SetWorkspaceName::SetWorkspaceName(BScreen &screen): SetWorkspaceName::~SetWorkspaceName() { FbTk::EventManager::instance()->remove(*this); - if (m_gc) - XFreeGC(FbTk::App::instance()->display(), m_gc); - hide(); } diff --git a/src/SetWorkspaceName.hh b/src/SetWorkspaceName.hh index 50e827f..3d8d010 100644 --- a/src/SetWorkspaceName.hh +++ b/src/SetWorkspaceName.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: SetWorkspaceName.hh,v 1.1 2003/08/26 23:48:19 fluxgen Exp $ +// $Id: SetWorkspaceName.hh,v 1.2 2003/08/27 18:05:12 fluxgen Exp $ #ifndef SETWORKSPACENAME_HH #define SETWORKSPACENAME_HH @@ -27,6 +27,7 @@ #include "FbTk/TextBox.hh" #include "FbTk/TextButton.hh" #include "FbTk/Font.hh" +#include "FbTk/GContext.hh" class BScreen; @@ -47,7 +48,7 @@ private: FbTk::TextBox m_textbox; FbTk::TextButton m_label; FbTk::Font m_font; - GC m_gc; + FbTk::GContext m_gc; BScreen &m_screen; int m_move_x, m_move_y; }; diff --git a/src/TextTheme.cc b/src/TextTheme.cc index 3a18b4b..bebf010 100644 --- a/src/TextTheme.cc +++ b/src/TextTheme.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: TextTheme.cc,v 1.5 2003/08/16 11:33:13 fluxgen Exp $ +// $Id: TextTheme.cc,v 1.6 2003/08/27 18:05:12 fluxgen Exp $ #include "TextTheme.hh" @@ -33,9 +33,7 @@ TextTheme::TextTheme(FbTk::Theme &theme, m_font(theme, name + ".font", altname + ".Font"), m_text_color(theme, name + ".textColor", altname + ".TextColor"), m_justify(theme, name + ".justify", altname + ".Justify"), - m_text_gc(XCreateGC(FbTk::App::instance()->display(), - RootWindow(FbTk::App::instance()->display(), - theme.screenNum()), 0, 0)) { + m_text_gc(RootWindow(FbTk::App::instance()->display(), theme.screenNum())) { *m_justify = FbTk::LEFT; // set default values m_font->load("fixed"); @@ -45,15 +43,11 @@ TextTheme::TextTheme(FbTk::Theme &theme, } TextTheme::~TextTheme() { - if (m_text_gc) - XFreeGC(FbTk::App::instance()->display(), m_text_gc); + } void TextTheme::update() { - XGCValues gcv; - gcv.foreground = m_text_color->pixel(); - XChangeGC(FbTk::App::instance()->display(), m_text_gc, - GCForeground, &gcv); + m_text_gc.setForeground(*m_text_color); } void TextTheme::setAntialias(bool value) { diff --git a/src/TextTheme.hh b/src/TextTheme.hh index 0764aca..d24b201 100644 --- a/src/TextTheme.hh +++ b/src/TextTheme.hh @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: TextTheme.hh,v 1.2 2003/08/13 09:54:30 fluxgen Exp $ +// $Id: TextTheme.hh,v 1.3 2003/08/27 18:05:12 fluxgen Exp $ #ifndef TEXTTHEME_HH #define TEXTTHEME_HH @@ -29,6 +29,7 @@ #include "FbTk/Font.hh" #include "FbTk/Color.hh" #include "FbTk/Text.hh" +#include "FbTk/GContext.hh" class TextTheme { public: @@ -43,12 +44,12 @@ public: const FbTk::Font &font() const { return *m_font; } const FbTk::Color &textColor() const { return *m_text_color; } FbTk::Justify justify() const { return *m_justify; } - GC textGC() const { return m_text_gc; } + GC textGC() const { return m_text_gc.gc(); } private: FbTk::ThemeItem m_font; FbTk::ThemeItem m_text_color; FbTk::ThemeItem m_justify; - GC m_text_gc; + FbTk::GContext m_text_gc; }; #endif // TEXTTHEME_HH -- cgit v0.11.2