home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / prefs / CAssortedMediators.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  9.4 KB  |  340 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. #pragma once
  20.  
  21. #include "CPrefsMediator.h"
  22.  
  23. //======================================
  24. #pragma mark
  25. class UAssortedPrefMediators
  26. //======================================
  27. {
  28. public:
  29.     static void RegisterViewClasses();
  30. }; // class UAssortedPrefMediators
  31.  
  32. class LTextColumn;
  33. class CMIMEListPane;
  34. class CDragOrderTextList;
  35.  
  36. //======================================
  37. #pragma mark
  38. class CAppearanceMainMediator
  39. //======================================
  40. :    public CPrefsMediator
  41. {
  42.     public:
  43.         
  44.         enum { class_ID = PrefPaneID::eAppearance_Main };
  45.         CAppearanceMainMediator(LStream*);
  46.  
  47.         virtual    void    LoadPrefs();
  48.         virtual    void    WritePrefs();
  49. };
  50.  
  51. //======================================
  52. #pragma mark
  53. class CAppearanceFontsMediator : public CPrefsMediator
  54. //======================================
  55. {
  56.     public:
  57.  
  58.         enum { class_ID = PrefPaneID::eAppearance_Fonts };
  59.         CAppearanceFontsMediator(LStream*);
  60.         virtual    ~CAppearanceFontsMediator()
  61.             { delete [] mEncodings;    }
  62.  
  63.         virtual void    ListenToMessage(MessageT inMessage, void *ioParam);
  64.  
  65.         virtual    void    LoadPrefs();
  66.         virtual    void    WritePrefs();
  67.  
  68.     private:
  69.  
  70.         struct Encoding
  71.         {
  72.             Encoding():
  73.             mCSID(0),
  74.             mPropFontSize(12),
  75.             mFixedFontSize(10),
  76.             mPropFontLocked(false),
  77.             mFixedFontLocked(false),
  78.             mPropFontSizeLocked(false),
  79.             mFixedFontSizeLocked(false)
  80.             {
  81.             };
  82.             CStr31            mLanguageGroup;
  83.             unsigned short    mCSID;
  84.             CStr31            mPropFont;
  85.             Boolean            mPropFontLocked;
  86.             CStr31            mFixedFont;
  87.             Boolean            mFixedFontLocked;
  88.             unsigned short    mPropFontSize;
  89.             Boolean            mPropFontSizeLocked;
  90.             unsigned short    mFixedFontSize;
  91.             Boolean            mFixedFontSizeLocked;
  92.         };
  93.  
  94.  
  95.                 void    LoadEncodings();
  96.                 void    ReadEncodings(Handle hndl);
  97.                 void    SetEncodingWithPref(Encoding& enc);
  98.                 void    SetPrefWithEncoding(const Encoding& enc);
  99.                 void    UpdateMenus();
  100.                 void    UpdateEncoding(PaneIDT changedMenuID);
  101.                 void    PopulateEncodingsMenus(PaneIDT menuID);
  102.                 void    WriteEncodingPrefs();
  103.                 Int16    GetFontSize(LGAPopup* whichPopup);
  104.                 int        GetSelectEncMenuItem();
  105.                 void    FontMenuChanged(PaneIDT changedMenuID);
  106.                 void    SizeMenuChanged(PaneIDT changedMenuID);
  107.  
  108.         Encoding    *mEncodings;
  109.         int            mEncodingsCount;
  110. };
  111.  
  112. //======================================
  113. #pragma mark
  114. class CAppearanceColorsMediator : public CPrefsMediator
  115. //======================================
  116. {
  117.     public:
  118.  
  119.         enum { class_ID = PrefPaneID::eAppearance_Colors };
  120.         CAppearanceColorsMediator(LStream*);
  121.         virtual    ~CAppearanceColorsMediator() {};
  122.         virtual void    ListenToMessage(MessageT inMessage, void *ioParam);
  123.     private:
  124.                 void    UseDefaults();
  125. };
  126.  
  127. //======================================
  128. #pragma mark
  129. class CBrowserMainMediator : public CPrefsMediator
  130. //======================================
  131. {
  132.     public:
  133.  
  134.         enum { class_ID = PrefPaneID::eBrowser_Main };
  135.         CBrowserMainMediator(LStream*);
  136.         virtual    ~CBrowserMainMediator() {if (mCurrentURL) XP_FREE(mCurrentURL);};
  137.  
  138.         virtual void    ListenToMessage(MessageT inMessage, void *ioParam);
  139.  
  140.         virtual    void    LoadPrefs();
  141.         virtual    void    UpdateFromIC();
  142.         virtual    void    LoadMainPane();
  143.         virtual    void    WritePrefs();
  144.  
  145.         static Boolean ExpireDaysValidationFunc(CValidEditField *daysTilExpire);
  146.  
  147.     private:
  148.                 void    URLChoosingButtons(Boolean enable);
  149.                 void    ExpireNow();
  150.         Boolean    mHomePageURLLocked;
  151.         char    *mCurrentURL;
  152. };
  153.  
  154. //======================================
  155. #pragma mark
  156. class CBrowserLanguagesMediator : public CPrefsMediator
  157. //======================================
  158. {
  159.     public:
  160.  
  161.         enum { class_ID = PrefPaneID::eBrowser_Languages };
  162.         CBrowserLanguagesMediator(LStream*);
  163.         virtual    ~CBrowserLanguagesMediator();
  164.  
  165.         virtual void    ListenToMessage(MessageT inMessage, void *ioParam);
  166.  
  167.         virtual    void    LoadMainPane();
  168.         virtual    void    LoadPrefs();
  169.         virtual    void    WritePrefs();
  170.  
  171.     private:
  172.                 void    LoadBuiltInArrays();
  173.                 void    SetLanguageListWithPref(const char *prefName,
  174.                                                 PaneIDT    languageListID,
  175.                                                 Boolean    &locked);
  176.                 void    SetPrefWithLanguageList(const char *prefName,
  177.                                                 PaneIDT    languageListID,
  178.                                                 Boolean    locked);
  179.                 char    *GetLanguageDisplayString(const char *languageCode);
  180.                             // For a code from the prefs, allocates (with XP_ALLOC())
  181.                             // the proper string for display.
  182.                             //    If languageCode is fr then returns French [fr]
  183.                             //     If the languageCode is not a builtin code, then
  184.                             //         a copy of languageCode is returned.
  185.                 void    UpdateButtons(LTextColumn *languageList = nil);
  186.                             // OK button.
  187.                 Boolean    GetNewLanguage(char *&newLanguage);
  188.                 Boolean    GetNewUniqueLanguage(char *&newLanguage);
  189.                 void    FillAddList(LTextColumn *list);
  190.                 char    *AppendLanguageCode(const char *originalString,
  191.                                             const char *stringToAdd);
  192.         Boolean    mLanguagesLocked;
  193.         Int32    mBuiltInCount;
  194.         char    **mLanguageStringArray;
  195.         char    **mLangaugeCodeArray;
  196.             // The following two members are only meaningful when the Add Language
  197.             // dialog is up.
  198.         Boolean    mOtherTextEmpty;    // This means that the "Other:" text field is empty.
  199.         LTextColumn    *mAddLanguageList;
  200. };
  201.  
  202. //======================================
  203. #pragma mark
  204. class CBrowserApplicationsMediator : public CPrefsMediator
  205. //======================================
  206. {
  207.     public:
  208.  
  209.         enum { class_ID = PrefPaneID::eBrowser_Applications };
  210.         CBrowserApplicationsMediator(LStream*);
  211.         virtual    ~CBrowserApplicationsMediator() {};
  212.  
  213.         virtual void    ListenToMessage(MessageT inMessage, void *ioParam);
  214.  
  215.         virtual    void    LoadMainPane();
  216.         virtual    void    WritePrefs();
  217.     private:
  218.         Boolean            mModified;            // Have any MIMEs been modified
  219.         CMIMEListPane*    mMIMETable;            // Scrolling table of MIME types
  220.         CMimeList        mDeletedTypes;
  221.  
  222.                 void    EditMimeEntry();
  223.                 void    NewMimeEntry();
  224.                 void    DeleteMimeEntry();
  225. };
  226.  
  227. #ifdef EDITOR
  228. //======================================
  229. #pragma mark
  230. class CEditorMainMediator : public CPrefsMediator
  231. //======================================
  232. {
  233.     public:
  234.  
  235.         enum { class_ID = PrefPaneID::eEditor_Main };
  236.         CEditorMainMediator(LStream*);
  237.         virtual    ~CEditorMainMediator() {};
  238.  
  239.         virtual void    ListenToMessage(MessageT inMessage, void *ioParam);
  240.  
  241.         virtual    void    LoadMainPane();
  242.  
  243.         static Boolean    SaveIntervalValidationFunc(CValidEditField *saveInterval);
  244.  
  245.     private:
  246.                 void    RestoreDefaultURL();
  247.         Boolean    mNewDocURLLocked;
  248. };
  249. #endif // EDITOR
  250.  
  251. //======================================
  252. #pragma mark
  253. class CAdvancedCacheMediator : public CPrefsMediator
  254. //======================================
  255. {
  256.     public:
  257.  
  258.         enum { class_ID = PrefPaneID::eAdvanced_Cache };
  259.         CAdvancedCacheMediator(LStream*);
  260.         virtual    ~CAdvancedCacheMediator() {};
  261.  
  262.         virtual void    ListenToMessage(MessageT inMessage, void *ioParam);
  263.     private:
  264.                 void    ClearDiskCacheNow();
  265. };
  266.  
  267. //======================================
  268. #pragma mark
  269. class CAdvancedProxiesMediator : public CPrefsMediator
  270. //======================================
  271. {
  272.     public:
  273.  
  274.         enum { class_ID = PrefPaneID::eAdvanced_Proxies };
  275.         CAdvancedProxiesMediator(LStream*);
  276.         virtual    ~CAdvancedProxiesMediator() {};
  277.  
  278.         virtual void    ListenToMessage(MessageT inMessage, void *ioParam);
  279.         virtual    void    WritePrefs();
  280.         class Protocol
  281.         {
  282.             public:
  283.                 char    *mProtocolServer;
  284.                 Boolean    mServerLocked;
  285.                 Int32    mProtocolPort;
  286.                 Boolean    mPortLocked;
  287.  
  288.                         Protocol();
  289.                         Protocol(const Protocol& original);
  290.                         ~Protocol();
  291.                 void    LoadFromPref(const char *serverPrefName, const char *portPrefName);
  292.                 void    WriteToPref(const char *serverPrefName, const char *portPrefName);
  293.                 void    PreEdit(LView *dialog, ResIDT serverEditID, ResIDT portEditID);
  294.                 void    PostEdit(LView *dialog, ResIDT serverEditID, ResIDT portEditID);
  295.         };
  296.  
  297.         class ManualProxy
  298.         {
  299.             public:
  300.                 Protocol    mFTP;
  301.                 Protocol    mGopher;
  302.                 Protocol    mHTTP;
  303.                 Protocol    mSSL;
  304.                 Protocol    mWAIS;
  305.                 char        *mNoProxyList;
  306.                 Boolean        mNoProxyListLocked;
  307.                 Protocol    mSOCKS;
  308.  
  309.                         ManualProxy();
  310.                         ManualProxy(const ManualProxy& original);
  311.                         ~ManualProxy();
  312.                 void    LoadPrefs();
  313.                 void    WritePrefs();
  314.                 Boolean    EditPrefs();
  315.         };
  316.     private:
  317.         ManualProxy    *mManualProxy;
  318. };
  319.  
  320. #ifdef MOZ_MAIL_NEWS
  321. //======================================
  322. #pragma mark
  323. class CAdvancedDiskSpaceMediator : public CPrefsMediator
  324. //======================================
  325. {
  326.     public:
  327.  
  328.         enum { class_ID = PrefPaneID::eAdvanced_DiskSpace };
  329.         CAdvancedDiskSpaceMediator(LStream*);
  330.         virtual    ~CAdvancedDiskSpaceMediator() {};
  331.  
  332.         virtual void    ListenToMessage(MessageT inMessage, void *ioParam);
  333.  
  334.         virtual    void    LoadMainPane();
  335.  
  336.         static Boolean    DiskSpaceValidationFunc(CValidEditField *editField);
  337. };
  338. #endif // MOZ_MAIL_NEWS
  339.  
  340.