File:  [mozdev] / chimera / BookmarksService.h
Revision 1.3: download - view: text, annotated - select for diffs - revision graph
Sat Feb 9 01:52:27 2002 UTC (15 years, 8 months ago) by hyatt
Branches: MAIN
CVS tags: HEAD
Preparing for bookmark notifications.

/*
 *  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"

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) ensureBookmarks;

-(IBAction)addBookmark:(id)aSender;
-(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;

@end

@interface BookmarkItem : NSObject
{
    nsIContent* mContentNode;
}

-(nsIContent*)contentNode;
-(void)setContentNode: (nsIContent*)aContentNode;
@end

class BookmarksService: public nsIDocumentObserver
{
public:
    BookmarksService();
    virtual ~BookmarksService();
    
    NS_DECL_ISUPPORTS;
    
    // nsIDocumentObserver interface
    NS_IMETHOD BeginUpdate(nsIDocument *aDocument) { return NS_OK; };
    NS_IMETHOD EndUpdate(nsIDocument *aDocument) { return NS_OK; };
    NS_IMETHOD BeginLoad(nsIDocument *aDocument)  { return NS_OK; };
    NS_IMETHOD EndLoad(nsIDocument *aDocument)  { return NS_OK; };
    NS_IMETHOD BeginReflow(nsIDocument *aDocument, nsIPresShell* aShell)  { return NS_OK; };
    NS_IMETHOD EndReflow(nsIDocument *aDocument, nsIPresShell* aShell)  { return NS_OK; };
    NS_IMETHOD ContentChanged(nsIDocument *aDocument,
                            nsIContent* aContent,
                            nsISupports* aSubContent)  { return NS_OK; };
    NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
                                  nsIContent* aContent1,
                                  nsIContent* aContent2)  { return NS_OK; };
    NS_IMETHOD ContentReplaced(nsIDocument *aDocument,
                             nsIContent* aContainer,
                             nsIContent* aOldChild,
                             nsIContent* aNewChild,
                             PRInt32 aIndexInContainer) { return NS_OK; };
    NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument,
                             nsIStyleSheet* aStyleSheet)  { return NS_OK; };

    NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument,
                               nsIStyleSheet* aStyleSheet)  { return NS_OK; };
    
    NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument,
                                            nsIStyleSheet* aStyleSheet,
                                            PRBool aDisabled)  { return NS_OK; };
    NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument,
                              nsIStyleSheet* aStyleSheet,
                              nsIStyleRule* aStyleRule,
                              PRInt32 aHint) { return NS_OK; };
    NS_IMETHOD StyleRuleAdded(nsIDocument *aDocument,
                            nsIStyleSheet* aStyleSheet,
                            nsIStyleRule* aStyleRule)  { return NS_OK; };
    NS_IMETHOD StyleRuleRemoved(nsIDocument *aDocument,
                              nsIStyleSheet* aStyleSheet,
                              nsIStyleRule* aStyleRule)  { return NS_OK; };
    NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument)  { return NS_OK; };


    NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
                              nsIContent*  aContent,
                              PRInt32      aNameSpaceID,
                              nsIAtom*     aAttribute,
                              PRInt32      aModType,    
                              PRInt32      aHint);  // See nsStyleConsts fot hint values
    NS_IMETHOD ContentAppended(nsIDocument *aDocument,
                             nsIContent* aContainer,
                             PRInt32     aNewIndexInContainer);

    NS_IMETHOD ContentInserted(nsIDocument *aDocument,
                             nsIContent* aContainer,
                             nsIContent* aChild,
                             PRInt32 aIndexInContainer);
    
    NS_IMETHOD ContentRemoved(nsIDocument *aDocument,
                            nsIContent* aContainer,
                            nsIContent* aChild,
                            PRInt32 aIndexInContainer);

    void AddObserver();
    void RemoveObserver();

public:
    static void GetRootContent(nsIContent** aResult);
    static BookmarkItem* GetWrapperFor(nsIContent* aItem);
    
private:
    // Global counter and pointers to our singletons.
    static PRUint32 gRefCnt;
    static nsIDocument* gBookmarks;
    static NSMutableDictionary* gDictionary;
    
public:
    static nsIAtom* gFolderAtom;
    static nsIAtom* gNameAtom;
    static nsIAtom* gHrefAtom;
    static nsIAtom* gBookmarkAtom;
};

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