Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 163 lines (126 sloc) 5.701 kB
dc5be1c Initial check-in.
uli authored
1 //
2 // UKFilePathView.h
3 // Shovel
4 //
5 // Created by Uli Kusterer on Thu Mar 25 2004.
720b0e7 @uliwitness Added licensing information to the source files.
authored
6 // Copyright (c) 2004 Uli Kusterer.
7 //
8 // This software is provided 'as-is', without any express or implied
9 // warranty. In no event will the authors be held liable for any damages
10 // arising from the use of this software.
11 //
12 // Permission is granted to anyone to use this software for any purpose,
13 // including commercial applications, and to alter it and redistribute it
14 // freely, subject to the following restrictions:
15 //
16 // 1. The origin of this software must not be misrepresented; you must not
17 // claim that you wrote the original software. If you use this software
18 // in a product, an acknowledgment in the product documentation would be
19 // appreciated but is not required.
20 //
21 // 2. Altered source versions must be plainly marked as such, and must not be
22 // misrepresented as being the original software.
23 //
24 // 3. This notice may not be removed or altered from any source
25 // distribution.
dc5be1c Initial check-in.
uli authored
26 //
27
28 #import <AppKit/AppKit.h>
29
30
31 /*
32 An NSView that displays a file path. This looks kind of like how Sherlock
33 displays the location of a file. Basically you get each folder's display
34 name with its icon in front of it, and little grey triangles between
35 them, and you get the icon of the file or folder at the end and its display
36 name.
37
38 If the path is too long, this takes items out of the middle and displays
39 an ellipsis character (...) instead.
40
41 You can also right-click or control-click on this to get a contextual menu
42 that contains "Reveal in Finder" and "Show Real Names" menu choices. Real
43 names displays the actual path, starting with "/", and using the actual
44 file names instead of their display names. As a shortcut, double-clicking
45 this view is the same as "Reveal in Finder".
46
47 This needs:
48 - UKGraphics.h/.m (for drawing the bezel around the view)
72dc690 @uliwitness Update UKFilePathView requirements.
authored
49 - UKFadedDrawing.h/.m (for drawing the shortened path components)
dc5be1c Initial check-in.
uli authored
50 */
51
6d79f1f UKFilePathView now looks nicer. Fades out text that's too long, suppo…
uli authored
52 @class UKFilePathEntry; // Private, internal class.
53
dc5be1c Initial check-in.
uli authored
54
55 @interface UKFilePathView : NSView
56 {
57 NSString* filePath; // The path to be displayed.
58 BOOL noDisplayNames; // Show actual names, not display names.
59 BOOL canChooseFiles; // Handed on directly to the open panel.
60 BOOL canChooseDirectories; // Handed on directly to the open panel.
61 BOOL treatsFilePackagesAsDirectories; // Handed on directly to the open/save panels.
e7e98f5 @uliwitness Expose more open panel properties.
authored
62 BOOL allowsMultipleSelection; // Handed on directly to the open/save panels.
63 NSURL* directoryURL; // Handed on directly to the open/save panels.
64 NSString* message; // Handed on directly to the open/save panels.
dc5be1c Initial check-in.
uli authored
65 NSArray* types; // Handed on directly to the open panel.
66 SEL action;
67 id target;
68 BOOL drawDropHighlight;
69 NSString* placeholderString; // A placeholder to show when path is NIL. Defaults to "none".
6d79f1f UKFilePathView now looks nicer. Fades out text that's too long, suppo…
uli authored
70 NSBorderType borderType;
71 BOOL acceptDrops;
72 BOOL allowContextMenu;
73 NSMutableArray* pathEntries; // array of UKFilePathEntry objects for the path components we display.
74 NSDictionary* textAttributes; // As you'd have them in an NSAttributedString.
0cf32ec @uliwitness Update data types for 64-bit.
authored
75 NSUInteger selectedPathEntry; // Entry to highlight during mouse tracking.
dc5be1c Initial check-in.
uli authored
76 }
77
6d79f1f UKFilePathView now looks nicer. Fades out text that's too long, suppo…
uli authored
78 -(NSString *) filePath;
79 -(void) setFilePath: (NSString *)newFilePath;
80
81 -(id) target;
82 -(void) setTarget: (id) theTarget;
83
84 -(SEL) action;
85 -(void) setAction: (SEL) theAction;
dc5be1c Initial check-in.
uli authored
86
6d79f1f UKFilePathView now looks nicer. Fades out text that's too long, suppo…
uli authored
87 -(void) revealInFinder: (id)sender;
88 -(void) showRealNames: (id)sender;
89 -(void) toggleShowRealNames: (id)sender;
dc5be1c Initial check-in.
uli authored
90
6d79f1f UKFilePathView now looks nicer. Fades out text that's too long, suppo…
uli authored
91 -(NSString *) stringValue; // same as filePath.
92 -(void) setStringValue: (NSString*)s; // same as setFilePath.
dc5be1c Initial check-in.
uli authored
93
6d79f1f UKFilePathView now looks nicer. Fades out text that's too long, suppo…
uli authored
94 -(void) setPlaceholderString: (NSString*)string;
95 -(NSString*) placeholderString;
dc5be1c Initial check-in.
uli authored
96
6d79f1f UKFilePathView now looks nicer. Fades out text that's too long, suppo…
uli authored
97 -(void) setBorderType: (NSBorderType)aType; // Only NSBezelBorder and NSNoBorder so far.
98 -(NSBorderType) borderType;
dc5be1c Initial check-in.
uli authored
99
6d79f1f UKFilePathView now looks nicer. Fades out text that's too long, suppo…
uli authored
100 -(NSString*) fullPathAsDisplayString;
dc5be1c Initial check-in.
uli authored
101
6d79f1f UKFilePathView now looks nicer. Fades out text that's too long, suppo…
uli authored
102 -(void) setAcceptDrops: (BOOL)doAccept;
103 -(BOOL) acceptDrops;
104
105 -(void) setAllowContextMenu: (BOOL)doCMM;
106 -(BOOL) allowContextMenu;
107
108 -(NSDictionary*) textAttributes;
109 -(void) setTextAttributes: (NSDictionary*)dict;
dc5be1c Initial check-in.
uli authored
110
111 // UI for changing value:
6d79f1f UKFilePathView now looks nicer. Fades out text that's too long, suppo…
uli authored
112 -(IBAction) pickFile: (id)sender; // NSOpenPanel. Chooses existing files.
113 -(IBAction) pickNewFile: (id)sender; // NSSavePanel. Lets the user specify name and location for new files.
114 -(IBAction) pickNoFile: (id)sender; // Sets the file path to NIL.
dc5be1c Initial check-in.
uli authored
115
116 // Getters/setters for the NSOpenPanel properties:
6d79f1f UKFilePathView now looks nicer. Fades out text that's too long, suppo…
uli authored
117 -(BOOL) canChooseFiles;
118 -(void) setCanChooseFiles: (BOOL)flag;
dc5be1c Initial check-in.
uli authored
119
6d79f1f UKFilePathView now looks nicer. Fades out text that's too long, suppo…
uli authored
120 -(BOOL) canChooseDirectories;
121 -(void) setCanChooseDirectories: (BOOL)flag;
dc5be1c Initial check-in.
uli authored
122
6d79f1f UKFilePathView now looks nicer. Fades out text that's too long, suppo…
uli authored
123 -(NSArray*) types;
124 -(void) setTypes: (NSArray*)theTypes;
dc5be1c Initial check-in.
uli authored
125
6d79f1f UKFilePathView now looks nicer. Fades out text that's too long, suppo…
uli authored
126 -(BOOL) treatsFilePackagesAsDirectories;
127 -(void) setTreatsFilePackagesAsDirectories: (BOOL)flag;
dc5be1c Initial check-in.
uli authored
128
e7e98f5 @uliwitness Expose more open panel properties.
authored
129 -(BOOL) allowsMultipleSelection;
130 -(void) setAllowsMultipleSelection: (BOOL)flag;
131
132 -(NSURL*) directoryURL;
133 -(void) setDirectoryURL: (NSURL*)url;
134
135 -(NSString*) message;
136 -(void) setMessage: (NSString*)msg;
137
dc5be1c Initial check-in.
uli authored
138 // private:
6d79f1f UKFilePathView now looks nicer. Fades out text that's too long, suppo…
uli authored
139 -(NSImage*) pathArrowImage;
140 -(void) rebuildPathComponentArray;
141 -(void) relayoutPathComponents;
0cf32ec @uliwitness Update data types for 64-bit.
authored
142 -(NSInteger) indexOfPathEntryAtPoint: (NSPoint)pos;
6d79f1f UKFilePathView now looks nicer. Fades out text that's too long, suppo…
uli authored
143 -(UKFilePathEntry*) lastVisiblePathEntry;
dc5be1c Initial check-in.
uli authored
144
145 @end
146
147
148 // Some constants we use for this view's metrics:
149 #define UK_PATH_NAME_LEFT_MARGIN 4
150 #define UK_PATH_NAME_RIGHT_MARGIN 4
151 #define UK_PATH_NAME_TOP_MARGIN 2
152 #define UK_PATH_NAME_BOTTOM_MARGIN 2
153 #define UK_PATH_NAME_TOTAL_VMARGIN (UK_PATH_NAME_TOP_MARGIN +UK_PATH_NAME_BOTTOM_MARGIN)
154 #define UK_PATH_NAME_TOTAL_HMARGIN (UK_PATH_NAME_LEFT_MARGIN +UK_PATH_NAME_RIGHT_MARGIN)
155 #define UK_PATH_ARROW_IMG_WIDTH 16
156 #define UK_PATH_ICON_IMG_WIDTH 16
157 #define UK_PATH_ICON_NAME_HDISTANCE 2
6d79f1f UKFilePathView now looks nicer. Fades out text that's too long, suppo…
uli authored
158 #define UK_MIN_TEXT_WIDTH 6
dc5be1c Initial check-in.
uli authored
159
160
161
162
Something went wrong with that request. Please try again.