commit-gnue
[Top][All Lists]
Advanced

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

gnue/forms/src/uidrivers/win32 ToolBar.py widge...


From: Bajusz Tamás
Subject: gnue/forms/src/uidrivers/win32 ToolBar.py widge...
Date: Fri, 28 Mar 2003 18:23:30 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Bajusz Tamás <address@hidden>   03/03/28 18:23:30

Modified files:
        forms/src/uidrivers/win32: ToolBar.py 
        forms/src/uidrivers/win32/widgets: _base.py 

Log message:
        a better toolbar

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/uidrivers/win32/ToolBar.py.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/uidrivers/win32/widgets/_base.py.diff?tr1=1.8&tr2=1.9&r1=text&r2=text

Patches:
Index: gnue/forms/src/uidrivers/win32/ToolBar.py
diff -c gnue/forms/src/uidrivers/win32/ToolBar.py:1.8 
gnue/forms/src/uidrivers/win32/ToolBar.py:1.9
*** gnue/forms/src/uidrivers/win32/ToolBar.py:1.8       Sun Mar 23 07:24:28 2003
--- gnue/forms/src/uidrivers/win32/ToolBar.py   Fri Mar 28 18:23:30 2003
***************
*** 27,38 ****
  # NOTES:
  #
  
! import string, sys, struct
  import win32api, win32gui, win32con, commctrl
  from gnue.forms.uidrivers.win32.widgets._base import Win32Window
  from gnue.forms.uidrivers._commonGuiToolkit.ToolBar import ToolBar as 
_BaseToolBar
  from gnue.forms.uidrivers.win32.common import getNextId
! from gnue.common.apps import GDebug
  from gnue.common import events
  
  class ToolBar(_BaseToolBar):
--- 27,38 ----
  # NOTES:
  #
  
! import string, sys, struct, os
  import win32api, win32gui, win32con, commctrl
  from gnue.forms.uidrivers.win32.widgets._base import Win32Window
  from gnue.forms.uidrivers._commonGuiToolkit.ToolBar import ToolBar as 
_BaseToolBar
  from gnue.forms.uidrivers.win32.common import getNextId
! from gnue.common.apps import GDebug, GConfig
  from gnue.common import events
  
  class ToolBar(_BaseToolBar):
***************
*** 40,46 ****
    # Create the menu
    def init(self):
      hinst = win32api.GetModuleHandle(None)
!     style = win32con.WS_CHILD | commctrl.TBSTYLE_TOOLTIPS 
#|win32con.WS_BORDER | commctrl.TBSTYLE_FLAT
      styleEx = 0
      self.toolbar = mainToolBar = Win32Window(self.driver, styleEx, 
commctrl.TOOLBARCLASSNAME, "GNUe toolbar",
        style, 0, 0, 0, 0,
--- 40,46 ----
    # Create the menu
    def init(self):
      hinst = win32api.GetModuleHandle(None)
!     style = win32con.WS_CHILD | commctrl.TBSTYLE_TOOLTIPS |win32con.WS_BORDER 
| commctrl.TBSTYLE_FLAT
      styleEx = 0
      self.toolbar = mainToolBar = Win32Window(self.driver, styleEx, 
commctrl.TOOLBARCLASSNAME, "GNUe toolbar",
        style, 0, 0, 0, 0,
***************
*** 50,56 ****
--- 50,68 ----
      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)
+     
+     iconpath = GConfig.getInstalledBase('form_images', 'common_images')
+     iconloc = os.path.join(iconpath, 'forms', '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)
  
+     self._buttonCount = 0
      self.toolbar.Show()
  
      return self.toolbar
***************
*** 59,94 ****
    def addAction(self, name, userAction):
      parent = self.toolbar
      label = name
-     iconloc = userAction.getIconLocation(size="24x24", format="bmp")
- 
-     # Set the action icon if available
-     if iconloc:
-       try:
-         # Some caching logic for faster second/third forms
-         hIcon = _cachedIcons[iconloc]
-       except KeyError:
-         try:
-           hIcon = win32gui.LoadImage(0, iconloc, win32con.IMAGE_BITMAP, 24, 
24, win32con.LR_LOADFROMFILE)
-         except:
-           return
-         _cachedIcons[iconloc] = hIcon
-     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)))
  
-     # Pack up the image
-     tbab = struct.pack("ii", 0, hIcon)
-     iBitmap = win32gui.SendMessage(parent.GetHwnd(), commctrl.TB_ADDBITMAP, 
1, tbab)
- 
  #    TBBUTTON stru (iBitmap, idCommand, fsState, fsStyle, dwData, iString)
!     tbb=struct.pack("iibbli", iBitmap, id, commctrl.TBSTATE_ENABLED, 
commctrl.TBSTYLE_BUTTON, 0, 0)
      win32gui.SendMessage(parent.GetHwnd(), commctrl.TB_ADDBUTTONS, 1, tbb)
  
      win32gui.SendMessage(parent.GetHwnd(), commctrl.TB_ADDSTRING, 0, 
userAction.description or '')
  
--- 71,87 ----
    def addAction(self, name, userAction):
      parent = self.toolbar
      label = name
  
      # 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)
+     # i have to count myself 'coz TB_BUTTONCOUNT counts separators too...
+     self._buttonCount += 1
  
      win32gui.SendMessage(parent.GetHwnd(), commctrl.TB_ADDSTRING, 0, 
userAction.description or '')
  
***************
*** 117,122 ****
    def endingItem(self, item):
      return
      self.toolbar.ToggleTool(item,0)
- 
- 
- _cachedIcons = {}
--- 110,112 ----
Index: gnue/forms/src/uidrivers/win32/widgets/_base.py
diff -c gnue/forms/src/uidrivers/win32/widgets/_base.py:1.8 
gnue/forms/src/uidrivers/win32/widgets/_base.py:1.9
*** gnue/forms/src/uidrivers/win32/widgets/_base.py:1.8 Wed Mar 19 15:58:57 2003
--- gnue/forms/src/uidrivers/win32/widgets/_base.py     Fri Mar 28 18:23:30 2003
***************
*** 82,88 ****
        print "cursorPosition=", cursorPosition
        gfObject = self._uiDriver._IdToGFObj[self._id]
        uiobject = self._uiDriver._IdToUIObj[self._id]
!       
        if 1: #not self.hasFocus():
        # Request Focus
          uiobject._eventHandler('requestFOCUS',gfObject,_form=gfObject._form)
--- 82,88 ----
        print "cursorPosition=", cursorPosition
        gfObject = self._uiDriver._IdToGFObj[self._id]
        uiobject = self._uiDriver._IdToUIObj[self._id]
!   
        if 1: #not self.hasFocus():
        # Request Focus
          uiobject._eventHandler('requestFOCUS',gfObject,_form=gfObject._form)
***************
*** 90,95 ****
--- 90,98 ----
          uiobject._eventHandler('requestJUMPRECORD',count - 
gfObject._visibleIndex,_form=gfObject._form)
  
        
uiobject._eventHandler('requestCURSORMOVE',position=cursorPosition,_form=gfObject._form)
+       if gfObject._type == 'GFButton':
+         self.SetFocus()
+         self._connectTable[self._id](self._id)
  
      elif msg == win32con.WM_KEYDOWN:
        keycode = wParam
***************
*** 169,175 ****
                       code=10)
  
        elif command and not keycode in NOT_WM_CHAR_KEYS:
!           action = events.Event('request%s' % command)
  
        elif object._type == 'GFButton':
          print "elif GFButton"
--- 172,181 ----
                       code=10)
  
        elif command and not keycode in NOT_WM_CHAR_KEYS:
!           if keycode == 13 and object._type == 'GFButton':
!             self._connectTable[self._id](self._id)
!           else:
!             action = events.Event('request%s' % command)
  
        elif object._type == 'GFButton':
          print "elif GFButton"
***************
*** 331,341 ****
  
  
  class Win32Button(Win32Base):
! 
!   def OnWMCommand(self, hwnd, msg, wParam, lParam):
!     print 'OnWMCommand in Win32Button', hwnd, msg, wParam, lParam
!     print self._connectTable[wParam]
!     self._connectTable[wParam](wParam)
  
  
  class Win32Page(Win32Base):
--- 337,347 ----
  
  
  class Win32Button(Win32Base):
!   pass
! #  def OnWMCommand(self, hwnd, msg, wParam, lParam):
! #    print 'OnWMCommand in Win32Button', hwnd, msg, wParam, lParam
! #    print self._connectTable[wParam]
! #    self._connectTable[wParam](wParam)
  
  
  class Win32Page(Win32Base):




reply via email to

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