X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c8ace611be19b19219865cae0d513e08e488dd63..6a8b9da42c22b34c1f8ea5f10080e7c51e21a330:/wxPython/demo/ColourDB.py diff --git a/wxPython/demo/ColourDB.py b/wxPython/demo/ColourDB.py index f23e294fe5..ad7c92fc74 100644 --- a/wxPython/demo/ColourDB.py +++ b/wxPython/demo/ColourDB.py @@ -5,11 +5,6 @@ from wxPython.lib import colourdb import images -# This loads a whole bunch of new color names and values -# into wxTheColourDatabase - -colourdb.updateColourDB() - #---------------------------------------------------------------------- class TestWindow(wxScrolledWindow): @@ -17,6 +12,7 @@ class TestWindow(wxScrolledWindow): wxScrolledWindow.__init__(self, parent, -1) self.clrList = colourdb.getColourList() + #self.clrList.sort() self.bg_bmp = images.getGridBGBitmap() EVT_PAINT(self, self.OnPaint) @@ -27,7 +23,7 @@ class TestWindow(wxScrolledWindow): dc = wxClientDC(self) dc.SetFont(self.font) - w,h,d,e = dc.GetFullTextExtent("Wy") # a wide character and one that decends + w,h,d,e = dc.GetFullTextExtent("Wy") # a wide character and one that descends self.textHeight = h + d self.lineHeight = self.textHeight + 5 self.cellWidth = w @@ -51,7 +47,7 @@ class TestWindow(wxScrolledWindow): while x < sz.width: y = -dy while y < sz.height: - dc.DrawBitmap(self.bg_bmp, x, y) + dc.DrawBitmap(self.bg_bmp, (x, y)) y = y + h x = x + w @@ -60,6 +56,8 @@ class TestWindow(wxScrolledWindow): dc = evt.GetDC() if not dc: dc = wxClientDC(self) + rect = self.GetUpdateRegion().GetBox() + dc.SetClippingRect(rect) self.TileBackground(dc) @@ -78,7 +76,7 @@ class TestWindow(wxScrolledWindow): numColours = len(colours) if rgn: - # determine the subset that have been exposed and needs drawn + # determine the subset that has been exposed and needs drawn rect = rgn.GetBox() pixStart = vs[1]*self.lineHeight + rect.y pixStop = pixStart + rect.height @@ -86,29 +84,53 @@ class TestWindow(wxScrolledWindow): stop = pixStop / self.lineHeight else: start = 0 - stop = len(numColours) + stop = numColours for line in range(max(0,start), min(stop,numColours)): clr = colours[line] y = (line+1) * self.lineHeight + 2 - dc.DrawText(clr, self.cellWidth, y) + dc.DrawText(clr, (self.cellWidth, y)) brush = wxBrush(clr, wxSOLID) dc.SetBrush(brush) - dc.DrawRectangle(12 * self.cellWidth, y, 6 * self.cellWidth, self.textHeight) + dc.DrawRectangle((12 * self.cellWidth, y), + (6 * self.cellWidth, self.textHeight)) dc.EndDrawing() +# On wxGTK there needs to be a panel under wxScrolledWindows if they are +# going to be in a wxNotebook... +class TestPanel(wxPanel): + def __init__(self, parent): + wxPanel.__init__(self, parent, -1) + self.win = TestWindow(self) + EVT_SIZE(self, self.OnSize) + + def OnSize(self, evt): + self.win.SetSize(evt.GetSize()) + + #---------------------------------------------------------------------- def runTest(frame, nb, log): - win = TestWindow(nb) + # This loads a whole bunch of new color names and values + # into wxTheColourDatabase + colourdb.updateColourDB() + + win = TestPanel(nb) return win #---------------------------------------------------------------------- overview = """ """ + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])]) +