]> err.no Git - sope/blob - sopex/SOPEX/SOPEXBrowserWindow.m
fixed a warning
[sope] / sopex / SOPEX / SOPEXBrowserWindow.m
1 /*
2  Copyright (C) 2004 Marcus Mueller <znek@mulle-kybernetik.com>
3
4  This file is part of OGo
5
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
9  later version.
10
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.
15
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
19  02111-1307, USA.
20  */
21 // $Id: SOPEXBrowserWindow.m 1 2004-08-20 11:17:52Z znek $
22 //  Created by znek on Mon Mar 22 2004.
23
24
25 #import "SOPEXBrowserWindow.h"
26
27
28 #define USE_NSTheme_PRIVATE_API 0
29
30
31 #if USE_NSTheme_PRIVATE_API
32 @interface NSView (NSTheme_PrivateAPI_We_Know_Exists)
33 - (void)addFileButton:(id)fp8;
34 - (id)newFileButton;
35 @end
36
37
38 @implementation NSImageView (HACQUE_alert)
39 - (NSString *)representedFilename
40 {
41     return nil;
42 }
43 @end
44 #endif
45
46
47 @interface SOPEXBrowserWindow (PrivateAPI)
48 - (NSView *)borderView;
49 - (NSRect)favIconFrameForTitle:(NSString *)_title;
50 @end
51
52
53 @implementation SOPEXBrowserWindow
54
55 #if 0
56 - (void)dealloc
57 {
58     [self->favIconView release];
59     [super dealloc];
60 }
61 #endif
62
63 - (NSView *)borderView
64 {
65     return self->_borderView;
66 }
67
68 #if !USE_NSTheme_PRIVATE_API
69 - (NSRect)favIconFrameForTitle:(NSString *)_title
70 {
71     NSDictionary *attrs;
72     NSRect frame, bvFrame;
73     float textWidth;
74     
75     attrs = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont systemFontOfSize:[NSFont systemFontSize]], NSFontAttributeName, nil];
76     textWidth = [_title sizeWithAttributes:attrs].width;
77     bvFrame = [[self borderView] frame];
78     frame = NSMakeRect((NSMidX(bvFrame) - (textWidth / 2.0)) - 24, NSHeight(bvFrame) - 19, 16, 16);
79     return frame;
80 }
81 #endif
82
83 - (void)setFavIcon:(NSImage *)_favIcon
84 {
85 #if 0
86     if(self->favIconView == nil)
87     {
88 #if !USE_NSTheme_PRIVATE_API
89         self->favIconView = [[NSImageView alloc] initWithFrame:[self favIconFrameForTitle:[self title]]];
90         [self->favIconView setAutoresizingMask:(NSViewMinYMargin | NSViewMinXMargin | NSViewMaxXMargin)];
91 #else
92         self->favIconView = [[self borderView] newFileButton];
93         [self->favIconView retain];
94 #endif
95
96 #if !USE_NSTheme_PRIVATE_API
97         [[self borderView] addSubview:self->favIconView];
98 #else
99         [[self borderView] addFileButton:self->favIconView];
100 #endif
101         [self->favIconView release];
102     }
103     [self->favIconView setImage:_favIcon];
104 #endif
105 }
106
107 #if !USE_NSTheme_PRIVATE_API
108 - (void)setTitle:(NSString *)_title
109 {
110     if(self->favIconView != nil)
111     {
112         [self->favIconView setFrame:[self favIconFrameForTitle:_title]];
113         [[self borderView] setNeedsDisplay:YES];
114     }
115     [super setTitle:_title];
116 }
117 #endif
118
119 @end