File:  [mozdev] / chimera / BookmarksService.h
Revision 1.10: download - view: text, annotated - select for diffs - revision graph
Sun Apr 14 08:43:03 2002 UTC (18 years, 1 month ago) by hyatt
Branches: MAIN
CVS tags: HEAD
So many changes I can't even go into it. :)

    1: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
    2: /* ***** BEGIN LICENSE BLOCK *****
    3:  * Version: NPL 1.1/GPL 2.0/LGPL 2.1
    4:  *
    5:  * The contents of this file are subject to the Netscape Public License
    6:  * Version 1.1 (the "License"); you may not use this file except in
    7:  * compliance with the License. You may obtain a copy of the License at
    8:  * http://www.mozilla.org/NPL/
    9:  *
   10:  * Software distributed under the License is distributed on an "AS IS" basis,
   11:  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
   12:  * for the specific language governing rights and limitations under the
   13:  * License.
   14:  *
   15:  * The Original Code is mozilla.org code.
   16:  *
   17:  * The Initial Developer of the Original Code is 
   18:  * Netscape Communications Corporation.
   19:  * Portions created by the Initial Developer are Copyright (C) 2002
   20:  * the Initial Developer. All Rights Reserved.
   21:  *
   22:  * Contributor(s):
   23:  *
   24:  * Alternatively, the contents of this file may be used under the terms of
   25:  * either the GNU General Public License Version 2 or later (the "GPL"), or 
   26:  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
   27:  * in which case the provisions of the GPL or the LGPL are applicable instead
   28:  * of those above. If you wish to allow use of your version of this file only
   29:  * under the terms of either the GPL or the LGPL, and not to allow others to
   30:  * use your version of this file under the terms of the NPL, indicate your
   31:  * decision by deleting the provisions above and replace them with the notice
   32:  * and other provisions required by the GPL or the LGPL. If you do not delete
   33:  * the provisions above, a recipient may use your version of this file under
   34:  * the terms of any one of the NPL, the GPL or the LGPL.
   35:  *
   36:  * ***** END LICENSE BLOCK ***** */
   37: 
   38: #include <Appkit/Appkit.h>
   39: #include <Carbon/Carbon.h>
   40: #include "nsCOMPtr.h"
   41: #include "nsIDocument.h"
   42: #include "nsIDocumentObserver.h"
   43: #include "nsVoidArray.h"
   44: #import "MainController.h"
   45: 
   46: class BookmarksService;
   47: class nsIAtom;
   48: 
   49: @interface BookmarksDataSource : NSObject
   50: {
   51:     BookmarksService* mBookmarks;
   52:     IBOutlet id mOutlineView;
   53:     IBOutlet id mBrowserWindowController;
   54:     IBOutlet id mAddButton;
   55:     IBOutlet id mDeleteButton;
   56: }
   57: 
   58: -(id) init;
   59: -(void) dealloc;
   60: -(void) windowClosing;
   61: 
   62: -(void) ensureBookmarks;
   63: 
   64: -(IBAction)addBookmark:(id)aSender;
   65: -(IBAction)deleteBookmark: (id)aSender;
   66: 
   67: -(void)addBookmark:(id)aSender useSelection:(BOOL)aSel;
   68: 
   69: // Datasource methods.
   70: - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item;
   71: - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item;
   72: - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item;
   73: - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
   74: - (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
   75: 
   76: - (void)reloadDataForItem:(id)item reloadChildren: (BOOL)aReloadChildren;
   77: 
   78: @end
   79: 
   80: @interface BookmarkItem : NSObject
   81: {
   82:     nsIContent* mContentNode;
   83: }
   84: 
   85: -(nsIContent*)contentNode;
   86: -(void)setContentNode: (nsIContent*)aContentNode;
   87: - (id)copyWithZone:(NSZone *)aZone;
   88: @end
   89: 
   90: class BookmarksService
   91: {
   92: public:
   93:     BookmarksService(BookmarksDataSource* aDataSource);
   94:     virtual ~BookmarksService();
   95:     
   96:     void AddObserver();
   97:     void RemoveObserver();
   98: 
   99:     static void BookmarkAdded(nsIContent* aContainer, nsIContent* aChild);
  100:     static void BookmarkChanged(nsIContent* aItem);
  101:     static void BookmarkRemoved(nsIContent* aContainer, nsIContent* aChild);
  102:     
  103: public:
  104:     static void GetRootContent(nsIContent** aResult);
  105:     static BookmarkItem* GetWrapperFor(nsIContent* aItem);
  106:     static void FlushBookmarks();
  107:     
  108:     static void ConstructBookmarksMenu(NSMenu* aMenu, nsIContent* aContent);
  109:     static void OpenMenuBookmark(BrowserWindowController* aController, id aMenuItem);
  110:     static void AddMenuBookmark(NSMenu* aMenu, nsIContent* aParent, nsIContent* aChild, PRInt32 aIndex);
  111:     static NSMenu* LocateMenu(nsIContent* aContent);
  112: 
  113: private:
  114:     // Global counter and pointers to our singletons.
  115:     static PRUint32 gRefCnt;
  116:     
  117:     // A dictionary that maps from content IDs (which uniquely identify content nodes)
  118:     // to Obj-C bookmarkItem objects.  These objects are handed back to UI elements like
  119:     // the outline view.
  120:     static NSMutableDictionary* gDictionary;
  121:         
  122: public:
  123:     static MainController* gMainController;
  124:     static NSMenu* gBookmarksMenu;
  125:     static nsIAtom* gFolderAtom;
  126:     static nsIAtom* gNameAtom;
  127:     static nsIAtom* gHrefAtom;
  128:     static nsIAtom* gBookmarkAtom;
  129:     static nsIDocument* gBookmarks;
  130:     static nsVoidArray* gInstances;
  131:         
  132: private:
  133:     BookmarksDataSource* mDataSource;
  134: };

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