commit-gnue
[Top][All Lists]
Advanced

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

r6252 - in trunk/gnue-forms: images/default src/uidrivers/win32


From: btami
Subject: r6252 - in trunk/gnue-forms: images/default src/uidrivers/win32
Date: Sat, 4 Sep 2004 16:56:25 -0500 (CDT)

Author: btami
Date: 2004-09-04 16:56:24 -0500 (Sat, 04 Sep 2004)
New Revision: 6252

Added:
   trunk/gnue-forms/images/default/toolbar-24x24.bmp
Modified:
   trunk/gnue-forms/src/uidrivers/win32/ToolBar.py
Log:
changed back to pre XP compatible toolbar handling

Added: trunk/gnue-forms/images/default/toolbar-24x24.bmp
===================================================================
(Binary files differ)


Property changes on: trunk/gnue-forms/images/default/toolbar-24x24.bmp
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/gnue-forms/src/uidrivers/win32/ToolBar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/ToolBar.py     2004-09-04 14:39:54 UTC 
(rev 6251)
+++ trunk/gnue-forms/src/uidrivers/win32/ToolBar.py     2004-09-04 21:56:24 UTC 
(rev 6252)
@@ -34,8 +34,7 @@
 from gnue.forms.uidrivers.win32.common import getNextId
 from gnue.common.apps import GDebug, GConfig
 from gnue.common import events
-
-
+
 class ToolBar(_BaseToolBar):
 
   # Create the menu
@@ -47,22 +46,29 @@
       style, 0, 0, 0, 0,
       self.container, getNextId(), hinst)
 
-    win32gui.SendMessage(mainToolBar.GetHwnd(), commctrl.TB_BUTTONSTRUCTSIZE, 
12, 0)
-    win32gui.SendMessage(mainToolBar.GetHwnd(), commctrl.TB_SETBITMAPSIZE, 0, 
(24<<16) + 24) # 24x24
-    win32gui.SendMessage(mainToolBar.GetHwnd(), commctrl.TB_SETBUTTONSIZE, 0, 
(24<<16) + 24)  # 24x24
-    #win32gui.SendMessage(mainToolBar.GetHwnd(), commctrl.TB_AUTOSIZE, 0, 0)
+#    win32gui.SendMessage(mainToolBar.GetHwnd(), commctrl.TB_BUTTONSTRUCTSIZE, 
12, 0)
+#    win32gui.SendMessage(mainToolBar.GetHwnd(), commctrl.TB_SETBITMAPSIZE, 0, 
(24<<16) + 24) # 24x24
+#    win32gui.SendMessage(mainToolBar.GetHwnd(), commctrl.TB_SETBUTTONSIZE, 0, 
(24<<16) + 24)  # 24x24
 
     style = win32con.WS_CHILD | win32con.SS_SUNKEN
     Win32Window(self.driver, 0, 'STATIC', '', style, 0, 30, 9999, 2, 
self.toolbar)
 
-    self.himl = himl = win32gui.ImageList_Create(24, 24, commctrl.ILC_COLOR32, 
0, 3)
+    iconpath = GConfig.getInstalledBase('form_images', 'common_images')
+    iconloc = os.path.join(iconpath, 'forms/default', 'toolbar-24x24.bmp')
+    if not os.path.isfile(iconloc):
+      print "*** WARNING: Cannot add 'toolbar-24x24.bmp' to toolbar"
+    else:
+      # commctrl.CLR_DEFAULT = 0xFF000000L produces OverflowError...
+      himl = win32gui.ImageList_LoadImage(0, iconloc, 24, 0, 0xFF000000, 
win32con.IMAGE_BITMAP,
+        win32con.LR_LOADFROMFILE | win32con.LR_SHARED | 
win32con.LR_CREATEDIBSECTION)
+      tbab = struct.pack("ii", 0, himl)
+      win32gui.SendMessage(mainToolBar.GetHwnd(), commctrl.TB_SETIMAGELIST, 0, 
himl)
 
-    tbab = struct.pack("ii", 0, himl)
-    win32gui.SendMessage(mainToolBar.GetHwnd(), commctrl.TB_SETIMAGELIST, 0, 
himl)
-
     self._htt = win32gui.SendMessage(mainToolBar.GetHwnd(), 
commctrl.TB_GETTOOLTIPS, 0, 0)
-    win32gui.SendMessage(self._htt, commctrl.TTM_SETMAXTIPWIDTH , 0, 250)
+    win32gui.SendMessage(self._htt, commctrl.TTM_SETMAXTIPWIDTH , 0, 250)
+    
     self._buttonCount = 0
+    win32gui.SendMessage(mainToolBar.GetHwnd(), commctrl.TB_AUTOSIZE, 0, 0)
     self.toolbar.Show()
 
     return self.toolbar
@@ -71,26 +77,12 @@
   def addAction(self, name, userAction):
     parent = self.toolbar
     label = name
-
-    id = getNextId()
-    event = 'request' + userAction.event
-
-    iconloc = userAction.getIconLocation(format="bmp", size="24x24")
-    
-    # Set the action icon if available
-    if iconloc:
-      icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_SHARED
-      
-      him = win32gui.LoadImage(0, iconloc, win32con.IMAGE_BITMAP, 24, 24, 
icon_flags)
-      win32gui.ImageList_Add(self.himl, him, 0)
-
-    else:
-      print "** WARNING: Cannot add '%s' to toolbar; no icon" % 
userAction.event
-      return
 
     # Create an event binding in windows
+    id = getNextId()
+    event = 'request' + userAction.event
     self.container.Connect(id, lambda l=self.driver, e=event, f=self.form: 
l.dispatchEvent(events.Event(e,_form=f)))
-
+
 #    TBBUTTON stru (iBitmap, idCommand, fsState, fsStyle, dwData, iString)
     tbb=struct.pack("iibbli", self._buttonCount, id, commctrl.TBSTATE_ENABLED, 
commctrl.TBSTYLE_BUTTON, 0, 0)
     win32gui.SendMessage(parent.GetHwnd(), commctrl.TB_ADDBUTTONS, 1, tbb)





reply via email to

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