File:  [mozdev] / chimera / BookmarksService.h
Revision 1.6: download - view: text, annotated - select for diffs - revision graph
Sat Feb 9 23:17:02 2002 UTC (18 years, 3 months ago) by hyatt
Branches: MAIN
CVS tags: HEAD
Rearranging the menus and making bookmarks show up in the menu.

    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: 
   17: class BookmarksService;
   18: class nsIAtom;
   19: 
   20: @interface BookmarksDataSource : NSObject
   21: {
   22:     BookmarksService* mBookmarks;
   23:     IBOutlet id mOutlineView;
   24:     IBOutlet id mBrowserView;
   25:     IBOutlet id mAddButton;
   26:     IBOutlet id mDeleteButton;
   27: }
   28: 
   29: -(id) init;
   30: -(void) dealloc;
   31: -(void) windowClosing;
   32: 
   33: -(void) ensureBookmarks;
   34: 
   35: -(IBAction)addBookmark:(id)aSender;
   36: -(IBAction)deleteBookmark: (id)aSender;
   37: 
   38: // Datasource methods.
   39: - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item;
   40: - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item;
   41: - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item;
   42: - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
   43: - (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
   44: 
   45: - (void)reloadDataForItem:(id)item reloadChildren: (BOOL)aReloadChildren;
   46: 
   47: @end
   48: 
   49: @interface BookmarkItem : NSObject
   50: {
   51:     nsIContent* mContentNode;
   52: }
   53: 
   54: -(nsIContent*)contentNode;
   55: -(void)setContentNode: (nsIContent*)aContentNode;
   56: - (id)copyWithZone:(NSZone *)aZone;
   57: @end
   58: 
   59: class BookmarksService
   60: {
   61: public:
   62:     BookmarksService(BookmarksDataSource* aDataSource);
   63:     virtual ~BookmarksService();
   64:     
   65:     void AddObserver();
   66:     void RemoveObserver();
   67: 
   68:     void NotifyObserver(nsIContent* aContainer, PRBool aReloadChildren);
   69:     static void NotifyObservers(nsIContent* aContainer, PRBool aReloadChildren);
   70: 
   71: public:
   72:     static void GetRootContent(nsIContent** aResult);
   73:     static BookmarkItem* GetWrapperFor(nsIContent* aItem);
   74:     static void FlushBookmarks();
   75:     
   76:     static void ConstructBookmarksMenu(NSMenu* aMenu, nsIContent* aContent);
   77:     
   78: private:
   79:     // Global counter and pointers to our singletons.
   80:     static PRUint32 gRefCnt;
   81:     
   82:     // A dictionary that maps from content IDs (which uniquely identify content nodes)
   83:     // to Obj-C bookmarkItem objects.  These objects are handed back to UI elements like
   84:     // the outline view.
   85:     static NSMutableDictionary* gDictionary;
   86:     
   87:     // Dictionaries that map from menus to bookmark items and vice versa.  We use these dictionaries
   88:     // to look up the content node that a menu or menu item represents and vice versa.
   89:     static NSMutableDictionary* gMenuToBookmarkMap;
   90:     static NSMutableDictionary* gBookmarkToMenuMap;
   91:     
   92: public:
   93:     static nsIAtom* gFolderAtom;
   94:     static nsIAtom* gNameAtom;
   95:     static nsIAtom* gHrefAtom;
   96:     static nsIAtom* gBookmarkAtom;
   97:     static nsIDocument* gBookmarks;
   98:     static nsVoidArray* gInstances;
   99:     
  100: private:
  101:     BookmarksDataSource* mDataSource;
  102: };

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