home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / gui / CPersonalToolbarManager.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.8 KB  |  118 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. //
  20. // CPersonalToolbarManager.h
  21. //
  22. // Interface to the class that manages all of the personal toolbars in browser windows. We
  23. // need a central manager so that we can keep all the windows in sync when things change
  24. // (say when the user adds a bookmark to one window). This reads all its info from RDF,
  25. // not from the outdated BM UI. 
  26. //
  27.  
  28. #pragma once
  29.  
  30. #include <string>
  31. #include "htrdf.h"
  32. #include "ntypes.h"
  33. #include "CRDFNotificationHandler.h"
  34.  
  35. class CPersonalToolbarTable;
  36. class CBookmarksContext;
  37.  
  38.  
  39. //
  40. // CUserButtonInfo
  41. //
  42. class CUserButtonInfo 
  43. {
  44. public:
  45.  
  46.     CUserButtonInfo( const string & pName, const string & pURL, Uint32 nBitmapID, Uint32 nBitmapIndex, 
  47.                         bool bIsFolder);
  48.     ~CUserButtonInfo();
  49.  
  50.     const string & GetName(void) const                 { return mName; }
  51.     const string & GetURL(void) const                 { return mURL; }
  52.     
  53.     bool IsResourceID(void) const                     { return mIsResourceID; }
  54.     Uint32 GetBitmapID(void) const                     { return mBitmapID; }
  55.     Uint32 GetBitmapIndex(void) const                 { return mBitmapIndex; }
  56.     bool IsFolder(void) const                         { return mIsFolder;}
  57.  
  58. private:
  59.     const string mName;
  60.     const string mURL;
  61.     bool    mIsResourceID;
  62.     Uint32    mBitmapID;
  63.     Uint32    mBitmapIndex;
  64.     string    mBitmapFile;
  65.     bool    mIsFolder;
  66.  
  67. }; // CUserButtonInfo
  68.  
  69.  
  70. //
  71. // CPersonalToolbarManager
  72. //
  73. // Nothing really needs to be static because there will be only one of these and it
  74. // can be easily accessed from a static variable in CFrontApp
  75. //
  76. class CPersonalToolbarManager : public LBroadcaster, public CRDFNotificationHandler
  77. {
  78.     public:
  79.         //--- some constants and messages
  80.         enum { kMinPersonalToolbarChars = 15, kMaxPersonalToolbarChars = 30 };
  81.         enum MessageT { k_PTToolbarChanged = 'TbCh' } ;
  82.         
  83.         CPersonalToolbarManager ( ) ;
  84.         virtual ~CPersonalToolbarManager ( ) ;
  85.     
  86.         //--- create, add, delete, etc operations on the toolbars
  87.         void RegisterNewToolbar ( CPersonalToolbarTable* inBar );
  88.         void ToolbarChanged();
  89.         void AddButton ( HT_Resource inBookmark, Uint32 inIndex) ;
  90.         void AddButton ( const string & inURL, const string & inTitle, Uint32 inIndex ) ;
  91.         void RemoveButton ( Uint32 inIndex );
  92.         
  93.         //--- utilities
  94.         Uint32 GetMaxToolbarButtonChars() const { return mMaxToolbarButtonChars; }
  95.         Uint32 GetMinToolbarButtonChars() const { return mMinToolbarButtonChars; }
  96.         void SetMaxToolbarButtonChars(Uint32 inNewMax) { mMaxToolbarButtonChars = inNewMax; }
  97.         void SetMinToolbarButtonChars(Uint32 inNewMin) { mMinToolbarButtonChars = inNewMin; }
  98.         
  99.         LArray & GetButtons ( ) { return mUserButtonInfoArray; }
  100.         HT_View GetHTView() const { return mToolbarView; }
  101.  
  102.     protected:        
  103.     
  104.         HT_View        mToolbarView;
  105.         HT_Resource    mToolbarRoot;
  106.         Uint32        mMaxToolbarButtonChars;
  107.         Uint32        mMinToolbarButtonChars;
  108.         LArray        mUserButtonInfoArray;
  109.         
  110.         static const char* kMaxButtonCharsPref;
  111.         static const char* kMinButtonCharsPref;
  112.         
  113.         void InitializeButtonInfo();
  114.         void RemoveToolbarButtons();
  115.         void HandleNotification( HT_Notification notifyStruct, HT_Resource node, HT_Event event);
  116.     
  117. }; // CPersonalToolbarManager
  118.