CPObjectCPResponder
CPWindow
@implementation CPWindow : CPResponder
An CPWindow
instance represents a window, panel or menu on the screen.
Each window has a style, which determines how the window is decorated; whether it has a border, a title bar, a resize bar, minimise and close buttons.
A window has a frame. This is the frame of the entire window on the screen, including all decorations and borders. The origin of the frame represents its bottom left corner and the frame is expressed in screen coordinates.
A window always contains a content view which is the highest level view available for public (application) use. This view fills the area of the window inside any decoration/border. This is the only part of the window that application programmers are allowed to draw in directly.
You can convert between view coordinates and window base coordinates using the nil
view argument.
Global Variables |
---|
CPBorderlessBridgeWindowMask = 1 << 20 |
CPTitledWindowMask = 1 << 0 |
CPResizableWindowMask = 1 << 3 |
CPClosableWindowMask = 1 << 1 |
CPHUDBackgroundWindowMask = 1 << 21 |
CPBorderlessWindowMask = 0 |
CPMiniaturizableWindowMask = 1 << 2 |
CPTexturedBackgroundWindowMask = 1 << 8 |
Method Summary | |
---|---|
+(CGRect) | frameRectForContentRect:(CGRect)aContentRect styleMask:(unsigned)aStyleMask Returns the frame rectangle used by a window. |
-(id) | initWithContentRect:(CGRect)aContentRect styleMask:(unsigned int)aStyleMask Initializes the window. |
-(BOOL) | acceptsFirstResponder Returns YES if the receiver is able to become the first responder. |
-(BOOL) | acceptsMouseMovedEvents |
-(CPWindow) | attachedSheet Returns the window's attached sheet. |
-(CPColor) | backgroundColor Returns the window's background color. |
-(void) | becomeKeyWindow Called when the receiver should become the key window. |
-(void) | becomeMainWindow Called to tell the receiver that it has become the main window. |
-(BOOL) | canBecomeKeyWindow Determines if the window can become the key window. |
-(BOOL) | canBecomeMainWindow Returns YES if the window can become the main window. |
-(void) | center Sets the window location to be the center of the screen. |
-(void) | close Closes the window. |
-(CGRect) | contentRectForFrameRect:(CGRect)aFrame Returns the receiver's content rectangle. |
-(CPView) | contentView Returns the window's current content view. |
-(id) | delegate Returns window's delegate. |
-(void) | doCommandBySelector:(SEL)aSelector The receiver will attempt to perform the command, if it responds to it. |
-(void) | dragImage:(CPImage)anImage at:(CGPoint)imageLocation offset:(CGSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack Initiates a drag operation from the receiver to another view that accepts dragged data. |
-(void) | dragView:(CPView)aView at:(CGPoint)imageLocation offset:(CGSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack Initiates a drag operation from the receiver to another view that accepts dragged data. |
-(CPResponder) | firstResponder Returns the window's current first responder. |
-(CGRect) | frame Returns the window's frame rectangle. |
-(CGRect) | frameRectForContentRect:(CGRect)aContentRect Retrieves the frame rectangle for this window. |
-(BOOL) | hasShadow Returns YES if the window has a drop shadow. |
-(BOOL) | isDocumentEdited Returns YES if the document has been edited. |
-(BOOL) | isDocumentSaving |
-(BOOL) | isKeyWindow Returns YES if the window is the key window. |
-(BOOL) | isMainWindow Returns YES if this the main window. |
-(BOOL) | isMovableByWindowBackground Returns YES if the window can be moved by dragging its background. |
-(BOOL) | isSheet Returns YES if the window has ever run as a sheet. |
-(BOOL) | isVisible Returns YES if the window is visible. |
-(int) | level Returns the window's current level. |
-(void) | makeFirstResponder:(CPResponder)aResponder Attempts to make the aResponder the first responder. |
-(void) | makeKeyAndOrderFront:(id)aSender Makes the window the key window and brings it to the front of the screen list. |
-(void) | makeKeyWindow Makes this window the key window. |
-(void) | makeMainWindow Makes the receiver the main window. |
-(CGSize) | maxSize Returns the window's maximum size. |
-(CGSize) | minSize Returns the windows minimum size. |
-(void) | orderFront:(id)aSender Makes the receiver the front most window in the screen ordering. |
-(void) | orderOut:(id)aSender Hides the window. |
-(void) | orderWindow:(CPWindowOrderingMode)aPlace relativeTo:(int)otherWindowNumber Relocates the window in the screen list. |
-(void) | performClose:(id)aSender Simulates the user closing the window, then closes the window. |
-(void) | redo:(id)aSender Sends the undo manager a redo: message. |
-(CPString) | representedFilename Returns the path to the file the receiver represents. |
-(CPURL) | representedURL Returns the URL that the receiver represents. |
-(void) | resignKeyWindow Causes the window to resign it's key window status. |
-(void) | resignMainWindow Called when the window resigns main window status. |
-(CGSize) | resizeIndicatorOffset Returns the offset of the window's resize indicator. |
-(void) | sendEvent:(CPEvent)anEvent Dispatches events that are sent to it from CPApplication . |
-(void) | setAcceptsMouseMovedEvents:(BOOL)shouldAcceptMouseMovedEvents |
-(void) | setBackgroundColor:(CPColor)aColor Sets the window's background color. |
-(void) | setContentView:(CPView)aView Sets the window's content view. |
-(void) | setDelegate:(id)aDelegate Sets the delegate for the window. |
-(void) | setDocumentEdited:(BOOL)isDocumentEdited Sets whether the document has been edited. |
-(void) | setDocumentSaving:(BOOL)isDocumentSaving |
-(void) | setFrame:(CGRect)aFrame Sets the window's frame rectangle. |
-(void) | setFrameOrigin:(CGPoint)anOrigin Sets the window's location. |
-(void) | setFrameSize:(CGSize)aSize Sets the window's size. |
-(void) | setFrame:(CGRect)aFrame display:(BOOL)shouldDisplay animate:(BOOL)shouldAnimate Sets the window's frame rectangle. |
-(void) | setHasShadow:(BOOL)shouldHaveShadow Sets whether the window should have a drop shadow. |
-(void) | setLevel:(int)aLevel Sets the window's level. |
-(void) | setMaxSize:(CGSize)aSize Sets the window's maximum size. |
-(void) | setMinSize:(CGSize)aSize Sets the window's minimum size. |
-(void) | setMovableByWindowBackground:(BOOL)shouldBeMovableByWindowBackground Sets whether the window can be moved by dragging its background. |
-(void) | setRepresentedFilename:(CPString)aFilePath Sets the path to the file the receiver represents. |
-(void) | setRepresentedURL:(CPURL)aURL Sets the URL that the receiver represents. |
-(void) | setResizeIndicatorOffset:(CGSize)anOffset Sets the offset of the window's resize indicator. |
-(void) | setShowsResizeIndicator:(BOOL)shouldShowResizeIndicator Sets the window's resize indicator. |
-(void) | setTitle:(CPString)aTitle Sets the window's title bar string. |
-(void) | setTitleWithRepresentedFilename:(CPString)aFilePath Sets the title bar to represent a file path. |
-(void) | setToolbar:(CPToolbar)aToolbar Sets the window's toolbar. |
-(void) | setWindowController:(CPWindowController)aWindowController Sets the window's controller. |
-(BOOL) | showsResizeIndicator Returns YES if the window's resize indicator is showing. |
-(unsigned) | styleMask Returns the window's style mask. |
-(CPString) | title Returns the window's title bar string. |
-(CPToolbar) | toolbar Return's the window's toolbar. |
-(void) | undo:(id)aSender Sends the undo manager an undo message. |
-(CPUndoManager) | undoManager Returns the window's undo manager. |
-(CPWindowController) | windowController Returns the window's controller. |
-(int) | windowNumber Returns the window's number in the desktop's screen list. |
-(BOOL) | worksWhenModal Returns YES if the receiver is able to receive input events
even when a modal session is active. |
Delegate Method Summary | |
---|---|
-(void) | windowDidResize:(CPNotification)notification Sent from the notification center when the window has been resized. |
-(CPUndoManager) | windowWillReturnUndoManager:(CPWindow)window Called to obtain the undo manager for a window. |
-(void) | windowDidBecomeMain:(CPNotification)notification Sent from the notification center when the delegate's window becomes the main window. |
-(void) | windowDidResignMain:(CPNotification)notification Sent from the notification center when the delegate's window has resigned main window status. |
-(void) | windowDidResignKey:(CPNotification)notification Sent from the notification center when the delegate's window has resigned key window status. |
-(BOOL) | windowShouldClose:(id)window Called when the user tries to close the window. |
Method Detail |
---|
+(CGRect)frameRectForContentRect:(CGRect)aContentRect styleMask:(unsigned)aStyleMask
aContentRect
- the content rectangle of the windowaStyleMask
- the style mask of the window-(id)initWithContentRect:(CGRect)aContentRect styleMask:(unsigned int)aStyleMask
CPBorderlessWindowMask CPTitledWindowMask CPClosableWindowMask CPMiniaturizableWindowMask CPResizableWindowMask CPTexturedBackgroundWindowMask
aContentRect
- the size and location of the window in screen spaceaStyleMask
- a style mask-(BOOL)acceptsFirstResponder
YES
if the receiver is able to become the first responder. NO
otherwise.-(BOOL)acceptsMouseMovedEvents
-(CPWindow)attachedSheet
-(CPColor)backgroundColor
-(void)becomeKeyWindow
becomeKeyWindow
message to the first responder.-(void)becomeMainWindow
-(BOOL)canBecomeKeyWindow
YES
means the window can become the key window.
-(BOOL)canBecomeMainWindow
YES
if the window can become the main window.-(void)center
-(void)close
CPWindowWillCloseNotification
to the
notification center before closing the window.-(CGRect)contentRectForFrameRect:(CGRect)aFrame
aFrame
- the window's frame rectangle-(CPView)contentView
-(id)delegate
-(void)doCommandBySelector:(SEL)aSelector
nextResponder
will be called to do it.aSelector
- the command to attempt-(void)dragImage:(CPImage)anImage at:(CGPoint)imageLocation offset:(CGSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack
anImage
- the image to be draggedimageLocation
mouseOffset
- the distance from the mouseDown:
location and the current locationanEvent
- the mouseDown:
that triggered the dragaPasteboard
aSourceObject
- the drag operation controllerslideBack
- Whether the image should 'slide back' if the drag is rejected-(void)dragView:(CPView)aView at:(CGPoint)imageLocation offset:(CGSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack
aView
- the view to be draggedimageLocation
mouseOffset
- the distance from the mouseDown:
location and the current locationanEvent
- the mouseDown:
that triggered the dragaPasteboard
aSourceObject
- the drag operation controllerslideBack
- Whether the view should 'slide back' if the drag is rejected-(CPResponder)firstResponder
-(CGRect)frame
-(CGRect)frameRectForContentRect:(CGRect)aContentRect
aContentRect
- the window's content rectangle-(BOOL)hasShadow
YES
if the window has a drop shadow. NO
otherwise.-(BOOL)isDocumentEdited
YES
if the document has been edited.-(BOOL)isDocumentSaving
-(BOOL)isKeyWindow
YES
if the window is the key window.-(BOOL)isMainWindow
YES
if this the main window.-(BOOL)isMovableByWindowBackground
YES
if the window can be moved by dragging its background.-(BOOL)isSheet
YES
if the window has ever run as a sheet.-(BOOL)isVisible
YES
if the window is visible. It does not mean that the window is not obscured by other windows.-(int)level
-(void)makeFirstResponder:(CPResponder)aResponder
aResponder
the first responder. Before trying
to make it the first responder, the receiver will ask the current first responder
to resign its first responder status. If it resigns, it will ask
aResponder
accept first responder, then finally tell it to become first responder.aResponder
YES
if the attempt was successful. NO
otherwise.
-(void)makeKeyAndOrderFront:(id)aSender
aSender
- the object requesting this-(void)makeKeyWindow
-(void)makeMainWindow
-(CGSize)maxSize
-(CGSize)minSize
-(void)orderFront:(id)aSender
aSender
- the object that requested this-(void)orderOut:(id)aSender
aSender
-(void)orderWindow:(CPWindowOrderingMode)aPlace relativeTo:(int)otherWindowNumber
aPlace
- the positioning relative to otherWindowNumber
otherWindowNumber
- the window relative to which the receiver should be placed-(void)performClose:(id)aSender
aSender
- the object making this request-(void)redo:(id)aSender
redo:
message.aSender
- the object requesting this-(CPString)representedFilename
-(CPURL)representedURL
-(void)resignKeyWindow
-(void)resignMainWindow
-(CGSize)resizeIndicatorOffset
-(void)sendEvent:(CPEvent)anEvent
CPApplication
.anEvent
- the event to be dispatched-(void)setAcceptsMouseMovedEvents:(BOOL)shouldAcceptMouseMovedEvents
shouldAcceptMouseMovedEvents
-(void)setBackgroundColor:(CPColor)aColor
aColor
- the new color for the background-(void)setContentView:(CPView)aView
aView
- the new content view for the receiver-(void)setDelegate:(id)aDelegate
nil
will just remove the window's current delegate.aDelegate
- an object to respond to the various delegate methods of CPWindow
-(void)setDocumentEdited:(BOOL)isDocumentEdited
isDocumentEdited
- YES
if the document has been edited.-(void)setDocumentSaving:(BOOL)isDocumentSaving
isDocumentSaving
-(void)setFrame:(CGRect)aFrame
aFrame
-(void)setFrameOrigin:(CGPoint)anOrigin
anOrigin
- the new location for the window-(void)setFrameSize:(CGSize)aSize
aSize
- the new size for the window-(void)setFrame:(CGRect)aFrame display:(BOOL)shouldDisplay animate:(BOOL)shouldAnimate
aFrame
- the new size and location for the windowshouldDisplay
- whether the window should redraw its viewsshouldAnimate
- whether the window resize should be animated-(void)setHasShadow:(BOOL)shouldHaveShadow
shouldHaveShadow
- YES
to have a drop shadow.-(void)setLevel:(int)aLevel
aLevel
-(void)setMaxSize:(CGSize)aSize
aSize
- the new maximum size-(void)setMinSize:(CGSize)aSize
aSize
-(void)setMovableByWindowBackground:(BOOL)shouldBeMovableByWindowBackground
shouldBeMovableByWindowBackground
- YES
makes the window move from a background drag.-(void)setRepresentedFilename:(CPString)aFilePath
aFilePath
-(void)setRepresentedURL:(CPURL)aURL
aURL
-(void)setResizeIndicatorOffset:(CGSize)anOffset
anOffset
-(void)setShowsResizeIndicator:(BOOL)shouldShowResizeIndicator
shouldShowResizeIndicator
- YES
sets the window to show its resize indicator.-(void)setTitle:(CPString)aTitle
aTitle
-(void)setTitleWithRepresentedFilename:(CPString)aFilePath
aFilePath
-(void)setToolbar:(CPToolbar)aToolbar
aToolbar
- the window's new toolbar-(void)setWindowController:(CPWindowController)aWindowController
aWindowController
- a window controller-(BOOL)showsResizeIndicator
YES
if the window's resize indicator is showing. NO
otherwise.-(unsigned)styleMask
-(CPString)title
-(CPToolbar)toolbar
-(void)undo:(id)aSender
undo
message.aSender
- the object requesting this-(CPUndoManager)undoManager
-(CPWindowController)windowController
-(int)windowNumber
-(BOOL)worksWhenModal
YES
if the receiver is able to receive input events
even when a modal session is active.Delegate Method Detail |
---|
-(void)windowDidResize:(CPNotification)notification
notification
- contains information about the resize event-(CPUndoManager)windowWillReturnUndoManager:(CPWindow)window
window
- the window for which to return the undo manager-(void)windowDidBecomeMain:(CPNotification)notification
notification
- contains information about the event-(void)windowDidResignMain:(CPNotification)notification
notification
- contains information about the event-(void)windowDidResignKey:(CPNotification)notification
notification
- contains information about the event-(BOOL)windowShouldClose:(id)window
window
- the window to closeYES
allows the window to close. NO
vetoes the close operation and leaves the window open.
Created on Sat Sep 13 14:15:43 PDT 2008