Package Camelot :: Package camelot :: Package view :: Package controls :: Module appscheme
[frames] | no frames]

Source Code for Module Camelot.camelot.view.controls.appscheme

  1  #  ============================================================================ 
  2  # 
  3  #  Copyright (C) 2007-2008 Conceptive Engineering bvba. All rights reserved. 
  4  #  www.conceptive.be / project-camelot@conceptive.be 
  5  # 
  6  #  This file is part of the Camelot Library. 
  7  # 
  8  #  This file may be used under the terms of the GNU General Public 
  9  #  License version 2.0 as published by the Free Software Foundation 
 10  #  and appearing in the file LICENSE.GPL included in the packaging of 
 11  #  this file.  Please review the following information to ensure GNU 
 12  #  General Public Licensing requirements will be met: 
 13  #  http://www.trolltech.com/products/qt/opensource.html 
 14  # 
 15  #  If you are unsure which license is appropriate for your use, please 
 16  #  review the following information: 
 17  #  http://www.trolltech.com/products/qt/licensing.html or contact 
 18  #  project-camelot@conceptive.be. 
 19  # 
 20  #  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 
 21  #  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 
 22  # 
 23  #  For use of this library in commercial applications, please contact 
 24  #  project-camelot@conceptive.be 
 25  # 
 26  #  ============================================================================ 
 27   
 28  """Encapsulates various ms office schemes""" 
 29   
 30  Office2003BlueStyle = { 
 31    'SplitterDark' : '(21, 28, 171)', 
 32    'SplitterLight' : '(129, 168, 226)', 
 33    'BorderColor' : '(21, 28, 171)', 
 34    'TextColor' : '(0, 0, 0)', 
 35    'ButtonNormalBegin' : '(201, 223, 251)', 
 36    'ButtonNormalMiddleBegin' : '(165, 196, 239)', 
 37    'ButtonNormalMiddleEnd' : '(165, 196, 239)', 
 38    'ButtonNormalEnd' : '(129, 168, 226)', 
 39    'ButtonMouseOverBegin' : '(255, 253, 216)', 
 40    'ButtonMouseOverMiddleBegin' : '(251, 222, 152)', 
 41    'ButtonMouseOverMiddleEnd' : '(251, 222, 152)', 
 42    'ButtonMouseOverEnd' : '(248, 194, 95)', 
 43    'SelectedTextColor' : '(0, 0, 0)', 
 44    'ButtonSelectedBegin' : '(251, 228, 144)', 
 45    'ButtonSelectedMiddleBegin' : '(245, 190, 85)', 
 46    'ButtonSelectedMiddleEnd' : '(245, 190, 85)', 
 47    'ButtonSelectedEnd' : '(240, 153, 25)', 
 48    'CaptionBegin' : '(201, 223, 251)', 
 49    'CaptionEnd' : '(129, 168, 226)', 
 50    'CaptionDescBegin' : '(201, 223, 251)', 
 51    'CaptionDescEnd' : '(129, 168, 226)', 
 52    'CaptionTextColor' : '(21, 28, 171)', 
 53    'ContextMenuBackColor' : '(253, 250, 255)' 
 54  } 
 55   
 56  Office2003SilverStyle = { 
 57    'SplitterDark' : '(150, 148, 178)', 
 58    'SplitterLight' : '(223, 224, 234)', 
 59    'BorderColor' : '(100, 97, 135)', 
 60    'TextColor' : '(0, 0, 0)', 
 61    'ButtonNormalBegin' : '(223, 224, 234)', 
 62    'ButtonNormalMiddleBegin' : '(190, 190, 209)', 
 63    'ButtonNormalMiddleEnd' : '(190, 190, 209)', 
 64    'ButtonNormalEnd' : '(150, 148, 178)', 
 65    'ButtonMouseOverBegin' : '(255, 253, 216)', 
 66    'ButtonMouseOverMiddleBegin' : '(251, 222, 152)', 
 67    'ButtonMouseOverMiddleEnd' : '(251, 222, 152)', 
 68    'ButtonMouseOverEnd' : '(248, 194, 95)', 
 69    'SelectedTextColor' : '(0, 0, 0)', 
 70    'ButtonSelectedBegin' : '(251, 228, 144)', 
 71    'ButtonSelectedMiddleBegin' : '(245, 190, 85)', 
 72    'ButtonSelectedMiddleEnd' : '(245, 190, 85)', 
 73    'ButtonSelectedEnd' : '(240, 153, 25)', 
 74    'CaptionBegin' : '(223, 224, 234)', 
 75    'CaptionEnd' : '(100, 97, 135)', 
 76    'CaptionDescBegin' : '(223, 224, 234)', 
 77    'CaptionDescEnd' : '(150, 148, 178)', 
 78    'CaptionTextColor' : '(0, 0, 0)', 
 79    'ContextMenuBackColor' : '(253, 250, 255)' 
 80  } 
 81   
 82  Office2003OliveStyle = { 
 83    'SplitterDark' : '(182, 196, 144)', 
 84    'SplitterLight' : '(233, 239, 205)', 
 85    'BorderColor' : '(134, 161, 105)', 
 86    'TextColor' : '(0, 0, 0)', 
 87    'ButtonNormalBegin' : '(233, 239, 205)', 
 88    'ButtonNormalMiddleBegin' : '(208, 218, 176)', 
 89    'ButtonNormalMiddleEnd' : '(208, 218, 176)', 
 90    'ButtonNormalEnd' : '(182, 196, 144)', 
 91    'ButtonMouseOverBegin' : '(255, 253, 216)', 
 92    'ButtonMouseOverMiddleBegin' : '(251, 222, 152)', 
 93    'ButtonMouseOverMiddleEnd' : '(251, 222, 152)', 
 94    'ButtonMouseOverEnd' : '(248, 194, 95)', 
 95    'SelectedTextColor' : '(0, 0, 0)', 
 96    'ButtonSelectedBegin' : '(251, 228, 144)', 
 97    'ButtonSelectedMiddleBegin' : '(245, 190, 85)', 
 98    'ButtonSelectedMiddleEnd' : '(245, 190, 85)', 
 99    'ButtonSelectedEnd' : '(240, 153, 25)', 
100    'CaptionBegin' : '(233, 239, 205)', 
101    'CaptionEnd' : '(134, 161, 105)', 
102    'CaptionDescBegin' : '(233, 239, 205)', 
103    'CaptionDescEnd' : '(182, 196, 144)', 
104    'CaptionTextColor' : '(0, 0, 0)', 
105    'ContextMenuBackColor' : '(253, 250, 255)' 
106  } 
107   
108  Office2007BlueStyle = { 
109    'SplitterDark' : '(192, 219, 255)', 
110    'SplitterLight' : '(227, 239, 255)', 
111    'BorderColor' : '(101, 147, 207)', 
112    'TextColor' : '(32, 77, 137)', 
113    'ButtonNormalBegin' : '(227, 239, 255)', 
114    'ButtonNormalMiddleBegin' : '(196, 221, 255)', 
115    'ButtonNormalMiddleEnd' : '(173, 209, 255)', 
116    'ButtonNormalEnd' : '(192, 219, 255)', 
117    'ButtonMouseOverBegin' : '(255, 254, 228)', 
118    'ButtonMouseOverMiddleBegin' : '(255, 232, 167)', 
119    'ButtonMouseOverMiddleEnd' : '(255, 215, 103)', 
120    'ButtonMouseOverEnd' : '(255, 230, 158)', 
121    'SelectedTextColor' : '(0, 0, 0)', 
122    'ButtonSelectedBegin' : '(255, 217, 170)', 
123    'ButtonSelectedMiddleBegin' : '(255, 187, 110)', 
124    'ButtonSelectedMiddleEnd' : '(255, 171, 63)', 
125    'ButtonSelectedEnd' : '(254, 225, 122)', 
126    'ButtonSelectedOverBegin' : '(255, 189, 105)', 
127    'ButtonSelectedOverMiddleBegin' : '(255, 172, 66)', 
128    'ButtonSelectedOverMiddleEnd' : '(251, 140, 60)', 
129    'ButtonSelectedOverEnd' : '(254, 211, 100)', 
130    'CaptionBegin' : '(227, 239, 255)', 
131    'CaptionEnd' : '(173, 209, 255)', 
132    'CaptionDescBegin' : '(227, 239, 255)', 
133    'CaptionDescEnd' : '(192, 219, 255)', 
134    'CaptionTextColor' : '(21, 66, 139)', 
135    'ContextMenuBackColor' : '(227, 239, 255)' 
136  } 
137   
138  Office2007BlackStyle = { 
139    'SplitterDark' : '(199, 203, 209)', 
140    'SplitterLight' : '(219, 222, 226)', 
141    'BorderColor' : '(76, 83, 92)', 
142    'TextColor' : '(76, 83, 92)', 
143    'ButtonNormalBegin' : '(248, 248, 249)', 
144    'ButtonNormalMiddleBegin' : '(223, 226, 228)', 
145    'ButtonNormalMiddleEnd' : '(199, 203, 209)', 
146    'ButtonNormalEnd' : '(219, 222, 226)', 
147    'ButtonMouseOverBegin' : '(255, 254, 228)', 
148    'ButtonMouseOverMiddleBegin' : '(255, 232, 167)', 
149    'ButtonMouseOverMiddleEnd' : '(255, 215, 103)', 
150    'ButtonMouseOverEnd' : '(255, 230, 158)', 
151    'SelectedTextColor' : '(0, 0, 0)', 
152    'ButtonSelectedBegin' : '(255, 217, 170)', 
153    'ButtonSelectedMiddleBegin' : '(255, 187, 110)', 
154    'ButtonSelectedMiddleEnd' : '(255, 171, 63)', 
155    'ButtonSelectedEnd' : '(254, 225, 122)', 
156    'CaptionBegin' : '(240, 241, 242)', 
157    'CaptionEnd' : '(189, 193, 200)', 
158    'CaptionDescBegin' : '(240, 241, 242)', 
159    'CaptionDescEnd' : '(189, 193, 200)', 
160    'CaptionTextColor' : '(0, 0, 0)', 
161    'ContextMenuBackColor' : '(248, 248, 249)' 
162  } 
163   
164  Office2007SilverStyle = { 
165    'SplitterDark' : '(119, 118, 151)', 
166    'SplitterLight' : '(168, 167, 191)', 
167    'BorderColor' : '(111, 112, 116)', 
168    'TextColor' : '(111, 112, 116)', 
169    'ButtonNormalBegin' : '(235, 238, 250)', 
170    'ButtonNormalMiddleBegin' : '(214, 218, 228)', 
171    'ButtonNormalMiddleEnd' : '(197, 199, 204)', 
172    'ButtonNormalEnd' : '(212, 216, 226)', 
173    'ButtonMouseOverBegin' : '(255, 254, 228)', 
174    'ButtonMouseOverMiddleBegin' : '(255, 232, 167)', 
175    'ButtonMouseOverMiddleEnd' : '(255, 215, 103)', 
176    'ButtonMouseOverEnd' : '(255, 230, 158)', 
177    'SelectedTextColor' : '(0, 0, 0)', 
178    'ButtonSelectedBegin' : '(255, 217, 170)', 
179    'ButtonSelectedMiddleBegin' : '(255, 187, 110)', 
180    'ButtonSelectedMiddleEnd' : '(255, 171, 63)', 
181    'ButtonSelectedEnd' : '(254, 225, 122)', 
182    'CaptionBegin' : '(246, 247, 248)', 
183    'CaptionEnd' : '(218, 223, 230)', 
184    'CaptionDescBegin' : '(246, 247, 248)', 
185    'CaptionDescEnd' : '(218, 223, 230)', 
186    'CaptionTextColor' : '(21, 66, 139)', 
187    'ContextMenuBackColor' : '(235, 238, 250)' 
188  } 
189   
190 -class Scheme(object):
191 - def __init__(self, styledict=Office2007BlueStyle):
192 self.styledict = styledict
193
194 - def color(self, r, g, b):
195 return 'rgb(%s, %s, %s)' % (r, g, b)
196
197 - def bordercolor(self):
198 return 'rgb%(BorderColor)s' % self.styledict
199
200 - def textcolor(self):
201 return 'rgb%(TextColor)s' % self.styledict
202
203 - def selectedcolor(self):
204 return 'rgb%(SelectedTextColor)s' % self.styledict
205
206 - def captiontextcolor(self):
207 return 'rgb%(CaptionTextColor)s' % self.styledict
208
209 - def twocolorgradient(self, rgb1, rgb2):
210 s = 'qlineargradient(spread:pad, ' \ 211 'x1:0.5, y1:0, x2:0.5, y2:1, ' \ 212 'stop:0 rgba%s, 255), ' \ 213 'stop:1 rgba%s, 255))' % (rgb1, rgb2) 214 215 return s
216
217 - def fourcolorgradient(self, rgb1, rgb2, rgb3, rgb4):
218 s = 'qlineargradient(spread:pad, ' \ 219 'x1:0.5, y1:0, x2:0.5, y2:1, ' \ 220 'stop:0 rgba%s, 255), ' \ 221 'stop:0.4 rgba%s, 255), ' \ 222 'stop:0.401 rgba%s, 255), ' \ 223 'stop:1 rgba%s, 255))' % (rgb1, rgb2, rgb3, rgb4) 224 225 return s
226
227 - def normalbackground(self):
228 rgb1 = self.styledict['ButtonNormalBegin'].rstrip(')') 229 rgb2 = self.styledict['ButtonNormalMiddleBegin'].rstrip(')') 230 rgb3 = self.styledict['ButtonNormalMiddleEnd'].rstrip(')') 231 rgb4 = self.styledict['ButtonNormalEnd'].rstrip(')') 232 233 return self.fourcolorgradient(rgb1, rgb2, rgb3, rgb4)
234
235 - def hoveredbackground(self):
236 rgb1 = self.styledict['ButtonMouseOverBegin'].rstrip(')') 237 rgb2 = self.styledict['ButtonMouseOverMiddleBegin'].rstrip(')') 238 rgb3 = self.styledict['ButtonMouseOverMiddleEnd'].rstrip(')') 239 rgb4 = self.styledict['ButtonMouseOverEnd'].rstrip(')') 240 241 return self.fourcolorgradient(rgb1, rgb2, rgb3, rgb4)
242
243 - def selectedbackground(self, inverted=False):
244 if inverted: 245 rgb1 = self.styledict['ButtonSelectedOverBegin'].rstrip(')') 246 rgb2 = self.styledict['ButtonSelectedOverMiddleBegin'].rstrip(')') 247 rgb3 = self.styledict['ButtonSelectedOverMiddleEnd'].rstrip(')') 248 rgb4 = self.styledict['ButtonSelectedOverEnd'].rstrip(')') 249 else: 250 rgb1 = self.styledict['ButtonSelectedBegin'].rstrip(')') 251 rgb2 = self.styledict['ButtonSelectedMiddleBegin'].rstrip(')') 252 rgb3 = self.styledict['ButtonSelectedMiddleEnd'].rstrip(')') 253 rgb4 = self.styledict['ButtonSelectedEnd'].rstrip(')') 254 255 return self.fourcolorgradient(rgb1, rgb2, rgb3, rgb4)
256
257 - def captionbackground(self):
258 rgb1 = self.styledict['CaptionBegin'].rstrip(')') 259 rgb2 = self.styledict['CaptionEnd'].rstrip(')') 260 261 return self.twocolorgradient(rgb1, rgb2)
262 263 scheme = Scheme() 264 defaultUI = Office2007BlueStyle 265