2 Copyright (C) 2004 Marcus Mueller <znek@mulle-kybernetik.com>
4 This file is part of OGo
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21 // $Id: SOPEXTextView.m 1 2004-08-20 11:17:52Z znek $
22 // Created by znek on Thu Apr 01 2004.
25 #import "SOPEXTextView.h"
28 @interface SOPEXTextView (PrivateAPI)
29 - (void)adjustStatusField;
33 @implementation SOPEXTextView
37 [self setErrorStatus:nil];
40 - (void)setErrorStatus:(NSError *)status
42 if((status != nil) && (self->statusField != nil))
44 [self->statusField setStringValue:[status localizedDescription]];
45 [self adjustStatusField];
46 [self->statusField setHidden:NO];
47 [[self window] makeFirstResponder:self->statusField];
51 [self->statusField setHidden:YES];
55 - (void)adjustStatusField
57 NSRect frame, sfFrame;
59 frame = [[self superview] frame]; // superview is a clipview
60 frame = [self convertRect:frame toView:[self->statusField superview]];
61 [self->statusField sizeToFit];
62 sfFrame = [self->statusField frame];
63 sfFrame.origin.x = NSWidth(frame) - NSWidth(sfFrame) + 1.0;
64 sfFrame.origin.y = NSMaxY(frame) - NSHeight(sfFrame) + 1.0;
65 [self->statusField setFrame:sfFrame];
68 #if SOPEXTextViewNotifiesAboutResponderState
69 - (void)setDelegate:(id)delegate
71 [super setDelegate:delegate];
72 delegateFlags.respondsToWillBecomeFirstResponder = [delegate respondsToSelector:@selector(textViewWillBecomeFirstResponder:)];
73 delegateFlags.respondsToWillResignFirstResponder = [delegate respondsToSelector:@selector(textViewWillResignFirstResponder:)];
77 - (BOOL)becomeFirstResponder
81 yn = [super becomeFirstResponder];
82 #if SOPEXTextViewNotifiesAboutResponderState
83 if(yn && delegateFlags.respondsToWillBecomeFirstResponder)
84 [[self delegate] textViewWillBecomeFirstResponder:self];
86 [self->statusField setHidden:YES];
90 - (BOOL)resignFirstResponder
94 yn = [super resignFirstResponder];
95 #if SOPEXTextViewNotifiesAboutResponderState
96 if(yn && delegateFlags.respondsToWillResignFirstResponder)
97 [[self delegate] textViewWillResignFirstResponder:self];