| 1 |
#!/usr/bin/env python |
|---|
| 2 |
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 3 |
##~ License |
|---|
| 4 |
##~ |
|---|
| 5 |
##- The RuneBlade Foundation library is intended to ease some |
|---|
| 6 |
##- aspects of writing intricate Jabber, XML, and User Interface (wxPython, etc.) |
|---|
| 7 |
##- applications, while providing the flexibility to modularly change the |
|---|
| 8 |
##- architecture. Enjoy. |
|---|
| 9 |
##~ |
|---|
| 10 |
##~ Copyright (C) 2002 TechGame Networks, LLC. |
|---|
| 11 |
##~ |
|---|
| 12 |
##~ This library is free software; you can redistribute it and/or |
|---|
| 13 |
##~ modify it under the terms of the BSD style License as found in the |
|---|
| 14 |
##~ LICENSE file included with this distribution. |
|---|
| 15 |
##~ |
|---|
| 16 |
##~ TechGame Networks, LLC can be reached at: |
|---|
| 17 |
##~ 3578 E. Hartsel Drive #211 |
|---|
| 18 |
##~ Colorado Springs, Colorado, USA, 80920 |
|---|
| 19 |
##~ |
|---|
| 20 |
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 21 |
|
|---|
| 22 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 23 |
#~ Imports |
|---|
| 24 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 25 |
|
|---|
| 26 |
from layout import wx, layout |
|---|
| 27 |
from RBSkinning.wxTools.wxExpandableSizers import wxExpandableBoxSizer |
|---|
| 28 |
|
|---|
| 29 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 30 |
#~ Definitions |
|---|
| 31 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 32 |
|
|---|
| 33 |
class expander(layout): |
|---|
| 34 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 35 |
#~ Constants / Variables / Etc. |
|---|
| 36 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 37 |
|
|---|
| 38 |
default_settings = layout.default_settings.copy() |
|---|
| 39 |
default_settings.update({ |
|---|
| 40 |
'ctxvar': 'layout', |
|---|
| 41 |
#'orientation': 'opposite', |
|---|
| 42 |
#'frame': Gets parent by default, |
|---|
| 43 |
}) |
|---|
| 44 |
|
|---|
| 45 |
orientation_map = { |
|---|
| 46 |
# Opposite is default vertical |
|---|
| 47 |
'opposite': (wxExpandableBoxSizer, (wx.wxVERTICAL,)), |
|---|
| 48 |
'vertical': (wxExpandableBoxSizer, (wx.wxVERTICAL,)), |
|---|
| 49 |
'vert': (wxExpandableBoxSizer, (wx.wxVERTICAL,)), |
|---|
| 50 |
|
|---|
| 51 |
'horizontal': (wxExpandableBoxSizer, (wx.wxHORIZONTAL,)), |
|---|
| 52 |
'horiz': (wxExpandableBoxSizer, (wx.wxHORIZONTAL,)), |
|---|
| 53 |
} |
|---|
| 54 |
|
|---|
| 55 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 56 |
#~ Public |
|---|
| 57 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 58 |
|
|---|
| 59 |
def SkinInitialize(self): |
|---|
| 60 |
orientation = self.settings.get('orientation', 'opposite') |
|---|
| 61 |
|
|---|
| 62 |
# Grab the window parent object, or the first layout derived parent |
|---|
| 63 |
self.winParent = self.wxGetParentObject((wx.wxWindowPtr, layout)) |
|---|
| 64 |
if not isinstance(self.winParent, wx.wxWindowPtr): |
|---|
| 65 |
# Layouts cancel the window parent |
|---|
| 66 |
parentLayout = self.winParent |
|---|
| 67 |
self.winParent = None |
|---|
| 68 |
|
|---|
| 69 |
# Figure out what type of sizer we should be creating |
|---|
| 70 |
if orientation == 'opposite': |
|---|
| 71 |
orientation = wx.wxVERTICAL # New Default |
|---|
| 72 |
# Calculate the "real" opposite |
|---|
| 73 |
try: GetOrientation = parentLayout.GetOrientation |
|---|
| 74 |
except AttributeError: pass |
|---|
| 75 |
else: |
|---|
| 76 |
if GetOrientation() == wx.wxVERTICAL: |
|---|
| 77 |
orientation = wx.wxHORIZONTAL |
|---|
| 78 |
else: orientation = wx.wxVERTICAL |
|---|
| 79 |
|
|---|
| 80 |
expandwindow = self.wxEvalCond('frame', None) |
|---|
| 81 |
if expandwindow is None: |
|---|
| 82 |
expandwindow = self.winParent or self.wxGetParentObject(wx.wxWindowPtr) |
|---|
| 83 |
|
|---|
| 84 |
# Create the layout sizer |
|---|
| 85 |
sizerClass, preArgs = self.orientation_map[orientation] |
|---|
| 86 |
postArgs = self.wxEvalCond('args', ()) |
|---|
| 87 |
self.object = sizerClass(expandwindow, *(preArgs + postArgs)) |
|---|
| 88 |
self.object.SetExpandingEnabled(False) |
|---|
| 89 |
self.wxInitialStandardOptions() |
|---|
| 90 |
|
|---|
| 91 |
# Tinker with the context to make things available |
|---|
| 92 |
self.PushContext() |
|---|
| 93 |
|
|---|
| 94 |
def SkinFinalize(self): |
|---|
| 95 |
layout.SkinFinalize(self) |
|---|
| 96 |
self.object.SetExpandingEnabled(True) |
|---|
| 97 |
|
|---|