frame.py :  » Windows » pyExcelerator » pywin32-214 » pythonwin » pywin » framework » editor » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Windows » pyExcelerator 
pyExcelerator » pywin32 214 » pythonwin » pywin » framework » editor » frame.py
# frame.py - The MDI frame window for an editor.
import pywin.framework.window
import win32ui
import win32con
import afxres

import ModuleBrowser

class EditorFrame(pywin.framework.window.MDIChildWnd):
    def OnCreateClient(self, cp, context):

        # Create the default view as specified by the template (ie, the editor view)
        view = context.template.MakeView(context.doc)
        # Create the browser view.
        browserView = ModuleBrowser.BrowserView(context.doc)
        view2 = context.template.MakeView(context.doc)

        splitter = win32ui.CreateSplitter()
        style = win32con.WS_CHILD | win32con.WS_VISIBLE
        splitter.CreateStatic (self, 1, 2, style, win32ui.AFX_IDW_PANE_FIRST)
        sub_splitter = self.sub_splitter = win32ui.CreateSplitter()
        sub_splitter.CreateStatic (splitter, 2, 1, style, win32ui.AFX_IDW_PANE_FIRST+1)

        # Note we must add the default view first, so that doc.GetFirstView() returns the editor view.
        sub_splitter.CreateView(view, 1, 0, (0,0)) 
        splitter.CreateView (browserView, 0, 0, (0,0))
        sub_splitter.CreateView(view2,0, 0, (0,0)) 

##        print "First view is", context.doc.GetFirstView()
##        print "Views are", view, view2, browserView
##        print "Parents are", view.GetParent(), view2.GetParent(), browserView.GetParent()
##        print "Splitter is", splitter
##        print "sub splitter is", sub_splitter
        ## Old 
##        splitter.CreateStatic (self, 1, 2)
##        splitter.CreateView(view, 0, 1, (0,0)) # size ignored.
##        splitter.CreateView (browserView, 0, 0, (0, 0))

        # Restrict the size of the browser splitter (and we can avoid filling
        # it until it is shown)
        splitter.SetColumnInfo(0, 10, 20)
        # And the active view is our default view (so it gets initial focus)
        self.SetActiveView(view)

    def GetEditorView(self):
        # In a multi-view (eg, splitter) environment, get
        # an editor (ie, scintilla) view
        # Look for the splitter opened the most!
        if self.sub_splitter is None:
            return self.GetDlgItem(win32ui.AFX_IDW_PANE_FIRST)
        v1 = self.sub_splitter.GetPane(0,0)
        v2 = self.sub_splitter.GetPane(1,0)
        r1 = v1.GetWindowRect()
        r2 = v2.GetWindowRect()
        if r1[3]-r1[1] > r2[3]-r2[1]:
            return v1
        return v2

    def GetBrowserView(self):
        # XXX - should fix this :-)
        return self.GetActiveDocument().GetAllViews()[1]

    def OnClose(self):
        doc=self.GetActiveDocument()
        if not doc.SaveModified():              
            ## Cancel button selected from Save dialog, do not actually close
            ## print 'close cancelled'
            return 0
        ## So the 'Save' dialog doesn't come up twice
        doc._obj_.SetModifiedFlag(False)

        # Must force the module browser to close itself here (OnDestroy for the view itself is too late!)
        self.sub_splitter = None # ensure no circles!
        self.GetBrowserView().DestroyBrowser()
        return self._obj_.OnClose()
    
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.