root/trunk/RBSkinning/RBSkinning/wxPythonSkin/bitmap_button.py

Revision 730, 2.9 kB (checked in by gwm, 5 years ago)

*** empty log message ***

Line 
1 #!/usr/bin/env python
2 ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 ##~ License
4 ##~
5 ##- The RuneBlade Foundation library is intended to ease some
6 ##- aspects of writing intricate Jabber, XML, and User Interface (wxPython, etc.)
7 ##- applications, while providing the flexibility to modularly change the
8 ##- architecture. Enjoy.
9 ##~
10 ##~ Copyright (C) 2002  TechGame Networks, LLC.
11 ##~
12 ##~ This library is free software; you can redistribute it and/or
13 ##~ modify it under the terms of the BSD style License as found in the
14 ##~ LICENSE file included with this distribution.
15 ##~
16 ##~ TechGame Networks, LLC can be reached at:
17 ##~ 3578 E. Hartsel Drive #211
18 ##~ Colorado Springs, Colorado, USA, 80920
19 ##~
20 ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21
22 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 #~ Imports
24 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25
26 from wxSkinLayoutObject import wx, wxSkinLayoutObject, wxSkinObjectNoData
27 from RBSkinning.wxTools.wxRolloverEvents import wxRolloverMixin
28
29 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30 #~ Class
31 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32
33 class wxBitmapButtonWithRollover(wxRolloverMixin, wx.wxBitmapButton):
34     def _SetupDefaultRollovers(self):
35         if self.GetBitmapRollover() is None:
36             self.SetBitmapRollover(self.GetBitmapSelected())
37         if self.GetBitmapNonRollover() is None:
38             self.SetBitmapNonRollover(self.GetBitmapLabel())
39
40     def _SetRolloverBitmap(self, evt):
41         self.SetBitmapLabel(self.GetBitmapRollover())
42         self.Refresh()
43         evt.Skip()
44
45     def _SetNonRolloverBitmap(self, evt):
46         self.SetBitmapLabel(self.GetBitmapNonRollover())
47         self.Refresh()
48         evt.Skip()
49
50 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51
52 class bitmap_button(wxSkinLayoutObject, wxSkinObjectNoData):
53     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54     #~ Constants / Variables / Etc.
55     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56
57     default_settings = wxSkinLayoutObject.default_settings.copy()
58     default_settings.update({
59         'name':     __name__,
60         'wxid':       'wx.wxNewId()',
61         'default':  '0',
62         })
63     BitmapButtonFactory = wxBitmapButtonWithRollover
64
65     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66     #~ Public
67     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68
69     def SkinInitialize(self):
70         winParent = self.wxGetParentObject(wx.wxWindowPtr)
71         kwSettings = self.wxSettingDict(['wxid', 'style', 'pos', 'size'], ['name'])
72         kwSettings['bitmap'] = wx.wxEmptyBitmap(*kwSettings['size'])
73         self.object = self.BitmapButtonFactory(winParent, **kwSettings)
74         if self.wxEval('default'):
75             self.object.SetDefault()
76         self.wxInitialStandardOptions()
77         self.object._SetupEvents()
78
79     def SkinFinalize(self):
80         self.wxFinalStandardOptions()
81         self.object._SetupDefaultRollovers()
82
Note: See TracBrowser for help on using the browser.