commit-gnue
[Top][All Lists]
Advanced

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

gnue-navigator/src UIwin32.py


From: Bajusz Tamás
Subject: gnue-navigator/src UIwin32.py
Date: Sat, 05 Jul 2003 18:09:30 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue-navigator
Branch:         
Changes by:     Bajusz Tamás <address@hidden>   03/07/05 18:09:30

Modified files:
        src            : UIwin32.py 

Log message:
        A first activex contol in GNUe, wow !

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-navigator/src/UIwin32.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: gnue-navigator/src/UIwin32.py
diff -c gnue-navigator/src/UIwin32.py:1.2 gnue-navigator/src/UIwin32.py:1.3
*** gnue-navigator/src/UIwin32.py:1.2   Fri Jun 27 03:22:43 2003
--- gnue-navigator/src/UIwin32.py       Sat Jul  5 18:09:30 2003
***************
*** 29,36 ****
  # reuse GNUe Form's UI* classes if at all possible.
  
  
! from time import sleep
! import os, sys, string
  from gnue.common.datasources import GDataObjects, GConnections
  from gnue.common.utils.FileUtils import dyn_import, openResource
  from gnue.common.apps import GConfig
--- 29,35 ----
  # reuse GNUe Form's UI* classes if at all possible.
  
  
! import os, sys
  from gnue.common.datasources import GDataObjects, GConnections
  from gnue.common.utils.FileUtils import dyn_import, openResource
  from gnue.common.apps import GConfig
***************
*** 48,55 ****
    FORMS_SUPPORT=1
    print 'GNUe Forms is not installed on your system'
  
! import struct, array
  import win32api, win32gui, win32ui, win32con, commctrl
  
  ID_EXIT = getNextId()
  ID_FAV_ORG = getNextId()
--- 47,60 ----
    FORMS_SUPPORT=1
    print 'GNUe Forms is not installed on your system'
  
! import struct, array, tempfile
  import win32api, win32gui, win32ui, win32con, commctrl
+ from pywin.mfc import window, activex
+ from win32com.client import gencache
+ 
+ WebBrowserModule = 
gencache.EnsureModule("{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}", 0, 1, 1)
+ if WebBrowserModule is None:
+   raise ImportError, "IE4 does not appear to be installed."
  
  ID_EXIT = getNextId()
  ID_FAV_ORG = getNextId()
***************
*** 58,70 ****
  
  _menustyle = win32con.MF_STRING
  
  
  class Instance:
    def __init__(self, processes):
      self.processes = processes
      self._formInstances = {}
  
!     self.titlePage = "A part of the GNU Enterprise Project"
  
      win32gui.InitCommonControls()
      message_map = {
--- 63,86 ----
  
  _menustyle = win32con.MF_STRING
  
+ images_dir = GConfig.getInstalledBase('forms_images','common_images') + '/'
  
  class Instance:
    def __init__(self, processes):
      self.processes = processes
      self._formInstances = {}
  
!     self.titlePage = """
!     <html>
!       <body>
!         <center>
!          <B>GNUe Navigator</B>
!          <p><img src="%s"></p>
!          <p>A part of the <a href="http://www.gnuenteprise.org/";>GNU 
Enterprise Project</a></p>
!         </center>
!       </body>
!     </html>
!     """ % (images_dir+"/ship2.png")
  
      win32gui.InitCommonControls()
      message_map = {
***************
*** 81,87 ****
      wc.lpfnWndProc = message_map # could also specify a wndproc.
      self.classAtom = win32gui.RegisterClass(wc)
      self.hTree = 0
-     self.hEdit = 0
  
    def run(self, connections):
      #
--- 97,102 ----
***************
*** 104,110 ****
      
      self.CreateMenu()
      self.BuildTree()
!     self.CreateEdit()
  
      self.processes.setClientHandlers({'form':self.runForm})
  
--- 119,130 ----
      
      self.CreateMenu()
      self.BuildTree()
!     self.tempfile = tempfile.mktemp('.html')
!     self.tempfileHandle = open(self.tempfile, 'w')
!     self.tempfileHandle.write(self.titlePage)
!     self.tempfileHandle.flush()
! 
!     self.CreateBrowser(self.tempfile)
  
      self.processes.setClientHandlers({'form':self.runForm})
  
***************
*** 155,172 ****
  #    win32gui.SendMessage(self.hTree, commctrl.TVM_SETIMAGELIST, 
commctrl.TVSIL_NORMAL, himl)
  
  
!   def CreateEdit(self):
      l,t,r,b = win32gui.GetClientRect(self.hMainWindow)
!     style = win32con.WS_VISIBLE | win32con.WS_CHILD |\
!                win32con.ES_MULTILINE | win32con.ES_READONLY | 
win32con.ES_LEFT #CENTER 
!     width = (r-l) - (r-l)/3
!     height = b-t
!     self.hEdit = win32gui.CreateWindowEx(win32con.WS_EX_CLIENTEDGE, 'EDIT', 
'', style, \
!                                                           (r-l)/3,0, 
width,height, self.hMainWindow, getNextId(), 0, None)
! 
!     text = 'GNUe Navigator \r\n \r\n A part of the GNU Enterprise Project'
!     win32gui.SetWindowText(self.hEdit, text)
!     win32gui.ShowWindow(self.hEdit, win32con.SW_SHOWNORMAL)
  
  
    def OnWMNotify(self, hwnd, msg, wParam, lParam):
--- 175,185 ----
  #    win32gui.SendMessage(self.hTree, commctrl.TVM_SETIMAGELIST, 
commctrl.TVSIL_NORMAL, himl)
  
  
!   def CreateBrowser(self, url):
!     self.browser = BrowserFrame(url)
      l,t,r,b = win32gui.GetClientRect(self.hMainWindow)
!     self.browser.Create("", rect=((r-l)/3, 0, r-l, b-t),\
!                                
parent=win32ui.CreateWindowFromHandle(self.hMainWindow))
  
  
    def OnWMNotify(self, hwnd, msg, wParam, lParam):
***************
*** 182,197 ****
  
      if code == commctrl.TVN_SELCHANGED:
        object = self._mapping[nhItem]
!       win32gui.SetWindowText(self.hEdit, "")
        for item in object._children:
          if item._type == 'GNDescription':
!           # TODO: use win32help.HtmlHelp or something else...
!           text0 = item.getChildrenAsContent()
!           text1 = 
text0.replace("\n","").replace("<CENTER>","").replace("</CENTER>","").replace("<H1>","").replace("</H1>","\r\n\r\n")
!           text2 = 
text1.replace("<p>","\r\n").replace("<B>","").replace("</B>","\r\n").replace("<hr>","\r\n\r\n").replace("<i>","")
!           text3 = text2.replace("</i>","").replace("<a 
href=","").replace('<font size="-2">',"").replace("</font>","").replace(">","")
!           text4 = text3.replace("\t"," ").replace("  ","|").replace("|","")
!           win32gui.SetWindowText(self.hEdit, text4)
            break
  
      elif code == commctrl.NM_DBLCLK or code == commctrl.NM_RETURN:
--- 195,209 ----
  
      if code == commctrl.TVN_SELCHANGED:
        object = self._mapping[nhItem]
!       win32gui.SetWindowText(self.browser.GetSafeHwnd(), "")
        for item in object._children:
          if item._type == 'GNDescription':
!           content = item.getChildrenAsContent()
!           self.tempfileHandle.truncate(0)
!           self.tempfileHandle.write("<html\n>")
!           self.tempfileHandle.write(content)
!           self.tempfileHandle.flush()
!           self.browser.ocx.Refresh()
            break
  
      elif code == commctrl.NM_DBLCLK or code == commctrl.NM_RETURN:
***************
*** 209,214 ****
--- 221,227 ----
      win32gui.DestroyWindow(hwnd)
      if len(self._app._MainWindowList) == 0:
        win32gui.PostQuitMessage(0) # Terminate the app.
+     self.tempfileHandle.close()
  
  
    def OnWMCommand(self, hwnd, msg, wParam, lParam):
***************
*** 223,229 ****
    def OnWMSize(self, hwnd, msg, wParam, lParam):
      l,t,r,b = win32gui.GetClientRect(self.hMainWindow)
      win32gui.SetWindowPos(self.hTree, 0, 0, 0, (r-l)/3, b-t, 
win32con.SWP_NOMOVE | win32con.SWP_NOZORDER)
!     win32gui.SetWindowPos(self.hEdit, 0, (r-l)/3, 0, (r-l) - (r-l)/3, b-t, 
win32con.SWP_NOZORDER)
  
  
    def __buildTreeControl(self, object):
--- 236,245 ----
    def OnWMSize(self, hwnd, msg, wParam, lParam):
      l,t,r,b = win32gui.GetClientRect(self.hMainWindow)
      win32gui.SetWindowPos(self.hTree, 0, 0, 0, (r-l)/3, b-t, 
win32con.SWP_NOMOVE | win32con.SWP_NOZORDER)
!     try:
!       win32gui.SetWindowPos(self.browser.GetSafeHwnd(), 0, (r-l)/3, 0, (r-l) 
- (r-l)/3, b-t, win32con.SWP_NOZORDER)
!     except:
!       pass
  
  
    def __buildTreeControl(self, object):
***************
*** 346,348 ****
--- 362,394 ----
  #    dlg.Destroy()
  
       print mesg
+ 
+ 
+ class MyWebBrowser(activex.Control, WebBrowserModule.WebBrowser):
+   pass
+ #  def OnBeforeNavigate2(self, pDisp, URL, Flags, TargetFrameName, PostData, 
Headers, Cancel):
+ #    self.GetParent().OnNavigate(URL)
+ 
+ 
+ class BrowserFrame(window.Wnd):
+   def __init__(self, url):
+     self.url = url
+ 
+   def Create(self, title, rect = None, parent = None):
+     style = win32con.WS_CHILD | win32con.WS_VISIBLE
+     window.Wnd.__init__(self, win32ui.CreateWnd ())
+     self._obj_.AttachObject(self)
+     self._obj_.CreateWindow(None, title, style, rect, parent, getNextId())
+     rect = self.GetClientRect()
+     rect = (0,0,rect[2]-rect[0], rect[3]-rect[1])
+     self.ocx = MyWebBrowser()
+     win32ui.EnableControlContainer()
+     self.ocx.CreateControl("", style, rect, self, getNextId())    
+     self.ocx.Navigate(self.url)
+     self.HookMessage (self.OnSize, win32con.WM_SIZE)
+     
+   def OnSize (self, params):
+     rect = self.GetClientRect()
+     rect = (0,0,rect[2]-rect[0], rect[3]-rect[1])
+     self.ocx.SetWindowPos(0, rect, 0)
+ 




reply via email to

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