Changeset 200

Show
Ignore:
Timestamp:
04/26/08 11:47:50 (9 months ago)
Author:
tal
Message:
Vanilla Cleanup Phase 2:

All wrapped classes are available to subclasses via attributes.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • packages/vanilla/trunk/Lib/vanilla/vanillaBox.py

    r1 r200  
    3434    } 
    3535 
     36    nsBoxClass = NSBox 
     37 
    3638    def __init__(self, posSize, title=None): 
    3739        """ 
     
    4042        *title* The title to be displayed dabove the box. Pass _None_ if no title is desired. 
    4143        """ 
    42         self._setupView("NSBox", posSize) 
     44        self._setupView(self.nsBoxClass, posSize) 
    4345        if title: 
    4446            self._nsObject.setTitle_(title) 
     
    9193class _Line(Box): 
    9294 
     95    nsBoxClass = NSBox 
     96 
    9397    def __init__(self, posSize): 
    94         self._setupView("NSBox", posSize) 
     98        self._setupView(self.nsBoxClass, posSize) 
    9599        self._nsObject.setBorderType_(NSLineBorder) 
    96100        self._nsObject.setBoxType_(NSBoxSeparator) 
  • packages/vanilla/trunk/Lib/vanilla/vanillaButton.py

    r199 r200  
    4747    """ 
    4848 
     49    nsButtonClass = NSButton 
    4950    nsBezelStyle = NSRoundedBezelStyle 
    5051    nsButtonType = NSMomentaryPushInButton 
     52 
    5153    _frameAdjustments = { 
    5254        'mini': (-1, -2, 2, 2), 
     
    7476        | "mini"    | 
    7577        """ 
    76         self._setupView("NSButton", posSize, callback=callback) 
     78        self._setupView(self.nsButtonClass, posSize, callback=callback) 
    7779        self._setSizeStyle(sizeStyle) 
    7880        self._nsObject.setTitle_(title) 
  • packages/vanilla/trunk/Lib/vanilla/vanillaColorWell.py

    r1 r200  
    2929    """ 
    3030 
     31    nsColorWellClass = NSColorWell 
     32 
    3133    def __init__(self, posSize, callback=None, color=None): 
    3234        """ 
     
    3739        *color* A _NSColor_ object. If _None_ is given, the color shown will be white. 
    3840        """ 
    39         self._setupView("NSColorWell", posSize, callback=callback) 
     41        self._setupView(self.nsColorWellClass, posSize, callback=callback) 
    4042        if color is not None: 
    4143            self._nsObject.setColor_(color) 
  • packages/vanilla/trunk/Lib/vanilla/vanillaComboBox.py

    r1 r200  
     1from AppKit import NSComboBox 
    12from vanillaBase import VanillaBaseControl 
    23 
     
    2425    ComboBoxDemo() 
    2526    """ 
    26      
     27 
     28    nsComboBoxClass = NSComboBox 
     29 
    2730    _frameAdjustments = { 
    2831        'mini': (0, -4, 1, 5), 
     
    5558        | "mini"    | 
    5659        """ 
    57         self._setupView("NSComboBox", posSize, callback=callback) 
     60        self._setupView(self.nsComboBoxClass, posSize, callback=callback) 
    5861        self._setSizeStyle(sizeStyle) 
    5962        self._nsObject.addItemsWithObjectValues_(items) 
  • packages/vanilla/trunk/Lib/vanilla/vanillaDrawer.py

    r1 r200  
    4242    """ 
    4343 
     44    nsDrawerClass = NSDrawer 
     45 
    4446    def __init__(self, size, parentWindow, minSize=None, maxSize=None, 
    4547            preferredEdge="left", forceEdge=False, leadingOffset=20, trailingOffset=20): 
     
    6971        self._preferredEdge = preferredEdge 
    7072        self._forceEdge = forceEdge 
    71         drawer = self._nsObject = NSDrawer.alloc().initWithContentSize_preferredEdge_( 
     73        drawer = self._nsObject = self.nsDrawerClass.alloc().initWithContentSize_preferredEdge_( 
    7274                size, _drawerEdgeMap[preferredEdge]) 
    7375        drawer.setLeadingOffset_(leadingOffset) 
  • packages/vanilla/trunk/Lib/vanilla/vanillaGroup.py

    r1 r200  
     1from AppKit import NSView 
    12from vanillaBase import VanillaBaseObject 
    23 
     
    2526    No special naming is required for the attributes. However, each attribute must have a unique name. 
    2627    """ 
    27      
     28 
     29    nsViewClass = NSView 
     30 
    2831    def __init__(self, posSize): 
    2932        """ 
    3033        *posSize* Tuple of form (left, top, width, height) representing the position and size of the group. 
    3134        """ 
    32         self._setupView("NSView", posSize) 
     35        self._setupView(self.nsViewClass, posSize) 
    3336     
    3437    def getNSView(self): 
  • packages/vanilla/trunk/Lib/vanilla/vanillaImageView.py

    r1 r200  
    2323class ImageView(VanillaBaseObject): 
    2424 
     25    nsImageViewClass = NSImageView 
     26 
    2527    def __init__(self, posSize, horizontalAlignment="center", verticalAlignment="center", scale="proportional"): 
    2628        """ 
     
    4547        | "none"         | Do not scale the image. | 
    4648        """ 
    47         self._setupView("NSImageView", posSize) 
     49        self._setupView(self.nsImageViewClass, posSize) 
    4850        align = _imageAlignmentMap[(horizontalAlignment, verticalAlignment)] 
    4951        self._nsObject.setImageAlignment_(align) 
  • packages/vanilla/trunk/Lib/vanilla/vanillaLevelIndicator.py

    r1 r200  
    4444    LevelIndicatorDemo() 
    4545    """ 
    46      
     46 
     47    nsLevelIndicatorClass = NSLevelIndicator 
     48 
    4749    def __init__(self, posSize, style="discrete", 
    4850                    value=5, minValue=0, maxValue=10, warningValue=None, criticalValue=None, 
     
    9294        *callback* The method to be called when the level indicator has been edited. If no callback is given, the level indicator will not be editable. 
    9395        """ 
    94         self._setupView("NSLevelIndicator", posSize, callback=callback) 
     96        self._setupView(self.nsLevelIndicatorClass, posSize, callback=callback) 
    9597        self._nsObject.cell().setLevelIndicatorStyle_(_levelIndicatorStyleMap[style]) 
    9698        self._nsObject.setMinValue_(minValue) 
  • packages/vanilla/trunk/Lib/vanilla/vanillaList.py

    r199 r200  
    955955 
    956956def SliderListCell(minValue=0, maxValue=100): 
    957      
    958957    """ 
    959958    An object that displays a slider in a List column. 
  • packages/vanilla/trunk/Lib/vanilla/vanillaPopUpButton.py

    r1 r200  
     1from AppKit import NSPopUpButton 
    12from vanillaBase import VanillaBaseControl 
    23 
     
    2425    PopUpButtonDemo() 
    2526    """ 
    26      
     27 
     28    nsPopUpButtonClass = NSPopUpButton 
     29 
    2730    _frameAdjustments = { 
    2831        'mini': (-1, 0, 3, 0), 
     
    5053        | "mini"    | 
    5154        """ 
    52         self._setupView("NSPopUpButton", posSize, callback=callback) 
     55        self._setupView(self.nsPopUpButtonClass, posSize, callback=callback) 
    5356        self._setSizeStyle(sizeStyle) 
    5457        self._nsObject.addItemsWithTitles_(items) 
  • packages/vanilla/trunk/Lib/vanilla/vanillaProgressBar.py

    r1 r200  
    2828    ProgressBarDemo() 
    2929    """ 
    30      
     30 
     31    nsProgressIndicatorClass = NSProgressIndicator 
     32 
    3133    _allFrameAdjustments = { 
    3234        'small': (-1, -0, 2, 0), 
     
    5355        | "small"   | 
    5456        """ 
    55         self._setupView('NSProgressIndicator', posSize) 
     57        self._setupView(self.nsProgressIndicatorClass, posSize) 
    5658        self._frameAdjustments = self._allFrameAdjustments[sizeStyle] 
    5759        self._nsObject.setControlSize_(_sizeStyleMap[sizeStyle]) 
  • packages/vanilla/trunk/Lib/vanilla/vanillaProgressSpinner.py

    r1 r200  
    2323    """ 
    2424 
     25    nsProgressIndicatorClass = NSProgressIndicator 
     26 
    2527    def __init__(self, posSize, displayWhenStopped=False, sizeStyle="regular"): 
    2628        """ 
     
    3840        | "small"   | 
    3941        """ 
    40         self._setupView("NSProgressIndicator", posSize) 
     42        self._setupView(self.nsProgressIndicatorClass, posSize) 
    4143        sizeStyle = _sizeStyleMap[sizeStyle] 
    4244        self._nsObject.setControlSize_(sizeStyle) 
  • packages/vanilla/trunk/Lib/vanilla/vanillaRadioGroup.py

    r199 r200  
    2626    """ 
    2727 
     28    nsMatrixClass = NSMatrix 
    2829    nsCellClass = NSButtonCell 
    2930 
     
    4445        | "mini"    | 
    4546        """ 
    46         self._setupView("NSMatrix", posSize, callback=callback) 
     47        self._setupView(self.nsMatrixClass, posSize, callback=callback) 
    4748        self._isVertical = isVertical 
    4849        matrix = self._nsObject 
  • packages/vanilla/trunk/Lib/vanilla/vanillaSearchBox.py

    r153 r200  
     1from AppKit import NSSearchField 
    12from vanillaBase import VanillaBaseControl 
    23 
     
    2324    SearchBoxDemo() 
    2425    """ 
    25      
     26 
     27    nsSearchFieldClass = NSSearchField 
     28 
    2629    def __init__(self, posSize, text="", callback=None, formatter=None, sizeStyle="regular"): 
    2730        """ 
     
    4548        | "mini"    | 
    4649        """ 
    47         self._setupView("NSSearchField", posSize, callback=callback) 
     50        self._setupView(self.nsSearchFieldClass, posSize, callback=callback) 
    4851        self._setSizeStyle(sizeStyle) 
    4952        self._nsObject.setStringValue_(text) 
  • packages/vanilla/trunk/Lib/vanilla/vanillaSegmentedButton.py

    r167 r200  
    1111 
    1212class SegmentedButton(VanillaBaseControl): 
    13      
     13 
     14    nsSegmentedControlClass = NSSegmentedControl 
     15 
    1416    _frameAdjustments = { 
    1517        "mini": (0, -1, 0, 1), #15 
     
    1921 
    2022    def __init__(self, posSize, segmentDescriptions, callback=None, selectionStyle="one", sizeStyle="small"): 
    21         self._setupView("NSSegmentedControl", posSize, callback=callback) 
     23        self._setupView(self.nsSegmentedControlClass, posSize, callback=callback) 
    2224        self._setSizeStyle(sizeStyle) 
    2325        nsObject = self._nsObject 
  • packages/vanilla/trunk/Lib/vanilla/vanillaSlider.py

    r1 r200  
    3232    SliderDemo() 
    3333    """ 
    34      
     34 
     35    nsSliderClass = NSSlider 
     36 
    3537    _allFrameAdjustments = { 
    3638        'H-Slider-Above': { 
     
    102104        | "mini"    | 
    103105        """ 
    104         self._setupView("NSSlider", posSize, callback=callback) 
     106        self._setupView(self.nsSliderClass, posSize, callback=callback) 
    105107        self._setSizeStyle(sizeStyle) 
    106108        self._nsObject.setMinValue_(minValue) 
  • packages/vanilla/trunk/Lib/vanilla/vanillaTabs.py

    r1 r200  
    44 
    55 
    6 class _VanillaTabItem(VanillaBaseObject): 
     6class VanillaTabItem(VanillaBaseObject): 
     7 
     8    nsTabViewItemClass = NSTabViewItem 
    79 
    810    def __init__(self, title): 
    9         self._tabItem = NSTabViewItem.alloc().initWithIdentifier_(title) 
     11        self._tabItem = self.nsTabViewItemClass.alloc().initWithIdentifier_(title) 
    1012        self._tabItem.setLabel_(title) 
    1113 
     
    5456    myTab = self.w.tabs[0] 
    5557    """ 
    56      
     58 
     59    nsTabViewClass = NSTabView 
     60    vanillaTabViewItemClass = VanillaTabItem 
     61 
    5762    _allFrameAdjustments = { 
    5863        # The sizeStyle will be part of the 
     
    7782        | "mini"    | 
    7883        """ 
    79         self._setupView("NSTabView", posSize) # hold off on setting callback 
     84        self._setupView(self.nsTabViewClass, posSize) # hold off on setting callback 
    8085        self._setSizeStyle(sizeStyle) 
    8186        self._tabItems = [] 
    8287        for title in titles: 
    83             tab = _VanillaTabItem(title) 
     88            tab = self.vanillaTabViewItemClass(title) 
    8489            self._tabItems.append(tab) 
    8590            self._nsObject.addTabViewItem_(tab._tabItem) 
  • packages/vanilla/trunk/Lib/vanilla/vanillaTextBox.py

    r1 r200  
    3030    """ 
    3131 
     32    nsTextFieldClass = NSTextField 
     33 
    3234    def __init__(self, posSize, text="", alignment="natural", selectable=False, sizeStyle="regular"): 
    3335        """ 
     
    5759        | "mini"    | 
    5860        """ 
    59         self._setupView("NSTextField", posSize) 
     61        self._setupView(self.nsTextFieldClass, posSize) 
    6062        self._setSizeStyle(sizeStyle) 
    6163        self._nsObject.setStringValue_(text) 
  • packages/vanilla/trunk/Lib/vanilla/vanillaTextEditor.py

    r199 r200  
    3434    """ 
    3535 
     36    nsScrollViewClass = NSScrollView 
    3637    nsTextViewClass = NSTextView 
    3738 
     
    4950        """ 
    5051        self._posSize = posSize 
    51         self._nsObject = NSScrollView.alloc().init()  # no need to do getNSSubclass() here 
     52        self._nsObject = self.nsScrollViewClass.alloc().init()  # no need to do getNSSubclass() here 
    5253        self._nsObject.setHasVerticalScroller_(True) 
    5354        self._nsObject.setBorderType_(NSBezelBorder)