~ubuntu-branches/ubuntu/gutsy/viewpdf.app/gutsy

« back to all changes in this revision

Viewing changes to FindView.m

  • Committer: Bazaar Package Importer
  • Author(s): Gürkan Sengün
  • Date: 2004-11-12 22:04:50 UTC
  • Revision ID: james.westby@ubuntu.com-20041112220450-hp9da460x7pvz96z
Tags: upstream-0.9
Import upstream version 0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2004  Stefan Kleine Stegemann
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License
 
6
 * as published by the Free Software Foundation; either version 2
 
7
 * of the License, or (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
17
 */
 
18
 
 
19
#include <AppKit/NSEvent.h>
 
20
#include <AppKit/NSWindow.h>
 
21
#include "FindView.h"
 
22
 
 
23
/**
 
24
 * Non-Public methods.
 
25
 */
 
26
@interface FindView (Private)
 
27
- (void) _centerVerticallyInView: (NSView*)aView;
 
28
@end
 
29
 
 
30
 
 
31
@implementation FindView
 
32
 
 
33
- (id) initWithFrame: (NSRect)aFrame
 
34
{
 
35
   if ((self = [super initWithFrame: aFrame]))
 
36
   {
 
37
      [self setAutoresizesSubviews: NO];
 
38
 
 
39
      text = [[NSTextField alloc] init];
 
40
      [text setFrame: NSMakeRect(5, 0, 200, 24)];
 
41
      [self _centerVerticallyInView: text];
 
42
      [self addSubview: text];
 
43
      RELEASE(text);
 
44
 
 
45
      NSLog(@"DEBUG %@", [[text nextResponder] description]);
 
46
   }
 
47
 
 
48
   return self;
 
49
}
 
50
 
 
51
 
 
52
- (void) dealloc
 
53
{
 
54
   [super dealloc];
 
55
}
 
56
 
 
57
 
 
58
- (void) activate
 
59
{
 
60
   [[text window] makeFirstResponder: text];
 
61
}
 
62
 
 
63
 
 
64
- (void) deactivate
 
65
{
 
66
   return;
 
67
}
 
68
 
 
69
@end
 
70
 
 
71
 
 
72
/* ----------------------------------------------------- */
 
73
/*  Category Private                                     */
 
74
/* ----------------------------------------------------- */
 
75
 
 
76
@implementation FindView (Private)
 
77
 
 
78
/*
 
79
 * Center a view vertically in this view.
 
80
 */
 
81
- (void) _centerVerticallyInView: (NSView*)aView
 
82
{
 
83
   NSRect newFrame;
 
84
   
 
85
   newFrame = NSMakeRect(NSMinX([aView frame]),
 
86
                         (NSHeight([self frame]) / 2) - (NSHeight([aView frame]) / 2),
 
87
                         NSWidth([aView frame]),
 
88
                         NSHeight([aView frame]));
 
89
 
 
90
   [aView setFrame: newFrame];
 
91
}
 
92
 
 
93
@end
 
94