home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / mac / UserInterface / UStdDialogs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  6.5 KB  |  233 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 <UModalDialogs.h>
  22.  
  23. #include "PascalString.h"
  24.  
  25. const ResIDT cDefaultTextTraitsID = 128;
  26. const ResIDT cPasswordTextTraitsID = 4000;
  27.  
  28. const Int16 cDialogSpacing = 13;
  29.  
  30. const PaneIDT    PaneID_AlertCaption     =     'capt';
  31. const PaneIDT    PaneID_AlertIcon        =    'icon';
  32. const PaneIDT    PaneID_AlertEditField    =    'edit';
  33. const PaneIDT    PaneID_PasswordEditName =    'name';
  34. const PaneIDT    PaneID_PasswordEditPass    =    'pass';
  35. const PaneIDT    PaneID_MessageCaption    =    'mesg';
  36.  
  37.  
  38. enum {
  39.     WIND_NameAndPassword                =    16000,
  40.     WIND_Password,
  41.     WIND_StandardAlert,
  42.     WIND_Resizeable,
  43.     WIND_OkCancelAlert,
  44.     WIND_BigMessageAlert,
  45.     WIND_MessageDialog        // for non-alert uses of FE_Alert
  46. };
  47.  
  48.  
  49. enum EAlertType {
  50.     eAlertTypeStop = 1,
  51.     eAlertTypeNote,
  52.     eAlertTypeCaution,
  53.     eAlertTypeError
  54. };
  55.  
  56. enum EAlertIconID {
  57.     eAlertIconStop = 10000,
  58.     eAlertIconNote,
  59.     eAlertIconCaution,
  60.     eAlertIconError = eAlertIconCaution
  61. };
  62.  
  63. enum {
  64.     FORMAT_TEXT,
  65.     FORMAT_HTML
  66. };
  67.  
  68. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  69.  
  70. class StStdDialogHandler : public StDialogHandler
  71. {
  72.         enum {
  73.             noAutoCenter                    = 0x0000,
  74.             centerMainScreen                = 0x280A,
  75.             alertPositionMainScreen            = 0x300A,
  76.             staggerMainScreen                = 0x380A,
  77.             centerParentWindow                = 0xA80A,
  78.             alertPositionParentWindow        = 0xB00A,
  79.             staggerParentWindow                = 0xB80A,
  80.             centerParentWindowScreen        = 0x680A,
  81.             alertPositionParentWindowScreen    = 0x700A,
  82.             staggerParentWindowScreen        = 0x780A
  83.         };
  84.  
  85.     public:
  86.                             StStdDialogHandler(
  87.                                     ResIDT                inDialogID,
  88.                                     LCommander*         inSuper);
  89.                                     
  90.         void                SetInitialDialogPosition(LWindow* inParentWindow);
  91.         virtual    MessageT    WaitUserResponse(void);
  92.  
  93.         void                SetCaption(ConstStringPtr inCaption);
  94.     
  95.         // Handy macros
  96.         LPane*                GetPane(PaneIDT id);
  97.         LPane*                GetControl(PaneIDT id) { return (LControl*)GetPane(id); }
  98.         void                HidePane(PaneIDT id);
  99.         void                ShowPane(PaneIDT id);
  100.         void                EnablePane(PaneIDT id);
  101.         void                DisablePane(PaneIDT id);
  102.         void                SetValue(PaneIDT id, Int32 value);
  103.         Int32                GetValue(PaneIDT id);
  104.         void                SetBoolean(PaneIDT id, Boolean value);
  105.         Boolean                GetBoolean(PaneIDT id);
  106.         void                SetText(PaneIDT id, ConstStr255Param value);
  107.         void                SetNumberText(PaneIDT id, SInt32 value);
  108.         void                GetText(PaneIDT id, Str255 value);
  109.         SInt32                GetNumberText(PaneIDT id);
  110.  
  111.     protected:
  112.  
  113.         void                CalcDialogTargetBounds(
  114.                                 Int16                     inPlacement,
  115.                                 LWindow*                inParentWindow,
  116.                                 Rect&                    outBounds);
  117.  
  118.         Int16                CalcDialogPlacement(void);
  119.  
  120.     private:
  121.  
  122.         ResIDT                mDialogResID;
  123. };
  124.  
  125. class StAlertHandler : public StStdDialogHandler
  126. {
  127.     public:
  128.                         StAlertHandler(
  129.                                 ConstStringPtr             inAlertText,
  130.                                 EAlertType                inAlertType,
  131.                                 LCommander*                inSuper);
  132.                                 
  133.                         StAlertHandler(
  134.                                 ResIDT                    inStrListID,
  135.                                 Int16                     inIndex,
  136.                                 EAlertType                inAlertType,
  137.                                 LCommander*                inSuper);
  138.     protected:
  139.         
  140.         void            SetAlertTitle(ConstStringPtr inTitle);
  141.         void            SetAlertIcon(EAlertType    inAlertType);
  142. };
  143.  
  144. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  145.  
  146. class StAutoSizingDialog : public StStdDialogHandler
  147. {
  148.     public:
  149.                         StAutoSizingDialog(
  150.                                 ResIDT                    inDialogID,
  151.                                 const CString&    inAlertText,
  152.                                 const CString&    inDefaultEditText,
  153.                                 LCommander*                inSuper);
  154.  
  155.         void            SetInitialDialogSize(void);
  156. };
  157.  
  158. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  159.  
  160. class UStdDialogs
  161. {
  162.     public:
  163.         static void        Alert(
  164.                                 ConstStringPtr        inAlertText,
  165.                                 EAlertType            inType,
  166.                                 LWindow*            inOverWindow = NULL,
  167.                                 LCommander*            inSuper = NULL,
  168.                                 LStr255*            inWindowTitle = NULL
  169.                                 );
  170.         
  171.         static Boolean    AskWithCustomButtons(
  172.                                 ConstStringPtr         inQuestion,
  173.                                 ConstStringPtr        inDefaultTextBtn = nil,
  174.                                 ConstStringPtr        inCancelTextBtn = nil,
  175.                                 LWindow*            inOverWindow = nil,
  176.                                 LCommander*            inSuper = nil,
  177.                                 LStr255*            inWindowTitle = nil
  178.                                 );
  179.                                 
  180.         static Boolean     AskOkCancel(
  181.                                 ConstStringPtr        inQuestion,
  182.                                 LWindow*            inOverWindow = NULL,
  183.                                 LCommander*            inSuper = NULL,
  184.                                 LStr255*            inWindowTitle = NULL);
  185.  
  186.         static Boolean    AskStandardTextPrompt(
  187.                                 const CStr255&        inTitleText,
  188.                                 const CStr255&        inPromptText,
  189.                                 CString&            ioString,
  190.                                 LWindow*            inOverWindow = NULL,
  191.                                 LCommander*            inSuper = NULL,
  192.                                 Int32                 maxIOStringSize = 255);
  193.  
  194.         static Boolean    AskForPassword(
  195.                                 const CString&        inPromptText,
  196.                                 CString&            ioPassString,
  197.                                 LWindow*            inOverWindow = NULL,
  198.                                 LCommander*            inSuper = NULL);
  199.  
  200.         static Boolean    AskForNameAndPassword(
  201.                                 const CString&    inPromptText,
  202.                                 CString&    ioNameString,
  203.                                 CString&    ioPassString,
  204.                                 LWindow*            inOverWindow = NULL,
  205.                                 LCommander*            inSuper = NULL);
  206.  
  207.  
  208.         static OSErr    AskSaveAsTextOrSource(
  209.                                 StandardFileReply&     ioReply,
  210.                                 const CString& initialFilename,
  211.                                 Int16&                 ioFormat);
  212.  
  213.         static OSErr    AskSaveAsSource(
  214.                                 StandardFileReply&     ioReply,
  215.                                 const CString& initialFilename,
  216.                                 Int16&                 ioFormat);
  217.                         
  218.  
  219.         static OSErr    AskUploadAsDataOrMacBin(
  220.                                 StandardFileReply&     ioReply,
  221.                                 Int16&                 ioFormat);
  222.  
  223.         static Boolean     TryToInteract(Int32 inForSeconds = -1);
  224.  
  225. // FIX ME -- this is commented out to get editor to compile                         
  226. //    protected:
  227.     
  228.             // dialog hook function for CustomPutFile call
  229.         static pascal short SaveAsHook( short item, DialogPtr dialog, void* dataPtr );
  230.             // dialog hook function for CustomGetFile call
  231.         static pascal short UploadAsHook( short item, DialogPtr dialog, void* dataPtr );
  232. };
  233.