X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5c9d9745fef51025196de74cc7092b08941a5d7f..6ed100b4a122dfdb8752b020e250e8b6c9e1381e:/wxPython/tests/test_renderHeaderButton.py diff --git a/wxPython/tests/test_renderHeaderButton.py b/wxPython/tests/test_renderHeaderButton.py new file mode 100644 index 0000000000..dba1174800 --- /dev/null +++ b/wxPython/tests/test_renderHeaderButton.py @@ -0,0 +1,130 @@ + +import wx +import cStringIO + +#import os; print os.getpid(); raw_input("Press enter...") + + +class Panel(wx.Panel): + def __init__(self, parent): + wx.Panel.__init__(self, parent) + self.Bind(wx.EVT_PAINT, self.OnPaint) + + def OnPaint(self, evt): + dc = wx.PaintDC(self) + dc.SetFont(self.GetFont()) + r = wx.RendererNative.Get() + rect = wx.Rect(40,10, 95,r.GetHeaderButtonHeight(self)) + #print rect + + # simple helper to make calling DrawHeaderButton so many times a + # bit easier and less messy + def dhb(idx, rect, flags=0, sort=0, params=None): + dc.DrawText("%02d." % idx, rect.x-25, rect.y) + r.DrawHeaderButton(self, dc, rect, flags, sort, params) + rect.y += 30 + + dhb(1, rect) + dhb(2, rect, wx.CONTROL_SELECTED) + dhb(3, rect, wx.CONTROL_CURRENT) + dhb(4, rect, wx.CONTROL_SELECTED|wx.CONTROL_CURRENT) + dhb(5, rect, 0, wx.HDR_SORT_ICON_UP) + dhb(6, rect, 0, wx.HDR_SORT_ICON_DOWN) + dhb(7, rect, wx.CONTROL_SELECTED, wx.HDR_SORT_ICON_UP) + dhb(8, rect, wx.CONTROL_SELECTED, wx.HDR_SORT_ICON_DOWN) + + rect.x = 180 + rect.y = 10 + hp = wx.HeaderButtonParams() + hp.m_labelText = "Hello" + dhb(9, rect, params=hp) + hp.m_labelAlignment = wx.ALIGN_CENTER + dhb(10, rect, params=hp) + hp.m_labelAlignment = wx.ALIGN_RIGHT + dhb(11, rect, params=hp) + hp.m_labelAlignment = wx.ALIGN_CENTER + dhb(12, rect, wx.CONTROL_SELECTED, 0, hp) + dhb(13, rect, wx.CONTROL_SELECTED, wx.HDR_SORT_ICON_UP, hp) + hp.m_labelText = "This label is too long" + dhb(14, rect, params=hp) + dhb(15, rect, wx.CONTROL_SELECTED, 0, hp) + dhb(16, rect, wx.CONTROL_SELECTED, wx.HDR_SORT_ICON_UP, hp) + + rect.x = 320 + rect.y = 10 + hp = wx.HeaderButtonParams() + hp.m_labelBitmap = getBitmap() + dhb(17, rect, params=hp) + hp.m_labelAlignment = wx.ALIGN_CENTER + dhb(18, rect, params=hp) + hp.m_labelAlignment = wx.ALIGN_RIGHT + dhb(19, rect, params=hp) + hp.m_labelAlignment = wx.ALIGN_CENTER + dhb(20, rect, wx.CONTROL_SELECTED, 0, hp) + dhb(21, rect, wx.CONTROL_SELECTED, wx.HDR_SORT_ICON_UP, hp) + + + hp.m_labelText = "label" + hp.m_labelAlignment = wx.ALIGN_LEFT + dhb(22, rect, 0, 0, hp) + hp.m_labelAlignment = wx.ALIGN_CENTER + dhb(23, rect, 0, 0, hp) + hp.m_labelAlignment = wx.ALIGN_RIGHT + dhb(24, rect, 0, 0, hp) + + rect.x = 460 + rect.y = 10 + hp.m_labelAlignment = wx.ALIGN_LEFT + dhb(25, rect, wx.CONTROL_SELECTED, wx.HDR_SORT_ICON_UP, hp) + hp.m_labelAlignment = wx.ALIGN_CENTER + dhb(26, rect, wx.CONTROL_SELECTED, wx.HDR_SORT_ICON_UP, hp) + hp.m_labelAlignment = wx.ALIGN_RIGHT + dhb(27, rect, wx.CONTROL_SELECTED, wx.HDR_SORT_ICON_UP, hp) + + hp.m_labelText = "longer label" + hp.m_labelAlignment = wx.ALIGN_LEFT + dhb(28, rect, wx.CONTROL_SELECTED, wx.HDR_SORT_ICON_UP, hp) + hp.m_labelAlignment = wx.ALIGN_CENTER + dhb(29, rect, wx.CONTROL_SELECTED, wx.HDR_SORT_ICON_UP, hp) + hp.m_labelAlignment = wx.ALIGN_RIGHT + dhb(30, rect, wx.CONTROL_SELECTED, wx.HDR_SORT_ICON_UP, hp) + + +def getData(): + return \ +'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\ +\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\ +\x00\x01\xceIDAT8\x8d\x95\x93=h\x14A\x14\xc7\x7f\xfbq\xc7m\xce\x0b\xe4\xa2F/\ +~\x04\x9b\x03O\x0bE\x10\x04\x91\x10\x88X\xa4J\xe7&\x8a\x10A\xc4Bb\xe9uje\xc0\ +\xd2\xd2\xca\x94V\xa9\xa3X\x88i\x14\x0b\x91\x14\xae$dO\x8d\x97#\xf1