• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • twin/lib
 

twin/lib

  • twin
  • lib
kdecoration_p.cpp
1/*****************************************************************
2This file is part of the KDE project.
3
4Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
5
6Permission is hereby granted, free of charge, to any person obtaining a
7copy of this software and associated documentation files (the "Software"),
8to deal in the Software without restriction, including without limitation
9the rights to use, copy, modify, merge, publish, distribute, sublicense,
10and/or sell copies of the Software, and to permit persons to whom the
11Software is furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22DEALINGS IN THE SOFTWARE.
23******************************************************************/
24
25#include "kdecoration_p.h"
26
27#include <tdeconfig.h>
28#include <tdeglobalsettings.h>
29#include <tqpalette.h>
30#include <tqapplication.h>
31#include <assert.h>
32
33KDecorationOptionsPrivate::KDecorationOptionsPrivate()
34 {
35 for(int i=0; i < NUM_COLORS*2; ++i)
36 cg[i] = NULL;
37 }
38
39KDecorationOptionsPrivate::~KDecorationOptionsPrivate()
40 {
41 int i;
42 for(i=0; i < NUM_COLORS*2; ++i)
43 {
44 if(cg[i])
45 {
46 delete cg[i];
47 cg[i] = NULL;
48 }
49 }
50 }
51
52void KDecorationOptionsPrivate::defaultKWinSettings()
53 {
54 title_buttons_left = "MS";
55 title_buttons_right = "HIAX";
56 custom_button_positions = false;
57 show_tooltips = true;
58 border_size = BorderNormal;
59 cached_border_size = BordersCount; // invalid
60 move_resize_maximized_windows = true;
61 OpMaxButtonRightClick = MaximizeOp;
62 OpMaxButtonMiddleClick = VMaximizeOp;
63 OpMaxButtonLeftClick = HMaximizeOp;
64 }
65
66unsigned long KDecorationOptionsPrivate::updateKWinSettings( TDEConfig* config )
67 {
68 unsigned long changed = 0;
69 TQString old_group = config->group();
70 config->setGroup( "WM" );
71
72// SettingColors
73 TQColor old_colors[NUM_COLORS*2];
74 for( int i = 0;
75 i < NUM_COLORS*2;
76 ++i )
77 old_colors[ i ] = colors[ i ];
78
79 TQPalette pal = TQApplication::palette();
80 // normal colors
81 colors[ColorFrame] = pal.active().background();
82 colors[ColorFrame] = config->readColorEntry("frame", &colors[ColorFrame]);
83 colors[ColorHandle] = colors[ColorFrame];
84 colors[ColorHandle] = config->readColorEntry("handle", &colors[ColorHandle]);
85
86 // full button configuration (background, blend, and foreground
87 if(TQPixmap::defaultDepth() > 8)
88 colors[ColorButtonBg] = colors[ColorFrame].light(130);
89 else
90 colors[ColorButtonBg] = colors[ColorFrame];
91 colors[ColorButtonBg] = config->readColorEntry("activeTitleBtnBg",
92 &colors[ColorFrame]);
93 colors[ColorTitleBar] = pal.active().highlight();
94 colors[ColorTitleBar] = config->readColorEntry("activeBackground",
95 &colors[ColorTitleBar]);
96 if(TQPixmap::defaultDepth() > 8)
97 colors[ColorTitleBlend] = colors[ ColorTitleBar ].dark(110);
98 else
99 colors[ColorTitleBlend] = colors[ ColorTitleBar ];
100 colors[ColorTitleBlend] = config->readColorEntry("activeBlend",
101 &colors[ColorTitleBlend]);
102
103 colors[ColorFont] = pal.active().highlightedText();
104 colors[ColorFont] = config->readColorEntry("activeForeground", &colors[ColorFont]);
105
106 // inactive
107 colors[ColorFrame+NUM_COLORS] = config->readColorEntry("inactiveFrame",
108 &colors[ColorFrame]);
109 colors[ColorTitleBar+NUM_COLORS] = colors[ColorFrame];
110 colors[ColorTitleBar+NUM_COLORS] = config->
111 readColorEntry("inactiveBackground", &colors[ColorTitleBar+NUM_COLORS]);
112
113 if(TQPixmap::defaultDepth() > 8)
114 colors[ColorTitleBlend+NUM_COLORS] = colors[ ColorTitleBar+NUM_COLORS ].dark(110);
115 else
116 colors[ColorTitleBlend+NUM_COLORS] = colors[ ColorTitleBar+NUM_COLORS ];
117 colors[ColorTitleBlend+NUM_COLORS] =
118 config->readColorEntry("inactiveBlend", &colors[ColorTitleBlend+NUM_COLORS]);
119
120 // full button configuration
121 if(TQPixmap::defaultDepth() > 8)
122 colors[ColorButtonBg+NUM_COLORS] = colors[ColorFrame+NUM_COLORS].light(130);
123 else
124 colors[ColorButtonBg+NUM_COLORS] = colors[ColorFrame+NUM_COLORS];
125 colors[ColorButtonBg+NUM_COLORS] =
126 config->readColorEntry("inactiveTitleBtnBg",
127 &colors[ColorButtonBg]);
128
129 colors[ColorHandle+NUM_COLORS] =
130 config->readColorEntry("inactiveHandle", &colors[ColorHandle]);
131
132 colors[ColorFont+NUM_COLORS] = colors[ColorFrame].dark();
133 colors[ColorFont+NUM_COLORS] = config->readColorEntry("inactiveForeground",
134 &colors[ColorFont+NUM_COLORS]);
135
136 for( int i = 0;
137 i < NUM_COLORS*2;
138 ++i )
139 if( old_colors[ i ] != colors[ i ] )
140 changed |= SettingColors;
141
142// SettingFont
143 TQFont old_activeFont = activeFont;
144 TQFont old_inactiveFont = inactiveFont;
145 TQFont old_activeFontSmall = activeFontSmall;
146 TQFont old_inactiveFontSmall = inactiveFontSmall;
147
148 TQFont activeFontGuess = TDEGlobalSettings::windowTitleFont();
149
150 activeFont = config->readFontEntry("activeFont", &activeFontGuess);
151 inactiveFont = config->readFontEntry("inactiveFont", &activeFont);
152
153 activeFontSmall = activeFont;
154 activeFontSmall.setPointSize(activeFont.pointSize() - 2);
155 activeFontSmall = config->readFontEntry("activeFontSmall", &activeFontSmall);
156 inactiveFontSmall = config->readFontEntry("inactiveFontSmall", &activeFontSmall);
157
158 if( old_activeFont != activeFont
159 || old_inactiveFont != inactiveFont
160 || old_activeFontSmall != activeFontSmall
161 || old_inactiveFontSmall != inactiveFontSmall )
162 changed |= SettingFont;
163
164 config->setGroup( "Style" );
165// SettingsButtons
166 TQString old_title_buttons_left = title_buttons_left;
167 TQString old_title_buttons_right = title_buttons_right;
168 bool old_custom_button_positions = custom_button_positions;
169 custom_button_positions = config->readBoolEntry("CustomButtonPositions", false);
170 if (custom_button_positions)
171 {
172 title_buttons_left = config->readEntry("ButtonsOnLeft", "MS");
173 title_buttons_right = config->readEntry("ButtonsOnRight", "HIAX");
174 }
175 else
176 {
177 title_buttons_left = "MS";
178 title_buttons_right = "HIAX";
179 }
180 if( old_custom_button_positions != custom_button_positions
181 || ( custom_button_positions &&
182 ( old_title_buttons_left != title_buttons_left
183 || old_title_buttons_right != title_buttons_right )))
184 changed |= SettingButtons;
185
186// SettingTooltips
187 bool old_show_tooltips = show_tooltips;
188 show_tooltips = config->readBoolEntry("ShowToolTips", true);
189 if( old_show_tooltips != show_tooltips )
190 changed |= SettingTooltips;
191
192// SettingBorder
193
194 BorderSize old_border_size = border_size;
195 int border_size_num = config->readNumEntry( "BorderSize", BorderNormal );
196 if( border_size_num >= 0 && border_size_num < BordersCount )
197 border_size = static_cast< BorderSize >( border_size_num );
198 else
199 border_size = BorderNormal;
200 if( old_border_size != border_size )
201 changed |= SettingBorder;
202 cached_border_size = BordersCount; // invalid
203
204 config->setGroup( "Windows" );
205 bool old_move_resize_maximized_windows = move_resize_maximized_windows;
206 move_resize_maximized_windows = config->readBoolEntry( "MoveResizeMaximizedWindows", false );
207 if( old_move_resize_maximized_windows != move_resize_maximized_windows )
208 changed |= SettingBorder;
209
210// destroy cached values
211 int i;
212 for(i=0; i < NUM_COLORS*2; ++i)
213 {
214 if(cg[i])
215 {
216 delete cg[i];
217 cg[i] = NULL;
218 }
219 }
220
221 config->setGroup( old_group );
222
223 return changed;
224 }
225
226KDecorationDefines::BorderSize KDecorationOptionsPrivate::findPreferredBorderSize( BorderSize size,
227 TQValueList< BorderSize > sizes ) const
228 {
229 for( TQValueList< BorderSize >::ConstIterator it = sizes.begin();
230 it != sizes.end();
231 ++it )
232 if( size <= *it ) // size is either a supported size, or *it is the closest larger supported
233 return *it;
234 return sizes.last(); // size is larger than all supported ones, return largest
235 }
KDecorationDefines::BorderSize
BorderSize
Border size.
Definition: kdecoration.h:142

twin/lib

Skip menu "twin/lib"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

twin/lib

Skip menu "twin/lib"
  • kate
  • libkonq
  • twin
  •   lib
Generated for twin/lib by doxygen 1.9.4
This website is maintained by Timothy Pearson.