From c8ace611be19b19219865cae0d513e08e488dd63 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 19 Apr 2001 23:32:05 +0000 Subject: [PATCH] Added a demo to show off all the colours that can be added to wxTheColourDatabase by the wxPython.lib.colourdb module. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9801 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/demo/ColourDB.py | 114 ++++++++++++++++++++++++++++ wxPython/demo/Main.py | 1 + wxPython/demo/bmp_source/GridBG.gif | Bin 0 -> 681 bytes wxPython/demo/encode_bitmaps.py | 3 +- wxPython/demo/images.py | 21 +++++ 5 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 wxPython/demo/ColourDB.py create mode 100644 wxPython/demo/bmp_source/GridBG.gif diff --git a/wxPython/demo/ColourDB.py b/wxPython/demo/ColourDB.py new file mode 100644 index 0000000000..f23e294fe5 --- /dev/null +++ b/wxPython/demo/ColourDB.py @@ -0,0 +1,114 @@ + +from wxPython.wx import * +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): + def __init__(self, parent): + wxScrolledWindow.__init__(self, parent, -1) + + self.clrList = colourdb.getColourList() + self.bg_bmp = images.getGridBGBitmap() + + EVT_PAINT(self, self.OnPaint) + EVT_ERASE_BACKGROUND(self, self.OnEraseBackground) + #self.SetBackgroundColour("WHITE") + + self.font = wxFont(10, wxSWISS, wxNORMAL, wxNORMAL) + dc = wxClientDC(self) + dc.SetFont(self.font) + + w,h,d,e = dc.GetFullTextExtent("Wy") # a wide character and one that decends + self.textHeight = h + d + self.lineHeight = self.textHeight + 5 + self.cellWidth = w + + numCells = 24 + self.SetScrollbars(self.cellWidth, self.lineHeight, numCells, len(self.clrList) + 2) + + + def TileBackground(self, dc): + # tile the background bitmap + sz = self.GetClientSize() + w = self.bg_bmp.GetWidth() + h = self.bg_bmp.GetHeight() + + # adjust for scrolled position + spx, spy = self.GetScrollPixelsPerUnit() + vsx, vsy = self.GetViewStart() + dx, dy = (spx * vsx) % w, (spy * vsy) % h + + x = -dx + while x < sz.width: + y = -dy + while y < sz.height: + dc.DrawBitmap(self.bg_bmp, x, y) + y = y + h + x = x + w + + + def OnEraseBackground(self, evt): + dc = evt.GetDC() + if not dc: + dc = wxClientDC(self) + self.TileBackground(dc) + + + def OnPaint(self, evt): + dc = wxPaintDC(self) + self.PrepareDC(dc) + self.Draw(dc, self.GetUpdateRegion(), self.GetViewStart()) + + + def Draw(self, dc, rgn=None, vs=None): + dc.BeginDrawing() + dc.SetTextForeground("BLACK") + dc.SetPen(wxPen("BLACK", 1, wxSOLID)) + dc.SetFont(self.font) + colours = self.clrList + numColours = len(colours) + + if rgn: + # determine the subset that have been exposed and needs drawn + rect = rgn.GetBox() + pixStart = vs[1]*self.lineHeight + rect.y + pixStop = pixStart + rect.height + start = pixStart / self.lineHeight - 1 + stop = pixStop / self.lineHeight + else: + start = 0 + stop = len(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) + + brush = wxBrush(clr, wxSOLID) + dc.SetBrush(brush) + dc.DrawRectangle(12 * self.cellWidth, y, 6 * self.cellWidth, self.textHeight) + + dc.EndDrawing() + + + +#---------------------------------------------------------------------- + + +def runTest(frame, nb, log): + win = TestWindow(nb) + return win + +#---------------------------------------------------------------------- + +overview = """ +""" diff --git a/wxPython/demo/Main.py b/wxPython/demo/Main.py index 076240ec1d..8f8297e773 100644 --- a/wxPython/demo/Main.py +++ b/wxPython/demo/Main.py @@ -23,6 +23,7 @@ import images _treeList = [ ('New since last release', ['ColourSelect', 'ImageBrowser', 'infoframe', + 'ColourDB', ]), ('Managed Windows', ['wxFrame', 'wxDialog', 'wxMiniFrame']), diff --git a/wxPython/demo/bmp_source/GridBG.gif b/wxPython/demo/bmp_source/GridBG.gif new file mode 100644 index 0000000000000000000000000000000000000000..c1adaf0b47eddea0fa0fae4eace55ae01daa386f GIT binary patch literal 681 zcmV;a0#^M;Nk%w1VN?KA0HOc@rL(!Au(qJDwVkcAnW?aqrmg+~0ssI2A^8La6aWSQ zEC2ui08{`}000C3Si0Q)Fv>|ExVVVTHQ&V`j^0;xAD9ZKnzrm(V3{nBr2Xn9kM1wp z1xCb)h(1>jxNLTW0OZR!kUEvWYmE66T07J)cD&V!SDYTp){wIgf9Ug^gZ>mp6Tsf193;W|5qTelnz?nVzX8VW*0q zW}!XPhu= z-p30pC*AyT=s=^V(qYoLS>Je8onq0k6%JY#-W8p8;svhxks~ literal 0 HcmV?d00001 diff --git a/wxPython/demo/encode_bitmaps.py b/wxPython/demo/encode_bitmaps.py index 01206b94b2..c3935a284f 100644 --- a/wxPython/demo/encode_bitmaps.py +++ b/wxPython/demo/encode_bitmaps.py @@ -46,7 +46,8 @@ command_lines = [ "-a -n Smiles bmp_source/smiles.bmp images.py", - #"-a -n bmp_source/ images.py", + "-a -n GridBG bmp_source/GridBG.gif images.py", + ] diff --git a/wxPython/demo/images.py b/wxPython/demo/images.py index 3686cfad9e..5e42b32bbd 100644 --- a/wxPython/demo/images.py +++ b/wxPython/demo/images.py @@ -5183,3 +5183,24 @@ def getSmilesBitmap(): def getSmilesImage(): return wxImageFromBitmap(getSmilesBitmap()) +#---------------------------------------------------------------------- +def getGridBGData(): + return cPickle.loads(zlib.decompress( +"x\332\355\230\301\012\2030\014\206\357>Ea\007\007\202\2648e}\012\017^<\354\ +\222Nv\032\270\367?mD{pd\222\035\252\006\022\204\300o\373\265\2054M{~\276\\\ +\326\345\327\213\371|\215qy\006]nn\326\271\2739\371\032\032\030P*g\011\352P\ +\005\217R\037%\013\217P\2434\306\216\003\014\241B\251\215\222\007\037,JE\354\ +\350\202\015\3154b\002\233\300%\232\351\321\242\033\321\276D\266S\260xp\262p\ +k\3218S]\266\234\035\265`\005\213\007'\0137rr\344\256Y\272\002\215\024\025,\ +\036\274m\270\361\035\265k\024,\036\274m\270\221\251\227]\023(X<8Y\270\221y\ +\225\237\244\177\037\377\012\026\014\336\3630\345_u\246\226\012\026\017N\035\ +n\214\372\222\221\262\211D\257`\211\340\003\324nk\227\233\305\202\025,\036|\ +\200w7\366j\024,\036\274Qv[\011\373\177\037\246\025,\030\274g\355\266\266k\ +\250\177\012\226\015.\337F\021\023\224" )) + +def getGridBGBitmap(): + return wxBitmapFromXPMData(getGridBGData()) + +def getGridBGImage(): + return wxImageFromBitmap(getGridBGBitmap()) +