
import wx

""" 
AddSpacer

An intelligent function to add a variety of spacers.  
Interger values of zero or greater are valid.

Syntax:
    AddSpacer( sizerName, reqArg, rectYarg )

A) reqArg is a single integer. Inserts a one-demensional spacer
   along the sizer's major axis. This is a safe alternative 
   to the sizer.AddSpacer( n ) method which inserts a square 
   shaped spacer which can unintentionally interfere with 
   adjacent controls stacked along one or both of the 
   sizer's minor axis.

B) reqArg is a 2-tuple of integers. Inserts a rectanguler spacer.
   E.g.:   (20, 30)
   Inserts a rectanguler spacer.
   
C) reqArg and optArg are integer arguments.
   E.g.:   20, 30
   Inserts a rectanguler spacer.
   

Ray Pasco
2010-09-25-Sat__PM-03-14-19__September
"""

import os, sys
import wx

def AddSpacer( boxsizer, reqArg, optArg=None ) :
    """ A smart spacer for use with any BoxSizer """
    
    if (type( reqArg ) == type( 123 )) and (optArg == None) :
        
        orientation = boxsizer.GetOrientation()
        if   (orientation == wx.HORIZONTAL) :
            boxsizer.Add( (reqArg, 0) )
            
        elif (orientation == wx.VERTICAL) :
            boxsizer.Add( (0, reqArg) )
        #end if
            
    elif (type( reqArg ) == type( (123, 123) ))  and (optArg == None) and  \
         (type( reqArg[0] ) == type( 123 ))      and (type( reqArg[1] ) == type( 123 )) :
    
        boxsizer.Add( reqArg )
        
    elif (type( reqArg ) == type( 123 )) and (type( optArg ) == type( 123 )) :
    
        boxsizer.Add( (reqArg, optArg) )
        
    else :
        print
        print '####  AddSpacer():    Argument Types are Not Recognized.'
        sys.exit(1)
    #end if

#end def

#------------------------------------------------------------------------------

""" 
AddLinearSpacer

This is included for backward compatibility in the demo apps.

Simple, foolproof, and intelligent function to properly insert 
a variety of spacers.  Interger values of zero or greater are valid.

Syntax:
    AddLinearSpacer( sizerName, int )

Ray Pasco
2010-09-25-Sat__PM-03-14-19__September
"""

def AddLinearSpacer( boxsizer, pixelSpacing ) :
    """ 
    A one-dimensional spacer for use with any BoxSizer.
    """

    orientation = boxsizer.GetOrientation()
    if   (orientation == wx.HORIZONTAL) :
        boxsizer.Add( (pixelSpacing, 0) )

    elif (orientation == wx.VERTICAL) :
        boxsizer.Add( (0, pixelSpacing) )
    #end if

#end def
