list control check mixin clipped images

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

list control check mixin clipped images

Donn Ingle
Hello,
I am moving an older wxpython app from windows to Ubuntu Hardy. The check
boxes on the checklistctrlmixin are being cut-off (clipped) at the bottom
of each row. I have been going spare googling around for some simple way to
increase the row height of individual list items, but it seems there is no
way.

Can anyone advise? I don't want to mess with the gtk/gnome themes, I'd
rather it just work. If I must then I will create my own check box images
and load them, but this too may not work.

Thanks,
\d

_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: list control check mixin clipped images

Robin Dunn
Donn Ingle wrote:

> Hello,
> I am moving an older wxpython app from windows to Ubuntu Hardy. The check
> boxes on the checklistctrlmixin are being cut-off (clipped) at the bottom
> of each row. I have been going spare googling around for some simple way to
> increase the row height of individual list items, but it seems there is no
> way.
>
> Can anyone advise? I don't want to mess with the gtk/gnome themes, I'd
> rather it just work. If I must then I will create my own check box images
> and load them, but this too may not work.

CheckListCtrlMixin uses the wx.RendererNative to draw the checkboxes to
the bitmaps to use, but it looks like it assumes that they will always
be 16x16.  A little bit of refactoring of that class to allow it to use
different sizes, or to more easily substitute alternate bitmaps would be
welcomed.



--
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!

_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: list control check mixin clipped images

Donn Ingle
Robin Dunn wrote:
 
> CheckListCtrlMixin uses the wx.RendererNative to draw the checkboxes to
> the bitmaps to use, but it looks like it assumes that they will always
> be 16x16.  
I will try my own images and make them smaller than that.

> A little bit of refactoring of that class to allow it to use
> different sizes, or to more easily substitute alternate bitmaps would be
> welcomed.
I bravely grepped around until I found it, but all that SWIGgery is beyond
me! It looks like a job for a pro :)

Thanks.
\d

_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

RE: Re: list control check mixin clipped images

Phillip Piper
(Shameless plug) Have a look at ObjectListView
http://objectlistview.sourceforge.net/python.

The images used for checkboxes are (or, at least, should be) changeable:
  self.olv1.AddNamedImages(ObjectListView.NAME_CHECKED_IMAGE,
myCustomBitmap)
  self.olv1.AddNamedImages(ObjectListView.NAME_UNCHECKED_IMAGE,
myOtherCustomBitmap)

Your custom image must be the same size as the small image list.

Regards,
Phillip

------------------------------------------------------------------------
Phillip Piper  www.bigfoot.com/~phillip_piper  [hidden email]
A man's life does not consist in the abundance of his possessions

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Donn Ingle
Sent: Monday, 7 July 2008 6:53 AM
To: [hidden email]
Subject: [wxpython-users] Re: list control check mixin clipped images

Robin Dunn wrote:
 
> CheckListCtrlMixin uses the wx.RendererNative to draw the checkboxes to
> the bitmaps to use, but it looks like it assumes that they will always
> be 16x16.  
I will try my own images and make them smaller than that.

> A little bit of refactoring of that class to allow it to use
> different sizes, or to more easily substitute alternate bitmaps would be
> welcomed.
I bravely grepped around until I found it, but all that SWIGgery is beyond
me! It looks like a job for a pro :)

Thanks.
\d

_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: Re: list control check mixin clipped images

Robin Dunn
In reply to this post by Donn Ingle
Donn Ingle wrote:

> Robin Dunn wrote:
>  
>> CheckListCtrlMixin uses the wx.RendererNative to draw the checkboxes to
>> the bitmaps to use, but it looks like it assumes that they will always
>> be 16x16.  
> I will try my own images and make them smaller than that.
>
>> A little bit of refactoring of that class to allow it to use
>> different sizes, or to more easily substitute alternate bitmaps would be
>> welcomed.
> I bravely grepped around until I found it, but all that SWIGgery is beyond
> me! It looks like a job for a pro :)

Sorry, I meant a refactor of the CheckListCtrlMixin class, which is in
wx/lib/mixins/listctrl.py, so no SWIGery required. ;-)  It could be
tweaked such that it allowed the icon size to be specified by the
derived class, or made easier to use custom icons, or both.

--
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!

_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

RE: Re: list control check mixin clipped images

Donn Ingle
In reply to this post by Phillip Piper
Phillip Piper wrote:
> (Shameless plug) Have a look at ObjectListView
I will have a go with your wrapper - perhaps I'll get the urge to code back
again :)

\d

_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: list control check mixin clipped images

Cody Precord
In reply to this post by Robin Dunn
Hello,

On Jul 6, 2008, at 5:39 PM, Robin Dunn wrote:

> Donn Ingle wrote:
>> Hello,
>> I am moving an older wxpython app from windows to Ubuntu Hardy. The  
>> check
>> boxes on the checklistctrlmixin are being cut-off (clipped) at the  
>> bottom
>> of each row. I have been going spare googling around for some  
>> simple way to
>> increase the row height of individual list items, but it seems  
>> there is no
>> way. Can anyone advise? I don't want to mess with the gtk/gnome  
>> themes, I'd
>> rather it just work. If I must then I will create my own check box  
>> images
>> and load them, but this too may not work.

I am having a little trouble seeing the issue on my linux install.  
Donn could I trouble you for what theme you are using and possibly a  
a screenshot to better illustrate what you are seeing.

>>
>
> CheckListCtrlMixin uses the wx.RendererNative to draw the checkboxes  
> to the bitmaps to use, but it looks like it assumes that they will  
> always be 16x16.  A little bit of refactoring of that class to allow  
> it to use different sizes, or to more easily substitute alternate  
> bitmaps would be welcomed.
>

This should make it a little more flexible

Index: listctrl.py
===================================================================
--- listctrl.py (revision 54461)
+++ listctrl.py (working copy)
@@ -691,14 +691,22 @@
      You should not set a imagelist for the ListCtrl once this mixin  
is used.
      """
      def __init__(self, check_image=None, uncheck_image=None):
-        self.__imagelist_ = wx.ImageList(16, 16)
+        if check_image is not None:
+            imgsz = check_image.GetSize()
+        elif uncheck_image is not None:
+            imgsz = check_image.GetSize()
+        else:
+            imgsz = (16, 16)

-        if not check_image:
-            check_image = self.__CreateBitmap(wx.CONTROL_CHECKED)
+        self.__imagelist_ = wx.ImageList(*imgsz)

-        if not uncheck_image:
-            uncheck_image = self.__CreateBitmap()
+        # Create default checkbox images if none were specified
+        if check_image is None:
+            check_image = self.__CreateBitmap(wx.CONTROL_CHECKED,  
imgsz)

+        if uncheck_image is None:
+            uncheck_image = self.__CreateBitmap(0, imgsz)
+
          self.uncheck_image = self.__imagelist_.Add(uncheck_image)
          self.check_image = self.__imagelist_.Add(check_image)
          self.SetImageList(self.__imagelist_, wx.IMAGE_LIST_SMALL)
@@ -709,15 +717,16 @@
          # override the default methods of ListCtrl/ListView
          self.InsertStringItem = self.__InsertStringItem_

-    def __CreateBitmap(self, flag=0):
+    def __CreateBitmap(self, flag=0, size=(16, 16)):
          """Create a bitmap of the platforms native checkbox. The flag
          is used to determine the checkboxes state (see wx.CONTROL_*)

          """
-        bmp = wx.EmptyBitmap(16, 16)
+        bmp = wx.EmptyBitmap(*size)
          dc = wx.MemoryDC(bmp)
          dc.Clear()
-        wx.RendererNative.Get().DrawCheckBox(self, dc, (0, 0, 16,  
16), flag)
+        wx.RendererNative.Get().DrawCheckBox(self, dc,
+                                             (0, 0, size[0],  
size[1]), flag)
          dc.SelectObject(wx.NullBitmap)
          return bmp


Regards,

Cody
_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: list control check mixin clipped images

Robin Dunn
Cody Precord wrote:

> Hello,
>
> On Jul 6, 2008, at 5:39 PM, Robin Dunn wrote:
>
>> Donn Ingle wrote:
>>> Hello,
>>> I am moving an older wxpython app from windows to Ubuntu Hardy. The
>>> check
>>> boxes on the checklistctrlmixin are being cut-off (clipped) at the
>>> bottom
>>> of each row. I have been going spare googling around for some simple
>>> way to
>>> increase the row height of individual list items, but it seems there
>>> is no
>>> way. Can anyone advise? I don't want to mess with the gtk/gnome
>>> themes, I'd
>>> rather it just work. If I must then I will create my own check box
>>> images
>>> and load them, but this too may not work.
>
> I am having a little trouble seeing the issue on my linux install. Donn
> could I trouble you for what theme you are using and possibly a  a
> screenshot to better illustrate what you are seeing.
>
>>>
>>
>> CheckListCtrlMixin uses the wx.RendererNative to draw the checkboxes
>> to the bitmaps to use, but it looks like it assumes that they will
>> always be 16x16.  A little bit of refactoring of that class to allow
>> it to use different sizes, or to more easily substitute alternate
>> bitmaps would be welcomed.
>>
>

Thanks.  I've checked in a slightly different change (to allow the
images size to be changed, but still use the images generated from the
renderer.)


--
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!

_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: list control check mixin clipped images

Donn Ingle
In reply to this post by Cody Precord
Cody Precord wrote:

> I am having a little trouble seeing the issue on my linux install.
> Donn could I trouble you for what theme you are using and possibly a
> a screenshot to better illustrate what you are seeing.
It's attached.
Ubuntu 8.04
Theme: default human. Just tried others and problem remains.
Compiz was on and off -- same clipping both times.

hth,
\d

_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Screenshot.png (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: list control check mixin clipped images

Phillip Piper
Under Ubuntu (at least) reducing the size of the rectangle passed to DrawCheckBox() to less than 16 pixels does not change the size of the checkbox. So:

    wx.RendererNative.Get().DrawCheckBox(self, dc, (0, 0, 12, 12), state)

produces the same checkbox as:

    wx.RendererNative.Get().DrawCheckBox(self, dc, (0, 0, 16, 16), state)

Under Linux, there seems to be an off-by-1 error with the rendering. If I change my code to this:

    wx.RendererNative.Get().DrawCheckBox(self, dc, (0, -1, 16, 16), state)

the clipping seen in Donn's screenshot disappears.

2008/7/8 Donn Ingle <[hidden email]>:
Cody Precord wrote:

> I am having a little trouble seeing the issue on my linux install.
> Donn could I trouble you for what theme you are using and possibly a
> a screenshot to better illustrate what you are seeing.
It's attached.
Ubuntu 8.04
Theme: default human. Just tried others and problem remains.
Compiz was on and off -- same clipping both times.

hth,
\d

_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users




--
------------------------------------------------------------------------
Phillip Piper www.bigfoot.com/~phillip_piper [hidden email]
A man's life does not consist in the abundance of his possessions
_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: Re: list control check mixin clipped images

Donn Ingle
Phillip Piper wrote:

> Under Linux, there seems to be an off-by-1 error with the rendering. If I
> change my code to this:
>     wx.RendererNative.Get().DrawCheckBox(self, dc, (0, -1, 16, 16), state)
> the clipping seen in Donn's screenshot disappears.
Can you put this into context for me? Do I simply issue that command before
continuing to use the list control or is there some more wiring? It looks
like part of the fix in listctrl.py

Thanks for the hacking all.
\d

_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: list control check mixin clipped images

Phillip Piper
I was thinking about my code in ObjectListView but trying to make it general.

Sorry. The fix is not that simple. You'll have to find the RendererNative call in listctrl.py and modify it directly.

Remember, this is just a nasty hack :) There is probably a neat, elegant solution somewhere in the bowels of wx.

Even with ObjectListView, you'll still have to modify the RendererNative call -- at least until I commit a change to the SVN.

Regards,
Phillip

2008/7/8 Donn Ingle <[hidden email]>:
Phillip Piper wrote:

> Under Linux, there seems to be an off-by-1 error with the rendering. If I
> change my code to this:
>     wx.RendererNative.Get().DrawCheckBox(self, dc, (0, -1, 16, 16), state)
> the clipping seen in Donn's screenshot disappears.
Can you put this into context for me? Do I simply issue that command before
continuing to use the list control or is there some more wiring? It looks
like part of the fix in listctrl.py

Thanks for the hacking all.
\d

_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users



--
------------------------------------------------------------------------
Phillip Piper  www.bigfoot.com/~phillip_piper  [hidden email]
A man's life does not consist in the abundance of his possessions
_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users