API  1.0.0
CPPanel.j
Go to the documentation of this file.
1 /*
2  * CPPanel.j
3  * AppKit
4  *
5  * Created by Francisco Tolmasky.
6  * Copyright 2008, 280 North, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 
24 @global CPApp
25 
28 
30 
51 /*
52  @global
53 */
54 @implementation CPPanel : CPWindow
55 {
56  BOOL _becomesKeyOnlyIfNeeded;
57  BOOL _worksWhenModal;
58 }
59 
63 - (BOOL)isFloatingPanel
64 {
65  return [self level] == CPFloatingWindowLevel;
66 }
67 
73 - (void)setFloatingPanel:(BOOL)isFloatingPanel
74 {
75  [self setLevel:isFloatingPanel ? CPFloatingWindowLevel : CPNormalWindowLevel];
76 }
77 
82 - (BOOL)becomesKeyOnlyIfNeeded
83 {
84  return _becomesKeyOnlyIfNeeded;
85 }
86 
91 - (void)setBecomesKeyOnlyIfNeeded:(BOOL)shouldBecomeKeyOnlyIfNeeded
92 {
93  _becomesKeyOnlyIfNeeded = shouldBecomeKeyOnlyIfNeeded
94 }
95 
96 - (BOOL)worksWhenModal
97 {
98  return _worksWhenModal;
99 }
100 
105 - (void)setWorksWhenModal:(BOOL)shouldWorkWhenModal
106 {
107  _worksWhenModal = shouldWorkWhenModal;
108 }
109 
110 - (BOOL)canBecomeMainWindow
111 {
112  return NO;
113 }
114 
115 - (BOOL)canBecomeKeyWindow
116 {
117  return YES;
118 }
119 
120 
121 #pragma mark -
122 #pragma mark Overrides
123 
127 - (void)cancelOperation:(id)sender
128 {
129  if ([[CPApp currentEvent] _couldBeKeyEquivalent] && [self performKeyEquivalent:[CPApp currentEvent]])
130  return;
131 
132  [[self firstResponder] tryToPerform:@selector(cancel:) with:self];
133 }
134 
135 - (void)cancel:(id)sender
136 {
137  [self performClose:sender];
138 }
139 
140 @end
BOOL tryToPerform:with:(SEL aSelector, [with] id anObject)
Definition: CPResponder.j:319
CPResponder firstResponder()
Definition: CPWindow.j:1657
CPFloatingWindowLevel
global CPApp CPOKButton
Definition: CPPanel.j:26
CPDocModalWindowMask
Definition: CPPanel.j:29
int level()
Definition: CPWindow.j:1100
Definition: CPPanel.h:2
CPCancelButton
Definition: CPPanel.j:27
void performClose:(id aSender)
Definition: CPWindow.j:2372