commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r9027 - in trunk/gnue-forms/src/uidrivers/win32: . widgets/form


From: btami
Subject: [gnue] r9027 - in trunk/gnue-forms/src/uidrivers/win32: . widgets/form
Date: Sat, 11 Nov 2006 10:57:44 -0600 (CST)

Author: btami
Date: 2006-11-11 10:57:44 -0600 (Sat, 11 Nov 2006)
New Revision: 9027

Modified:
   trunk/gnue-forms/src/uidrivers/win32/UILoginHandler.py
   trunk/gnue-forms/src/uidrivers/win32/dialog.py
   trunk/gnue-forms/src/uidrivers/win32/dialogs.py
   trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py
Log:
fixed some dialog issues

Modified: trunk/gnue-forms/src/uidrivers/win32/UILoginHandler.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/UILoginHandler.py      2006-11-11 
15:27:59 UTC (rev 9026)
+++ trunk/gnue-forms/src/uidrivers/win32/UILoginHandler.py      2006-11-11 
16:57:44 UTC (rev 9027)
@@ -53,10 +53,6 @@
 
     dlg = dialogs.InputDialog (0, title, lfields)
 
-    try:
-      dlg.DoModal ()
-      result = dlg.inputData
-    finally:
-      dlg.Destroy ()
-
+    dlg.DoModal ()
+    result = dlg.inputData
     return result

Modified: trunk/gnue-forms/src/uidrivers/win32/dialog.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/dialog.py      2006-11-11 15:27:59 UTC 
(rev 9026)
+++ trunk/gnue-forms/src/uidrivers/win32/dialog.py      2006-11-11 16:57:44 UTC 
(rev 9027)
@@ -75,9 +75,7 @@
 
   def OnInitDialog(self, hwnd, msg, wparam, lparam):
     self.hwnd = hwnd
-    self.dc = win32gui.GetDC(hwnd)
 
-
   def OnClose(self, hwnd, msg, wparam, lparam):
     win32gui.EndDialog(hwnd, 1)
     win32gui.SetFocus(self.oldfocus)

Modified: trunk/gnue-forms/src/uidrivers/win32/dialogs.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/dialogs.py     2006-11-11 15:27:59 UTC 
(rev 9026)
+++ trunk/gnue-forms/src/uidrivers/win32/dialogs.py     2006-11-11 16:57:44 UTC 
(rev 9027)
@@ -100,6 +100,7 @@
     """
     BaseDialog.__init__(self, parent, title, cancel)
     self.message_map [win32con.WM_CTLCOLORSTATIC] = self.OnCtlColorStatic
+    self.message_map [win32con.WM_CLOSE] = self.OnClose
     
     self.fields = fields
     self.inputData  = {}
@@ -209,8 +210,9 @@
         if control in self.__warnings:
           dlgItem = win32gui.GetDlgItem(hwnd, control)
           text = win32gui.GetWindowText(dlgItem)
-          newText = self.wrapText(text, self.dlgWidth)
-          win32gui.SetDlgItemText(hwnd, control, newText)
+          #~ newText = self.wrapText(text, self.dlgWidth)
+          #~ win32gui.SetDlgItemText(hwnd, control, newText)
+          win32gui.SetDlgItemText(hwnd, control, text)
           
         self.SetPosition(control, (self.dlgWidth-self.Width(control))/2 + 
border + 8 , ypos)
         ypos += self.Height(control) + 5
@@ -257,6 +259,10 @@
     first = win32gui.GetDlgItem(hwnd, self.__inputs[0])
     win32gui.SetFocus(first)
 
+  def OnClose(self, hwnd, msg, wparam, lparam):
+      self.inputData = None
+      win32gui.EndDialog(hwnd, 0)
+      win32gui.SetFocus(self.oldfocus)
 
   def OnCommand(self, hwnd, msg, wparam, lparam):
     id = win32api.LOWORD(wparam)
@@ -286,15 +292,16 @@
 
   def Width(self, id):
     item = win32gui.GetDlgItem(self.hwnd, id)
+    dc = win32gui.GetDC(item)
     if (id in self.__labels) or (id in self.__texts):
       text = win32gui.GetWindowText(item)
       if '\n' in text:
-        w = max ([win32gui.GetTextExtentPoint32(self.dc, t) [0] for t in 
text.split ('\n')])
+        w = max ([win32gui.GetTextExtentPoint32(dc, t) [0] for t in text.split 
('\n')])
       else:
-        w, h = win32gui.GetTextExtentPoint32(self.dc, text)
+        w, h = win32gui.GetTextExtentPoint32(dc, text)
       return w
     elif id in self.__inputs:
-      w, h = win32gui.GetTextExtentPoint32(self.dc, 'W'*12)
+      w, h = win32gui.GetTextExtentPoint32(dc, 'W'*8)
       return w
     else:
       l,t,r,b = win32gui.GetWindowRect(item)
@@ -302,42 +309,43 @@
 
   def Height(self, id):
     item = win32gui.GetDlgItem(self.hwnd, id)
+    dc = win32gui.GetDC(item)
     if (id in self.__labels) or (id in self.__texts):
       text = win32gui.GetWindowText(item)
       if '\n' in text:
-        h = sum ([win32gui.GetTextExtentPoint32(self.dc, t) [1] for t in 
text.split ('\n')])
+        h = sum ([win32gui.GetTextExtentPoint32(dc, t) [1] for t in text.split 
('\n')])
       else:
-        w, h = win32gui.GetTextExtentPoint32(self.dc, text)
+        w, h = win32gui.GetTextExtentPoint32(dc, text)
       return h
     elif id in self.__inputs:
-      w, h = win32gui.GetTextExtentPoint32(self.dc, 'W')
-      return h + 5
+      w, h = win32gui.GetTextExtentPoint32(dc, 'W')
+      return h
     else:
       l,t,r,b = win32gui.GetWindowRect(item)
       return b-t
 
   def SetPosition(self, id, x, y):
     item = win32gui.GetDlgItem(self.hwnd, id)
-    win32gui.SetWindowPos(item, 0,
+    win32gui.SetWindowPos(item, self.hwnd,
                           x, y,
                           self.Width(id), self.Height(id),
                           win32con.SWP_NOACTIVATE | win32con.SWP_NOZORDER)
 
-  def wrapText(self, text, width):
-    textSoFar = ""
-    thisLine = ""
-    for part in text.split('\n'):
-      for word in part.split():
-        if win32gui.GetTextExtentPoint32(self.dc, thisLine + word)[0] > width:
-          textSoFar += thisLine + " \n"
-          thisLine = word + " "
-        else:
-          thisLine += word + " "
+  #~ def wrapText(self, text, width):
+    #~ textSoFar = ""
+    #~ thisLine = ""
+    #~ for part in text.split('\n'):
+      #~ for word in part.split():
+        #~ if win32gui.GetTextExtentPoint32(dc, thisLine + word)[0] > width:
+          #~ textSoFar += thisLine + " \n"
+          #~ thisLine = word + " "
+        #~ else:
+          #~ thisLine += word + " "
 
-      textSoFar += thisLine + " \n"
-      thisLine = ""
+      #~ textSoFar += thisLine + " \n"
+      #~ thisLine = ""
 
-    return textSoFar
+    #~ return textSoFar
 
 
 # =============================================================================
@@ -392,8 +400,9 @@
 
     for (ix, itemId) in enumerate (self.__labels):
       item = win32gui.GetDlgItem(hwnd, itemId)
+      dc = win32gui.GetDC(item)
       text = win32gui.GetWindowText(item)
-      (width, height) = win32gui.GetTextExtentPoint32(self.dc, text)
+      (width, height) = win32gui.GetTextExtentPoint32(dc, text)
       maxW = max (maxW, width)
 
       win32gui.SetWindowPos(item, 0, 0, 0, width, height, flags)
@@ -407,12 +416,13 @@
 
     for (ix, itemId) in enumerate (self.__contents):
       item = win32gui.GetDlgItem(hwnd, itemId)
+      dc = win32gui.GetDC(item)
       text = win32gui.GetWindowText(item)
       if '\n' in text:
-        width  = max ([win32gui.GetTextExtentPoint32(self.dc, p) [0] for p in 
text.split ('\n')])
-        height = sum ([win32gui.GetTextExtentPoint32(self.dc, p) [1] for p in 
text.split ('\n')])
+        width  = max ([win32gui.GetTextExtentPoint32(dc, p) [0] for p in 
text.split ('\n')])
+        height = sum ([win32gui.GetTextExtentPoint32(dc, p) [1] for p in 
text.split ('\n')])
       else:
-        (width, height) = win32gui.GetTextExtentPoint32(self.dc, text)
+        (width, height) = win32gui.GetTextExtentPoint32(dc, text)
 
       (left, top, w, h) = win32gui.GetWindowRect(item)
       left, top = win32gui.ScreenToClient(self.hwnd, (left, top))
@@ -611,15 +621,16 @@
 
   def Width(self, id):
     item = win32gui.GetDlgItem(self.hwnd, id)
+    dc = win32gui.GetDC(item)
     if id == self.messageID or id == self.detailID:
       text = win32gui.GetWindowText(item)
       # GetWindowText has only 512 byte buffer, sigh...
       if id == self.detailID:
         text = self.detail
       if '\n' in text:
-        w = max ([win32gui.GetTextExtentPoint32(self.dc, t) [0] for t in 
text.split ('\n')])
+        w = max ([win32gui.GetTextExtentPoint32(dc, t) [0] for t in text.split 
('\n')])
       else:
-        w, h = win32gui.GetTextExtentPoint32(self.dc, text)
+        w, h = win32gui.GetTextExtentPoint32(dc, text)
       return w
     else:
       l,t,r,b = win32gui.GetWindowRect(item)
@@ -628,14 +639,15 @@
 
   def Height(self, id):
     item = win32gui.GetDlgItem(self.hwnd, id)
+    dc = win32gui.GetDC(item)
     if id == self.messageID or id == self.detailID:
       text = win32gui.GetWindowText(item)
       if id == self.detailID:
         text = self.detail
       if '\n' in text:
-        h = sum ([win32gui.GetTextExtentPoint32(self.dc, t) [1] -2 for t in 
text.split ('\n')])
+        h = sum ([win32gui.GetTextExtentPoint32(dc, t) [1] -2 for t in 
text.split ('\n')])
       else:
-        w, h = win32gui.GetTextExtentPoint32(self.dc, text)
+        w, h = win32gui.GetTextExtentPoint32(dc, text)
       #~ if id == self.detailID:
         #~ h += -8 # extra for WS_EX_STATICEDGE
       return h

Modified: trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py 2006-11-11 
15:27:59 UTC (rev 9026)
+++ trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py 2006-11-11 
16:57:44 UTC (rev 9027)
@@ -25,7 +25,8 @@
 # NOTES:
 #
 
-import struct
+import struct
+import types
 
 import win32ui
 import win32api
@@ -252,9 +253,9 @@
     @param cancel: If True a cancel button will be added to the dialog
     @return: True if the Ok-, Close-, or Yes-button was pressed, False if the
         No-button was pressed or None if the Cancel-button was pressed.
-    """
+    """
     mbRec  = _MBOX_KIND.get (kind)
-    flags = win32con.MB_TASKMODAL | mbRec['icon'] | mbRec['buttons']
+    flags = win32con.MB_TASKMODAL | mbRec['icon']
 
     if title is not None and len (title):
       if isinstance (title, types.StringType):
@@ -262,16 +263,15 @@
     else:
       title = mbRec['type']
 
-    cButtons = [win32con.MB_OKCANCEL, win32con.MB_YESNOCANCEL]
-
-    if cancel and not mbRec ['buttons'] in cButtons:
+    if cancel:
       if mbRec ['buttons'] == win32con.MB_OK:
         flags = flags | win32con.MB_OKCANCEL
       elif mbRec ['buttons'] == win32con.MB_YESNO:
-        flags = flags | win32con.MB_YESNOCANCEL
+        flags = flags | win32con.MB_YESNOCANCEL
+    else:
+        flags = flags | mbRec['buttons']
 
     res = win32gui.MessageBox(0, message, title, flags)
-
     return _RESPONSE [res]
 
 





reply via email to

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