lisp_sizers_codegen.py :  » GUI » wxGlade » wxGlade-0.6.3 » edit_sizers » 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 » GUI » wxGlade 
wxGlade » wxGlade 0.6.3 » edit_sizers » lisp_sizers_codegen.py
# lisp_sizers_codegen.py : lisp generator functions for the various wxSizerS
# $Id: lisp_sizers_codegen.py,v 1.2 2006/12/02 11:20:29 agriggio Exp $
#
# Copyright (c) 2002-2004 D.H. aka crazyinsomniac on sourceforge.net
# License: MIT (see license.txt)
# THIS PROGRAM COMES WITH NO WARRANTY
#

import common

class LispBoxSizerBuilder:
    def get_code(self, obj):
        orient = obj.properties.get('orient', 'wxHORIZONTAL')
        init = [
            '(setf (slot-%s obj) (wxBoxSizer_Create  %s))\n' % (obj.name, orient)
            ]
        layout = []

        if obj.is_toplevel:
            if not obj.parent.is_toplevel:
                parent = '(slot-%s obj)' % obj.parent.name
            else:
                parent = '(slot-top-window obj)'

            #layout.append('(wxWindow_SetAutoLayout %s 1)\n' % parent)
            layout.append('(wxWindow_SetSizer %s (slot-%s obj))\n' % (parent, obj.name))

            if not obj.parent.properties.has_key('size') and \
                   obj.parent.is_toplevel:
                layout.append('(wxSizer_Fit (slot-%s obj) %s)\n' % (obj.name, parent))
            if obj.parent.properties.get('sizehints', False):
                layout.append('(wxSizer_SetSizeHints (slot-%s obj) %s)\n'
                              % (obj.name, parent))
        return init, [], layout

# end of class LispBoxSizerBuilder


class LispStaticBoxSizerBuilder:
    def get_code(self, obj):
        plgen = common.code_writers['lisp']
        orient = obj.properties.get('orient', 'wxHORIZONTAL')
        label = obj.properties.get('label', '')
        if not obj.parent.is_toplevel: parent = '(slot-%s obj)' % obj.parent.name
        else: parent = '(slot-frame obj)'
        init = [
          '(setf (slot-%s obj) (StaticBoxSizer_Create (wxStaticBox:wxStaticBox_Create %s %s) %s))\n'
          % (obj.name, parent, plgen.quote_str(label), orient)
        ]
        layout = []
        if obj.is_toplevel:
            #layout.append('(wxWindow_SetAutoLayout %s 1)\n' % parent)
            layout.append('(wxWindow_SetSizer %s (slot-%s obj))\n' % (parent, obj.name))
            if not obj.parent.properties.has_key('size') and \
                   obj.parent.is_toplevel:
                layout.append('(wxSizer_Fit (slot-%s obj) %s)\n' % (obj.name, parent))
            if obj.parent.properties.get('sizehints', False):
                layout.append('(wxSizer_SetSizeHints (slot-%s obj) %s)\n'
                              % (obj.name, parent))
        return init, [], layout

# end of class LispStaticBoxSizerBuilder


class LispGridSizerBuilder:
    klass = 'Wx::GridSizer'

    def get_code(self, obj):
        props = obj.properties
        if not obj.parent.is_toplevel:
            parent = '(slot-%s obj)' % obj.parent.name
        else:
                parent = '(slot-frame obj)'
        rows = props.get('rows', '0')
        cols = props.get('cols', '0')
        vgap = props.get('vgap', '0')
        hgap = props.get('hgap', '0')
        init = [
            '(setf (slot-%s obj) (wxGridSizer_Create %s %s %s %s))\n' %
                (obj.name, rows, cols, vgap, hgap)
            ]
        layout = []
        if obj.is_toplevel:
            #layout.append('(wxWindow_SetAutoLayout %s 1)\n' % parent)
            layout.append('(wxWindow_SetSizer %s (slot-%s obj))\n' % (parent, obj.name))
            if not obj.parent.properties.has_key('size') and \
                   obj.parent.is_toplevel:
                layout.append('(wxSizer_Fit (slot-%s obj) %s)\n' % (obj.name, parent))
            if obj.parent.properties.get('sizehints', False):
                layout.append('(wxSizer_SetSizeHints (slot-%s obj) %s)\n'
                              % (obj.name, parent))
        return init, [], layout   

# end of class LispGridSizerBuilder


class LispFlexGridSizerBuilder(LispGridSizerBuilder):
    klass = 'Wx::FlexGridSizer'

    def get_code(self, obj):
        init, p, layout = LispGridSizerBuilder.get_code(self, obj)
        props = obj.properties
        if props.has_key('growable_rows'):
            for r in props['growable_rows'].split(','):
                layout.append('(wxFlexGridSizer_AddGrowableRow (slot-%s obj) %s)\n' %
                              (obj.name, r.strip()))
        if props.has_key('growable_cols'):
            for r in props['growable_cols'].split(','):
                layout.append('(wxFlexGridSizer_AddGrowableCol (slot-%s obj) %s)\n' %
                              (obj.name, r.strip()))
        return init, p, layout

# end of class LispFlexGridSizerBuilder


def initialize():
    cn = common.class_names
    cn['EditBoxSizer'] = 'wxBoxSizer'
    cn['EditStaticBoxSizer'] = 'wxStaticBoxSizer'
    cn['EditGridSizer'] = 'wxGridSizer'
    cn['EditFlexGridSizer'] = 'wxFlexGridSizer'

    plgen  = common.code_writers.get("lisp")
    if plgen:
        awh = plgen.add_widget_handler
        awh('wxBoxSizer', LispBoxSizerBuilder())
        awh('wxStaticBoxSizer', LispStaticBoxSizerBuilder())
        awh('wxGridSizer', LispGridSizerBuilder())
        awh('wxFlexGridSizer', LispFlexGridSizerBuilder())
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.