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 (16 years, 5 months ago) by hyatt
Branches: MAIN
CVS tags: HEAD
Bookmarks in the menu bar work!

 *  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"
#import "MainController.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);
    static void OpenMenuBookmark(BrowserWindowController* aController, id aMenuItem);
    // 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;
    static MainController* gMainController;
    static nsIAtom* gFolderAtom;
    static nsIAtom* gNameAtom;
    static nsIAtom* gHrefAtom;
    static nsIAtom* gBookmarkAtom;
    static nsIDocument* gBookmarks;
    static nsVoidArray* gInstances;
    BookmarksDataSource* mDataSource;

FreeBSD-CVSweb <>