commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r9441 - in trunk/gnue-forms/src/uidrivers/win32: . widgets widget


From: btami
Subject: [gnue] r9441 - in trunk/gnue-forms/src/uidrivers/win32: . widgets widgets/form
Date: Tue, 13 Mar 2007 05:32:27 -0500 (CDT)

Author: btami
Date: 2007-03-13 05:32:26 -0500 (Tue, 13 Mar 2007)
New Revision: 9441

Removed:
   trunk/gnue-forms/src/uidrivers/win32/MenuBar.py
   trunk/gnue-forms/src/uidrivers/win32/ToolBar.py
Modified:
   trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py
   trunk/gnue-forms/src/uidrivers/win32/widgets/toolbar.py
   trunk/gnue-forms/src/uidrivers/win32/widgets/toolbutton.py
Log:
cleanup

Deleted: trunk/gnue-forms/src/uidrivers/win32/MenuBar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/MenuBar.py     2007-03-12 17:56:32 UTC 
(rev 9440)
+++ trunk/gnue-forms/src/uidrivers/win32/MenuBar.py     2007-03-13 10:32:26 UTC 
(rev 9441)
@@ -1,102 +0,0 @@
-# This file is part of GNU Enterprise.
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# Copyright 2000-2007 Free Software Foundation
-#
-# $Id$
-#
-# DESCRIPTION:
-# A PyWin32 based user interface driver for GNUe forms.
-#
-# NOTES:
-#
-
-import win32gui
-import win32con
-
-from gnue.common import events
-
-from gnue.forms.uidrivers._commonGuiToolkit.MenuBar import MenuBar as 
_BaseMenuBar
-from gnue.forms.uidrivers.win32.common import getNextId, textEncode
-
-_menustyle = win32con.MF_STRING
-
-class MenuBar(_BaseMenuBar):
-
-    # Create the menu
-    def init(self):
-        self.menu = win32gui.CreateMenu()
-        win32gui.SetMenu(self.container.GetHwnd(), self.menu )
-        return Menu(self.menu, self.container)
-
-    # Add a (sub)menu
-    def addMenu(self, name, parent):
-        menu = win32gui.CreatePopupMenu()
-        win32gui.AppendMenu(parent.id, _menustyle | win32con.MF_POPUP, menu, 
textEncode(name))
-        return Menu(menu, parent)
-
-    # Add a menu item (action)
-    def addAction(self, name, parent, userAction):
-        label = name
-        hotkey = userAction.getHotKeyText()
-        iconloc = userAction.getIconLocation(size="16x16")
-
-        if hotkey:
-            label += '\t%s' % hotkey
-
-        # Set the action icon if available
-        if iconloc:
-            try:
-                # Some caching logic for faster second/third forms
-                icon = _cachedIcons[iconloc]
-            except KeyError:
-                pass
-
-        id = getNextId()
-        self.container.addDescription(id, textEncode(userAction.description) 
or '')
-        win32gui.AppendMenu(parent.id, _menustyle, id, textEncode(label))
-        self.container.Connect(id, lambda u=userAction: self._fire(u))
-
-        return Menu(id, parent)
-
-
-    # Add a separator
-    def addSeparator(self, parent):
-        win32gui.AppendMenu(parent.id, win32con.MF_SEPARATOR, 0, "")
-
-    # Enable a menu item
-    def enableItem(self, item):
-        try:
-            win32gui.EnableMenuItem(item.parent.id, item.id, 
win32con.MF_BYCOMMAND|win32con.MF_ENABLED)
-        except:
-            pass
-
-    # Disable a menu item
-    def disableItem(self, item):
-        try:
-            win32gui.EnableMenuItem(item.parent.id, item.id, 
win32con.MF_BYCOMMAND|win32con.MF_GRAYED)
-        except:
-            pass
-
-
-class Menu:
-    def __init__(self, id, parent):
-        self.id = id
-        self.parent = parent
-
-
-_cachedIcons = {}

Deleted: trunk/gnue-forms/src/uidrivers/win32/ToolBar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/ToolBar.py     2007-03-12 17:56:32 UTC 
(rev 9440)
+++ trunk/gnue-forms/src/uidrivers/win32/ToolBar.py     2007-03-13 10:32:26 UTC 
(rev 9441)
@@ -1,172 +0,0 @@
-# This file is part of GNU Enterprise.
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# Copyright 2000-2007 Free Software Foundation
-#
-# $Id$
-#
-# DESCRIPTION:
-# A PyWin32 based user interface driver for GNUe forms.
-#
-# NOTES:
-#
-
-import os
-import sys
-import array
-import struct
-
-import win32api
-import win32con
-import win32gui
-import commctrl
-
-from gnue.common import events
-from gnue.common.apps import GConfig
-
-from gnue.forms.uidrivers._commonGuiToolkit.ToolBar import ToolBar as 
_BaseToolBar
-from gnue.forms.uidrivers.win32.widgets._base import Win32Window
-from gnue.forms.uidrivers.win32.common import getNextId, textEncode
-
-winver = sys.getwindowsversion()
-XP = winver[0]==5 and winver[1]==1 and winver[3]==2
-
-class ToolBar(_BaseToolBar):
-
-    # Create the menu
-    def init(self):
-        hinst = win32api.GetModuleHandle(None)
-        style = win32con.WS_CHILD | commctrl.TBSTYLE_TOOLTIPS | 
commctrl.TBSTYLE_FLAT #|win32con.WS_BORDER
-        styleEx = 0
-        self.toolbar = mainToolBar = Win32Window(self.driver, styleEx, 
commctrl.TOOLBARCLASSNAME, "GNUe toolbar",
-          style, 0, 0, 0, 0,
-          self.container, getNextId(), hinst)
-
-        style = win32con.WS_CHILD | win32con.SS_SUNKEN
-        Win32Window(self.driver, 0, 'STATIC', '', style, 0, 30, 9999, 2, 
self.toolbar)
-    
-        if XP:
-            self.himl = himl = win32gui.ImageList_Create(24, 24, 
commctrl.ILC_COLOR32, 0, 3)
-        else:
-            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"
-                return
-            else:
-                himl = win32gui.ImageList_LoadImage(0, iconloc, 24, 0, 
win32api.RGB(192,192,192), 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)
-
-        self._htt = win32gui.SendMessage(mainToolBar.GetHwnd(), 
commctrl.TB_GETTOOLTIPS, 0, 0)
-        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
-
-    # Add a menu item (action)
-    def addAction(self, name, userAction):
-        parent = self.toolbar
-        label = name
-
-        # Create an event binding in windows
-        id = getNextId()
-        event = 'request' + userAction.event
-    
-        if XP:
-            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
-        
-        if userAction.canToggle:
-            self.container.Connect(id, 
-              lambda u=userAction,
-                    tb=parent.GetHwnd(): self._fire(u,
-                        not win32gui.SendMessage(tb, 
commctrl.TB_ISBUTTONCHECKED, id,
-                            0)))
-            check = 1
-            style = commctrl.TBSTYLE_CHECK
-      
-        else:
-            self.container.Connect(id, 
-              lambda u=userAction: self._fire(u, False))
-            check = 0
-            style = commctrl.TBSTYLE_BUTTON
-
-#    TBBUTTON stru (iBitmap, idCommand, fsState, fsStyle, dwData, iString)
-        tbb=struct.pack("iibbli", self._buttonCount, id, 
commctrl.TBSTATE_ENABLED, style, 0, 0)
-        win32gui.SendMessage(parent.GetHwnd(), commctrl.TB_ADDBUTTONS, 1, tbb)
-        # i have to count myself 'coz TB_BUTTONCOUNT counts separators too...
-        self._buttonCount += 1
-
-#    TOOLINFO stru (cbSize, uFlags, hwnd, uId, rect, hinst, lpszText, lParam)
-        buff = array.array('c', '%s \0x00' % 
(textEncode(userAction.description) or ''))
-        addrText = buff.buffer_info()[0]
-        format = "IIiIllllili"
-        size = struct.calcsize(format)
-        ti = struct.pack(format, size, 0, self.toolbar.GetHwnd(), id, 0, 0, 0, 
0, 0, addrText, 0)
-        win32gui.SendMessage(self._htt, commctrl.TTM_UPDATETIPTEXT , 0, ti)
-
-#        return (parent, id, check)
-        return ToolButton(parent, id, check)
-
-
-    # Add a separator
-    def addSeparator(self):
-        tbb=struct.pack("iibbli", 0, 0, commctrl.TBSTATE_ENABLED, 
commctrl.TBSTYLE_SEP, 0, 0)
-        win32gui.SendMessage(self.toolbar.GetHwnd(), commctrl.TB_ADDBUTTONS, 
1, tbb)
-
-    # Enable a menu item
-    def enableItem(self, item):
-        parent, id, check = item.data
-        win32gui.SendMessage(self.toolbar.GetHwnd(), commctrl.TB_ENABLEBUTTON, 
id, 1)
-
-    # Disable a menu item
-    def disableItem(self, item):
-        parent, id, check = item.data
-        win32gui.SendMessage(self.toolbar.GetHwnd(), commctrl.TB_ENABLEBUTTON, 
id, 0)
-
-    def startingItem(self, item):
-        parent, id, check = item.data
-        if check:
-            win32gui.SendMessage(self.toolbar.GetHwnd(), 
commctrl.TB_CHECKBUTTON, id, 1)
-        else:
-            win32gui.SendMessage(self.toolbar.GetHwnd(), 
commctrl.TB_PRESSBUTTON, id, 1)
-
-    def endingItem(self, item):
-        parent, id, check = item.data
-        if check:
-            win32gui.SendMessage(self.toolbar.GetHwnd(), 
commctrl.TB_CHECKBUTTON, id, 0)
-        else:
-            win32gui.SendMessage(self.toolbar.GetHwnd(), 
commctrl.TB_PRESSBUTTON, id, 0)
-
-
-class ToolButton:
-    def __init__(self, parent, id, check):
-        self.data = (parent, id, check)

Modified: trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py 2007-03-12 
17:56:32 UTC (rev 9440)
+++ trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py 2007-03-13 
10:32:26 UTC (rev 9441)
@@ -100,7 +100,7 @@
             self.buttonbarHeight = 0
         else:
             # TODO: calculate
-            self.buttonbarWidth = 13*(24+8) + 5*7 #buttons and separators
+            self.buttonbarWidth = 13*(24+8) + 6*7 #buttons and separators
             self.buttonbarHeight = 24+8
 
         if object._layout.tabbed != 'none':

Modified: trunk/gnue-forms/src/uidrivers/win32/widgets/toolbar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/widgets/toolbar.py     2007-03-12 
17:56:32 UTC (rev 9440)
+++ trunk/gnue-forms/src/uidrivers/win32/widgets/toolbar.py     2007-03-13 
10:32:26 UTC (rev 9441)
@@ -21,9 +21,6 @@
 #
 # $Id$
 
-import os
-import sys
-import array
 import struct
 
 import win32api
@@ -34,8 +31,6 @@
 from gnue.forms.uidrivers.win32.widgets._base import UIHelper, Win32Window
 from gnue.forms.uidrivers.win32.common import getNextId, textEncode
 
-winver = sys.getwindowsversion()
-XP = winver[0]>5 or (winver[0]==5 and winver[1]>=1 and winver[3]==2)
 
 # =============================================================================
 # Wrap an UI layer around a wxMenu widget

Modified: trunk/gnue-forms/src/uidrivers/win32/widgets/toolbutton.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/widgets/toolbutton.py  2007-03-12 
17:56:32 UTC (rev 9440)
+++ trunk/gnue-forms/src/uidrivers/win32/widgets/toolbutton.py  2007-03-13 
10:32:26 UTC (rev 9441)
@@ -21,8 +21,6 @@
 #
 # $Id$
 
-import os
-import sys
 import array
 import struct
 
@@ -77,7 +75,6 @@
                 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)
@@ -102,7 +99,7 @@
             win32gui.SendMessage(self.parent.toolbar.GetHwnd(), 
commctrl.TB_ADDBUTTONS, 1, tbb)
             
         self.__widget = widget
-
+
         return widget
 
 
@@ -151,6 +148,7 @@
 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]