[Skencil-commits] r754 - in skencil/branches/skencil-0.6/src/Sketch: Base UI
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sat Oct 9 19:30:51 CEST 2010
Author: igor_n
Date: 2010-10-09 19:30:50 +0200 (Sat, 09 Oct 2010)
New Revision: 754
Modified:
skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py
skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py
skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py
Log:
ruler redesign
Modified: skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py 2010-10-09 01:10:19 UTC (rev 753)
+++ skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py 2010-10-09 17:30:50 UTC (rev 754)
@@ -157,7 +157,7 @@
"""
bg = '#d4d0c8'
- foreground = '#000000'
+ fg = '#000000'
highlightbackground = '#f3f2ef'
highlightcolor = '#b0ada5'
disabledforeground = '#b0ada6'
@@ -241,7 +241,7 @@
"""
self.bg = gtk_colors['bg normal']
- self.foreground = gtk_colors['text normal']
+ self.fg = gtk_colors['text normal']
self.highlightbackground = gtk_colors['bg active']
self.highlightcolor = gtk_colors['fg active']
@@ -276,13 +276,13 @@
widget.tk.call('tk_setPalette', color_scheme.bg)
widget.tk.call('option', 'add', '*background', color_scheme.bg, 'interactive')
- widget.tk.call('option', 'add', '*foreground', color_scheme.foreground, 'interactive')
+ widget.tk.call('option', 'add', '*foreground', color_scheme.fg, 'interactive')
widget.tk.call('option', 'add', '*selectForeground', color_scheme.selectforeground, 'interactive')
widget.tk.call('option', 'add', '*selectBackground', color_scheme.selectbackground, 'interactive')
widget.tk.call('option', 'add', '*highlightBackground', color_scheme.highlightbackground, 'interactive')
widget.tk.call('option', 'add', '*highlightColor', color_scheme.highlightcolor, 'interactive')
widget.tk.call('option', 'add', '*activeBackground', color_scheme.bg, 'interactive')
- widget.tk.call('option', 'add', '*activeForeground', color_scheme.foreground, 'interactive')
+ widget.tk.call('option', 'add', '*activeForeground', color_scheme.fg, 'interactive')
widget.tk.call('option', 'add', '*Menu.activeBackground', color_scheme.selectbackground, 'interactive')
widget.tk.call('option', 'add', '*Menu.activeForeground', color_scheme.selectforeground, 'interactive')
@@ -310,7 +310,7 @@
print tkfont_from_list(['San\ Serif', ['bold', 'italic'], 10])
scheme = ColorScheme()
print scheme.bg
- print scheme.foreground
+ print scheme.fg
print scheme.selectbackground
print scheme.selectforeground
print scheme.normal_border
Modified: skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py 2010-10-09 01:10:19 UTC (rev 753)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py 2010-10-09 17:30:50 UTC (rev 754)
@@ -586,6 +586,9 @@
line = Frame(root, height = 1, bg=Sketch.ui_colors.d3_dark)
line.pack(fill = X)
+ space = Frame(root, height = 3)
+ space.pack(fill = X)
+
self.status_bar = Frame(root, name = 'statusbar')
self.status_bar.pack(side = BOTTOM, fill=X)
Modified: skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py 2010-10-09 01:10:19 UTC (rev 753)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py 2010-10-09 17:30:50 UTC (rev 754)
@@ -22,9 +22,11 @@
import pax
-from Sketch import config, const, GuideLine, Point
+from Sketch import StandardColors, GraphicsDevice, Identity, gtkutils
+from Sketch import config, const, GuideLine, Point, ui_colors
from Sketch.warn import warn, USER
from Sketch.const import CHANGED
+from Sketch.Graphics.color import XRGBColor
from tkext import PyWidget
@@ -43,65 +45,66 @@
#'pt': (72.0, (2, 3, 12)),
}
+HFONT = {'.': (2, [(0, 0, 0, 0)]),
+ ',': (2, [(0, 0, 0, 0)]),
+ '-': (4, [(0, 2, 2, 2)]),
+ '0': (5, [(0, 0, 3, 0), (3, 0, 3, 4), (3, 4, 0, 4), (0, 4, 0, 0)]),
+ '1': (3, [(1, 0, 1, 4), (1, 4, 0, 4)]),
+ '2': (5, [(3, 0, 0, 0), (0, 0, 0, 2), (0, 2, 3, 2), (3, 2, 3, 4), (3, 4, 0, 4)]),
+ '3': (5, [(0, 0, 3, 0), (0, 2, 3, 2), (0, 4, 3, 4), (3, 4, 3, 0)]),
+ '4': (5, [(0, 4, 0, 1), (0, 1, 3, 1), (3, 0, 3, 4)]),
+ '5': (5, [(0, 0, 3, 0), (3, 0, 3, 2), (3, 2, 0, 2), (0, 2, 0, 4), (0, 4, 3, 4)]),
+ '6': (5, [(2, 4, 0, 4), (0, 4, 0, 0), (0, 0, 3, 0), (3, 0, 3, 2), (3, 2, 0, 2)]),
+ '7': (5, [(0, 4, 3, 4), (3, 3, 1, 1), (1, 1, 1, 0)]),
+ '8': (5, [(0, 0, 0, 4), (3, 0, 3, 4), (0, 0, 3, 0), (0, 2, 3, 2), (0, 4, 3, 4)]),
+ '9': (5, [(1, 0, 3, 0), (3, 0, 3, 4), (3, 4, 0, 4), (0, 4, 0, 2), (0, 2, 3, 2)]),
+ }
+
+VFONT = {'.': (2, [(0, 0, 0, 0),]),
+ ',': (2, [(0, 0, 0, 0),]),
+ '-': (4, [(2, 0, 2, 2),]),
+ '0': (5, [(0, 0, 4, 0), (4, 0, 4, 3), (4, 3, 0, 3), (0, 3, 0, 0)]),
+ '1': (3, [(0, 1, 4, 1), (4, 1, 4, 0)]),
+ '2': (5, [(0, 3, 0, 0), (0, 0, 2, 0), (2, 0, 2, 3), (2, 3, 4, 3), (4, 3, 4, 0)]),
+ '3': (5, [(0, 0, 0, 3), (0, 3, 4, 3), (4, 3, 4, 0), (2, 3, 2, 0)]),
+ '4': (5, [(4, 0, 1, 0), (1, 0, 1, 3), (4, 3, 0, 3)]),
+ '5': (5, [(4, 3, 4, 0), (4, 0, 2, 0), (2, 0, 2, 3), (2, 3, 0, 3), (0, 3, 0, 0)]),
+ '6': (5, [(4, 2, 4, 0), (4, 0, 0, 0), (0, 0, 0, 3), (0, 3, 2, 3), (2, 3, 2, 0)]),
+ '7': (5, [(4, 0, 4, 3), (3, 3, 1, 1), (1, 1, 0, 1)]),
+ '8': (5, [(0, 0, 0, 3), (0, 3, 4, 3), (4, 3, 4, 0), (2, 3, 2, 0), (4, 0, 0, 0)]),
+ '9': (5, [(0, 1, 0, 3), (0, 3, 4, 3), (4, 3, 4, 0), (4, 0, 2, 0), (2, 0, 2, 2)]),
+ }
+
+
class Ruler(PyWidget):
def __init__(self, master=None, orient = HORIZONTAL, canvas = None, **kw):
apply(PyWidget.__init__, (self, master), kw)
self.orient = orient
self.canvas = canvas
- self.gcs_initialized = 0
- self.gc = None
+
+ self.gc_initialized = 0
+ self.gc = GraphicsDevice()
+ self.gc.SetViewportTransform(1.0, Identity, Identity)
+
self.positions = None
self.SetRange(0.0, 1.0, force = 1)
- if orient == VERTICAL:
- self.text_type = config.preferences.ruler_text_type
- else:
- self.text_type = 'horizontal'
- font = None
- fontname = config.preferences.ruler_font
- try:
- font = self.tkwin.LoadQueryFont(fontname)
- except:
- # NLS
- warn(USER, 'Could not load font %s for ruler. using defaults.',
- `fontname`)
- font = self.tkwin.LoadQueryFont('fixed')
- self.font = font
- font = None
- if self.text_type == 'rotated':
- fontname = config.preferences.ruler_font_rotated
- try:
- font = self.tkwin.LoadQueryFont(fontname)
- except:
- # NLS
- warn(USER, 'Could not load font %s for ruler. using defaults.',
- `fontname`)
- self.rotated_font = font
- if not self.rotated_font and self.text_type == 'rotated':
- self.text_type = 'horizontal'
+ self['height'] = 19
+ self['width'] = 19
+
+ self.border_color = XRGBColor(ui_colors.light_border)
+ self.bg_color = XRGBColor(ui_colors.menubackground)
+ self.fg_color = XRGBColor(ui_colors.fg)
+
+ self.gradient = []
+ start = ui_colors.menubackground
+ stop = ui_colors.light_border
+ for pos in range(20):
+ color = gtkutils.middle_color(start, stop, pos * 3.5 /100)
+ self.gradient.append(XRGBColor(color))
+
- border_width = self.option_get('borderWidth', 'BorderWidth')
- if border_width:
- self.border_width = atoi(border_width)
- else:
- self.border_width = 0
-
- height = self.font.ascent + self.font.descent \
- + self.border_width + tick_lengths[0]
- if orient == HORIZONTAL:
- self['height'] = height
- else:
- if self.text_type == 'rotated':
- self['width'] = height
- elif self.text_type == 'vertical':
- self['width'] = self.font.TextWidth('0') + self.border_width \
- + tick_lengths[0]
- else: # horizontal
- width = self.font.TextWidth('000') + self.border_width \
- + tick_lengths[0]
- self['width'] = width
-
self.bind('<ButtonPress>', self.ButtonPressEvent)
self.bind('<ButtonRelease>', self.ButtonReleaseEvent)
self.bind('<Motion>', self.PointerMotionEvent)
@@ -115,9 +118,9 @@
self.canvas = None
def MapMethod(self):
- if not self.gcs_initialized:
- self.init_gcs()
- self.gcs_initialized = 1
+ if not self.gc_initialized:
+ self.gc.init_gc(self.tkwin)
+ self.gc_initialized = 1
def init_gcs(self):
cmap = self.tkwin.colormap()
@@ -238,99 +241,70 @@
def RedrawMethod(self, region = None):
- pixmap = self.tkwin.CreatePixmap()
- width = self.tkwin.width
- height = self.tkwin.height
- bd = self.border_width
- self.gc.SetDrawable(pixmap)
- self.tkborder.Fill3DRectangle(pixmap, 0, 0, width, height,
- bd, pax.TK_RELIEF_RAISED);
if self.orient == HORIZONTAL:
self.draw_ruler_horizontal()
else:
self.draw_ruler_vertical()
- self.gc.SetDrawable(self.tkwin)
- pixmap.CopyArea(self.tkwin, self.gc, 0, 0, width, height, 0, 0)
-
def draw_ruler_horizontal(self):
- darkgc = self.tkborder.BorderGC(pax.TK_3D_DARK_GC)
- darkgc.SetDrawable(self.gc.drawable)
- lightgc = self.tkborder.BorderGC(pax.TK_3D_LIGHT_GC)
- lightgc.SetDrawable(self.gc.drawable)
- DrawString = self.gc.DrawString
- DrawDarkLine = darkgc.DrawLine
- DrawLightLine = lightgc.DrawLine
- TextWidth = self.font.TextWidth
- descent = self.font.descent
+ DrawLine = self.gc.gc.DrawLine
height = self.tkwin.height
-
+ width = self.tkwin.width
+
+ for pos in range(0,20):
+ self.gc.SetFillColor(self.gradient[pos])
+ DrawLine(0, pos, width, pos)
+
+ self.gc.SetFillColor(self.fg_color)
ticks, texts = self.get_positions()
for h, pos in ticks:
- DrawDarkLine(pos, height, pos, height - h)
+ DrawLine(pos, height, pos, height - h - 1)
pos = pos + 1
- DrawLightLine(pos, height, pos, height - h)
- y = height - tick_lengths[0] - descent
+ y = 8
for text, pos in texts:
- if text[0] != '-':
- tw = TextWidth(text)
- else:
- tw = TextWidth(text[1:])
- pos = pos - TextWidth('-')
- DrawString(pos - tw / 2, y, text)
+ pos += 1
+ for character in str(text):
+ data = HFONT[character]
+ lines = data[1]
+ for line in lines:
+ DrawLine(line[0] + pos, y - line[1], line[2] + pos, y - line[3])
+ pos += data[0]
+ self.gc.SetFillColor(self.border_color)
+ self.gc.gc.DrawLine(0, 0, 0, height)
+ self.gc.gc.DrawLine(0, height - 1, width, height - 1)
+
def draw_ruler_vertical(self):
- darkgc = self.tkborder.BorderGC(pax.TK_3D_DARK_GC)
- darkgc.SetDrawable(self.gc.drawable)
- lightgc = self.tkborder.BorderGC(pax.TK_3D_LIGHT_GC)
- lightgc.SetDrawable(self.gc.drawable)
- DrawString = self.gc.DrawString
- DrawDarkLine = darkgc.DrawLine
- DrawLightLine = lightgc.DrawLine
- descent = self.font.descent
+ DrawLine = self.gc.gc.DrawLine
height = self.tkwin.height
width = self.tkwin.width
- font_height = self.font.ascent + self.font.descent
+ for pos in range(0,20):
+ self.gc.SetFillColor(self.gradient[pos])
+ DrawLine(pos, 0, pos, height)
+
+ self.gc.SetFillColor(self.fg_color)
ticks, texts = self.get_positions()
for h, pos in ticks:
pos = height - pos
- DrawDarkLine(width - h, pos, width, pos)
+ DrawLine(width - h - 1, pos, width, pos)
pos = pos + 1
- DrawLightLine(width - h, pos, width, pos)
- if self.text_type == 'rotated':
- TextWidth = self.font.TextWidth
- x = width - self.font.descent - tick_lengths[0]
- for text, pos in texts:
- pos = height - pos
- if text[0] != '-':
- tw = TextWidth(text)
- else:
- tw = TextWidth(text[1:])
- pos = pos + TextWidth('-')
- y = pos + tw / 2
- for c in text:
- DrawString(x, y, c)
- y = y - TextWidth(c)
- elif self.text_type == 'vertical':
- x = width - self.font.TextWidth('0') - tick_lengths[0]
- for text, pos in texts:
- pos = height - pos
- #print `text`
- y = pos + self.font.ascent - (len(text) * font_height) / 2
- for c in text:
- DrawString(x, y, c)
- y = y + font_height
- else: # horizontal
- TextWidth = self.font.TextWidth
- dx = width - tick_lengths[0]
- dy = self.font.ascent - font_height / 2
- for text, pos in texts:
- pos = height - pos + dy
- #print `text`
- DrawString(dx - TextWidth(text), pos, text)
+ x = 8
+ for text, pos in texts:
+ pos = height - pos
+ pos -= 1
+ for character in str(text):
+ data = VFONT[character]
+ lines = data[1]
+ for line in lines:
+ DrawLine(x - line[0], pos - line[1], x - line[2], pos - line[3])
+ pos -= data[0]
+
+ self.gc.SetFillColor(self.border_color)
+ DrawLine(0, 0, width, 0)
+ DrawLine(width - 1, 0, width - 1, height)
def ButtonPressEvent(self, event):
if event.num == const.Button1:
More information about the Skencil-commits
mailing list