commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r9440 - trunk/gnue-forms/src/uidrivers/win32/widgets


From: btami
Subject: [gnue] r9440 - trunk/gnue-forms/src/uidrivers/win32/widgets
Date: Mon, 12 Mar 2007 12:56:33 -0500 (CDT)

Author: btami
Date: 2007-03-12 12:56:32 -0500 (Mon, 12 Mar 2007)
New Revision: 9440

Modified:
   trunk/gnue-forms/src/uidrivers/win32/widgets/toolbar.py
   trunk/gnue-forms/src/uidrivers/win32/widgets/toolbutton.py
Log:
more new-style toolbar work

Modified: trunk/gnue-forms/src/uidrivers/win32/widgets/toolbar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/widgets/toolbar.py     2007-03-12 
13:54:20 UTC (rev 9439)
+++ trunk/gnue-forms/src/uidrivers/win32/widgets/toolbar.py     2007-03-12 
17:56:32 UTC (rev 9440)
@@ -59,7 +59,6 @@
 
         if self._gfObject.name == '__main_toolbar__' \
                 and not self._form._features['GUI:TOOLBAR:SUPPRESS']:
-            print '__main_toolbar__'
 
             self.hinst = win32api.GetModuleHandle(None)
             style = win32con.WS_CHILD | commctrl.TBSTYLE_TOOLTIPS | 
commctrl.TBSTYLE_FLAT #|win32con.WS_BORDER
@@ -82,8 +81,7 @@
             self._buttonCount = 0
             win32gui.SendMessage(mainToolBar.GetHwnd(), commctrl.TB_AUTOSIZE, 
0, 0)
             mainToolBar.Show()
-
-
+            
         self._container = self
 
         return widget

Modified: trunk/gnue-forms/src/uidrivers/win32/widgets/toolbutton.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/widgets/toolbutton.py  2007-03-12 
13:54:20 UTC (rev 9439)
+++ trunk/gnue-forms/src/uidrivers/win32/widgets/toolbutton.py  2007-03-12 
17:56:32 UTC (rev 9440)
@@ -57,50 +57,49 @@
         icon_file = self._gfObject._get_icon_file(size="24x24", format="bmp")
         label = self._gfObject.label
         description = self._gfObject.description
-        check = (self._gfObject.action_off is not None)
+        self.check = (self._gfObject.action_off is not None)
 
-        check = 0
-        style = commctrl.TBSTYLE_BUTTON
-        self.parent = parent = event.container
+        if self.check:
+            style = commctrl.TBSTYLE_CHECK
+        else:
+            style = commctrl.TBSTYLE_BUTTON
+            
+        self.parent = event.container
+        self.id = getNextId()
 
         if label is not None:
-            self.id = id = getNextId()
-            #~ if check:
-                #~ kind = wx.ITEM_CHECK
-            #~ else:
-                #~ kind = wx.ITEM_NORMAL
-
             # Set the action icon if available
             if icon_file:
-                icon_flags = win32con.LR_LOADFROMFILE #| win32con.LR_SHARED
+                icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_SHARED
                 try:
-                    him = win32gui.LoadImage(0, icon_file, 
win32con.IMAGE_BITMAP, 0, 0, icon_flags)
-                    win32gui.ImageList_Add(parent.himl, him, 0)
+                    him = win32gui.LoadImage(0, str(icon_file), 
win32con.IMAGE_BITMAP, 24, 24, icon_flags)
+                    win32gui.ImageList_Add(self.parent.himl, him, 0)
                 except:
                     print win32api.FormatMessage(0)
 
             #~ wx.EVT_TOOL(event.container, widget.GetId(), self.__on_tool)
+            self.parent.toolbar.Connect(self.id, self.__on_tool)
 
 #    TBBUTTON stru (iBitmap, idCommand, fsState, fsStyle, dwData, iString)
-            tbb=struct.pack("iibbli", parent._buttonCount, id, 
commctrl.TBSTATE_ENABLED, style, 0, 0)
-            win32gui.SendMessage(parent.toolbar.GetHwnd(), 
commctrl.TB_ADDBUTTONS, 1, tbb)
+            tbb=struct.pack("iibbli", self.parent._buttonCount, self.id, 
commctrl.TBSTATE_ENABLED, style, 0, 0)
+            win32gui.SendMessage(self.parent.toolbar.GetHwnd(), 
commctrl.TB_ADDBUTTONS, 1, tbb)
             # i have to count myself 'coz TB_BUTTONCOUNT counts separators 
too...
-            parent._buttonCount += 1
+            self.parent._buttonCount += 1
 
 #    TOOLINFO stru (cbSize, uFlags, hwnd, uId, rect, hinst, lpszText, lParam)
             buff = array.array('c', '%s \0x00' % (textEncode(description) or 
''))
             addrText = buff.buffer_info()[0]
             format = "IIiIllllili"
             size = struct.calcsize(format)
-            ti = struct.pack(format, size, 0, parent.toolbar.GetHwnd(), id, 0, 
0, 0, 0, 0, addrText, 0)
-            win32gui.SendMessage(parent._htt, commctrl.TTM_UPDATETIPTEXT , 0, 
ti)
+            ti = struct.pack(format, size, 0, self.parent.toolbar.GetHwnd(), 
self.id, 0, 0, 0, 0, 0, addrText, 0)
+            win32gui.SendMessage(self.parent._htt, commctrl.TTM_UPDATETIPTEXT 
, 0, ti)
 
-            widget = ToolButton(parent, id, check)
+            widget = ToolButton(self.parent, self.id, self.check)
 
         else:
             widget = None
             tbb=struct.pack("iibbli", 0, 0, commctrl.TBSTATE_ENABLED, 
commctrl.TBSTYLE_SEP, 0, 0)
-            win32gui.SendMessage(parent.toolbar.GetHwnd(), 
commctrl.TB_ADDBUTTONS, 1, tbb)
+            win32gui.SendMessage(self.parent.toolbar.GetHwnd(), 
commctrl.TB_ADDBUTTONS, 1, tbb)
             
         self.__widget = widget
 
@@ -111,7 +110,7 @@
     # Events
     # -------------------------------------------------------------------------
 
-    def __on_tool(self, event):
+    def __on_tool(self, *args):
         self._gfObject._event_fire()
 
     # -------------------------------------------------------------------------
@@ -119,26 +118,33 @@
     # -------------------------------------------------------------------------
 
     def _ui_switch_on_(self):
-        if self.__widget is not None:
-            pass
+        if self.__widget is not None:
+            if self.check:
+                win32gui.SendMessage(self.parent.toolbar.GetHwnd(), 
commctrl.TB_CHECKBUTTON, self.id, 1)
+            else:
+                win32gui.SendMessage(self.parent.toolbar.GetHwnd(), 
commctrl.TB_PRESSBUTTON, self.id, 1)
+
     # -------------------------------------------------------------------------
 
     def _ui_switch_off_(self):
-        if self.__widget is not None:
-            pass
+        if self.__widget is not None:
+            if self.check:
+                win32gui.SendMessage(self.parent.toolbar.GetHwnd(), 
commctrl.TB_CHECKBUTTON, self.id, 0)
+            else:
+                win32gui.SendMessage(self.parent.toolbar.GetHwnd(), 
commctrl.TB_PRESSBUTTON, self.id, 0)
 
     # -------------------------------------------------------------------------
     # Enable/disable menu item
     # -------------------------------------------------------------------------
 
-    def _ui_enable_(self):
-        if self.__widget is not None:
+    def _ui_enable_(self):
+        if self.__widget is not None:
             win32gui.SendMessage(self.parent.toolbar.GetHwnd(), 
commctrl.TB_ENABLEBUTTON, self.id, 1)
 
     # -------------------------------------------------------------------------
 
     def _ui_disable_(self):
-        if self.__widget is not None:
+        if self.__widget is not None:
             win32gui.SendMessage(self.parent.toolbar.GetHwnd(), 
commctrl.TB_ENABLEBUTTON, self.id, 0)
 
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]