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 (16 years, 7 months ago) by hyatt
Branches: MAIN
CVS tags: HEAD
Rearranging the menus and making bookmarks show up in the menu.

 *  BookmarksService.h
 *  Chimera
 *  Created by David Hyatt on Thu Feb 07 2002.
 *  Copyright (c) 2001 __MyCompanyName__. All rights reserved.

#include <Appkit/Appkit.h>
#include <Carbon/Carbon.h>
#include "nsCOMPtr.h"
#include "nsIDocument.h"
#include "nsIDocumentObserver.h"
#include "nsVoidArray.h"

class BookmarksService;
class nsIAtom;

@interface BookmarksDataSource : NSObject
    BookmarksService* mBookmarks;
    IBOutlet id mOutlineView;
    IBOutlet id mBrowserView;
    IBOutlet id mAddButton;
    IBOutlet id mDeleteButton;

-(id) init;
-(void) dealloc;
-(void) windowClosing;

-(void) ensureBookmarks;

-(IBAction)deleteBookmark: (id)aSender;

// Datasource methods.
- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item;
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item;
- (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item;
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
- (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;

- (void)reloadDataForItem:(id)item reloadChildren: (BOOL)aReloadChildren;


@interface BookmarkItem : NSObject
    nsIContent* mContentNode;

-(void)setContentNode: (nsIContent*)aContentNode;
- (id)copyWithZone:(NSZone *)aZone;

class BookmarksService
    BookmarksService(BookmarksDataSource* aDataSource);
    virtual ~BookmarksService();
    void AddObserver();
    void RemoveObserver();

    void NotifyObserver(nsIContent* aContainer, PRBool aReloadChildren);
    static void NotifyObservers(nsIContent* aContainer, PRBool aReloadChildren);

    static void GetRootContent(nsIContent** aResult);
    static BookmarkItem* GetWrapperFor(nsIContent* aItem);
    static void FlushBookmarks();
    static void ConstructBookmarksMenu(NSMenu* aMenu, nsIContent* aContent);
    // Global counter and pointers to our singletons.
    static PRUint32 gRefCnt;
    // A dictionary that maps from content IDs (which uniquely identify content nodes)
    // to Obj-C bookmarkItem objects.  These objects are handed back to UI elements like
    // the outline view.
    static NSMutableDictionary* gDictionary;
    // Dictionaries that map from menus to bookmark items and vice versa.  We use these dictionaries
    // to look up the content node that a menu or menu item represents and vice versa.
    static NSMutableDictionary* gMenuToBookmarkMap;
    static NSMutableDictionary* gBookmarkToMenuMap;
    static nsIAtom* gFolderAtom;
    static nsIAtom* gNameAtom;
    static nsIAtom* gHrefAtom;
    static nsIAtom* gBookmarkAtom;
    static nsIDocument* gBookmarks;
    static nsVoidArray* gInstances;
    BookmarksDataSource* mDataSource;

FreeBSD-CVSweb <>