New toolbar wrappers

wxMask demos
GenericButton now derives from wxControl
Lots of small changes.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5086 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
1999-12-23 20:05:08 +00:00
parent 8d772832a0
commit 9b3d3bc44b
42 changed files with 4249 additions and 2442 deletions

View File

@@ -22,14 +22,14 @@ _useNestedSplitter = true
_treeList = [
('New since last release', ['wxMVCTree', 'wxVTKRenderWindow',
'FileBrowseButton', #'wxToggleButton',
'GenericButtons']),
'FileBrowseButton', 'GenericButtons',
'wxMask']),
('Managed Windows', ['wxFrame', 'wxDialog', 'wxMiniFrame']),
('Non-Managed Windows', ['wxGrid', 'wxSashWindow',
'wxScrolledWindow', 'wxSplitterWindow',
'wxStatusBar', 'wxToolBar', 'wxNotebook',
'wxStatusBar', 'wxNotebook',
'wxHtmlWindow']),
('Common Dialogs', ['wxColourDialog', 'wxDirDialog', 'wxFileDialog',
@@ -40,15 +40,15 @@ _treeList = [
('Controls', ['wxButton', 'wxCheckBox', 'wxCheckListBox', 'wxChoice',
'wxComboBox', 'wxGauge', 'wxListBox', 'wxListCtrl', 'wxTextCtrl',
'wxTreeCtrl', 'wxSpinButton', 'wxStaticText', 'wxStaticBitmap',
'wxRadioBox', 'wxSlider', #'wxToggleButton'
'wxRadioBox', 'wxSlider', 'wxToolBar', #'wxToggleButton'
]),
('Window Layout', ['wxLayoutConstraints', 'Sizers', 'OldSizers']),
('Miscellaneous', [ 'DragAndDrop', 'CustomDragAndDrop', 'FontEnumerator',
'wxTimer', 'wxValidator', 'wxGLCanvas', 'DialogUnits',
'wxImage', 'PrintFramework', 'wxOGL', 'PythonEvents',
'Threads']),
'wxImage', 'wxMask', 'PrintFramework', 'wxOGL',
'PythonEvents', 'Threads']),
('wxPython Library', ['Layoutf', 'wxScrolledMessageDialog',
'wxMultipleChoiceDialog', 'wxPlotCanvas', 'wxFloatBar',

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View File

@@ -10,16 +10,17 @@ class TestPanel(wxPanel):
b = wxButton(self, 10, "Hello", wxPoint(20, 20))
EVT_BUTTON(self, 10, self.OnClick)
b.SetDefault()
b.SetBackgroundColour(wxBLUE)
b.SetForegroundColour(wxWHITE)
b.SetDefault()
wxButton(self, 20, "HELLO AGAIN!", wxPoint(20, 60), wxSize(90, 45))
EVT_BUTTON(self, 20, self.OnClick)
bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP)
#mask = wxMaskColour(bmp, wxBLUE)
#bmp.SetMask(mask)
if wxPlatform == '__WXMSW__':
mask = wxMaskColour(bmp, wxBLUE)
bmp.SetMask(mask)
wxBitmapButton(self, 30, bmp, wxPoint(140, 20),
wxSize(bmp.GetWidth()+10, bmp.GetHeight()+10))
EVT_BUTTON(self, 30, self.OnClick)

View File

@@ -0,0 +1,103 @@
from wxPython.wx import *
#----------------------------------------------------------------------
logic = ['']*16
def rlf(x):
logic[eval(x)]=x
rlf('wxAND')
rlf('wxAND_INVERT')
rlf('wxAND_REVERSE')
rlf('wxCLEAR')
rlf('wxCOPY')
rlf('wxEQUIV')
rlf('wxINVERT')
rlf('wxNAND')
rlf('wxNOR')
rlf('wxNO_OP')
rlf('wxOR')
rlf('wxOR_INVERT')
rlf('wxOR_REVERSE')
rlf('wxSET')
rlf('wxSRC_INVERT')
rlf('wxXOR')
class TestMaskWindow(wxScrolledWindow):
def __init__(self, parent):
wxScrolledWindow.__init__(self, parent, -1)
self.SetBackgroundColour(wxColour(0,128,0))
# A reference bitmap that we won't mask
self.bmp_nomask = wxBitmap('bitmaps/test_image.png', wxBITMAP_TYPE_PNG)
# One that we will
self.bmp_withmask = wxBitmap('bitmaps/test_image.png', wxBITMAP_TYPE_PNG)
# this mask comes from a monochrome bitmap
self.bmp_themask = wxBitmap('bitmaps/test_mask.bmp', wxBITMAP_TYPE_BMP)
self.bmp_themask.SetDepth(1)
mask = wxMask(self.bmp_themask)
# set the mask on our bitmap
self.bmp_withmask.SetMask(mask)
# Now we'll create a mask in a bit of an easier way, by picking a
# colour in the image that is to be the transparent colour.
self.bmp_withcolourmask = wxBitmap('bitmaps/test_image.png', wxBITMAP_TYPE_PNG)
mask = wxMaskColour(self.bmp_withcolourmask, wxWHITE)
self.bmp_withcolourmask.SetMask(mask)
self.SetScrollbars(20, 20, 600/20, 460/20)
def OnPaint (self, e):
dc = wxPaintDC(self)
self.PrepareDC(dc)
dc.SetTextForeground(wxWHITE)
# make an interesting background...
dc.SetPen(wxMEDIUM_GREY_PEN)
for i in range(100):
dc.DrawLine(0,i*10,i*10,0)
# draw raw image, mask, and masked images
dc.DrawText('original image', 0,0)
dc.DrawBitmap(self.bmp_nomask, 0,20, 0)
dc.DrawText('with colour mask', 0,100)
dc.DrawBitmap(self.bmp_withcolourmask, 0,120, 1)
dc.DrawText('the mask image', 0,200)
dc.DrawBitmap(self.bmp_themask, 0,220, 0)
dc.DrawText('masked image', 0,300)
dc.DrawBitmap(self.bmp_withmask, 0,320, 1)
cx,cy = self.bmp_themask.GetWidth(), self.bmp_themask.GetHeight()
# draw array of assorted blit operations
mdc = wxMemoryDC()
for i in range(16):
text = logic[i]
x,y = 120+100*(i%4), 20+100*(i/4)
dc.DrawText(text, x,y-20)
mdc.SelectObject(self.bmp_withcolourmask)
dc.Blit(x,y, cx,cy, mdc, 0,0, i,1)
#----------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestMaskWindow(nb)
return win
#----------------------------------------------------------------------
overview = """\
"""

View File

@@ -11,47 +11,49 @@ class TestToolBar(wxFrame):
wxWindow(self, -1).SetBackgroundColour(wxNamedColour("WHITE"))
tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER)
tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER) #|wxTB_FLAT)
#tb = wxToolBar(self, -1, wxDefaultPosition, wxDefaultSize,
# wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT)
#self.SetToolBar(tb)
self.CreateStatusBar()
tb.AddTool(10, wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP),
wxNullBitmap, false, -1, -1, "New", "Long help for 'New'")
tb.AddSimpleTool(10, wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP),
"New", "Long help for 'New'")
EVT_TOOL(self, 10, self.OnToolClick)
EVT_TOOL_RCLICKED(self, 10, self.OnToolRClick)
tb.AddTool(20, wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP),
wxNullBitmap, false, -1, -1, "Open")
tb.AddSimpleTool(20, wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP), "Open")
EVT_TOOL(self, 20, self.OnToolClick)
EVT_TOOL_RCLICKED(self, 20, self.OnToolRClick)
tb.AddSeparator()
tb.AddTool(30, wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP),
wxNullBitmap, false, -1, -1, "Copy")
tb.AddSimpleTool(30, wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP), "Copy")
EVT_TOOL(self, 30, self.OnToolClick)
EVT_TOOL_RCLICKED(self, 30, self.OnToolRClick)
tb.AddTool(40, wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP),
wxNullBitmap, false, -1, -1, "Paste")
tb.AddSimpleTool(40, wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP), "Paste")
EVT_TOOL(self, 40, self.OnToolClick)
EVT_TOOL_RCLICKED(self, 40, self.OnToolRClick)
tb.AddSeparator()
tb.AddTool(50, wxBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
wxNullBitmap, true, -1, -1, "Toggle this")
tool = tb.AddTool(50, wxBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
shortHelpString="Toggle this", toggle=true)
EVT_TOOL(self, 50, self.OnToolClick)
EVT_TOOL_RCLICKED(self, 50, self.OnToolRClick)
tb.AddTool(60, wxBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
wxBitmap('bitmaps/tog2.bmp', wxBITMAP_TYPE_BMP),
true, -1, -1, "Toggle with 2 bitmaps")
shortHelpString="Toggle with 2 bitmaps", toggle=true)
EVT_TOOL(self, 60, self.OnToolClick)
EVT_TOOL_RCLICKED(self, 60, self.OnToolRClick)
tb.AddSeparator()
tb.AddControl(wxComboBox(tb, -1, "", LIST=["", "This", "is a", "wxComboBox"],
size=(150,-1), style=wxCB_DROPDOWN))
tb.Realize()

View File

@@ -15,12 +15,26 @@ class TestTreeCtrlPanel(wxPanel):
self.tree = wxTreeCtrl(self, tID, wxDefaultPosition, wxDefaultSize,
wxTR_HAS_BUTTONS | wxTR_EDIT_LABELS)# | wxTR_MULTIPLE)
self.il = wxImageList(16, 16)
idx1 = self.il.Add(wxBitmap('bitmaps/smiles.bmp', wxBITMAP_TYPE_BMP))
idx2 = self.il.Add(wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP))
idx3 = self.il.Add(wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP))
idx4 = self.il.Add(wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP))
idx5 = self.il.Add(wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP))
self.tree.SetImageList(self.il)
self.root = self.tree.AddRoot("The Root Item")
self.tree.SetItemImage(self.root, idx1)
for x in range(15):
child = self.tree.AppendItem(self.root, "Item %d" % x)
#self.tree.SelectItem(child)
self.tree.SetItemImage(child, idx2)
self.tree.SetItemSelectedImage(child, idx3)
for y in range(5):
last = self.tree.AppendItem(child, "item %d-%s" % (x, chr(ord("a")+y)))
self.tree.SetItemImage(last, idx4)
self.tree.SetItemSelectedImage(last, idx5)
for z in range(5):
self.tree.AppendItem(last, "item %d-%s-%d" % (x, chr(ord("a")+y), z))