API  0.9.8
 All Classes Files Functions Variables Typedefs Macros Groups Pages
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 
27 
48 /*
49  @global
50 */
52 
53 @implementation CPPanel : CPWindow
54 {
55  BOOL _becomesKeyOnlyIfNeeded;
56  BOOL _worksWhenModal;
57 }
58 
62 - (BOOL)isFloatingPanel
63 {
64  return [self level] == CPFloatingWindowLevel;
65 }
66 
72 - (void)setFloatingPanel:(BOOL)isFloatingPanel
73 {
74  [self setLevel:isFloatingPanel ? CPFloatingWindowLevel : CPNormalWindowLevel];
75 }
76 
81 - (BOOL)becomesKeyOnlyIfNeeded
82 {
83  return _becomesKeyOnlyIfNeeded;
84 }
85 
90 - (void)setBecomesKeyOnlyIfNeeded:(BOOL)shouldBecomeKeyOnlyIfNeeded
91 {
92  _becomesKeyOnlyIfNeeded = shouldBecomeKeyOnlyIfNeeded
93 }
94 
95 - (BOOL)worksWhenModal
96 {
97  return _worksWhenModal;
98 }
99 
104 - (void)setWorksWhenModal:(BOOL)shouldWorkWhenModal
105 {
106  _worksWhenModal = shouldWorkWhenModal;
107 }
108 
109 - (BOOL)canBecomeMainWindow
110 {
111  return NO;
112 }
113 
114 - (BOOL)canBecomeKeyWindow
115 {
116  return YES;
117 }
118 
119 
120 #pragma mark -
121 #pragma mark Overrides
122 
126 - (void)cancelOperation:(id)sender
127 {
128  if ([[CPApp currentEvent] _couldBeKeyEquivalent] && [self performKeyEquivalent:[CPApp currentEvent]])
129  return;
130 
131  [[self firstResponder] tryToPerform:@selector(cancel:) with:self];
132 }
133 
134 - (void)cancel:(id)sender
135 {
136  [self performClose:sender];
137 }
138 
139 @end