summaryrefslogtreecommitdiff
path: root/src/FbWinFrameTheme.cc
blob: c0847485c56acc25396581c47dd96bbb01dc0745 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// FbWinFrameTheme.cc for Fluxbox Window Manager
// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

// $Id: FbWinFrameTheme.cc,v 1.5 2003/07/10 11:38:12 fluxgen Exp $

#include "FbWinFrameTheme.hh"
#include "App.hh"

#include <X11/cursorfont.h>

#include <iostream>

FbWinFrameTheme::FbWinFrameTheme(int screen_num): 
    FbTk::Theme(screen_num),
    m_label_focus(*this, "window.label.focus", "Window.Label.Focus"),
    m_label_unfocus(*this, "window.label.unfocus", "Window.Label.Unfocus"),

    m_title_focus(*this, "window.title.focus", "Window.Title.Focus"),
    m_title_unfocus(*this, "window.title.unfocus", "Window.Title.Unfocus"),

    m_handle_focus(*this, "window.handle.focus", "Window.Handle.Focus"),
    m_handle_unfocus(*this, "window.handle.unfocus", "Window.Handle.Unfocus"),

    m_button_focus(*this, "window.button.focus", "Window.Button.Focus"),
    m_button_unfocus(*this, "window.button.unfocus", "Window.Button.Unfocus"),
    m_button_pressed(*this, "window.button.pressed", "Window.Button.Pressed"),
    
    m_grip_focus(*this, "window.grip.focus", "Window.Grip.Focus"),
    m_grip_unfocus(*this, "window.grip.unfocus", "Window.Grip.Unfocus"),
  
    m_label_focus_color(*this, "window.label.focus.textColor", "Window.Label.Focus.TextColor"),
    m_label_unfocus_color(*this, "window.label.unfocus.textColor", "Window.Label.Unfocus.TextColor"),
    
    m_frame_focus_color(*this, "window.frame.focusColor", "Window.Frame.FocusColor"), 
    m_frame_unfocus_color(*this, "window.frame.unfocusColor", "Window.Frame.UnfocusColor"),

    m_button_focus_color(*this, "window.button.focus.picColor", "Window.Button.Focus.PicColor"),
    m_button_unfocus_color(*this, "window.button.unfocus.picColor", "Window.Button.Unfocus.PicColor"),

    m_font(*this, "window.font", "Window.Font"),
    m_textjustify(*this, "window.justify", "Window.Justify"),
    m_shape_place(*this, "window.shape", "Window.Shape") {

    // create GCs
    Display *disp = FbTk::App::instance()->display();
    Window rootwin = RootWindow(disp, screen_num);
    m_label_text_focus_gc = XCreateGC(disp, rootwin, 0, 0);
    m_label_text_unfocus_gc = XCreateGC(disp, rootwin, 0, 0);
    m_button_pic_focus_gc = XCreateGC(disp, rootwin, 0, 0);
    m_button_pic_unfocus_gc = XCreateGC(disp, rootwin, 0, 0);
    // create cursors
    m_cursor_move = XCreateFontCursor(disp, XC_fleur);
    m_cursor_lower_left_angle = XCreateFontCursor(disp, XC_ll_angle);
    m_cursor_lower_right_angle = XCreateFontCursor(disp, XC_lr_angle);

}

FbWinFrameTheme::~FbWinFrameTheme() {
    // destroy GCs
    Display *disp = FbTk::App::instance()->display();
    XFreeGC(disp, m_label_text_focus_gc);
    XFreeGC(disp, m_label_text_unfocus_gc);
    XFreeGC(disp, m_button_pic_focus_gc);
    XFreeGC(disp, m_button_pic_unfocus_gc);
}

void FbWinFrameTheme::reconfigTheme() {

    XGCValues gcv;
    unsigned long gc_value_mask = GCForeground;
    Display *disp = FbTk::App::instance()->display();

    gcv.foreground = m_label_focus_color->pixel();
    XChangeGC(disp, m_label_text_focus_gc, gc_value_mask, &gcv);

    gcv.foreground = m_label_unfocus_color->pixel();
    XChangeGC(disp, m_label_text_unfocus_gc, gc_value_mask, &gcv);

    gcv.foreground = m_button_focus_color->pixel();
    XChangeGC(disp, m_button_pic_focus_gc, gc_value_mask, &gcv);

    gcv.foreground = m_button_unfocus_color->pixel();
    XChangeGC(disp, m_button_pic_unfocus_gc, gc_value_mask, &gcv);

    // notify listeners
    m_theme_change.notify();
}