File:  [mozdev] / chimera / BookmarksService.h
Revision 1.7: download - view: text, annotated - select for diffs - revision graph
Sun Feb 10 00:29:08 2002 UTC (18 years, 3 months ago) by hyatt
Branches: MAIN
CVS tags: HEAD
Bookmarks in the menu bar work!

    1: /*
    2:  *  BookmarksService.h
    3:  *  Chimera
    4:  *
    5:  *  Created by David Hyatt on Thu Feb 07 2002.
    6:  *  Copyright (c) 2001 __MyCompanyName__. All rights reserved.
    7:  *
    8:  */
    9: 
   10: #include <Appkit/Appkit.h>
   11: #include <Carbon/Carbon.h>
   12: #include "nsCOMPtr.h"
   13: #include "nsIDocument.h"
   14: #include "nsIDocumentObserver.h"
   15: #include "nsVoidArray.h"
   16: #import "MainController.h"
   17: 
   18: class BookmarksService;
   19: class nsIAtom;
   20: 
   21: @interface BookmarksDataSource : NSObject
   22: {
   23:     BookmarksService* mBookmarks;
   24:     IBOutlet id mOutlineView;
   25:     IBOutlet id mBrowserView;
   26:     IBOutlet id mAddButton;
   27:     IBOutlet id mDeleteButton;
   28: }
   29: 
   30: -(id) init;
   31: -(void) dealloc;
   32: -(void) windowClosing;
   33: 
   34: -(void) ensureBookmarks;
   35: 
   36: -(IBAction)addBookmark:(id)aSender;
   37: -(IBAction)deleteBookmark: (id)aSender;
   38: 
   39: // Datasource methods.
   40: - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item;
   41: - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item;
   42: - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item;
   43: - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
   44: - (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
   45: 
   46: - (void)reloadDataForItem:(id)item reloadChildren: (BOOL)aReloadChildren;
   47: 
   48: @end
   49: 
   50: @interface BookmarkItem : NSObject
   51: {
   52:     nsIContent* mContentNode;
   53: }
   54: 
   55: -(nsIContent*)contentNode;
   56: -(void)setContentNode: (nsIContent*)aContentNode;
   57: - (id)copyWithZone:(NSZone *)aZone;
   58: @end
   59: 
   60: class BookmarksService
   61: {
   62: public:
   63:     BookmarksService(BookmarksDataSource* aDataSource);
   64:     virtual ~BookmarksService();
   65:     
   66:     void AddObserver();
   67:     void RemoveObserver();
   68: 
   69:     void NotifyObserver(nsIContent* aContainer, PRBool aReloadChildren);
   70:     static void NotifyObservers(nsIContent* aContainer, PRBool aReloadChildren);
   71: 
   72: public:
   73:     static void GetRootContent(nsIContent** aResult);
   74:     static BookmarkItem* GetWrapperFor(nsIContent* aItem);
   75:     static void FlushBookmarks();
   76:     
   77:     static void ConstructBookmarksMenu(NSMenu* aMenu, nsIContent* aContent);
   78:     static void OpenMenuBookmark(BrowserWindowController* aController, id aMenuItem);
   79:     
   80: private:
   81:     // Global counter and pointers to our singletons.
   82:     static PRUint32 gRefCnt;
   83:     
   84:     // A dictionary that maps from content IDs (which uniquely identify content nodes)
   85:     // to Obj-C bookmarkItem objects.  These objects are handed back to UI elements like
   86:     // the outline view.
   87:     static NSMutableDictionary* gDictionary;
   88:         
   89: public:
   90:     static MainController* gMainController;
   91:     static nsIAtom* gFolderAtom;
   92:     static nsIAtom* gNameAtom;
   93:     static nsIAtom* gHrefAtom;
   94:     static nsIAtom* gBookmarkAtom;
   95:     static nsIDocument* gBookmarks;
   96:     static nsVoidArray* gInstances;
   97:         
   98: private:
   99:     BookmarksDataSource* mDataSource;
  100: };

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>