Changeset 199
- Timestamp:
- 04/26/08 11:28:19 (9 months ago)
- Files:
-
- packages/vanilla/trunk/Lib/vanilla/vanillaBase.py (modified) (2 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaButton.py (modified) (4 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaCheckBox.py (modified) (3 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaEditText.py (modified) (4 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaGradientButton.py (modified) (1 diff)
- packages/vanilla/trunk/Lib/vanilla/vanillaList.py (modified) (6 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaRadioGroup.py (modified) (3 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaScrollView.py (modified) (3 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaTextEditor.py (modified) (3 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaWindows.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
packages/vanilla/trunk/Lib/vanilla/vanillaBase.py
r168 r199 17 17 18 18 def _setupView(self, classOrName, posSize, callback=None): 19 self._testForDeprecatedAttributes() 19 20 cls = getNSSubclass(classOrName) 20 21 self._nsObject = cls(self) … … 26 27 if hasattr(self, "_target"): 27 28 self._target.callback = None 29 30 def _testForDeprecatedAttributes(self): 31 pass 28 32 29 33 def _setCallback(self, callback): packages/vanilla/trunk/Lib/vanilla/vanillaButton.py
r170 r199 47 47 """ 48 48 49 _nsBezelStyle = NSRoundedBezelStyle50 _nsButtonType = NSMomentaryPushInButton49 nsBezelStyle = NSRoundedBezelStyle 50 nsButtonType = NSMomentaryPushInButton 51 51 _frameAdjustments = { 52 52 'mini': (-1, -2, 2, 2), … … 77 77 self._setSizeStyle(sizeStyle) 78 78 self._nsObject.setTitle_(title) 79 self._nsObject.setBezelStyle_(self._nsBezelStyle) 80 self._nsObject.setButtonType_(self._nsButtonType) 79 self._nsObject.setBezelStyle_(self.nsBezelStyle) 80 self._nsObject.setButtonType_(self.nsButtonType) 81 82 def _testForDeprecatedAttributes(self): 83 super(Button, self)._testForDeprecatedAttributes() 84 from warnings import warn 85 if hasattr(self, "_nsBezelStyle"): 86 warn(DeprecationWarning("The _nsBezelStyle attribute is deprecated. Use the nsBezelStyle attribute.")) 87 self.nsBezelStyle = self._nsBezelStyle 88 if hasattr(self, "_nsButtonType"): 89 warn(DeprecationWarning("The _nsButtonType attribute is deprecated. Use the nsButtonType attribute.")) 90 self.nsButtonType = self._nsButtonType 81 91 82 92 def getNSButton(self): … … 139 149 """ 140 150 141 _nsBezelStyle = NSShadowlessSquareBezelStyle151 nsBezelStyle = NSShadowlessSquareBezelStyle 142 152 _frameAdjustments = None 143 153 … … 292 302 """ 293 303 294 _nsBezelStyle = NSHelpButtonBezelStyle304 nsBezelStyle = NSHelpButtonBezelStyle 295 305 _frameAdjustments = { 296 306 'regular': (0, -3, 0, 3), packages/vanilla/trunk/Lib/vanilla/vanillaCheckBox.py
r1 r199 13 13 class _CheckBoxStandardBuild(Button): 14 14 15 _nsButtonType = NSSwitchButton15 nsButtonType = NSSwitchButton 16 16 _frameAdjustments = { 17 17 'mini': (-4, -4, 6, 8), … … 50 50 class _CheckBoxManualBuildButton(Button): 51 51 52 _nsButtonType = NSSwitchButton52 nsButtonType = NSSwitchButton 53 53 _frameAdjustments = { 54 54 'regular': (-2, -3, 4, 4), … … 70 70 class _CheckBoxManualBuildTextButton(Button): 71 71 72 _nsBezelStyle = NSShadowlessSquareBezelStyle72 nsBezelStyle = NSShadowlessSquareBezelStyle 73 73 _frameAdjustments = None 74 74 packages/vanilla/trunk/Lib/vanilla/vanillaEditText.py
r1 r199 38 38 """ 39 39 40 _textFieldClass = NSTextField40 nsTextFieldClass = NSTextField 41 41 42 42 def __init__(self, posSize, text="", callback=None, continuous=True, readOnly=False, formatter=None, placeholder=None, sizeStyle="regular"): … … 69 69 # 70 70 self._continuous = continuous 71 self._setupView(self. _textFieldClass, posSize, callback)71 self._setupView(self.nsTextFieldClass, posSize, callback) 72 72 self._posSize = posSize 73 73 # … … 84 84 if placeholder: 85 85 cell.setPlaceholderString_(placeholder) 86 87 def _testForDeprecatedAttributes(self): 88 super(EditText, self)._testForDeprecatedAttributes() 89 from warnings import warn 90 if hasattr(self, "_textFieldClass"): 91 warn(DeprecationWarning("The _textFieldClass attribute is deprecated. Use the nsTextFieldClass attribute.")) 92 self.nsTextFieldClass = self._textFieldClass 86 93 87 94 def getNSTextField(self): … … 142 149 """ 143 150 144 _textFieldClass = NSSecureTextField151 nsTextFieldClass = NSSecureTextField 145 152 packages/vanilla/trunk/Lib/vanilla/vanillaGradientButton.py
r170 r199 4 4 class GradientButton(ImageButton): 5 5 6 _nsBezelStyle = NSSmallSquareBezelStyle6 nsBezelStyle = NSSmallSquareBezelStyle 7 7 packages/vanilla/trunk/Lib/vanilla/vanillaList.py
r198 r199 256 256 """ 257 257 258 _scrollViewClass = NSScrollView259 _tableViewClass = _VanillaTableViewSubclass260 _arrayControllerClass = _VanillaArrayController261 _arrayControllerObserverClass = _VanillaArrayControllerObserver258 nsScrollViewClass = NSScrollView 259 nsTableViewClass = _VanillaTableViewSubclass 260 nsArrayControllerClass = _VanillaArrayController 261 nsArrayControllerObserverClass = _VanillaArrayControllerObserver 262 262 263 263 def __init__(self, posSize, items, dataSource=None, columnDescriptions=None, showColumnTitles=True, … … 349 349 self._posSize = posSize 350 350 self._enableDelete = enableDelete 351 self._nsObject = getNSSubclass(self. _scrollViewClass)(self)351 self._nsObject = getNSSubclass(self.nsScrollViewClass)(self) 352 352 self._nsObject.setAutohidesScrollers_(autohidesScrollers) 353 353 self._nsObject.setHasHorizontalScroller_(True) … … 357 357 self._setAutosizingFromPosSize(posSize) 358 358 # add a table view to the scroll view 359 self._tableView = getNSSubclass(self. _tableViewClass)(self)359 self._tableView = getNSSubclass(self.nsTableViewClass)(self) 360 360 self._nsObject.setDocumentView_(self._tableView) 361 361 # set up an observer that will be called by the bindings when a cell is edited 362 362 self._editCallback = editCallback 363 self._editObserver = self. _arrayControllerObserverClass.alloc().init()363 self._editObserver = self.nsArrayControllerObserverClass.alloc().init() 364 364 if editCallback is not None: 365 365 self._editObserver._targetMethod = self._edit # circular reference to be killed in _breakCycles … … 369 369 items = NSMutableArray.arrayWithArray_(items) 370 370 # set up an array controller 371 self._arrayController = self. _arrayControllerClass.alloc().initWithContent_(items)371 self._arrayController = self.nsArrayControllerClass.alloc().initWithContent_(items) 372 372 self._arrayController.setSelectsInsertedObjects_(False) 373 373 self._arrayController.setAvoidsEmptySelection_(not allowsEmptySelection) … … 415 415 if selectionCallback is not None: 416 416 self._selectionCallback = selectionCallback 417 self._selectionObserver = self. _arrayControllerObserverClass.alloc().init()417 self._selectionObserver = self.nsArrayControllerObserverClass.alloc().init() 418 418 self._arrayController.addObserver_forKeyPath_options_context_(self._selectionObserver, 'selectionIndexes', NSKeyValueObservingOptionNew, 0) 419 419 self._selectionObserver._targetMethod = self._selection # circular reference to be killed in _breakCycles … … 448 448 # set the drag data 449 449 self._dragSettings = dragSettings 450 450 451 def _testForDeprecatedAttributes(self): 452 super(List, self)._testForDeprecatedAttributes() 453 from warnings import warn 454 if hasattr(self, "_scrollViewClass"): 455 warn(DeprecationWarning("The _scrollViewClass attribute is deprecated. Use the nsScrollViewClass attribute.")) 456 self.nsScrollViewClass = self._scrollViewClass 457 if hasattr(self, "_tableViewClass"): 458 warn(DeprecationWarning("The _tableViewClass attribute is deprecated. Use the nsTableViewClass attribute.")) 459 self.nsTableViewClass = self._tableViewClass 460 if hasattr(self, "_arrayControllerClass"): 461 warn(DeprecationWarning("The _arrayControllerClass attribute is deprecated. Use the nsArrayControllerClass attribute.")) 462 self.nsArrayControllerClass = self._arrayControllerClass 463 if hasattr(self, "_arrayControllerObserverClass"): 464 warn(DeprecationWarning("The _arrayControllerObserverClass attribute is deprecated. Use the nsArrayControllerObserverClass attribute.")) 465 self.nsArrayControllerObserverClass = self._arrayControllerObserverClass 466 451 467 def getNSScrollView(self): 452 468 """ packages/vanilla/trunk/Lib/vanilla/vanillaRadioGroup.py
r1 r199 26 26 """ 27 27 28 _cellClass = NSButtonCell28 nsCellClass = NSButtonCell 29 29 30 30 def __init__(self, posSize, titles, isVertical=True, callback=None, sizeStyle="regular"): … … 48 48 matrix = self._nsObject 49 49 matrix.setMode_(NSRadioModeMatrix) 50 matrix.setCellClass_(self. _cellClass)50 matrix.setCellClass_(self.nsCellClass) 51 51 # XXX! this does not work for vertical radio groups! 52 52 matrix.setAutosizesCells_(True) … … 79 79 cell.setFont_(font) 80 80 81 def _testForDeprecatedAttributes(self): 82 super(RadioGroup, self)._testForDeprecatedAttributes() 83 from warnings import warn 84 if hasattr(self, "_cellClass"): 85 warn(DeprecationWarning("The _cellClass attribute is deprecated. Use the nsCellClass attribute.")) 86 self.nsCellClass = self._cellClass 87 81 88 def getNSMatrix(self): 82 89 """ packages/vanilla/trunk/Lib/vanilla/vanillaScrollView.py
r1 r199 31 31 """ 32 32 33 _scrollViewClass = NSScrollView33 nsScrollViewClass = NSScrollView 34 34 35 35 def __init__(self, posSize, nsView, hasHorizontalScroller=True, hasVerticalScroller=True, … … 48 48 *backgroundColor* A _NSColor_ object representing the background color of the scroll view. 49 49 """ 50 self._setupView(self. _scrollViewClass, posSize)50 self._setupView(self.nsScrollViewClass, posSize) 51 51 if clipView is not None: 52 52 self._nsObject.setContentView_(clipView) … … 58 58 if backgroundColor: 59 59 self._nsObject.setBackgroundColor_(backgroundColor) 60 60 61 def _testForDeprecatedAttributes(self): 62 super(ScrollView, self)._testForDeprecatedAttributes() 63 from warnings import warn 64 if hasattr(self, "_scrollViewClass"): 65 warn(DeprecationWarning("The _scrollViewClass attribute is deprecated. Use the nsScrollViewClass attribute.")) 66 self.nsScrollViewClass = self._scrollViewClass 67 61 68 def getNSScrollView(self): 62 69 """ packages/vanilla/trunk/Lib/vanilla/vanillaTextEditor.py
r166 r199 34 34 """ 35 35 36 _textViewClass = NSTextView36 nsTextViewClass = NSTextView 37 37 38 38 def __init__(self, posSize, text="", callback=None, readOnly=False, checksSpelling=False): … … 53 53 self._nsObject.setBorderType_(NSBezelBorder) 54 54 self._nsObject.setDrawsBackground_(True) 55 self._textView = getNSSubclass(self. _textViewClass)(self)55 self._textView = getNSSubclass(self.nsTextViewClass)(self) 56 56 self._textView.setAllowsUndo_(True) 57 57 self._textView.setString_(text) … … 63 63 self._setCallback(callback) 64 64 self._setAutosizingFromPosSize(posSize) 65 66 def _testForDeprecatedAttributes(self): 67 super(TextEditor, self)._testForDeprecatedAttributes() 68 from warnings import warn 69 if hasattr(self, "_textViewClass"): 70 warn(DeprecationWarning("The _textViewClass attribute is deprecated. Use the nsTextViewClass attribute.")) 71 self.nsTextViewClass = self._textViewClass 65 72 66 73 def getNSScrollView(self): packages/vanilla/trunk/Lib/vanilla/vanillaWindows.py
r155 r199 41 41 return cls.alloc().init() 42 42 43 _nsWindowStyleMask = NSTitledWindowMask43 nsWindowStyleMask = NSTitledWindowMask 44 44 # use the unified title and toolbar in 10.4+ 45 45 try: 46 _nsWindowStyleMask |= NSUnifiedTitleAndToolbarWindowMask46 nsWindowStyleMask |= NSUnifiedTitleAndToolbarWindowMask 47 47 except NameError: 48 48 pass 49 _nsWindowClass = NSWindow50 _nsWindowLevel = NSNormalWindowLevel49 nsWindowClass = NSWindow 50 nsWindowLevel = NSNormalWindowLevel 51 51 52 52 def __init__(self, posSize, title="", minSize=None, maxSize=None, textured=False, … … 71 71 *initiallyVisible* Boolean value representing if the window will be initially visible. Default is True. If False, you can show the window later by calling window.show(). 72 72 """ 73 mask = self. _nsWindowStyleMask73 mask = self.nsWindowStyleMask 74 74 if closable: 75 75 mask = mask | NSClosableWindowMask … … 90 90 cascade = False 91 91 frame = _calcFrame(NSScreen.mainScreen().visibleFrame(), ((l, t), (w, h))) 92 self._window = self. _nsWindowClass.alloc().initWithContentRect_styleMask_backing_defer_(92 self._window = self.nsWindowClass.alloc().initWithContentRect_styleMask_backing_defer_( 93 93 frame, mask, NSBackingStoreBuffered, False) 94 94 if autosaveName is not None: … … 104 104 self._window.setMaxSize_(maxSize) 105 105 self._window.setTitle_(title) 106 self._window.setLevel_(self. _nsWindowLevel)106 self._window.setLevel_(self.nsWindowLevel) 107 107 self._window.setReleasedWhenClosed_(False) 108 108 self._window.setDelegate_(self) 109 109 self._bindings = {} 110 110 self._initiallyVisible = initiallyVisible 111 112 def _testForDeprecatedAttributes(self): 113 from warnings import warn 114 if hasattr(self, "_nsWindowStyleMask"): 115 warn(DeprecationWarning("The _nsWindowStyleMask attribute is deprecated. Use the nsWindowStyleMask attribute.")) 116 self.nsWindowStyleMask = self._nsWindowStyleMask 117 if hasattr(self, "_nsWindowClass"): 118 warn(DeprecationWarning("The _nsWindowClass attribute is deprecated. Use the nsWindowClass attribute.")) 119 self.nsWindowClass = self._nsWindowClass 120 if hasattr(self, "_nsWindowLevel"): 121 warn(DeprecationWarning("The _nsWindowLevel attribute is deprecated. Use the nsWindowLevel attribute.")) 122 self.nsWindowLevel = self._nsWindowLevel 111 123 112 124 def _cascade(self): … … 589 601 """ 590 602 591 _nsWindowStyleMask = NSTitledWindowMask | NSUtilityWindowMask592 _nsWindowClass = NSPanel593 _nsWindowLevel = NSFloatingWindowLevel603 nsWindowStyleMask = NSTitledWindowMask | NSUtilityWindowMask 604 nsWindowClass = NSPanel 605 nsWindowLevel = NSFloatingWindowLevel 594 606 595 607 def __init__(self, posSize, title="", minSize=None, maxSize=None,
