[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r10206 - in trunk/gnue-forms: . src/uidrivers/wx/widgets
From: |
reinhard |
Subject: |
[gnue] r10206 - in trunk/gnue-forms: . src/uidrivers/wx/widgets |
Date: |
Wed, 20 Oct 2010 09:20:26 -0500 (CDT) |
Author: reinhard
Date: 2010-10-20 09:20:26 -0500 (Wed, 20 Oct 2010)
New Revision: 10206
Modified:
trunk/gnue-forms/
trunk/gnue-forms/src/uidrivers/wx/widgets/image.py
Log:
Replaced black border around images with a standard sunken border, and made
images resizable.
Property changes on: trunk/gnue-forms
___________________________________________________________________
Name: bzr:revision-info
- timestamp: 2010-10-20 14:45:41.104000092 +0200
committer: Reinhard Müller <address@hidden>
properties:
branch-nick: forms
+ timestamp: 2010-10-20 16:19:05.575999975 +0200
committer: Reinhard Müller <address@hidden>
properties:
branch-nick: forms
Name: bzr:file-ids
- src/GFObjects/GFImage.py
address@hidden:trunk%2Fgnue-forms:src%2FGFObjects%2FGFImage.py
src/uidrivers/wx/widgets/image.py
address@hidden:trunk%2Fgnue-forms:src%2Fuidrivers%2Fwx%2Fwidgets%2Fimage.py
+ src/uidrivers/wx/widgets/image.py
address@hidden:trunk%2Fgnue-forms:src%2Fuidrivers%2Fwx%2Fwidgets%2Fimage.py
Name: bzr:revision-id:v4
- 3116 address@hidden
3117 address@hidden
3118 address@hidden
3119 address@hidden
3120 address@hidden
3121 address@hidden
3122 address@hidden
3123 address@hidden
3124 address@hidden
3125 address@hidden
3126 address@hidden
3127 address@hidden
3128 address@hidden
+ 3116 address@hidden
3117 address@hidden
3118 address@hidden
3119 address@hidden
3120 address@hidden
3121 address@hidden
3122 address@hidden
3123 address@hidden
3124 address@hidden
3125 address@hidden
3126 address@hidden
3127 address@hidden
3128 address@hidden
3129 address@hidden
Name: bzr:text-parents
- src/GFObjects/GFImage.py
svn-v3-single1-dHJ1bmsvZ251ZS1mb3Jtcw..:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:10015
src/uidrivers/wx/widgets/image.py
svn-v3-single1-dHJ1bmsvZ251ZS1mb3Jtcw..:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:10117
+
Modified: trunk/gnue-forms/src/uidrivers/wx/widgets/image.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/widgets/image.py 2010-10-20 12:46:14 UTC
(rev 10205)
+++ trunk/gnue-forms/src/uidrivers/wx/widgets/image.py 2010-10-20 14:20:26 UTC
(rev 10206)
@@ -59,16 +59,12 @@
def __init__(self, parent, size=wx.DefaultSize, fit='auto'):
- wx.Window.__init__(self, parent, -1, wx.DefaultPosition, size)
+ wx.Window.__init__(self, parent, -1, wx.DefaultPosition, size,
+ style=wx.BORDER_SUNKEN | wx.FULL_REPAINT_ON_RESIZE)
self.win = parent
self.image = None
- self.back_color = 'WHITE'
- self.border_color = 'BLACK'
self.fit = fit
- self.image_sizex = size[0]
- self.image_sizey = size[1]
-
self.Bind(wx.EVT_PAINT, self.OnPaint)
@@ -94,85 +90,46 @@
# -------------------------------------------------------------------------
- # Draw a border around the widget
- # -------------------------------------------------------------------------
-
- def DrawBorder(self, dc):
-
- brush = wx.Brush(wx.NamedColour(self.back_color), wx.SOLID)
- dc.SetBrush(brush)
- dc.SetPen(wx.Pen(wx.NamedColour(self.border_color), 1))
- dc.DrawRectangle(0, 0, self.image_sizex, self.image_sizey)
-
-
- # -------------------------------------------------------------------------
# Draw the image to the device context
# -------------------------------------------------------------------------
def DrawImage(self, dc):
- try:
- image = self.image
- except:
- return
- self.DrawBorder(dc)
-
- if image is None:
+ if self.image is None:
return
- bmp = image.ConvertToBitmap()
+ bmp = self.image.ConvertToBitmap()
+ image_w = bmp.GetWidth()
+ image_h = bmp.GetHeight()
- # Dimensions of the image file
- iwidth = bmp.GetWidth()
- iheight = bmp.GetHeight()
- scrx = self.image_sizex
- scry = self.image_sizey
+ win_w, win_h = self.GetClientSize()
fit = self.fit
if fit == "auto":
- if float(scrx) / iwidth < float(scry) / iwidth:
+ if float(win_w) / image_w < float(win_h) / image_h:
fit = "width"
else:
fit = "height"
- if fit == 'width':
- prop = float(self.image_sizex-10) / iwidth
- iwidth = self.image_sizex - 10
- diffx = 5
- iheight = abs(int(iheight * prop))
- diffy = (self.image_sizey - iheight)/2
+ if fit == 'height':
+ image_w = int(image_w * float(win_h) / image_h)
+ image_h = win_h
- if iheight >= self.image_sizey - 10:
- diffy = 5
- iheight = self.image_sizey - 10
+ elif fit == 'width':
+ image_h = int(image_h * float(win_w) / image_w)
+ image_w = win_w
- elif fit == 'height':
- prop = float(self.image_sizey-10) / iheight
- iheight = self.image_sizey - 10
- diffy = 5
-
- iwidth = abs(int(iwidth * prop))
- diffx = (self.image_sizex - iwidth) / 2
- if iwidth > self.image_sizex - 10:
- diffx = 5
- iwidth = self.image_sizex - 10
-
elif fit == 'both':
- diffx = (self.image_sizex - iwidth)/2 # center calc
- if iwidth >= self.image_sizex -10: # if image width fits in
- # window adjust
- diffx = 5
- iwidth = self.image_sizex - 10
+ image_w = win_w
+ image_h = win_h
- diffy = (self.image_sizey - iheight)/2 # center calc
- if iheight >= self.image_sizey - 10: # if image height fits in
- # window adjust
- diffy = 5
- iheight = self.image_sizey - 10
+ x = max((win_w - image_w) / 2, 0)
+ y = max((win_h - image_h) / 2, 0)
- image.Rescale(iwidth, iheight) # rescale to fit the window
- bmp = image.ConvertToBitmap()
- dc.DrawBitmap(bmp, diffx, diffy) # draw the image to window
+ img = self.image.Copy()
+ img.Rescale(image_w, image_h)
+ bmp = img.ConvertToBitmap()
+ dc.DrawBitmap(bmp, x, y)
# =============================================================================
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r10206 - in trunk/gnue-forms: . src/uidrivers/wx/widgets,
reinhard <=