mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 07:10:59 +00:00
Implement view stack.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3133 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
84112aa3fb
commit
79758f2570
1 changed files with 32 additions and 20 deletions
|
@ -61,45 +61,57 @@ static NSString *nsview_thread_key = @"NSViewThreadKey";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
+ (void) pushFocusView:(NSView *)focusView
|
||||||
// +++ Really each thread should have a stack!
|
|
||||||
//
|
|
||||||
+ (void)pushFocusView:(NSView *)focusView
|
|
||||||
{
|
{
|
||||||
|
if (focusView)
|
||||||
|
{
|
||||||
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
||||||
|
NSMutableArray *stack = [dict objectForKey: nsview_thread_key];
|
||||||
|
|
||||||
// If no context then remove from dictionary
|
if (stack == nil)
|
||||||
if (!focusView)
|
|
||||||
{
|
{
|
||||||
[dict removeObjectForKey: nsview_thread_key];
|
stack = [[NSMutableDictionary alloc] initWithCapacity: 4];
|
||||||
|
[dict setObject: stack forKey: nsview_thread_key];
|
||||||
|
[stack release];
|
||||||
}
|
}
|
||||||
else
|
[stack addObject: focusView];
|
||||||
{
|
|
||||||
[dict setObject: focusView forKey: nsview_thread_key];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSView *)popFocusView
|
+ (NSView *)popFocusView
|
||||||
{
|
{
|
||||||
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
||||||
id v;
|
NSMutableArray *stack = [dict objectForKey: nsview_thread_key];
|
||||||
|
NSView *v = nil;
|
||||||
|
|
||||||
// Remove from dictionary
|
if (stack)
|
||||||
v = [dict objectForKey: nsview_thread_key];
|
{
|
||||||
[dict removeObjectForKey: nsview_thread_key];
|
unsigned count = [stack count];
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
v = [stack objectAtIndex: --count];
|
||||||
|
[stack removeObjectAtIndex: count];
|
||||||
|
}
|
||||||
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSView *)focusView
|
+ (NSView *)focusView
|
||||||
{
|
{
|
||||||
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
||||||
|
NSMutableArray *stack = [dict objectForKey: nsview_thread_key];
|
||||||
NSView *current_view = nil;
|
NSView *current_view = nil;
|
||||||
|
|
||||||
// current_view is nil if no focused view
|
if (stack)
|
||||||
current_view = [dict objectForKey: nsview_thread_key];
|
{
|
||||||
|
unsigned count = [stack count];
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
current_view = [stack objectAtIndex: --count];
|
||||||
|
}
|
||||||
|
}
|
||||||
return current_view;
|
return current_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue