commit-gnue
[Top][All Lists]
Advanced

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

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


From: btami
Subject: [gnue] r9438 - trunk/gnue-forms/src/uidrivers/win32/widgets
Date: Mon, 12 Mar 2007 07:39:34 -0500 (CDT)

Author: btami
Date: 2007-03-12 07:39:34 -0500 (Mon, 12 Mar 2007)
New Revision: 9438

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

Modified: trunk/gnue-forms/src/uidrivers/win32/widgets/menu.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/widgets/menu.py        2007-03-12 
08:46:52 UTC (rev 9437)
+++ trunk/gnue-forms/src/uidrivers/win32/widgets/menu.py        2007-03-12 
12:39:34 UTC (rev 9438)
@@ -19,14 +19,14 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# $Id:$
+# $Id$
 
 import win32gui
 import win32con
 
-from gnue.forms.uidrivers.win32.widgets._base import UIHelper, Win32Window
+from gnue.forms.uidrivers.win32.widgets import menuitem
+from gnue.forms.uidrivers.win32.widgets._base import UIHelper, Win32Window
 from gnue.forms.uidrivers.win32.common import getNextId, textEncode
-from gnue.forms.uidrivers.win32 import MenuBar
 
 _menustyle = win32con.MF_STRING
 
@@ -49,19 +49,19 @@
         Creates a new Menu widget.
         """
         if self._gfObject.name == '__main_menu__' \
-                and not self._form._features['GUI:MENUBAR:SUPPRESS']:
+                and not self._form._features['GUI:MENUBAR:SUPPRESS']:
             # Menu bar of the form
             widget = win32gui.CreateMenu()
-            self._container = MenuBar.Menu(widget, self._uiForm.mainWindow)
+            self._container = menuitem.Menu(widget, self._uiForm.mainWindow)
             win32gui.SetMenu(self._uiForm.mainWindow.GetHwnd(), widget )
 
         else:
             # Submenu or popup menu
             widget = win32gui.CreatePopupMenu()
-            if isinstance(event.container, MenuBar.Menu):
+            if isinstance(event.container, menuitem.Menu):
                 label = textEncode(self._gfObject.label) or ''
                 win32gui.AppendMenu(event.container.id, _menustyle | 
win32con.MF_POPUP, widget, label)
-            self._container = MenuBar.Menu(widget, event.container)
+            self._container = menuitem.Menu(widget, event.container)
             
         return self._container
 

Modified: trunk/gnue-forms/src/uidrivers/win32/widgets/menuitem.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/widgets/menuitem.py    2007-03-12 
08:46:52 UTC (rev 9437)
+++ trunk/gnue-forms/src/uidrivers/win32/widgets/menuitem.py    2007-03-12 
12:39:34 UTC (rev 9438)
@@ -19,12 +19,11 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# $Id:$
+# $Id$
 
 import win32gui
 import win32con
 
-from gnue.forms.uidrivers.win32 import MenuBar
 from gnue.forms.uidrivers.win32.widgets._base import UIHelper
 from gnue.forms.uidrivers.win32.common import getNextId, textEncode
 
@@ -68,7 +67,7 @@
             widget = None
             win32gui.AppendMenu(event.container.id, win32con.MF_SEPARATOR, 0, 
"")
 
-        self.__widget = MenuBar.Menu(self.__id, event.container)
+        self.__widget = Menu(self.__id, event.container)
 
         return self.__widget
 
@@ -78,7 +77,6 @@
     # -------------------------------------------------------------------------
 
     def __on_menu(self, *args):
-        print '_event_fire'
         self._gfObject._event_fire()
 
 
@@ -116,6 +114,11 @@
                             win32con.MF_BYCOMMAND|win32con.MF_GRAYED)
 
 
+class Menu:
+    def __init__(self, id, parent):
+        self.id = id
+        self.parent = parent
+
 # =============================================================================
 # Configuration data
 # =============================================================================

Modified: trunk/gnue-forms/src/uidrivers/win32/widgets/toolbar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/widgets/toolbar.py     2007-03-12 
08:46:52 UTC (rev 9437)
+++ trunk/gnue-forms/src/uidrivers/win32/widgets/toolbar.py     2007-03-12 
12:39:34 UTC (rev 9438)
@@ -19,7 +19,7 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# $Id:$
+# $Id$
 
 import os
 import sys
@@ -60,20 +60,13 @@
         if self._gfObject.name == '__main_toolbar__' \
                 and not self._form._features['GUI:TOOLBAR:SUPPRESS']:
             print '__main_toolbar__'
-            # Make sure to disable the color-remapping in windows
-            #wx.SystemOptions.SetOption ('msw.remap', '0')
 
-            # Toolbar of the form
-            #~ if isinstance(self._uiForm.main_window, wx.Frame):
-                #~ widget = self._uiForm.main_window.CreateToolBar()
-                #~ widget.SetToolBitmapSize((24, 24))
-
-            hinst = win32api.GetModuleHandle(None)
+            self.hinst = win32api.GetModuleHandle(None)
             style = win32con.WS_CHILD | commctrl.TBSTYLE_TOOLTIPS | 
commctrl.TBSTYLE_FLAT #|win32con.WS_BORDER
             styleEx = 0
             widget = self.toolbar = mainToolBar = 
Win32Window(self._uiForm.mainWindow._uiDriver, styleEx, 
commctrl.TOOLBARCLASSNAME, "GNUe toolbar",
               style, 0, 0, 0, 0,
-              self._uiForm.mainWindow, getNextId(), hinst)
+              self._uiForm.mainWindow, getNextId(), self.hinst)
 
             style = win32con.WS_CHILD | win32con.SS_SUNKEN
             Win32Window(self._uiForm.mainWindow._uiDriver, 0, 'STATIC', '', 
style, 0, 30, 9999, 2, mainToolBar)

Modified: trunk/gnue-forms/src/uidrivers/win32/widgets/toolbutton.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/widgets/toolbutton.py  2007-03-12 
08:46:52 UTC (rev 9437)
+++ trunk/gnue-forms/src/uidrivers/win32/widgets/toolbutton.py  2007-03-12 
12:39:34 UTC (rev 9438)
@@ -19,7 +19,7 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# $Id:$
+# $Id$
 
 import os
 import sys
@@ -31,7 +31,6 @@
 import win32gui
 import commctrl
 
-from gnue.forms.uidrivers.win32 import ToolBar
 from gnue.forms.uidrivers.win32.widgets._base import UIHelper
 from gnue.forms.uidrivers.win32.common import getNextId, textEncode
 
@@ -73,23 +72,13 @@
 
             # Set the action icon if available
             if icon_file:
-                print icon_file
                 icon_flags = win32con.LR_LOADFROMFILE #| win32con.LR_SHARED
-                him = win32gui.LoadImage(0, icon_file, win32con.IMAGE_BITMAP, 
24, 24, icon_flags)
-                win32gui.ImageList_Add(event.container.himl, him, 0)
-            else:
-                print "** WARNING: Cannot a_commonGuiToolkitdd '%s' to 
toolbar; no icon" % userAction.event
-                return
+                try:
+                    him = win32gui.LoadImage(0, icon_file, 
win32con.IMAGE_BITMAP, 0, 0, icon_flags)
+                    win32gui.ImageList_Add(parent.himl, him, 0)
+                except:
+                    print win32api.FormatMessage(0)
 
-            #~ if icon_file:
-                #~ image = wx.Image(icon_file, wx.BITMAP_TYPE_PNG)
-            #~ else:
-                #~ image = None
-
-            #~ widget = event.container.AddLabelTool(wx.ID_ANY, label,
-                    #~ image.ConvertToBitmap(), kind=kind, shortHelp=label,
-                    #~ longHelp=(description or u""))
-
             #~ wx.EVT_TOOL(event.container, widget.GetId(), self.__on_tool)
 
 #    TBBUTTON stru (iBitmap, idCommand, fsState, fsStyle, dwData, iString)
@@ -106,11 +95,10 @@
             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)
 
-            widget = ToolBar.ToolButton(parent, id, check)
+            widget = ToolButton(parent, id, check)
 
         else:
-            widget = None
-            #event.container.AddSeparator()
+            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)
             
@@ -126,24 +114,17 @@
     def __on_tool(self, event):
         self._gfObject._event_fire()
 
-
     # -------------------------------------------------------------------------
     # Check/uncheck menu item
     # -------------------------------------------------------------------------
 
     def _ui_switch_on_(self):
         if self.__widget is not None:
-            # FIXME: why doesn't the next line work?
-            # self.__widget.SetToggle(True)
-            #self.__widget.GetToolBar().ToggleTool(self.__widget.GetId(), True)
             pass
     # -------------------------------------------------------------------------
 
     def _ui_switch_off_(self):
         if self.__widget is not None:
-            # FIXME: why doesn't the next line work?
-            # self.__widget.SetToggle(False)
-            #self.__widget.GetToolBar().ToggleTool(self.__widget.GetId(), 
False)
             pass
 
     # -------------------------------------------------------------------------
@@ -152,20 +133,18 @@
 
     def _ui_enable_(self):
         if self.__widget is not None:
-            # FIXME: why doesn't the next line work?
-            # self.__widget.Enable(True)
-            #self.__widget.GetToolBar().EnableTool(self.__widget.GetId(), True)
             win32gui.SendMessage(self.parent.toolbar.GetHwnd(), 
commctrl.TB_ENABLEBUTTON, self.id, 1)
 
     # -------------------------------------------------------------------------
 
     def _ui_disable_(self):
         if self.__widget is not None:
-            # FIXME: why doesn't the next line work?
-            # self.__widget.Enable(False)
-            #self.__widget.GetToolBar().EnableTool(self.__widget.GetId(), 
False)
             win32gui.SendMessage(self.parent.toolbar.GetHwnd(), 
commctrl.TB_ENABLEBUTTON, self.id, 0)
 
+
+class ToolButton:
+    def __init__(self, parent, id, check):
+        self.data = (parent, id, check)
 
 # =============================================================================
 # Configuration data





reply via email to

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