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

twin/lib

  • twin
  • lib
kdecoration_p.cpp
1 /*****************************************************************
2 This file is part of the KDE project.
3 
4 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
5 
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS 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 
33 KDecorationOptionsPrivate::KDecorationOptionsPrivate()
34  {
35  for(int i=0; i < NUM_COLORS*2; ++i)
36  cg[i] = NULL;
37  }
38 
39 KDecorationOptionsPrivate::~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 
52 void 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 
66 unsigned 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 
226 KDecorationDefines::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::ColorTitleBar
The color for the titlebar.
Definition: kdecoration.h:114
KDecorationDefines::SettingTooltips
The tooltip setting was changed.
Definition: kdecoration.h:133
KDecorationDefines::ColorFrame
The color for the window frame (border)
Definition: kdecoration.h:118
KDecorationDefines::SettingFont
The titlebar font was changed.
Definition: kdecoration.h:131
KDecorationDefines::SettingColors
The color palette was changed.
Definition: kdecoration.h:130
KDecorationDefines::ColorButtonBg
The color to use for the titlebar buttons.
Definition: kdecoration.h:117
KDecorationDefines::ColorTitleBlend
The blend color for the titlebar.
Definition: kdecoration.h:115
KDecorationDefines::ColorHandle
The color for the resize handle.
Definition: kdecoration.h:119
KDecorationDefines::SettingButtons
The button layout was changed.
Definition: kdecoration.h:132
KDecorationDefines::BorderNormal
Standard size borders, the default setting.
Definition: kdecoration.h:144
KDecorationDefines::BorderSize
BorderSize
Border size.
Definition: kdecoration.h:141
KDecorationDefines::SettingBorder
The border size setting was changed.
Definition: kdecoration.h:134
KDecorationDefines::ColorFont
The titlebar text color.
Definition: kdecoration.h:116

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.8.13
This website is maintained by Timothy Pearson.