[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7526 - trunk/gnue-forms/src/uidrivers/win32
From: |
btami |
Subject: |
[gnue] r7526 - trunk/gnue-forms/src/uidrivers/win32 |
Date: |
Wed, 4 May 2005 17:32:58 -0500 (CDT) |
Author: btami
Date: 2005-05-04 17:32:57 -0500 (Wed, 04 May 2005)
New Revision: 7526
Added:
trunk/gnue-forms/src/uidrivers/win32/dialog.py
Modified:
trunk/gnue-forms/src/uidrivers/win32/UILoginHandler.py
trunk/gnue-forms/src/uidrivers/win32/UIdriver.py
trunk/gnue-forms/src/uidrivers/win32/dialogs.py
Log:
fixed aboutbox dialog
Modified: trunk/gnue-forms/src/uidrivers/win32/UILoginHandler.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/UILoginHandler.py 2005-05-04
15:10:34 UTC (rev 7525)
+++ trunk/gnue-forms/src/uidrivers/win32/UILoginHandler.py 2005-05-04
22:32:57 UTC (rev 7526)
@@ -25,56 +25,37 @@
# NOTES:
#
-import os
+import os.path
+from gnue.common.apps import GConfig
from gnue.common.datasources import GLoginHandler
-from gnue.common.apps import GConfig, errors
-from gnue.forms.uidrivers.win32.dialogs import InputDialog
+from gnue.forms.uidrivers.win32 import dialogs
-# Shortcut
-images_dir = GConfig.getInstalledBase('forms_images','common_images') + '/'
-
class UILoginHandler(GLoginHandler.LoginHandler):
- def getLogin(self, loginData, errortext=None):#"Invalid username/password"):
- (connection, description, fields) = loginData
-
- if len(description):
- loginMesg = _('Login required for\n"%s"') % (description)
- else:
- loginMesg = _('Login required for %s') % (connection)
+
+ # ---------------------------------------------------------------------------
+ # Create an instance of an InputDialog and return it's result
+ # ---------------------------------------------------------------------------
- if os.path.isabs(gConfigForms('loginBMP')):
+ def _askLogin (self, title, fields):
+
+ lfields = fields [:]
+ if lfields [0][2] != 'image':
imageFile = gConfigForms('loginBMP')
- else:
- imageFile = images_dir+gConfigForms('loginBMP')
+ if not os.path.exists (imageFile):
+ imageFile = os.path.join (os.path.normpath ( \
+ GConfig.getInstalledBase ('forms_images', 'common_images')),
+ gConfigForms ('loginBMP'))
- if not imageFile[-3:].upper() == 'BMP':
- raise errors.AdminError, \
- _("The win32 forms driver supports only BMP format logo files!")
+ if os.path.exists (imageFile):
+ lfields.insert (0, ('', imageFile, 'image', None, None, []))
- title = _("GNU Enterprise: Login to %s") % connection
-
- dlgFields = []
- dlgFields.append(("", imageFile, "image", None, None, []))
- dlgFields.append((loginMesg, '_msg', "label", None, None, []))
+ dlg = dialogs.InputDialog (title, lfields)
- for prompt in fields:
- if prompt[2]:
- dlgFields.append((prompt[1], "%s" % prompt[0], "password", None, None,
[]))
- else:
- dlgFields.append((prompt[1], "%s" % prompt[0], "string", None, None,
[]))
+ try:
+ dlg.DoModal ()
+ return dlg.inputData
- if errortext:
- dlgFields.append((str(errortext), "_warn", "warning", None, None, []))
-
- dlg = InputDialog(title, dlgFields)
-
- result = {}
- if not dlg.DoModal():
- raise GLoginHandler.UserCanceledLogin
- else:
- for prompt in fields:
- result[prompt[0]] = dlg.inputData[prompt[0]]
- return result
-
\ No newline at end of file
+ finally:
+ dlg.Destroy ()
Modified: trunk/gnue-forms/src/uidrivers/win32/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/UIdriver.py 2005-05-04 15:10:34 UTC
(rev 7525)
+++ trunk/gnue-forms/src/uidrivers/win32/UIdriver.py 2005-05-04 22:32:57 UTC
(rev 7526)
@@ -51,6 +51,7 @@
from gnue.forms.uidrivers.win32.widgets._base import *
from gnue.forms.uidrivers.win32.common import textEncode
from gnue.forms.uidrivers.win32 import dialogs
+from gnue.forms.uidrivers.win32 import dialog
def OnWMVScroll(hwnd, msg, wParam, lParam, widget):
@@ -400,27 +401,5 @@
# ---------------------------------------------------------------------------
def _showAbout (self, name, appversion, formversion, author, description):
-
- # FIXME: can anyone find out why dialogs.AboutBox () does not show up if
- # added here, using something like:
- # d = dialogs.AboutBox (name, appversion, formversion, author, description)
- # d.DoModal ()
-
- message = "%(tVersion)s %(appversion)s\n" \
- "%(tDriver)s win32\n" \
- "%(tName)s %(name)s\n" \
- "%(tVersion)s %(formversion)s\n" \
- "%(tAuthor)s %(author)s\n" \
- "%(tDescription)s %(description)s\n" \
- % {'tVersion': u_("Version:"),
- 'tDriver': u_("Driver:"),
- 'tName': u_("Name:"),
- 'tAuthor': u_("Author"),
- 'tDescription': u_("Description:"),
- 'appversion': appversion,
- 'formversion': formversion,
- 'name': name,
- 'author': author,
- 'description': description}
-
- self._showMessage (message, title = u_("About %s") % name)
+ d = dialogs.AboutBox (name, appversion, formversion, author, description)
+ d.DoModal ()
Added: trunk/gnue-forms/src/uidrivers/win32/dialog.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/dialog.py 2005-05-04 15:10:34 UTC
(rev 7525)
+++ trunk/gnue-forms/src/uidrivers/win32/dialog.py 2005-05-04 22:32:57 UTC
(rev 7526)
@@ -0,0 +1,132 @@
+# GNU Enterprise Forms - Win32 UI Driver - UI specific base dialog
+#
+# Copyright 2001-2005 Free Software Foundation
+#
+# 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.
+#
+# $Id$
+
+import struct
+
+import win32ui
+import win32api
+import win32gui
+import win32con
+import commctrl
+
+from gnue.common.apps import i18n, errors
+from gnue.forms.uidrivers.win32.common import textEncode
+
+g_registeredClass = 0
+
+BUTTON = 0x0080
+
+
+class BaseDialog:
+
+ def __init__ (self, title, cancel = False):
+ win32gui.InitCommonControls()
+ self.hinst = win32api.GetModuleHandle(None)
+
+ self.message_map = {
+ win32con.WM_COMMAND: self.OnCommand,
+ win32con.WM_INITDIALOG: self.OnInitDialog,
+ win32con.WM_CLOSE: self.OnClose,
+ }
+
+ dlgClassName = self._RegisterWndClass()
+
+ style = win32con.WS_POPUP | win32con.WS_VISIBLE | win32con.WS_CAPTION | \
+ win32con.DS_SETFONT | win32con.WS_SYSMENU | win32con.DS_MODALFRAME
+
+ self.template = [ [textEncode(title), (0, 0, 120, 20), style, None, \
+ (8, "MS Sans Serif"), None, dlgClassName], ]
+
+ self.template.append ([BUTTON, _("Ok"), win32con.IDOK, (0, 0, 56, 15),
+ win32con.WS_CHILD | win32con.WS_VISIBLE | \
+ win32con.WS_TABSTOP | win32con.BS_DEFPUSHBUTTON])
+ if cancel:
+ self.template.append ([BUTTON, _("Cancel"), win32con.IDCANCEL, (60, 0,
56, 15),
+ win32con.WS_CHILD | win32con.WS_VISIBLE | \
+ win32con.WS_TABSTOP | win32con.BS_PUSHBUTTON])
+
+
+ def DoModal(self):
+ return win32gui.DialogBoxIndirect(self.hinst, self.template, 0,
self.message_map)
+
+
+ def OnInitDialog(self, hwnd, msg, wparam, lparam):
+ self.hwnd = hwnd
+
+ # Create a LOGFONT structure for the current font in use
+ hFont = win32gui.GetObject (win32gui.SendMessage (hwnd,
win32con.WM_GETFONT, 0, 0))
+ newFont = win32ui.CreateFont ( \
+ {'name' : hFont.lfFaceName,
+ 'height' : hFont.lfHeight,
+ 'width' : hFont.lfWidth,
+ 'charset' : hFont.lfCharSet,
+ 'weight' : hFont.lfWeight,
+ 'italic' : hFont.lfItalic,
+ 'underline' : hFont.lfUnderline,
+ 'pitch and family': hFont.lfPitchAndFamily})
+
+ # Use this font in the device context of the dialog
+ PyCWnd = win32ui.CreateWindowFromHandle(hwnd)
+ self.dc = PyCWnd.GetDC ()
+ of = self.dc.SelectObject (newFont)
+
+
+ def OnClose(self, hwnd, msg, wparam, lparam):
+ win32gui.EndDialog(hwnd, 0)
+
+
+ def Destroy(self):
+ pass
+
+
+ def OnCommand(self, hwnd, msg, wparam, lparam):
+ id = win32api.LOWORD(wparam)
+ if id == win32con.IDOK:
+ win32gui.EndDialog(hwnd, 1)
+ elif id == win32con.IDCANCEL:
+ win32gui.EndDialog(hwnd, 0)
+
+
+ def _RegisterWndClass(self):
+ className = "GNUe dialog"
+ global g_registeredClass
+ if not g_registeredClass:
+ message_map = {}
+ wc = win32gui.WNDCLASS()
+ wc.SetDialogProc() # Make it a dialog class.
+ self.hinst = wc.hInstance = win32api.GetModuleHandle(None)
+ wc.lpszClassName = className
+ wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW
+ wc.hCursor = win32gui.LoadCursor( 0, win32con.IDC_ARROW )
+ wc.hIcon = win32gui.LoadIcon(0, win32con.IDI_APPLICATION)
+ wc.hbrBackground = win32con.COLOR_WINDOW
+ wc.lpfnWndProc = message_map # could also specify a wndproc.
+ wc.cbWndExtra = win32con.DLGWINDOWEXTRA + struct.calcsize("Pi")
+ classAtom = win32gui.RegisterClass(wc)
+ g_registeredClass = 1
+ return className
+
+
+if __name__ == '__main__':
+ dialog = BaseDialog('MyDialog', cancel=True)
+ dialog.DoModal()
\ No newline at end of file
Modified: trunk/gnue-forms/src/uidrivers/win32/dialogs.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/dialogs.py 2005-05-04 15:10:34 UTC
(rev 7525)
+++ trunk/gnue-forms/src/uidrivers/win32/dialogs.py 2005-05-04 22:32:57 UTC
(rev 7526)
@@ -30,10 +30,10 @@
import win32gui
import win32con
import commctrl
-from pywin.mfc import dialog
from gnue.common.apps import i18n, errors
-from gnue.forms.uidrivers.win32.common import getNextId, centerWindow
+from gnue.forms.uidrivers.win32.dialog import BaseDialog
+from gnue.forms.uidrivers.win32.common import getNextId, centerWindow,
textEncode
from gnue.forms import VERSION
# =============================================================================
@@ -45,16 +45,13 @@
msg = u_("%s is not a valid type for an input field") % fieldtype
errors.ApplicationError.__init__ (self, msg)
-g_registeredClass = 0
-
-BUTTON = 0x0080
EDIT = 0x0081
STATIC = 0x0082
LISTBOX = 0x0084
DROPDOWN = 0x0085
-class InputDialog:
+class InputDialog(BaseDialog):
"""
Dialog class prompting the user for a given number of fields. These field
definitions are specified as follows:
@@ -101,22 +98,7 @@
@param fields: sequence of field definition tuples
@param cancel: If True add a Cancel button to the dialog
"""
- win32gui.InitCommonControls()
- self.hinst = win32api.GetModuleHandle(None)
-
- self.message_map = {
- win32con.WM_COMMAND: self.OnCommand,
- win32con.WM_INITDIALOG: self.OnInitDialog,
- win32con.WM_CLOSE: self.OnClose,
- }
-
- dlgClassName = self._RegisterWndClass()
-
- style = win32con.WS_POPUP | win32con.WS_VISIBLE | win32con.WS_CAPTION | \
- win32con.DS_SETFONT | win32con.WS_SYSMENU | win32con.DS_MODALFRAME
-
- self.template = [ [title, (0, 0, 0, 0), style, None, \
- (8, "MS Sans Serif"), None, dlgClassName], ]
+ BaseDialog.__init__(self, title, cancel)
self.fields = fields
self.inputData = {}
@@ -137,15 +119,7 @@
else:
self.AddControl(field)
- self.template.append ([BUTTON, _("Ok"), win32con.IDOK, (0, 0, 56, 15),
- win32con.WS_CHILD | win32con.WS_VISIBLE | \
- win32con.WS_TABSTOP | win32con.BS_DEFPUSHBUTTON])
- if cancel:
- self.template.append ([BUTTON, _("Cancel"), win32con.IDCANCEL, (0, 0,
56, 15),
- win32con.WS_CHILD | win32con.WS_VISIBLE | \
- win32con.WS_TABSTOP | win32con.BS_PUSHBUTTON])
-
def AddControl(self, field):
label, name, ftype, default, master, elements = field
cs = win32con.WS_CHILD | win32con.WS_VISIBLE
@@ -154,7 +128,7 @@
if ftype == 'label' or ftype == 'warning':
ID = getNextId()
s = cs | win32con.SS_CENTER #| win32con.WS_BORDER
- self.template.append([STATIC, label, ID, position, s])
+ self.template.append([STATIC, textEncode(label), ID, position, s])
self.__texts.append (ID)
if ftype == 'warning':
self.__warnings.append (ID)
@@ -162,7 +136,7 @@
elif ftype == 'string' or ftype == 'password':
ID = getNextId()
s = cs | win32con.SS_LEFT #| win32con.WS_BORDER
- self.template.append([STATIC, label, ID, position, s])
+ self.template.append([STATIC, textEncode(label), ID, position, s])
self.__labels.append (ID)
self.__controls.append (ID)
self.controlsName [ID] = name
@@ -186,12 +160,12 @@
elif ftype == 'button':
ID = getNextId()
s = cs | win32con.WS_TABSTOP | win32con.BS_PUSHBUTTON
- self.template.append([BUTTON, label, ID, position, s])
+ self.template.append([BUTTON, textEncode(label), ID, position, s])
elif ftype == 'dropdown':
ID = getNextId()
s = cs | win32con.SS_LEFT #| win32con.WS_BORDER
- self.template.append([STATIC, label, ID, position, s])
+ self.template.append([STATIC, textEncode(label), ID, position, s])
self.__labels.append (ID)
self.__controls.append (ID)
self.controlsName [ID] = name
@@ -205,30 +179,10 @@
self.__controls.append (ID)
self.controlsName [ID] = name
- def DoModal(self):
- return win32gui.DialogBoxIndirect(self.hinst, self.template, 0,
self.message_map)
+ def OnInitDialog(self, hwnd, msg, wparam, lparam):
+ BaseDialog.OnInitDialog(self, hwnd, msg, wparam, lparam)
- def OnInitDialog(self, hwnd, msg, wparam, lparam):
- self.hwnd = hwnd
-
- # Create a LOGFONT structure for the current font in use
- hFont = win32gui.GetObject (win32gui.SendMessage (hwnd,
win32con.WM_GETFONT, 0, 0))
- newFont = win32ui.CreateFont ( \
- {'name' : hFont.lfFaceName,
- 'height' : hFont.lfHeight,
- 'width' : hFont.lfWidth,
- 'charset' : hFont.lfCharSet,
- 'weight' : hFont.lfWeight,
- 'italic' : hFont.lfItalic,
- 'underline' : hFont.lfUnderline,
- 'pitch and family': hFont.lfPitchAndFamily})
-
- # Use this font in the device context of the dialog
- PyCWnd = win32ui.CreateWindowFromHandle(hwnd)
- self.dc = PyCWnd.GetDC ()
- of = self.dc.SelectObject (newFont)
-
for ID in self.__images.keys():
bmCtrl = win32gui.GetDlgItem(hwnd, ID)
win32gui.SendMessage(bmCtrl, win32con.STM_SETIMAGE,
win32con.IMAGE_BITMAP, \
@@ -292,12 +246,6 @@
centerWindow(hwnd)
- def OnClose(self, hwnd, msg, wparam, lparam):
- win32gui.EndDialog(hwnd, 0)
-
- def Destroy(self):
- win32gui.DestroyWindow(self._hwnd)
-
def OnCommand(self, hwnd, msg, wparam, lparam):
id = win32api.LOWORD(wparam)
if id == win32con.IDOK:
@@ -310,25 +258,6 @@
win32gui.EndDialog(hwnd, 0)
- def _RegisterWndClass(self):
- className = "GNUe dialog"
- global g_registeredClass
- if not g_registeredClass:
- message_map = {}
- wc = win32gui.WNDCLASS()
- wc.SetDialogProc() # Make it a dialog class.
- self.hinst = wc.hInstance = win32api.GetModuleHandle(None)
- wc.lpszClassName = className
- wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW
- wc.hCursor = win32gui.LoadCursor( 0, win32con.IDC_ARROW )
- wc.hIcon = win32gui.LoadIcon(0, win32con.IDI_APPLICATION)
- wc.hbrBackground = win32con.COLOR_WINDOW
- wc.lpfnWndProc = message_map # could also specify a wndproc.
- wc.cbWndExtra = win32con.DLGWINDOWEXTRA + struct.calcsize("Pi")
- classAtom = win32gui.RegisterClass(wc)
- g_registeredClass = 1
- return className
-
def Width(self, id):
item = win32gui.GetDlgItem(self.hwnd, id)
if (id in self.__labels) or (id in self.__texts):
@@ -367,7 +296,6 @@
x, y,
self.Width(id), self.Height(id),
win32con.SWP_NOACTIVATE | win32con.SWP_NOZORDER)
- l,t,r,b = win32gui.GetWindowRect(item)
def wrapText(self, text, width):
textSoFar = ""
@@ -389,179 +317,136 @@
# =============================================================================
# About Box
# =============================================================================
+class AboutBox (BaseDialog):
-class AboutBox (dialog.Dialog):
-
def __init__ (self, name, appversion, formversion, author, description):
"""
- """
+ """
+ title = textEncode(u_("About %s") % name)
+ BaseDialog.__init__(self, title, cancel= False)
- print "Creating new dialog for", name, appversion
- self.__lastId = 1000
self.__boxes = []
self.__labels = []
- self.__contents = []
-
- # Window frame and title
- title = u_("About %s") % name
- template = [[title, (0, 0, 300, 186), win32con.DS_MODALFRAME | \
- win32con.WS_POPUP | win32con.WS_VISIBLE | win32con.WS_CAPTION | \
- win32con.WS_SYSMENU | win32con.DS_SETFONT, None, (8, 'MS Sans Serif')]]
-
+ self.__contents = []
+
# Upper box with info about GNUe Forms
- template.append (self.__addBox (u_('GNUe Forms'), 8, 48))
- template.append (self.__addLabel (self.__labels, u_('Version:'), 20))
- template.append (self.__addLabel (self.__labels, u_('Driver:'), 34))
+ self.template.append (self.__addBox (textEncode(u_('GNUe Forms')), 8, 44))
+ self.template.append (self.__addLabel (self.__labels,
textEncode(u_('Version:')), 20))
+ self.template.append (self.__addLabel (self.__labels,
textEncode(u_('Driver:')), 34))
- template.append (self.__addLabel (self.__contents, appversion, 20))
- template.append (self.__addLabel (self.__contents, 'win32', 34))
+ self.template.append (self.__addLabel (self.__contents,
textEncode(appversion), 20))
+ self.template.append (self.__addLabel (self.__contents, 'win32', 34))
# Lower box with info about the form currently displayed
- template.append (self.__addBox (u_('Form Information'), 56, 98))
- template.append (self.__addLabel (self.__labels, u_('Name:'), 74))
- template.append (self.__addLabel (self.__labels, u_('Version:'), 88))
- template.append (self.__addLabel (self.__labels, u_('Author:'), 102))
- template.append (self.__addLabel (self.__labels, u_('Description:'), 116))
+ self.template.append (self.__addBox (textEncode(u_('Form Information')),
56, 74))
+ self.template.append (self.__addLabel (self.__labels,
textEncode(u_('Name:')), 74))
+ self.template.append (self.__addLabel (self.__labels,
textEncode(u_('Version:')), 88))
+ self.template.append (self.__addLabel (self.__labels,
textEncode(u_('Author:')), 102))
+ self.template.append (self.__addLabel (self.__labels,
textEncode(u_('Description:')), 116))
- template.append (self.__addLabel (self.__contents, name, 74))
- template.append (self.__addLabel (self.__contents, formversion, 88))
- template.append (self.__addLabel (self.__contents, author, 102))
+ self.template.append (self.__addLabel (self.__contents, textEncode(name),
74))
+ self.template.append (self.__addLabel (self.__contents,
textEncode(formversion), 88))
+ self.template.append (self.__addLabel (self.__contents,
textEncode(author), 102))
descr = '\n'.join (textwrap.wrap (description))
- template.append (self.__addLabel (self.__contents, descr, 116))
-
- # Ok Button
- template.append (['button', "Ok", win32con.IDOK, (121, 162, 56, 15),
- win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_TABSTOP | \
- win32con.BS_PUSHBUTTON | win32con.BS_DEFPUSHBUTTON])
-
- print "nearly done"
- dialog.Dialog.__init__ (self, template)
- print "constructor finished"
-
-
+ self.template.append (self.__addLabel (self.__contents, textEncode(descr),
116))
+
+
# ---------------------------------------------------------------------------
# Finalize the dialog's initialization
# ---------------------------------------------------------------------------
-
- def OnInitDialog (self):
+ def OnInitDialog(self, hwnd, msg, wparam, lparam):
+ BaseDialog.OnInitDialog(self, hwnd, msg, wparam, lparam)
"""
Recalculate sizes of all labels and boxes.
"""
-
- print "running on Init ..."
- dialog.Dialog.OnInitDialog (self)
-
- # Create a LOGFONT structure for the current font in use
- hFont = win32gui.GetObject (self.SendMessage (win32con.WM_GETFONT, 0, 0))
- newFont = win32ui.CreateFont ( \
- {'name' : hFont.lfFaceName,
- 'height' : hFont.lfHeight,
- 'width' : hFont.lfWidth,
- 'charset' : hFont.lfCharSet,
- 'weight' : hFont.lfWeight,
- 'italic' : hFont.lfItalic,
- 'underline' : hFont.lfUnderline,
- 'pitch and family': hFont.lfPitchAndFamily})
-
- # Use this font in the device context of the dialog
- dc = self.GetDC ()
- of = dc.SelectObject (newFont)
-
# Stretch all labels in the left column and calculate the widest label
maxW = 0
flags = win32con.SWP_NOMOVE | win32con.SWP_NOOWNERZORDER | \
win32con.SWP_NOZORDER | win32con.SWP_SHOWWINDOW
for (ix, itemId) in enumerate (self.__labels):
- item = self.GetDlgItem (itemId)
- text = item.GetWindowText ()
- (width, height) = dc.GetTextExtent (text)
+ item = win32gui.GetDlgItem(hwnd, itemId)
+ text = win32gui.GetWindowText(item)
+ (width, height) = self.dc.GetTextExtent (text)
maxW = max (maxW, width)
- item.SetWindowPos (0, (0, 0, width, height), flags)
+ win32gui.SetWindowPos(item, 0, 0, 0, width, height, flags)
- # Reposition and stretch all labels in the second column
+ # Reposition and stretch all labels in the second column
+ maxBottom = 0
right = 0
flags = win32con.SWP_NOOWNERZORDER | \
win32con.SWP_NOZORDER | win32con.SWP_SHOWWINDOW
for (ix, itemId) in enumerate (self.__contents):
- item = self.GetDlgItem (itemId)
- text = item.GetWindowText ()
+ item = win32gui.GetDlgItem(hwnd, itemId)
+ text = win32gui.GetWindowText(item)
if '\n' in text:
- width = max ([dc.GetTextExtent (p) [0] for p in text.split ('\n')])
- height = sum ([dc.GetTextExtent (p) [1] for p in text.split ('\n')])
+ width = max ([self.dc.GetTextExtent (p) [0] for p in text.split
('\n')])
+ height = sum ([self.dc.GetTextExtent (p) [1] for p in text.split
('\n')])
else:
- (width, height) = dc.GetTextExtent (text)
+ (width, height) = self.dc.GetTextExtent (text)
- (left, top, w, h) = self.ScreenToClient (item.GetWindowRect ())
+ (left, top, w, h) = win32gui.GetWindowRect(item)
+ left, top = win32gui.ScreenToClient(self.hwnd, (left, top))
left = maxW + 40
- item.SetWindowPos (0, (left, top, width, height), flags)
+ win32gui.SetWindowPos (item, 0, left, top, width, height, flags)
right = max ((left + width), right)
+ maxBottom = max (top + height, maxBottom,)
# Now stretch all boxes to fit the newly calculated width
right += 8
flags = win32con.SWP_NOMOVE | win32con.SWP_NOOWNERZORDER | \
win32con.SWP_NOZORDER | win32con.SWP_SHOWWINDOW
for itemId in self.__boxes:
- item = self.GetDlgItem (itemId)
- (left, top, r, bottom) = self.ScreenToClient (item.GetWindowRect ())
- item.SetWindowPos (0, (0, 0, right, bottom - top), flags)
+ item = win32gui.GetDlgItem(hwnd, itemId)
+ (left, top, r, bottom) = win32gui.GetWindowRect(item)
+ left, top = win32gui.ScreenToClient(self.hwnd, (left, top))
+ r, bottom = win32gui.ScreenToClient(self.hwnd, (r,bottom))
+ win32gui.SetWindowPos (item, 0, 0, 0, right, bottom - top, flags)
# Resize the dialog itself to the new width
right += 24
+ win32gui.SetWindowPos (self.hwnd, 0, 0, 0, right, maxBottom + 100, flags)
- (l, top, r, bottom) = self.ScreenToClient (self.GetWindowRect ())
- self.SetWindowPos (0, (0, 0, right, bottom - top), flags)
-
# Re-Center the Ok button
flags = win32con.SWP_NOOWNERZORDER | win32con.SWP_NOZORDER | \
win32con.SWP_SHOWWINDOW | win32con.SWP_NOSIZE
- item = self.GetDlgItem (win32con.IDOK)
- (l, t, r, b) = self.ScreenToClient (item.GetWindowRect ())
- left = right / 2 - (r - l) / 2
- item.SetWindowPos (0, (left, t, 0, 0), flags)
+ item = win32gui.GetDlgItem(hwnd, win32con.IDOK)
+ (l, t, r, b) = win32gui.GetWindowRect(item)
+ l, t = win32gui.ScreenToClient(self.hwnd, (l, t))
+ r, b = win32gui.ScreenToClient(self.hwnd, (r, b))
+ left = right / 2 - (r - l) / 2
+ win32gui.SetWindowPos (item, 0, left, maxBottom + 25, 0, 0, flags)
- print "leaving on init"
return 1
# ---------------------------------------------------------------------------
# Create a resource definition for a label
# ---------------------------------------------------------------------------
-
def __addLabel (self, collection, label, row):
s = win32con.WS_CHILD | win32con.WS_VISIBLE
- self.__lastId += 1
- collection.append (self.__lastId)
- return ['Static', label, self.__lastId, (16, row, 5, 14), s]
+ ID = getNextId()
+ collection.append (ID)
+ return ['Static', label, ID, (16, row, 5, 14), s]
# ---------------------------------------------------------------------------
# Create a resource sequence for a labeled box
# ---------------------------------------------------------------------------
-
def __addBox (self, label, top, height):
- self.__boxes.append (self.__nextId ())
+ self.__boxes.append (getNextId())
style = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_TABSTOP | \
win32con.BS_GROUPBOX
return ['button', label, self.__boxes [-1], (6, top, 282, height), style]
- # ---------------------------------------------------------------------------
- # Get another control id
- # ---------------------------------------------------------------------------
- def __nextId (self):
-
- self.__lastId += 1
- return self.__lastId
-
-
if __name__ == '__main__':
desc = "This is a quite long description of the application.\n" \
"It also contains newlines as well as a lot of text. This text " \
@@ -570,7 +455,6 @@
#desc = "Hey boyz, that thingy is quite complicated"
dialog = AboutBox ('Foobar', '1.0', '0.5.2', 'Frodo', desc)
dialog.DoModal ()
- dialog.Destroy
#
---------------------------------------------------------------------------
@@ -605,4 +489,3 @@
dialog = InputDialog('Foobar', fields)
dialog.DoModal()
print dialog.inputData
- dialog.Destroy
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7526 - trunk/gnue-forms/src/uidrivers/win32,
btami <=