commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8887 - trunk/gnue-forms/src/uidrivers/win32


From: btami
Subject: [gnue] r8887 - trunk/gnue-forms/src/uidrivers/win32
Date: Fri, 20 Oct 2006 12:35:35 -0500 (CDT)

Author: btami
Date: 2006-10-20 12:35:35 -0500 (Fri, 20 Oct 2006)
New Revision: 8887

Modified:
   trunk/gnue-forms/src/uidrivers/win32/UIdriver.py
   trunk/gnue-forms/src/uidrivers/win32/dialog.py
   trunk/gnue-forms/src/uidrivers/win32/dialogs.py
Log:
removed ExceptionDialog to better place

Modified: trunk/gnue-forms/src/uidrivers/win32/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/UIdriver.py    2006-10-20 17:31:06 UTC 
(rev 8886)
+++ trunk/gnue-forms/src/uidrivers/win32/UIdriver.py    2006-10-20 17:35:35 UTC 
(rev 8887)
@@ -52,14 +52,8 @@
 #from gnue.forms.uidrivers.wx.UIWXSplashScreen import *
 from gnue.forms.uidrivers.win32.widgets._base  import *
 from gnue.forms.uidrivers.win32.common import textEncode, textDecode
-from gnue.forms.uidrivers.win32.dialog import BaseDialog
 from gnue.forms.uidrivers.win32 import dialogs
 
-
-EDIT = 0x0081
-STATIC = 0x0082
-BUTTON = 0x0080
-
 
 def OnWMVScroll(hwnd, msg, wParam, lParam, widget):
   return widget.OnWMVScroll(hwnd, msg, wParam, lParam)
@@ -177,65 +171,18 @@
     self.widgetWidth  = self.textWidth             # The pixel width of a 1 
char widget (for things like buttons)
     self.widgetHeight = self.textHeight + 5       # The pixel height of a 1 
char widget (for things like buttons)
 
-    dummyWindow.ReleaseDC(dc)
+    dummyWindow.ReleaseDC(dc)
 
 
-  #############################################################################
-  #
-  # Incoming Event Processors
-  #
-  # Processes the incoming events from other objects
-  # From here down should be nothing but eventListeners listed
-
-  #
   # mainLoop
   #
   # The primary loop of the user interface.  Called once the UI is
   # fully activated
   #
   def mainLoop(self):
-    self._win32app.MainLoop() # simply call the wxApp's MainLoop method
+    self._win32app.MainLoop()
 
-  #
-  # Clipboard routines
-  #
-  # If a particular UI has a system-wide clipboard,
-  # these methods should be overridden to use that
-  # clipboard.
-  #
-  # TODO: kept only for reference for implementing entry.cut/copy/paste, these
-  # 2 functions are not used any more and can be deleted.
-  #
-  def getClipboardContents(self, event):
-    if None == win32clipboard.OpenClipboard():
-      success = win32clipboard.GetClipboardData(win32con.CF_TEXT)
-      win32clipboard.CloseClipboard()
-    else:
-      success = 0
-      assert gDebug(1,'Unable to open clipboard for read')
 
-    if success:
-      value = textDecode(success)
-    else:
-      assert gDebug(1,'Unable to obtain clipboard contents. Defaulting to 
Empty.')
-      value = None
-
-    assert gDebug(6, "Getting clipboard value '%s'" % value)
-    event.__result__ = value
-
-
-  def setClipboardContents(self, event):
-    assert gDebug(6,"Setting clipboard '%s'" % event.text)
-
-    if None == win32clipboard.OpenClipboard():
-      win32clipboard.EmptyClipboard()
-      handle = win32clipboard.SetClipboardText(textEncode(event.text))
-      assert gDebug(6,"Set Clipboard Data Handle: %s" % handle)
-      win32clipboard.CloseClipboard()
-    else:
-      assert gDebug(6,'Unable to open clipboard for write')
-
-
   # ---------------------------------------------------------------------------
   # Start an input dialog and return the data record or None if cancelled
   # ---------------------------------------------------------------------------
@@ -262,11 +209,11 @@
   # ---------------------------------------------------------------------------
 
   def _ui_show_exception_(self, group, name, message, detail):
-      
-    dialog = ExceptionDisplay (group, name, message, detail)
+
+    dialog = dialogs.ExceptionDialog (group, name, message, detail)
     dialog.DoModal ()
+        
 
-
   # ---------------------------------------------------------------------------
   # Exit the application
   # ---------------------------------------------------------------------------
@@ -287,180 +234,3 @@
       if isinstance(window, Win32Window):
         window.Enable(1)
         win32gui.SetActiveWindow(window.GetHwnd())
-
-
-# =============================================================================
-# This class implements a dialog for displaying exceptions
-# =============================================================================
-
-class ExceptionDisplay (BaseDialog):
-
-  _TITLE = {'system'     : _("GNUe Internal System Error"),
-            'admin'      : _("GNUe Unexpected Error"),
-            'application': _("GNUe Application Error")}
-
-  _FORMAT = {
-     'system': u_("An unexpected internal error has occured:\r\n%s.\r\n"
-                  "This means you have found a bug in GNU Enterprise. "
-                  "Please report it to address@hidden"),
-     'admin': u_("An unexpected error has occured:\r\n%s.\r\n"
-                 "Please contact your system administrator."),
-     'application': u_("An unexpected error has occured:\r\n%s.\r\n"
-                       "Please contact your system administrator.")}
-
-  # ---------------------------------------------------------------------------
-  # Constructor
-  # ---------------------------------------------------------------------------
-
-  def __init__ (self, group, name, message, detail):
-
-    BaseDialog.__init__(self, self._TITLE.get (group, _('Error')), cancel = 
False, ok = False)
-    self.message_map [win32con.WM_CTLCOLORSTATIC] = self.OnCtlColorStatic
-
-    self.detail = detail.replace('\n','\r\n')
-    
-    cs = win32con.WS_CHILD | win32con.WS_VISIBLE
-    position = (0, 0, 0, 0)
-
-    self.iconID = ID = getNextId()
-    s = cs | win32con.SS_ICON #| win32con.WS_BORDER
-    self.template.append([STATIC, 'icon', ID, (5,8,32,32), s])
-
-    self.messageID = ID = getNextId()
-    s = cs | win32con.SS_LEFT
-    self.template.append([STATIC, textEncode(self._FORMAT.get (group, "%s") % 
message), \
-                          ID, position, s])
-
-    s = cs | win32con.WS_TABSTOP | win32con.BS_DEFPUSHBUTTON
-    self.template.append([BUTTON, textEncode(u_('Close')), win32con.IDCLOSE, 
(0, 0, 56, 15), s])
-
-    self.detailsID = ID = getNextId()
-    s = cs | win32con.WS_TABSTOP | win32con.BS_PUSHBUTTON
-    self.template.append([BUTTON, textEncode(u_('>> Details')), ID, (0, 0, 56, 
15), s])
-
-    self.detailID = ID = getNextId()
-    s = cs | win32con.ES_MULTILINE | win32con.ES_READONLY | 
win32con.WS_TABSTOP \
-           | win32con.ES_AUTOVSCROLL #| win32con.WS_VSCROLL
-    es = win32con.WS_EX_STATICEDGE
-    self.template.append([EDIT, textEncode(self.detail), ID, position, s, es])
-
-    self._showsDetail  = False
-
-
-  def OnInitDialog(self, hwnd, msg, wparam, lparam):
-    BaseDialog.OnInitDialog(self, hwnd, msg, wparam, lparam)
-
-    item = win32gui.GetDlgItem(self.hwnd, self.detailID)
-    win32gui.EnableWindow(item, 0)
-
-    ico = win32gui.LoadIcon(0, win32con.IDI_ERROR)
-    bmCtrl = win32gui.GetDlgItem(self.hwnd, self.iconID)
-    win32gui.SendMessage(bmCtrl, win32con.STM_SETICON, ico, 0)
-
-    self.Recalculate()
-
-
-  def OnCommand(self, hwnd, msg, wparam, lparam):
-    id = win32api.LOWORD(wparam)
-    if id == win32con.IDCLOSE:
-      win32gui.EndDialog(hwnd, 1)
-    elif id == self.detailsID:
-      self._showsDetail = not self._showsDetail
-      if self._showsDetail:
-        item = win32gui.GetDlgItem(self.hwnd, self.detailID)
-        win32gui.EnableWindow(item, 1)
-        win32gui.SetDlgItemText(hwnd, id, u_("<< Details"))
-        self.Recalculate()
-      else:
-        item = win32gui.GetDlgItem(self.hwnd, self.detailID)
-        win32gui.EnableWindow(item, 0)
-        win32gui.SetDlgItemText(hwnd, id, u_(">> Details"))
-        self.Recalculate()
-
-  def OnCtlColorStatic(self, hwnd, msg, wparam, lparam):
-    if win32gui.GetDlgCtrlID(lparam) == self.detailID:
-      win32gui.SetBkMode(wparam, win32con.OPAQUE) #TRANSPARENT) #
-      win32gui.SetTextColor(wparam, win32api.RGB(0, 0, 0))
-      return 1
-
-  def Recalculate(self):
-    border = 10
-    
-    dlgWidth = self.Width(self.detailsID) + self.Width(win32con.IDCLOSE) + 20
-    dlgWidth = max(dlgWidth, self.Width(self.messageID))
-    if self._showsDetail:
-      dlgWidth = max(dlgWidth, self.Width(self.detailID))
-
-    ypos = border
-
-    self.SetPosition(self.messageID, border+40, ypos)
-    ypos += self.Height(self.messageID) + 10
-    
-    if self._showsDetail:
-      self.SetPosition(self.detailID, border, ypos)
-      ypos += self.Height(self.detailID) + 10
-    else:
-      dlgItem = win32gui.GetDlgItem(self.hwnd, self.detailID)
-      win32gui.SetWindowPos(dlgItem, 0, 0, 0, 0, 0, 0)
-
-    self.SetPosition(self.detailsID, dlgWidth + 2*border \
-                     - self.Width(self.detailsID) - 8, ypos + 10)
-
-    self.SetPosition(win32con.IDCLOSE, dlgWidth + 2*border \
-                     - self.Width(self.detailsID) \
-                     - self.Width(win32con.IDCLOSE) -15, ypos + 10)
-
-    ypos += self.Height(win32con.IDCLOSE) + border
-    
-    # resize the dialog
-    win32gui.SetWindowPos(self.hwnd, 0,
-                              0, 0,
-                              dlgWidth + 2*border + 10, ypos + 45,
-                              win32con.SWP_NOACTIVATE | win32con.SWP_NOZORDER \
-                              | win32con.SWP_NOMOVE)
-
-    # center the dialog
-    centerWindow(self.hwnd)
-
-
-  def Width(self, id):
-    item = win32gui.GetDlgItem(self.hwnd, id)
-    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 '\r\n' in text:
-        w = max ([win32gui.GetTextExtentPoint32(self.dc, t) [0] for t in 
text.split ('\r\n')])
-      else:
-        w, h = win32gui.GetTextExtentPoint32(self.dc, text)
-      return w + 40
-    else:
-      l,t,r,b = win32gui.GetWindowRect(item)
-      return r-l
-
-
-  def Height(self, id):
-    item = win32gui.GetDlgItem(self.hwnd, id)
-    if id == self.messageID or id == self.detailID:
-      text = win32gui.GetWindowText(item)
-      if id == self.detailID:
-        text = self.detail
-      if '\r\n' in text:
-        h = sum ([win32gui.GetTextExtentPoint32(self.dc, t) [1] for t in 
text.split ('\r\n')])
-      else:
-        w, h = win32gui.GetTextExtentPoint32(self.dc, text)
-      if id == self.detailID:
-        h += 2 # extra for WS_EX_STATICEDGE
-      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,
-                          x, y,
-                          self.Width(id), self.Height(id),
-                          win32con.SWP_NOACTIVATE | win32con.SWP_NOZORDER)

Modified: trunk/gnue-forms/src/uidrivers/win32/dialog.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/dialog.py      2006-10-20 17:31:06 UTC 
(rev 8886)
+++ trunk/gnue-forms/src/uidrivers/win32/dialog.py      2006-10-20 17:35:35 UTC 
(rev 8887)
@@ -81,7 +81,7 @@
 
 
   def Destroy(self):
-    pass
+    pass
 
 
   def OnCommand(self, hwnd, msg, wparam, lparam):

Modified: trunk/gnue-forms/src/uidrivers/win32/dialogs.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/dialogs.py     2006-10-20 17:31:06 UTC 
(rev 8886)
+++ trunk/gnue-forms/src/uidrivers/win32/dialogs.py     2006-10-20 17:35:35 UTC 
(rev 8887)
@@ -35,6 +35,12 @@
 from gnue.forms.uidrivers.win32.common import getNextId, centerWindow, 
textEncode
 from gnue.forms import VERSION
 
+BUTTON    = 0x0080
+EDIT     = 0x0081
+STATIC   = 0x0082
+LISTBOX  = 0x0084
+DROPDOWN = 0x0085
+
 # =============================================================================
 # Exceptions
 # =============================================================================
@@ -44,12 +50,7 @@
     msg = u_("%s is not a valid type for an input field") % fieldtype
     errors.ApplicationError.__init__ (self, msg)
 
-EDIT = 0x0081
-STATIC = 0x0082
-LISTBOX = 0x0084
-DROPDOWN = 0x0085
 
-
 class InputDialog(BaseDialog):
   """
   Dialog class prompting the user for a given number of fields. These field
@@ -351,7 +352,7 @@
     self.__boxes    = []
     self.__labels   = []
     self.__contents = []
-    
+
     # Upper box with info about GNUe Forms
     self.template.append (self.__addBox (textEncode(u_('GNUe Forms')), 8, 44))
     self.template.append (self.__addLabel (self.__labels, 
textEncode(u_('Version:')), 20))
@@ -469,6 +470,182 @@
             win32con.BS_GROUPBOX
     return ['button', label, self.__boxes [-1], (6, top, 282, height), style]
 
+
+# =============================================================================
+# This class implements a dialog for displaying exceptions
+# =============================================================================
+
+class ExceptionDialog (BaseDialog):
+
+  _TITLE = {'system'     : _("GNUe Internal System Error"),
+            'admin'      : _("GNUe Unexpected Error"),
+            'application': _("GNUe Application Error")}
+
+  _FORMAT = {
+     'system': u_("An unexpected internal error has occured:\r\n%s.\r\n"
+                  "This means you have found a bug in GNU Enterprise. "
+                  "Please report it to address@hidden"),
+     'admin': u_("An unexpected error has occured:\r\n%s.\r\n"
+                 "Please contact your system administrator."),
+     'application': u_("An unexpected error has occured:\r\n%s.\r\n"
+                       "Please contact your system administrator.")}
+
+  # ---------------------------------------------------------------------------
+  # Constructor
+  # ---------------------------------------------------------------------------
+
+  def __init__ (self, group, name, message, detail):
+
+    BaseDialog.__init__(self, self._TITLE.get (group, _('Error')), cancel = 
False, ok = False)
+    self.message_map [win32con.WM_CTLCOLORSTATIC] = self.OnCtlColorStatic
+
+    self.detail = detail.replace('\n','\r\n')
+    
+    cs = win32con.WS_CHILD | win32con.WS_VISIBLE
+    position = (0, 0, 0, 0)
+
+    self.iconID = ID = getNextId()
+    s = cs | win32con.SS_ICON #| win32con.WS_BORDER
+    self.template.append([STATIC, 'icon', ID, (5,8,32,32), s])
+
+    self.messageID = ID = getNextId()
+    s = cs | win32con.SS_LEFT
+    self.template.append([STATIC, textEncode(self._FORMAT.get (group, "%s") % 
message), \
+                          ID, position, s])
+
+    s = cs | win32con.WS_TABSTOP | win32con.BS_DEFPUSHBUTTON
+    self.template.append([BUTTON, textEncode(u_('Close')), win32con.IDCLOSE, 
(0, 0, 56, 15), s])
+
+    self.detailsID = ID = getNextId()
+    s = cs | win32con.WS_TABSTOP | win32con.BS_PUSHBUTTON
+    self.template.append([BUTTON, textEncode(u_('>> Details')), ID, (0, 0, 56, 
15), s])
+
+    self.detailID = ID = getNextId()
+    s = cs | win32con.ES_MULTILINE | win32con.ES_READONLY | 
win32con.WS_TABSTOP \
+           | win32con.ES_AUTOVSCROLL #| win32con.WS_VSCROLL
+    es = win32con.WS_EX_STATICEDGE
+    self.template.append([EDIT, textEncode(self.detail), ID, position, s, es])
+
+    self._showsDetail  = False
+
+
+  def OnInitDialog(self, hwnd, msg, wparam, lparam):
+    BaseDialog.OnInitDialog(self, hwnd, msg, wparam, lparam)
+
+    item = win32gui.GetDlgItem(self.hwnd, self.detailID)
+    win32gui.EnableWindow(item, 0)
+
+    ico = win32gui.LoadIcon(0, win32con.IDI_ERROR)
+    bmCtrl = win32gui.GetDlgItem(self.hwnd, self.iconID)
+    win32gui.SendMessage(bmCtrl, win32con.STM_SETICON, ico, 0)
+
+    self.Recalculate()
+
+
+  def OnCommand(self, hwnd, msg, wparam, lparam):
+    id = win32api.LOWORD(wparam)
+    if id == win32con.IDCLOSE:
+      win32gui.EndDialog(hwnd, 1)
+    elif id == self.detailsID:
+      self._showsDetail = not self._showsDetail
+      if self._showsDetail:
+        item = win32gui.GetDlgItem(self.hwnd, self.detailID)
+        win32gui.EnableWindow(item, 1)
+        win32gui.SetDlgItemText(hwnd, id, u_("<< Details"))
+        self.Recalculate()
+      else:
+        item = win32gui.GetDlgItem(self.hwnd, self.detailID)
+        win32gui.EnableWindow(item, 0)
+        win32gui.SetDlgItemText(hwnd, id, u_(">> Details"))
+        self.Recalculate()
+
+  def OnCtlColorStatic(self, hwnd, msg, wparam, lparam):
+    if win32gui.GetDlgCtrlID(lparam) == self.detailID:
+      win32gui.SetBkMode(wparam, win32con.OPAQUE) #TRANSPARENT) #
+      win32gui.SetTextColor(wparam, win32api.RGB(0, 0, 0))
+      return 1
+
+  def Recalculate(self):
+    border = 10
+    
+    dlgWidth = self.Width(self.detailsID) + self.Width(win32con.IDCLOSE) + 20
+    dlgWidth = max(dlgWidth, self.Width(self.messageID))
+    if self._showsDetail:
+      dlgWidth = max(dlgWidth, self.Width(self.detailID))
+
+    ypos = border
+
+    self.SetPosition(self.messageID, border+40, ypos)
+    ypos += self.Height(self.messageID) + 10
+    
+    if self._showsDetail:
+      self.SetPosition(self.detailID, border, ypos)
+      ypos += self.Height(self.detailID) + 10
+    else:
+      dlgItem = win32gui.GetDlgItem(self.hwnd, self.detailID)
+      win32gui.SetWindowPos(dlgItem, 0, 0, 0, 0, 0, 0)
+
+    self.SetPosition(self.detailsID, dlgWidth + 2*border \
+                     - self.Width(self.detailsID) - 8, ypos + 10)
+
+    self.SetPosition(win32con.IDCLOSE, dlgWidth + 2*border \
+                     - self.Width(self.detailsID) \
+                     - self.Width(win32con.IDCLOSE) -15, ypos + 10)
+
+    ypos += self.Height(win32con.IDCLOSE) + border
+    
+    # resize the dialog
+    win32gui.SetWindowPos(self.hwnd, 0,
+                              0, 0,
+                              dlgWidth + 2*border + 10, ypos + 45,
+                              win32con.SWP_NOACTIVATE | win32con.SWP_NOZORDER \
+                              | win32con.SWP_NOMOVE)
+
+    # center the dialog
+    centerWindow(self.hwnd)
+
+
+  def Width(self, id):
+    item = win32gui.GetDlgItem(self.hwnd, id)
+    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 '\r\n' in text:
+        w = max ([win32gui.GetTextExtentPoint32(self.dc, t) [0] for t in 
text.split ('\r\n')])
+      else:
+        w, h = win32gui.GetTextExtentPoint32(self.dc, text)
+      return w + 40
+    else:
+      l,t,r,b = win32gui.GetWindowRect(item)
+      return r-l
+
+
+  def Height(self, id):
+    item = win32gui.GetDlgItem(self.hwnd, id)
+    if id == self.messageID or id == self.detailID:
+      text = win32gui.GetWindowText(item)
+      if id == self.detailID:
+        text = self.detail
+      if '\r\n' in text:
+        h = sum ([win32gui.GetTextExtentPoint32(self.dc, t) [1] for t in 
text.split ('\r\n')])
+      else:
+        w, h = win32gui.GetTextExtentPoint32(self.dc, text)
+      if id == self.detailID:
+        h += 2 # extra for WS_EX_STATICEDGE
+      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,
+                          x, y,
+                          self.Width(id), self.Height(id),
+                          win32con.SWP_NOACTIVATE | win32con.SWP_NOZORDER)
 
 
 if __name__ == '__main__':





reply via email to

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