commit-gnue
[Top][All Lists]
Advanced

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

gnue/forms/src GFConfig.py uidrivers/win32/TODO...


From: Bajusz Tamás
Subject: gnue/forms/src GFConfig.py uidrivers/win32/TODO...
Date: Wed, 04 Jun 2003 13:00:16 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Bajusz Tamás <address@hidden>   03/06/04 13:00:16

Modified files:
        forms/src      : GFConfig.py 
        forms/src/uidrivers/win32: TODO UILoginHandler.py UIdriver.py 

Log message:
        * adding loginBMP support for win32 driver
        * removing hardcoded positioning/sizing
        * misc other win32 stuff

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFConfig.py.diff?tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/uidrivers/win32/TODO.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/uidrivers/win32/UILoginHandler.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/uidrivers/win32/UIdriver.py.diff?tr1=1.16&tr2=1.17&r1=text&r2=text

Patches:
Index: gnue/forms/src/GFConfig.py
diff -c gnue/forms/src/GFConfig.py:1.23 gnue/forms/src/GFConfig.py:1.24
*** gnue/forms/src/GFConfig.py:1.23     Sun Apr 27 11:51:36 2003
--- gnue/forms/src/GFConfig.py  Wed Jun  4 13:00:16 2003
***************
*** 295,300 ****
--- 295,306 ----
      'Description': 'Location of GNUe login logo (PNG format)',
      'Typecast'   : GTypecast.text,
      'Default'    : 'gnue.png' },
+   { 'Name'       : 'loginBMP',
+     'Type'       : 'Setting',
+     'Comment'    : 'Location of GNUe login logo (BMP format)',
+     'Description': 'Location of GNUe login logo (BMP format)',
+     'Typecast'   : GTypecast.text,
+     'Default'    : 'gnue.bmp' },
  
    { 'Name'       : 'widgetHeight',
      'Type'       : 'Setting',
Index: gnue/forms/src/uidrivers/win32/TODO
diff -c gnue/forms/src/uidrivers/win32/TODO:1.4 
gnue/forms/src/uidrivers/win32/TODO:1.5
*** gnue/forms/src/uidrivers/win32/TODO:1.4     Wed May 28 17:54:57 2003
--- gnue/forms/src/uidrivers/win32/TODO Wed Jun  4 13:00:16 2003
***************
*** 5,9 ****
  
  * handle key events when no entry in focus
  * multi-line edit CR/LF issues
- * remove hardcoded positioning/sizing from UILoginHandler.py
  * fix image widget painting bug, when stepping back to prev record
--- 5,8 ----
Index: gnue/forms/src/uidrivers/win32/UILoginHandler.py
diff -c gnue/forms/src/uidrivers/win32/UILoginHandler.py:1.4 
gnue/forms/src/uidrivers/win32/UILoginHandler.py:1.5
*** gnue/forms/src/uidrivers/win32/UILoginHandler.py:1.4        Thu May  8 
16:14:07 2003
--- gnue/forms/src/uidrivers/win32/UILoginHandler.py    Wed Jun  4 13:00:16 2003
***************
*** 33,50 ****
  from gnue.common.datasources import GLoginHandler
  from gnue.common.apps import GConfig
  from gnue.forms.uidrivers.win32.common import getNextId, centerWindow
  
  g_registeredClass = 0
  
  # Shortcut
  images_dir = GConfig.getInstalledBase('forms_images','common_images') + '/'
  
  
  #####################################################################
  ##
  ## Login Support
  ##
! ## Everything below this point is in support of the wx drivers
  ## UILoginHandler
  ##  
  #####################################################################
--- 33,54 ----
  from gnue.common.datasources import GLoginHandler
  from gnue.common.apps import GConfig
  from gnue.forms.uidrivers.win32.common import getNextId, centerWindow
+ from gnue.forms.uidrivers.win32.ErrorHandler import handleStartupError
  
  g_registeredClass = 0
  
  # Shortcut
  images_dir = GConfig.getInstalledBase('forms_images','common_images') + '/'
  
+ BUTTON = 0x0080
+ EDIT = 0x0081
+ STATIC = 0x0082
  
  #####################################################################
  ##
  ## Login Support
  ##
! ## Everything below this point is in support of the win32 drivers
  ## UILoginHandler
  ##  
  #####################################################################
***************
*** 57,79 ****
      win32gui.InitCommonControls()
      self.hinst = win32api.GetModuleHandle(None)
  
    def getLogin(self, loginData, errortext=None):#"Invalid username/password"):
      if 1: # TODO: This is left here to prevent me from having to unindent 
this code
            # TODO: Since the UI stuff is currently being gutted I'm not 
wasting the time
            # TODO: to do the right thingData.Items()
        self._loginData = loginData
        
        if len(loginData[1]):
          loginMesg = _('Login required for\n"%s"') % (loginData[1])
        else:
          loginMesg = _('Login required for %s') % (loginData[0])
  
! # TODO:
! #      if os.path.isabs(gConfigForms('loginPNG')):
! #        imageFile = gConfigForms('loginPNG')
! #      else:
! #        imageFile = images_dir+gConfigForms('loginPNG')
!       imageFile = images_dir + 'gnue.bmp'
        self._bmp = win32gui.LoadImage(0, imageFile, win32con.IMAGE_BITMAP, 
                                            0, 0, win32con.LR_LOADFROMFILE | 
win32con.LR_DEFAULTSIZE)
  
--- 61,91 ----
      win32gui.InitCommonControls()
      self.hinst = win32api.GetModuleHandle(None)
  
+     _font = win32gui.GetStockObject(win32con.SYSTEM_FONT)
+     fn = win32gui.GetObject(_font)
+     #print fn.lfHeight, fn.lfWidth,fn.lfCharSet,fn.lfPitchAndFamily
+     self.charWidth,self.charHeight = fn.lfWidth, fn.lfHeight
+ 
    def getLogin(self, loginData, errortext=None):#"Invalid username/password"):
      if 1: # TODO: This is left here to prevent me from having to unindent 
this code
            # TODO: Since the UI stuff is currently being gutted I'm not 
wasting the time
            # TODO: to do the right thingData.Items()
        self._loginData = loginData
+       self._errortext = errortext
        
        if len(loginData[1]):
          loginMesg = _('Login required for\n"%s"') % (loginData[1])
        else:
          loginMesg = _('Login required for %s') % (loginData[0])
  
!       if os.path.isabs(gConfigForms('loginBMP')):
!         imageFile = gConfigForms('loginBMP')
!       else:
!         imageFile = images_dir+gConfigForms('loginBMP')
! 
!       if not imageFile[-3:].upper() == 'BMP':
!         handleStartupError(_("The win32 forms driver supports only BMP format 
logo files!"))
! 
        self._bmp = win32gui.LoadImage(0, imageFile, win32con.IMAGE_BITMAP, 
                                            0, 0, win32con.LR_LOADFROMFILE | 
win32con.LR_DEFAULTSIZE)
  
***************
*** 86,132 ****
  
        style = win32con.WS_POPUP | win32con.WS_VISIBLE | win32con.WS_CAPTION | 
\
                  win32con.DS_SETFONT | win32con.WS_SYSMENU
!               
        cs = win32con.WS_CHILD | win32con.WS_VISIBLE
        title = _("GNU Enterprise: Login to %s") % loginData[0]
  
!       dlg = [ [title, (0, 0, 200, 180), style, None, (8, "MS Sans Serif"), 
None, dlgClassName], ]
  
-       Y=10
        self.ID_BITMAP = getNextId()
!       dlg.append([130, "", self.ID_BITMAP, (55, Y, 0, 0), win32con.WS_VISIBLE 
| win32con.SS_BITMAP])
!       Y += 40
! 
!       dlg.append([130, str(loginMesg), -1, (5, Y, 195, 100), cs | 
win32con.SS_CENTER])
  
        self.textctrlList = []
  
-       Y += 10
        for prompt in loginData[2]:
!         Y += 20
!         dlg.append([130, '%s:' % prompt[1], -1, (5, Y, 200, 12), cs | 
win32con.SS_LEFT])
  
          s = cs | win32con.WS_TABSTOP | win32con.WS_BORDER
          ID = getNextId()
          if prompt[2]:
!           dlg.append([129, None, ID, (55, Y, 100, 12), s | 
win32con.ES_PASSWORD])
          else:
!           dlg.append([129, None, ID, (55, Y, 100, 12), s])
          self.textctrlList.append(ID)
  
!       if errortext:
!         Y += 20
!         dlg.append([130, str(errortext), -1, (5, Y, 190, 100), cs | 
win32con.SS_CENTER])
          #errorField.SetForegroundColour(wxColour(223,0,0))
  
        # Buttons
!       Y += 40
        s = cs | win32con.WS_TABSTOP
!       self.ID_Login = getNextId()
!       dlg.append([128, _('Login'), self.ID_Login, (35, Y, 50, 14), s | 
win32con.BS_DEFPUSHBUTTON])
        s = s | win32con.BS_PUSHBUTTON
!       self.ID_Cancel = getNextId()
!       dlg.append([128, _('Cancel'), self.ID_Cancel, (115, Y, 50, 14), s])
  
      # If user cancels, this will be set to 0
      self._completed = 0
--- 98,160 ----
  
        style = win32con.WS_POPUP | win32con.WS_VISIBLE | win32con.WS_CAPTION | 
\
                  win32con.DS_SETFONT | win32con.WS_SYSMENU
! 
        cs = win32con.WS_CHILD | win32con.WS_VISIBLE
        title = _("GNU Enterprise: Login to %s") % loginData[0]
  
!       dlg = [ [title, (0, 0, 0, 0), style, None, (8, "MS Sans Serif"), None, 
dlgClassName], ]
  
        self.ID_BITMAP = getNextId()
!       dlg.append([STATIC, "", self.ID_BITMAP, \
!                        (0, 0, 0, 0), \
!                        win32con.WS_VISIBLE | win32con.SS_BITMAP]) # , 
win32con.SS_BLACKFRAME
! 
!       self.ID_MESG = getNextId()
!       dlg.append([STATIC, loginMesg, self.ID_MESG, \
!                        (0, 0, 100, 
(self.charHeight-4)*(loginMesg.count('\n')+1)), \
!                        cs | win32con.SS_CENTER])
  
        self.textctrlList = []
+       self.labelList = []
  
        for prompt in loginData[2]:
!         ID = getNextId()
!         dlg.append([STATIC, '%s:' % prompt[1], ID, \
!                          (0, 0, (self.charWidth-2)*len(prompt[1]), 
self.charHeight-4), \
!                          cs | win32con.SS_LEFT])
!         self.labelList.append(ID)
  
          s = cs | win32con.WS_TABSTOP | win32con.WS_BORDER
          ID = getNextId()
          if prompt[2]:
!           dlg.append([EDIT, None, ID, (0, 0, 100, self.charHeight-4), \
!                           s | win32con.ES_PASSWORD])
          else:
!           dlg.append([EDIT, None, ID, (0, 0, 100, self.charHeight-4), s])
          self.textctrlList.append(ID)
  
!       if self._errortext:
!         self.ID_ERROR = getNextId()
!         dlg.append([STATIC, str(self._errortext), self.ID_ERROR, \
!                         (0, 0, 210, 
(self.charHeight-4)*(self._errortext.count('\n')+2)), \
!                         cs | win32con.SS_CENTER])
          #errorField.SetForegroundColour(wxColour(223,0,0))
  
        # Buttons
!       login = _('Login')
!       cancel = _('Cancel')
!       buttonWidth = max(50, (self.charWidth-2)*len(login), 
(self.charWidth-2)*len(cancel))
        s = cs | win32con.WS_TABSTOP
!       self.ID_LOGIN = getNextId()
!       dlg.append([BUTTON, login, self.ID_LOGIN, \
!                       (0, 0, buttonWidth, self.charHeight-2), \
!                       s | win32con.BS_DEFPUSHBUTTON]) \
! 
        s = s | win32con.BS_PUSHBUTTON
!       self.ID_CANCEL = getNextId()
!       dlg.append([BUTTON, cancel, self.ID_CANCEL, \
!                       (0, 0, buttonWidth, self.charHeight-2), \
!                       s])
  
      # If user cancels, this will be set to 0
      self._completed = 0
***************
*** 160,174 ****
  
  
    def OnInitDialog(self, hwnd, msg, wparam, lparam):
!         # TODO: calculate and reposition the dialog items
!         # TODO: and resize the dialog window
!         self.hwnd = hwnd
! 
!         bmCtrl = win32gui.GetDlgItem(self.hwnd, self.ID_BITMAP)
!         win32gui.SendMessage(bmCtrl, win32con.STM_SETIMAGE, 
win32con.IMAGE_BITMAP, self._bmp)
! 
!         # center the dialog
!         centerWindow(hwnd)
  
    def OnClose(self, hwnd, msg, wparam, lparam):
          win32gui.EndDialog(hwnd, 0)
--- 188,274 ----
  
  
    def OnInitDialog(self, hwnd, msg, wparam, lparam):
!     # TODO: calculate and reposition the dialog items
!     # TODO: and resize the dialog window
!     self.hwnd = hwnd
! 
!     bmCtrl = win32gui.GetDlgItem(self.hwnd, self.ID_BITMAP)
!     win32gui.SendMessage(bmCtrl, win32con.STM_SETIMAGE, 
win32con.IMAGE_BITMAP, self._bmp)
! 
!     dlgWidth = max(self.Width(self.ID_BITMAP), self.Width(self.ID_MESG)+20)
!     dlgHeight = self.Height(self.ID_BITMAP) + self.Height(self.ID_MESG) + 95
! 
!     xSpacing = 0
!     ySpacing = 0
!     fieldLabelWidth = 0
! 
!     for i in range(len(self.textctrlList)):
!       t =self.textctrlList[i]
!       s = self.labelList[i]
! 
!       fieldLabelWidth = max(fieldLabelWidth, \
!                       self.Width(s) + self.Width(t) + 10)
! 
!       dlgWidth = max(dlgWidth, \
!                       self.Width(s) + self.Width(t) + 20)
! 
!       xSpacing = max(xSpacing, self.Width(s))
!       ySpacing = max(ySpacing, self.Height(s))
!       ySpacing = max(ySpacing, self.Height(t))
! 
!     dlgWidth = max(dlgWidth, self.Width(self.ID_LOGIN) +
!                         self.Width(self.ID_CANCEL) + 6) + 20
! 
!     dlgHeight += max(self.Height(self.ID_LOGIN),
!                    self.Height(self.ID_CANCEL)) -6
! 
!     if self._errortext:
!       dlgWidth = max(dlgWidth, self.Width(self.ID_ERROR)+10)
!       dlgHeight += self.Height(self.ID_ERROR) + 10
! 
!     firstY = self.Height(self.ID_BITMAP) + self.Height(self.ID_MESG) + 40
!     lastY = firstY
!     xSpacing += 3 # Add whitespace between widgets
!     ySpacing += 6 # Add whitespace between widgets
!     xPos = dlgWidth/2 - fieldLabelWidth/2
! 
!     self.SetPosition(self.ID_BITMAP,
!                 (dlgWidth - self.Width(self.ID_BITMAP))/2,
!                 12)
! 
!     self.SetPosition(self.ID_MESG,
!                 (dlgWidth - self.Width(self.ID_MESG))/2,
!                 30 + self.Height(self.ID_BITMAP))
! 
!     # Move the fields and labels into position
!     for i in range(len(self.textctrlList)):
!       dlgHeight = dlgHeight + ySpacing
!       self.SetPosition(self.labelList[i], xPos, lastY)
!       self.SetPosition(self.textctrlList[i], xPos + xSpacing, lastY)
!       lastY = lastY + ySpacing
! 
!     if self._errortext:
!       self.SetPosition(self.ID_ERROR,
!               dlgWidth/2 - self.Width(self.ID_ERROR)/2,
!               lastY+3)
! 
!     self.SetPosition(self.ID_CANCEL,
!                 dlgWidth - 20 - self.Width(self.ID_CANCEL),
!                 dlgHeight - 35 - max(self.Height(self.ID_LOGIN),
!                                             self.Height(self.ID_CANCEL)))
!     self.SetPosition(self.ID_LOGIN,
!                 dlgWidth - 26 - self.Width(self.ID_CANCEL) - \
!                 self.Width(self.ID_LOGIN),
!                 dlgHeight - 35 - max(self.Height(self.ID_LOGIN),
!                                             self.Height(self.ID_CANCEL)))
! 
!     # resize the dialog
!     win32gui.SetWindowPos(hwnd, 0,
!                               0, 0,
!                               dlgWidth, dlgHeight+8,
!                               win32con.SWP_NOACTIVATE | win32con.SWP_NOZORDER)
!     # center the dialog
!     centerWindow(self.hwnd)
  
    def OnClose(self, hwnd, msg, wparam, lparam):
          win32gui.EndDialog(hwnd, 0)
***************
*** 176,189 ****
  
    def OnCommand(self, hwnd, msg, wparam, lparam):
          id = win32api.LOWORD(wparam)
!         if id == self.ID_Login:
            for i in range(0, len(self._loginData[2])):
              dlgItem = win32gui.GetDlgItem(self.hwnd, self.textctrlList[i])
              self._rv[self._loginData[2][i][0]] = 
win32gui.GetWindowText(dlgItem)
            self._completed = 1
            win32gui.EndDialog(hwnd, 0)
!         elif id == self.ID_Cancel:
            self._completed = 0
            win32gui.EndDialog(hwnd, 0)
  
  
--- 276,325 ----
  
    def OnCommand(self, hwnd, msg, wparam, lparam):
          id = win32api.LOWORD(wparam)
!         if id == self.ID_LOGIN:
            for i in range(0, len(self._loginData[2])):
              dlgItem = win32gui.GetDlgItem(self.hwnd, self.textctrlList[i])
              self._rv[self._loginData[2][i][0]] = 
win32gui.GetWindowText(dlgItem)
            self._completed = 1
            win32gui.EndDialog(hwnd, 0)
!         elif id == self.ID_CANCEL:
            self._completed = 0
            win32gui.EndDialog(hwnd, 0)
  
  
+   def Width(self, id):
+     item = win32gui.GetDlgItem(self.hwnd, id)
+     l,t,r,b = win32gui.GetWindowRect(item)
+     return r-l
+ 
+   def Height(self, id):
+     item = win32gui.GetDlgItem(self.hwnd, id)
+     l,t,r,b = win32gui.GetWindowRect(item)
+     return b-t
+ 
+   def SetPosition(self, id, x, y):
+     win32gui.SetWindowPos(win32gui.GetDlgItem(self.hwnd, id),
+                               0,
+                               x, y,
+                               self.Width(id), self.Height(id),
+                               win32con.SWP_NOACTIVATE | win32con.SWP_NOZORDER)
+ 
+ #  def GetCharWidth(self):
+ #    PyCWnd = win32ui.CreateWindowFromHandle(self.hwnd)
+ #    font = win32gui.GetStockObject(win32con.SYSTEM_FONT)
+ #    xwin32gui.SendMessage(self.hwnd, win32con.WM_SETFONT, font, 0)
+ #    PyCWnd.SetFont(font,1)
+ 
+ #    dc = PyCWnd.GetWindowDC()
+ #    dc.SelectObject(font)
+ 
+ #    metrics = dc.GetTextMetrics()
+ #    maxWidth = metrics["tmAveCharWidth"]
+ #    maxLeading = metrics["tmExternalLeading"]
+ 
+ #    PyCWnd.ReleaseDC(dc)
+ 
+ #    return int(maxWidth+maxLeading)
+ 
+ #    win32gui.SendMessage(id, WM_SETFONT,
+ #                              font, 0)
Index: gnue/forms/src/uidrivers/win32/UIdriver.py
diff -c gnue/forms/src/uidrivers/win32/UIdriver.py:1.16 
gnue/forms/src/uidrivers/win32/UIdriver.py:1.17
*** gnue/forms/src/uidrivers/win32/UIdriver.py:1.16     Wed May 28 17:54:57 2003
--- gnue/forms/src/uidrivers/win32/UIdriver.py  Wed Jun  4 13:00:16 2003
***************
*** 30,36 ****
  import sys
  import string
  
! import win32gui, win32con, afxres, commctrl, win32clipboard
  
  from gnue.common import events
  from gnue.common.apps import GDebug
--- 30,36 ----
  import sys
  import string
  
! import win32gui, win32con, afxres, commctrl, win32clipboard, win32ui
  
  from gnue.common import events
  from gnue.common.apps import GDebug
***************
*** 94,107 ****
      ################################################################
      # win32 Specifics
      ################################################################
!     win32gui.InitCommonControls() 
  
      if not self._wndclass:
        # Register the "GNUeWindow" class.
        wc = win32gui.WNDCLASS()
        wc.lpszClassName = "GNUeWindow"
        wc.hCursor = win32gui.LoadCursor( 0, win32con.IDC_ARROW )
!       wc.hIcon = win32gui.LoadIcon(0, win32con.IDI_APPLICATION)
        wc.hbrBackground = win32con.COLOR_BTNSHADOW #win32con.COLOR_WINDOW
        wc.lpfnWndProc = self._wndproc
        self.__class__._wndclass = win32gui.RegisterClass(wc)
--- 94,112 ----
      ################################################################
      # win32 Specifics
      ################################################################
!     win32gui.InitCommonControls()
!     try:
!       icon = win32gui.LoadImage(0, sys.prefix+'\py.ico', win32con.IMAGE_ICON, 
!                                           0, 0, win32con.LR_LOADFROMFILE | 
win32con.LR_DEFAULTSIZE)
!     except:
!       icon = win32gui.LoadIcon(0, win32con.IDI_APPLICATION)
  
      if not self._wndclass:
        # Register the "GNUeWindow" class.
        wc = win32gui.WNDCLASS()
        wc.lpszClassName = "GNUeWindow"
        wc.hCursor = win32gui.LoadCursor( 0, win32con.IDC_ARROW )
!       wc.hIcon = icon
        wc.hbrBackground = win32con.COLOR_BTNSHADOW #win32con.COLOR_WINDOW
        wc.lpfnWndProc = self._wndproc
        self.__class__._wndclass = win32gui.RegisterClass(wc)
***************
*** 190,197 ****
      win32gui.SetForegroundWindow(child.mainWindow.GetHwnd())
  
    def _beep(self):
!     pass
!     #wxBell()
  
    
#############################################################################
    #
--- 195,201 ----
      win32gui.SetForegroundWindow(child.mainWindow.GetHwnd())
  
    def _beep(self):
!     win32gui.MessageBeep(0)
  
    
#############################################################################
    #
***************
*** 225,239 ****
    # interact with interface (e.g., while waiting for a query or a commit)
    #
    def beginWait (self, event):
!     pass
! #    wxBeginBusyCursor()
  
    #
    # Called whenever forms leaves a "wait" state
    #
    def endWait (self, event):
!     pass
! #    wxEndBusyCursor()
  
  
    #
--- 229,241 ----
    # interact with interface (e.g., while waiting for a query or a commit)
    #
    def beginWait (self, event):
!     win32ui.DoWaitCursor(1)
  
    #
    # Called whenever forms leaves a "wait" state
    #
    def endWait (self, event):
!     win32ui.DoWaitCursor(0)
  
  
    #




reply via email to

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