~ubuntu-branches/ubuntu/trusty/fluxbox/trusty-proposed

« back to all changes in this revision

Viewing changes to src/FbWinFrameTheme.cc

  • Committer: Bazaar Package Importer
  • Author(s): Dmitry E. Oboukhov
  • Date: 2008-07-01 10:38:14 UTC
  • mfrom: (2.1.12 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080701103814-khx2b6il152x9p93
Tags: 1.0.0+deb1-8
* x-dev has been removed from build-depends (out-of-date package).
* Standards-Version bumped to 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// FbWinFrameTheme.cc for Fluxbox Window Manager
2
 
// Copyright (c) 2003 - 2005 Henrik Kinnunen (fluxgen at fluxbox dot 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: FbWinFrameTheme.cc 3865 2005-01-24 18:34:57Z mathias $
23
 
 
24
 
#include "FbWinFrameTheme.hh"
25
 
#include "App.hh"
26
 
 
27
 
#include <X11/cursorfont.h>
28
 
 
29
 
#include <iostream>
30
 
using namespace std;
31
 
 
32
 
FbWinFrameTheme::FbWinFrameTheme(int screen_num): 
33
 
    FbTk::Theme(screen_num),
34
 
    m_label_focus(*this, "window.label.focus", "Window.Label.Focus"),
35
 
    m_label_unfocus(*this, "window.label.unfocus", "Window.Label.Unfocus"),
36
 
    m_label_active(*this, "window.label.active", "Window.Label.Active"),
37
 
 
38
 
    m_title_focus(*this, "window.title.focus", "Window.Title.Focus"),
39
 
    m_title_unfocus(*this, "window.title.unfocus", "Window.Title.Unfocus"),
40
 
 
41
 
    m_handle_focus(*this, "window.handle.focus", "Window.Handle.Focus"),
42
 
    m_handle_unfocus(*this, "window.handle.unfocus", "Window.Handle.Unfocus"),
43
 
 
44
 
    m_button_focus(*this, "window.button.focus", "Window.Button.Focus"),
45
 
    m_button_unfocus(*this, "window.button.unfocus", "Window.Button.Unfocus"),
46
 
    m_button_pressed(*this, "window.button.pressed", "Window.Button.Pressed"),
47
 
    
48
 
    m_grip_focus(*this, "window.grip.focus", "Window.Grip.Focus"),
49
 
    m_grip_unfocus(*this, "window.grip.unfocus", "Window.Grip.Unfocus"),
50
 
  
51
 
    m_label_focus_color(*this, "window.label.focus.textColor", "Window.Label.Focus.TextColor"),
52
 
    m_label_unfocus_color(*this, "window.label.unfocus.textColor", "Window.Label.Unfocus.TextColor"),
53
 
    m_label_active_color(*this, "window.label.active.textColor", "Window.Label.Active.TextColor"),
54
 
    
55
 
    m_button_focus_color(*this, "window.button.focus.picColor", "Window.Button.Focus.PicColor"),
56
 
    m_button_unfocus_color(*this, "window.button.unfocus.picColor", "Window.Button.Unfocus.PicColor"),
57
 
 
58
 
    m_font(*this, "window.font", "Window.Font"),
59
 
    m_textjustify(*this, "window.justify", "Window.Justify"),
60
 
    m_shape_place(*this, "window.roundCorners", "Window.RoundCorners"),
61
 
    m_title_height(*this, "window.title.height", "Window.Title.Height"),
62
 
    m_bevel_width(*this, "window.bevelWidth", "Window.BevelWidth"),
63
 
    m_handle_width(*this, "window.handleWidth", "Window.handleWidth"),
64
 
    m_border(*this, "window", "Window"), // for window.border*
65
 
    m_label_text_focus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)),
66
 
    m_label_text_unfocus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)),
67
 
    m_label_text_active_gc(RootWindow(FbTk::App::instance()->display(), screen_num)),
68
 
    m_button_pic_focus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)),
69
 
    m_button_pic_unfocus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)),
70
 
    m_focused_alpha(255),
71
 
    m_unfocused_alpha(255) {
72
 
 
73
 
    *m_title_height = 0;
74
 
    // set defaults
75
 
    m_font->load("fixed");
76
 
 
77
 
    // create cursors
78
 
    Display *disp = FbTk::App::instance()->display();
79
 
    m_cursor_move = XCreateFontCursor(disp, XC_fleur);
80
 
    m_cursor_lower_left_angle = XCreateFontCursor(disp, XC_ll_angle);
81
 
    m_cursor_lower_right_angle = XCreateFontCursor(disp, XC_lr_angle);
82
 
    m_cursor_upper_right_angle = XCreateFontCursor(disp, XC_ur_angle);
83
 
    m_cursor_upper_left_angle = XCreateFontCursor(disp, XC_ul_angle);
84
 
 
85
 
    reconfigTheme();
86
 
}
87
 
 
88
 
FbWinFrameTheme::~FbWinFrameTheme() {
89
 
 
90
 
}
91
 
 
92
 
bool FbWinFrameTheme::fallback(FbTk::ThemeItem_base &item) {
93
 
    if (item.name() == "window.borderWidth")
94
 
        return FbTk::ThemeManager::instance().loadItem(item, "borderWidth", "BorderWidth");
95
 
    else if (item.name() == "window.borderColor")
96
 
        return FbTk::ThemeManager::instance().loadItem(item, "borderColor", "BorderColor");
97
 
    else if (item.name() == "window.bevelWidth")
98
 
        return FbTk::ThemeManager::instance().loadItem(item, "bevelWidth", "bevelWidth");
99
 
    else if (item.name() == "window.handleWidth")
100
 
        return FbTk::ThemeManager::instance().loadItem(item, "handleWidth", "HandleWidth");
101
 
    else if (item.name() == "window.label.active") {
102
 
        // copy texture
103
 
        *m_label_active = *m_label_unfocus;
104
 
        return true;
105
 
    } else if (item.name() == "window.label.active.textColor") {
106
 
        return FbTk::ThemeManager::instance().loadItem(item, "window.label.unfocus.textColor", 
107
 
                                                       "Window.Label.Unfocus.TextColor");
108
 
    }
109
 
 
110
 
    return false;
111
 
}
112
 
 
113
 
void FbWinFrameTheme::reconfigTheme() {
114
 
    if (*m_bevel_width > 20)
115
 
        *m_bevel_width = 20;
116
 
    else if (*m_bevel_width < 0)
117
 
        *m_bevel_width = 0;
118
 
 
119
 
    if (*m_handle_width > 200)
120
 
        *m_handle_width = 200;
121
 
    else if (*m_handle_width < 0)
122
 
        *m_handle_width = 1;
123
 
 
124
 
    m_label_text_focus_gc.setForeground(*m_label_focus_color);
125
 
    m_label_text_unfocus_gc.setForeground(*m_label_unfocus_color);
126
 
    m_label_text_active_gc.setForeground(*m_label_active_color);
127
 
    m_button_pic_focus_gc.setForeground(*m_button_focus_color);
128
 
    m_button_pic_unfocus_gc.setForeground(*m_button_unfocus_color);
129
 
}
130