From ab87a4b960bf70ac7def486de5d2c51a4c6af7f1 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Tue, 1 Feb 2011 14:52:20 +0000 Subject: Bookmarks window. No editing yet. svn path=/trunk/netsurf/; revision=11581 --- cocoa/BookmarksController.h | 6 +- cocoa/BookmarksController.m | 17 +- cocoa/Makefile.target | 2 +- cocoa/NetSurf.xcodeproj/project.pbxproj | 2 + cocoa/Tree.m | 2 + cocoa/TreeView.m | 3 +- cocoa/res/BookmarksWindow.xib | 395 ++++++++++++++++++++++++++++++++ cocoa/res/MainMenu.xib | 20 +- 8 files changed, 424 insertions(+), 23 deletions(-) create mode 100644 cocoa/res/BookmarksWindow.xib diff --git a/cocoa/BookmarksController.h b/cocoa/BookmarksController.h index 0e43d207a..39449b647 100644 --- a/cocoa/BookmarksController.h +++ b/cocoa/BookmarksController.h @@ -19,17 +19,19 @@ #import @class Tree; +@class TreeView; -@interface BookmarksController : NSObject { +@interface BookmarksController : NSWindowController { Tree *tree; + TreeView *view; NSMapTable *nodeForMenu; NSMenu *defaultMenu; } @property (readwrite, retain, nonatomic) IBOutlet NSMenu *defaultMenu; +@property (readwrite, retain, nonatomic) IBOutlet TreeView *view; - (IBAction) openBookmarkURL: (id) sender; -- (IBAction) showBookmarksWindow: (id) sender; - (IBAction) addBookmark: (id) sender; @end diff --git a/cocoa/BookmarksController.m b/cocoa/BookmarksController.m index e78d76529..9ec6818d7 100644 --- a/cocoa/BookmarksController.m +++ b/cocoa/BookmarksController.m @@ -18,6 +18,7 @@ #import "cocoa/BookmarksController.h" #import "cocoa/Tree.h" +#import "cocoa/TreeView.h" #import "cocoa/NetsurfApp.h" #import "cocoa/BrowserViewController.h" #import "cocoa/gui.h" @@ -29,6 +30,7 @@ @implementation BookmarksController @synthesize defaultMenu; +@synthesize view; static const char *cocoa_hotlist_path( void ) { @@ -38,7 +40,7 @@ static const char *cocoa_hotlist_path( void ) - init; { - if ((self = [super init]) == nil) return nil; + if ((self = [super initWithWindowNibName: @"BookmarksWindow"]) == nil) return nil; tree = [[Tree alloc] initWithFlags: hotlist_get_tree_flags()]; hotlist_initialise( [tree tree], cocoa_hotlist_path(), "" ); @@ -49,9 +51,11 @@ static const char *cocoa_hotlist_path( void ) - (void) dealloc; { + [self setView: nil]; NSFreeMapTable( nodeForMenu ); hotlist_cleanup( cocoa_hotlist_path() ); [tree release]; + [super dealloc]; } @@ -112,11 +116,6 @@ static const char *cocoa_hotlist_path( void ) } } -- (IBAction) showBookmarksWindow: (id) sender; -{ - NSLog( @"TODO: show bookmarks window" ); -} - - (IBAction) addBookmark: (id) sender; { NSLog( @"TODO: add bookmark" ); @@ -133,6 +132,12 @@ static const char *cocoa_hotlist_path( void ) return YES; } +- (void) windowDidLoad; +{ + hotlist_expand_all( ); + [view setTree: tree]; +} + + (void) initialize; { diff --git a/cocoa/Makefile.target b/cocoa/Makefile.target index 2fcbdf1e3..8cab31eae 100644 --- a/cocoa/Makefile.target +++ b/cocoa/Makefile.target @@ -119,7 +119,7 @@ SOURCES := $(addprefix $(shell pwd)/,$(SOURCES)) EXETARGET := NetSurf S_XIBS := MainMenu.xib Browser.xib BrowserWindow.xib DownloadWindow.xib SearchWindow.xib PreferencesWindow.xib \ - HistoryWindow.xib + HistoryWindow.xib BookmarksWindow.xib R_RESOURCES := default.css adblock.css quirks.css NetSurf.icns R_RESOURCES := $(addprefix cocoa/res/,$(R_RESOURCES)) diff --git a/cocoa/NetSurf.xcodeproj/project.pbxproj b/cocoa/NetSurf.xcodeproj/project.pbxproj index f8238f25f..2b096827b 100644 --- a/cocoa/NetSurf.xcodeproj/project.pbxproj +++ b/cocoa/NetSurf.xcodeproj/project.pbxproj @@ -191,6 +191,7 @@ 26376A4412F7FA86000F45FE /* HistoryWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HistoryWindowController.m; sourceTree = ""; }; 26376A8A12F7FF57000F45FE /* BookmarksController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BookmarksController.h; sourceTree = ""; }; 26376A8B12F7FF57000F45FE /* BookmarksController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BookmarksController.m; sourceTree = ""; }; + 26376BAC12F820D7000F45FE /* BookmarksWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = BookmarksWindow.xib; sourceTree = ""; }; 2639E20512F2ADEE00699678 /* coordinates.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = coordinates.h; sourceTree = ""; }; 264C344112F0987E00D11246 /* gui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gui.h; sourceTree = ""; }; 265F30A712D6637E0048B600 /* NetSurf-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "NetSurf-Info.plist"; sourceTree = ""; }; @@ -583,6 +584,7 @@ 2666DC5B12F6D1770045E8B6 /* SearchWindow.xib */, 2625095012F72A8F0090D236 /* PreferencesWindow.xib */, 26376A4112F7FA67000F45FE /* HistoryWindow.xib */, + 26376BAC12F820D7000F45FE /* BookmarksWindow.xib */, ); name = Resources; path = res; diff --git a/cocoa/Tree.m b/cocoa/Tree.m index b5cbf2068..ce7f89100 100644 --- a/cocoa/Tree.m +++ b/cocoa/Tree.m @@ -18,6 +18,7 @@ #import "cocoa/Tree.h" #import "cocoa/coordinates.h" +#import "cocoa/font.h" #import "desktop/tree.h" @@ -115,6 +116,7 @@ static void tree_get_window_dimensions( int *width, int *height, void *data ) - (void) drawRect: (NSRect) rect inView: (NSView *) view; { + cocoa_set_font_scale_factor( 1.0 ); tree_draw( tree, 0, 0, cocoa_pt_to_px( NSMinX( rect ) ), cocoa_pt_to_px( NSMinY( rect )), cocoa_pt_to_px( NSWidth( rect ) ), cocoa_pt_to_px( NSHeight( rect ) ) ); } diff --git a/cocoa/TreeView.m b/cocoa/TreeView.m index 434ceecd4..1a6f83323 100644 --- a/cocoa/TreeView.m +++ b/cocoa/TreeView.m @@ -54,6 +54,8 @@ tree = [newTree retain]; [tree setDelegate: self]; [tree setRedrawing: YES]; + + [self setNeedsDisplay: YES]; } } @@ -96,7 +98,6 @@ } } - //MARK: - //MARK: Tree delegate methods diff --git a/cocoa/res/BookmarksWindow.xib b/cocoa/res/BookmarksWindow.xib new file mode 100644 index 000000000..9800b3e1d --- /dev/null +++ b/cocoa/res/BookmarksWindow.xib @@ -0,0 +1,395 @@ + + + + 1060 + 10J567 + 804 + 1038.35 + 462.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 804 + + + YES + + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + + YES + + YES + + + YES + + + + YES + + BookmarksController + + + FirstResponder + + + NSApplication + + + 15 + 2 + {{196, 142}, {367, 368}} + 1618477056 + Bookmarks + NSWindow + + {1.79769e+308, 1.79769e+308} + + + 256 + + YES + + + 274 + + YES + + + 2304 + + YES + + + 274 + {367, 328} + + TreeView + + + {{1, 1}, {367, 328}} + + + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2NjY3AA + + + 4 + + + + -2147483392 + {{353, 1}, {15, 313}} + + + _doScroller: + 1 + 0.96363627910614014 + + + + -2147483392 + {{1, 314}, {352, 15}} + + 1 + + _doScroller: + 0.50602412223815918 + + + {{-1, 39}, {369, 330}} + + + 562 + + + + + + {367, 368} + + + {{0, 0}, {1680, 1028}} + {1.79769e+308, 1.79769e+308} + + + + + YES + + + window + + + + 3 + + + + view + + + + 8 + + + + + YES + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 1 + + + YES + + + + + + 2 + + + YES + + + + + + 4 + + + YES + + + + + + + + 5 + + + + + 6 + + + + + 7 + + + + + + + YES + + YES + 1.IBEditorWindowLastContentRect + 1.IBPluginDependency + 1.IBWindowTemplateEditedContentRect + 1.NSWindowTemplate.visibleAtLaunch + 1.WindowOrigin + 1.editorWindowContentRectSynchronizationRect + 2.IBPluginDependency + 4.IBPluginDependency + 4.IBViewBoundsToFrameTransform + 5.IBPluginDependency + 6.IBPluginDependency + 7.IBPluginDependency + + + YES + {{344, 236}, {367, 368}} + com.apple.InterfaceBuilder.CocoaPlugin + {{344, 236}, {367, 368}} + + {196, 240} + {{202, 428}, {480, 270}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAAC/gAAAw7eAAA + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 8 + + + + YES + + BookmarksController + NSWindowController + + YES + + YES + addBookmark: + openBookmarkURL: + + + YES + id + id + + + + YES + + YES + addBookmark: + openBookmarkURL: + + + YES + + addBookmark: + id + + + openBookmarkURL: + id + + + + + YES + + YES + defaultMenu + view + + + YES + NSMenu + TreeView + + + + YES + + YES + defaultMenu + view + + + YES + + defaultMenu + NSMenu + + + view + TreeView + + + + + IBProjectSource + BookmarksController.h + + + + NSApplication + + IBProjectSource + PSMTabBarControl/PSMTabDragAssistant.h + + + + NSObject + + IBProjectSource + PSMTabBarControl/PSMTabBarCell.h + + + + NSObject + + IBProjectSource + PSMTabBarControl/PSMTabBarControl.h + + + + ScrollableView + NSView + + IBProjectSource + ScrollableView.h + + + + TreeView + ScrollableView + + IBProjectSource + TreeView.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + ../NetSurf.xcodeproj + 3 + + diff --git a/cocoa/res/MainMenu.xib b/cocoa/res/MainMenu.xib index 596c9ec83..d38240bfd 100644 --- a/cocoa/res/MainMenu.xib +++ b/cocoa/res/MainMenu.xib @@ -12,6 +12,7 @@ YES + @@ -1021,11 +1022,11 @@ - showBookmarksWindow: + showWindow: - 858 + 859 @@ -1755,7 +1756,7 @@ com.apple.InterfaceBuilder.CocoaPlugin {{525, 802}, {197, 73}} - {{656, 815}, {446, 20}} + {{604, 815}, {446, 20}} com.apple.InterfaceBuilder.CocoaPlugin {74, 862} @@ -1835,7 +1836,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{876, 809}, {64, 6}} + {{824, 809}, {64, 6}} com.apple.InterfaceBuilder.CocoaPlugin {{616, 718}, {206, 43}} com.apple.InterfaceBuilder.CocoaPlugin @@ -1861,27 +1862,25 @@ - 858 + 859 YES BookmarksController - NSObject + NSWindowController YES YES addBookmark: openBookmarkURL: - showBookmarksWindow: YES id id - id @@ -1890,7 +1889,6 @@ YES addBookmark: openBookmarkURL: - showBookmarksWindow: YES @@ -1902,10 +1900,6 @@ openBookmarkURL: id - - showBookmarksWindow: - id - -- cgit v1.2.3