home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / central / mforms.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  21.8 KB  |  682 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. // mforms.h - Defines form views
  20.  
  21.  
  22. #include <LButton.h>
  23. #include <LCaption.h>
  24. #include <LPane.h>
  25. #include <LStdControl.h>
  26. #include <LListBox.h>
  27. #include <LTextEdit.h>
  28. #include <LGARadioButton.h>
  29. #include <LGACheckbox.h>
  30. #include <LGAPushButton.h>
  31.  
  32. #include <LAttachment.h> // mjc
  33.  
  34. #include "CSimpleTextView.h"    // For CFormBigText
  35. //#include "VEditField.h"
  36. #include "CTSMEditField.h"
  37.  
  38. #include "CKeyUpReceiver.h" // mixin for forms that need to receive key up events
  39.  
  40. #include "PascalString.h"
  41. #include "cstring.h"
  42. #include "PopupBox.h"
  43.  
  44. #include "libmocha.h"
  45.  
  46. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  47. // CLayerClickDispatchAttachment
  48. //
  49. // Attached to a form view to intercept the click and dispatch to layers.
  50. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  51.  
  52. class CLayerClickDispatchAttachment : public LAttachment
  53. {
  54.     public:
  55.                             CLayerClickDispatchAttachment();
  56.         
  57.     protected:
  58.  
  59.         virtual void        ExecuteSelf(
  60.                                     MessageT            inMessage,
  61.                                     void*                ioParam);
  62.                 
  63.         virtual void        MouseDown(const SMouseDownEvent    &inMouseDown);
  64.         
  65.         LControl*            mOwningControl;
  66. };
  67.  
  68.  
  69. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  70. // CLayerClickCallbackMixin
  71. //
  72. // Abstract class which a form view must implement if it has a CLayerClickDispatchAttachment.
  73. // ClickSelfLayer is called from the html view when it receives a layer event which
  74. // is targeted at a form.
  75. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  76. class CLayerClickCallbackMixin
  77. {
  78.     public:
  79.         virtual void        ClickSelfLayer(const SMouseDownEvent &inMouseDown) = 0;
  80. };
  81.  
  82.  
  83. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  84. // CLayerKeyPressDispatchAttachment
  85. //
  86. // Attached to a form view to intercept the keypress and dispatch to layers.
  87. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  88.  
  89. class LFormElement;
  90.  
  91. class CLayerKeyPressDispatchAttachment : public LAttachment
  92. {
  93.     public:
  94.                             CLayerKeyPressDispatchAttachment();
  95.         
  96.     protected:
  97.  
  98.         virtual void        ExecuteSelf(
  99.                                     MessageT            inMessage,
  100.                                     void*                ioParam);
  101.                 
  102.         virtual void        KeyPress(const EventRecord& inKeyEvent);
  103.         
  104.         LFormElement*        mOwner;
  105. };
  106.  
  107. class StSetupFormDrawing
  108. {
  109. private:
  110.     LPane * fForm;    // We assume that form's superview is CHyperView
  111.     RGBColor fFore;    // Old foreground
  112.     RGBColor fBack;    // Old background
  113. public:
  114.     StSetupFormDrawing(LPane * formElement);
  115.     ~StSetupFormDrawing();
  116. };
  117.  
  118. class LFormElement;
  119.  
  120. /*****************************************************************************
  121.  * FE_Data structure in LO_FormElementStruct
  122.  *****************************************************************************/
  123. struct FormFEData    {
  124.     LPane             * fPane;
  125.     LFormElement    * fHost;
  126.     LCommander        * fCommander;
  127.     
  128.     FormFEData();
  129.     ~FormFEData();
  130. };
  131.  
  132.  
  133.  
  134. class LFormElement 
  135. {
  136. public:    
  137.     LFormElement();
  138.     virtual            ~LFormElement();
  139.     virtual void    InitFormElement(MWContext * context, LO_FormElementStruct *lo_element);
  140.     
  141.     // Set to true for non-focusable elements so that their state changes
  142.     // are appropriately reflected
  143.     //
  144.     void            SetReflectOnChange(Boolean reflect) { fReflectOnChange = reflect; }
  145.     
  146.     void            SetLayoutElement(LO_FormElementStruct *lo_element) { fLayoutElement = (LO_Element *) lo_element; }
  147.     LO_Element*        GetLayoutElement() { return fLayoutElement; } // mjc
  148.     MWContext*        GetContext() { return fContext; }
  149.     int16            GetWinCSID() const;
  150.     
  151.     virtual void    ReflectData();    // reflect to XP data structures
  152.     
  153.     virtual void     MochaFocus(Boolean doFocus, Boolean switchTarget=true);
  154.     // 97-06-14 pkc -- virtual callback called from mocha focus callback
  155.     virtual void    PostMochaFocusCallback() {}
  156.         
  157.     virtual void     MochaSelect();
  158.     virtual void    MochaChanged();
  159.     virtual void    MochaSubmit();
  160.     virtual void    SetFEData( FormFEData * data ) { fFEData = data; if (data) fPane = data->fPane; }
  161.     
  162.     void            MarkForDeath();
  163.     inline Boolean    IsMarkedForDeath()    { return fMarkedForDeath; }
  164.     
  165.     void            ClearInFocusCallAlready() { fInFocusCallAlready = false; }
  166.  
  167.     static inline LFormElement*    GetTargetedElement() { return sTargetedFormElement; }
  168.  
  169.     void*        fTimer;
  170.  
  171. protected:
  172.     LPane       *fPane;        // the pane that represents this element
  173.     LO_Element *fLayoutElement;
  174.     FormFEData *fFEData;    // Same thing pointed to by FEDATAPANE
  175.                             // We need a private copy because we might need to access
  176.                             // it after fLayoutElement has been freed
  177.     MWContext  *fContext;
  178.     
  179.     unsigned    fMochaChanged         : 1;
  180.     unsigned    fReflectOnChange    : 1;    // for elements that don't focus
  181.     unsigned    fInFocusCallAlready    : 1;
  182.     unsigned    fMarkedForDeath        : 1;
  183.     
  184.     Boolean        fPreviousFocus;
  185.     static LFormElement *sTargetedFormElement;
  186. };
  187.  
  188.  
  189. // This is a stack based class that tells the currently focused form element
  190. // that it has lost focus and then restores focus to it when destructed.
  191. //
  192. // This is needed because an action may invoke a mocha script that relies
  193. // on the current value of a focussed form field. But form field values
  194. // aren't reflected until focus is lost.  So we fake up losing focus.
  195. //
  196. // For example, the user changes a text field, and clicks on a button 
  197. // that invokes a script that uses the field's value.  Because the field
  198. // doesn't lose focus when the button is clicked, the value the script 
  199. // sees could be wrong.  So when clicking on the button, we must fake
  200. // the loss of focus for the text field.
  201. //
  202. // We do this rather than just reflect the focussed element's value directly
  203. // because other platforms actually transfer focus in these cases.
  204. //
  205. class StTempFormBlur
  206. {
  207. public:
  208.     StTempFormBlur();
  209.     ~StTempFormBlur();
  210.  
  211. private:
  212.  
  213.     LFormElement*    fSavedFocus;
  214. };
  215.  
  216.  
  217.  
  218. /*****************************************************************************
  219.  * class CWhiteEditField
  220.  * Draws on a white background
  221.  *****************************************************************************/
  222. class CWhiteEditField : public CTSMEditField, public LFormElement {
  223. public:
  224.     CWhiteEditField(LStream *inStream);
  225.     
  226.     virtual void    UserChangedText();    // to call MochaChanged
  227.     
  228.     
  229.     virtual Boolean HandleKeyPress(const EventRecord& inKeyEvent);
  230.  
  231. protected:
  232.     virtual void    BeTarget();            // to call MochaFocus
  233.     virtual void    DontBeTarget();        // to call MochaFocus
  234.     // Draws background to white
  235.     void DrawSelf();
  236.     virtual void    ClickSelf(const    SMouseDownEvent& event);    // to call MochaSelect
  237.         
  238. };
  239.  
  240. /*****************************************************************************
  241.  * class CFormLittleText
  242.  * EditField that broadcasts msg_SubmitText when return is pressed inside it.
  243.  * As with all forms, ioParam of the broadcast is 'this'
  244.  * Does not broadcast by default, must call SetBroadcast (just like layout interface)
  245.  *****************************************************************************/
  246. class CFormLittleText: public CWhiteEditField, public LBroadcaster, public CKeyUpReceiver
  247. {
  248. public:
  249.                                 enum { class_ID = 'ftxt' };
  250.  
  251.                                 CFormLittleText( LStream* inStream );
  252.  
  253.     virtual void                FindCommandStatus(
  254.                                     CommandT            inCommand,
  255.                                     Boolean                &outEnabled,
  256.                                     Boolean                &outUsesMark,
  257.                                     Char16                &outMark,
  258.                                     Str255                outName);
  259.     
  260.     // ÑÑ Form interface
  261.     void                        SetBroadcast( Boolean doBroadcast ) { fDoBroadcast = doBroadcast; }
  262.     void                        SetLayoutForm( LO_FormElementStruct* form )    { fLOForm = form; }
  263.     LO_FormElementStruct*        GetLayoutForm() { return fLOForm; }
  264.     
  265.     // Sets the number of visible characters, resizes accordingly
  266.     void                        SetVisibleChars( Int16 visChars );    
  267.     // Broadcast 'this'
  268.     virtual void                BroadcastValueMessage();
  269.     // Broadcast msg_EditSubmit on return
  270.     virtual Boolean                HandleKeyPress(const EventRecord& inKeyEvent);
  271.     virtual StringPtr    GetDescriptor(
  272.                                 Str255                outDescriptor) const;
  273.     virtual void        SetDescriptor(
  274.                                 ConstStr255Param    inDescriptor);
  275. protected:
  276.     virtual void                BeTarget();
  277.  
  278.     LO_FormElementStruct*        fLOForm;            // Layout form*
  279.     Boolean                        fDoBroadcast;        // True if we should broadcast 
  280. };
  281.  
  282. /*****************************************************************************
  283.  * class CFormBigText
  284.  * Large edit text field. Draws full white background;
  285.  *****************************************************************************/
  286.  
  287. class CFormBigText : public CSimpleTextView, public LFormElement, public CKeyUpReceiver {
  288. public:
  289.     enum { class_ID = 'fbtx' };
  290.  
  291. // ÑÑ Constructors/destructors
  292.     CFormBigText(LStream *inStream);
  293.     
  294.     virtual    ~CFormBigText();
  295.     
  296. // ÑÑ Misc
  297.     virtual Boolean ObeyCommand(CommandT inCommand, void *ioParam);
  298.     
  299.     virtual Boolean        FocusDraw(LPane* inSubPane = nil);
  300.     
  301.     virtual Boolean    HandleKeyPress(const EventRecord& inKeyEvent);
  302.     // we hook into the text engine as an attachment so that we know when the text changes
  303. //    virtual void    ListenToMessage(MessageT inMessage, void *ioParam);    // to call MochaChanged
  304.     
  305.     virtual void    UserChangedText(); //  to call MochaChanged
  306.     
  307.     virtual void    ClickSelf(const    SMouseDownEvent& event);            // to call MochaSelect
  308.     virtual void     DontBeTarget();                                        // MochaFocus
  309.     
  310.     //virtual Boolean HandleKeyPress(const EventRecord& inKeyEvent);
  311.  
  312. protected:
  313.     virtual void BeTarget();
  314.     void DrawSelf();// Draws background to white
  315. };
  316.  
  317. /*****************************************************************************
  318.  * class CFormList
  319.  * List used in forms.
  320.  * A wrapper around very bare PPlant's LListBox
  321.  * Has functions for simple element addition, and resizing
  322.  ****************************************************************************/
  323. class CFormList : public LListBox, public LFormElement {
  324.     Int32    fLongestItem;        // String length of the longest item
  325. public:
  326.     enum { class_ID = 'flst' };
  327.  
  328. // ÑÑ Constructors/destructors
  329.  
  330.     CFormList(LStream * inStream);
  331.     ~CFormList();
  332.  
  333. // ÑÑ Forms interface
  334.     void SetSelectMultiple(Boolean multipleSel);
  335.     
  336.     // Add an item to the list - must call AddRow first
  337.     void AddItem (const cstring& itemName, SInt16 inRow);
  338.     
  339.     // Add rows
  340.     void SyncRows( UInt16 nRows );
  341.     
  342.     void SetTextTraits();
  343.     
  344.     // Selecting items
  345.     void SetSelect(int item, Boolean selected);
  346.     void SelectNone();
  347.     
  348.     // Are they selected
  349.     Boolean IsSelected(int item);
  350.     // Resizes the list to the width of the longest item, and visRows
  351.     void ShrinkToFit(Int32 visRows);
  352. // ÑÑ drawing, making sure that background is white
  353.     virtual Boolean        FocusDraw(LPane* inSubPane = nil);    // Sets background to white
  354.     
  355.     
  356.     virtual Boolean    HandleKeyPress(const EventRecord    &inKeyEvent);
  357.     virtual void    ClickSelf(const SMouseDownEvent& event);
  358.     
  359. protected:
  360.     virtual void    BeTarget();        // MochaFocus
  361.     virtual void    DontBeTarget();    // MochaFocus
  362.     virtual void    DrawSelf();
  363.     void            MakeSelection( LArray& list );
  364.     Boolean            CheckSelection( LArray& list );
  365.     virtual void    ActivateSelf();
  366.     virtual void    DeactivateSelf();
  367.     
  368. protected:    //    Added from CCustomListBox (Developer 21)
  369.     virtual void         DrawElement (const short lMessage, const Boolean lSelect, const Rect *lRect,
  370.                                      const void *lElement, const short lDataLen) ;
  371.     virtual void        DrawElementSelf (const Rect *lRect, const void *lElement, const short lDataLen) ;
  372.  
  373. private: //    Added from CCustomListBox (Developer 21)     
  374.       friend pascal void  LDefProc (short lMessage, Boolean lSelect, Rect *lRect,
  375.                                      Cell lCell, unsigned short lDataOffset, unsigned short lDataLen, ListHandle lHandle) ;
  376.  
  377.       static ListDefUPP    callerLDEFUPP ;
  378.       
  379.       enum {
  380.           callerLDEFResID = 1100 
  381.       } ;    
  382. };
  383.  
  384. /*****************************************************************************
  385.  * class CFormButton
  386.  * Button used in forms.
  387.  * Broadcasts itself (this) instead of value when pressed.
  388.  * Also resizes itself to fit the width of the title
  389.  ****************************************************************************/
  390.  
  391. class CFormButton : public LStdButton, public LFormElement, public CLayerClickCallbackMixin {
  392.  
  393. public:
  394.     enum { class_ID = 'fbut' };
  395.  
  396. // ÑÑ Constructors/destructors
  397.  
  398.     CFormButton(LStream * inStream);
  399.  
  400. // ÑÑ Misc
  401.     // After the name is set, resizes the control to fit around it
  402.     virtual void SetDescriptor(ConstStr255Param    inDescriptor);
  403.     // Broadcasts 'this' as an ioParam.
  404.     virtual void BroadcastValueMessage();
  405.  
  406. // Mocha hot spot handling
  407.     virtual void        EventMouseUp(const EventRecord& inEvent);
  408.     virtual void         ClickSelfLayer(const SMouseDownEvent    &inMouseDown); // mjc
  409.     virtual void        HotSpotResult(Int16 inHotSpot);
  410.     void                HotSpotResultCallback(Int16 inHotSpot);
  411.  
  412. protected:
  413.     virtual void        DrawSelf();
  414.     virtual void        DrawTitle();
  415.     virtual void        HotSpotAction(Int16 inHotSpot, Boolean inCurrInside, Boolean inPrevInside);
  416.     virtual Boolean        TrackHotSpot(Int16 inHotSpot, Point inPoint, Int16 inModifiers);
  417.  
  418. };
  419.  
  420. /*****************************************************************************
  421.  * class CGAFormPushButton
  422.  * Button used in forms.
  423.  * Broadcasts itself (this) instead of value when pressed.
  424.  * Also resizes itself to fit the width of the title
  425.  ****************************************************************************/
  426.  
  427. class CGAFormPushButton : public LGAPushButton, public LFormElement, public CLayerClickCallbackMixin {
  428.  
  429. public:
  430.     enum { class_ID = 'Gfpb' };
  431.  
  432.     typedef LGAPushButton super;
  433.     
  434. // ÑÑ Constructors/destructors
  435.  
  436.     CGAFormPushButton(LStream * inStream);
  437.  
  438. // ÑÑ Misc
  439.     // After the name is set, resizes the control to fit around it
  440.     virtual void SetDescriptor(ConstStr255Param    inDescriptor);
  441.     // Broadcasts 'this' as an ioParam.
  442.     virtual void BroadcastValueMessage();
  443.  
  444. // Mocha hot spot handling
  445.     virtual void        EventMouseUp(const EventRecord& inEvent);
  446.     virtual void         ClickSelfLayer(const SMouseDownEvent    &inMouseDown); // mjc
  447.     virtual void        HotSpotResult(Int16 inHotSpot);
  448.     void                HotSpotResultCallback(Int16 inHotSpot);
  449.  
  450. protected:
  451.     virtual void        DrawButtonTitle( Int16    inDepth );
  452.  
  453. };
  454.  
  455. /*****************************************************************************
  456.  * class FormsGlypher
  457.  * Popup Glypher used in forms.
  458.  * Displays a FORM_TYPE_SELECT_ONE structure
  459.  ****************************************************************************/
  460.  
  461. struct lo_FormElementSelectData_struct;
  462. class FormsPopup: public StdPopup, public LFormElement {
  463. public:
  464.  
  465.     // 97-06-15 pkc -- different states for reflecting focus to mocha
  466.     enum EFocusState{
  467.         FocusState_None = 0,
  468.         FocusState_FirstCall,
  469.         FocusState_SecondCall,
  470.         FocusState_ThirdCall,
  471.         FocusState_FourthCall,
  472.         FocusState_FifthCall
  473.     };
  474.                     FormsPopup (CGAPopupMenu * target, lo_FormElementSelectData_struct * selections);
  475.     // interface
  476.     short            GetCount ();
  477.     CStr255            GetText (short item);
  478.     virtual void    ExecuteSelf (MessageT message, void *param);
  479.  
  480.     virtual void    PostMochaFocusCallback();
  481.  
  482. protected:
  483.         // do ScriptCode Menu Trick on IM:MacTbxEss Page3-46
  484.     virtual void    SetMenuItemText(MenuHandle aquiredMenu, int item, CStr255& itemText);
  485.     virtual    void     DrawTruncTextBox (CStr255 text, const Rect& box);
  486.     virtual Boolean    NeedCustomPopup() const;
  487. private:
  488.     virtual    Boolean    NeedDrawTextInOurOwn() const;
  489. private:
  490.     lo_FormElementSelectData_struct * fSelections;
  491.     EFocusState fFocusState;
  492.     LFormElement* fSavedFocus;
  493.     SInt32 fOldValue;
  494. };
  495.  
  496. /*****************************************************************************
  497.  * class CFormRadio
  498.  * Radio buttons used in forms. Have white background
  499.  ****************************************************************************/
  500. class CFormRadio: public LStdRadioButton, public LFormElement, public CLayerClickCallbackMixin {
  501.     static RgnHandle sRadioRgn;
  502.     void    SetupClip();
  503. public:
  504.     enum { class_ID = 'frad' };
  505.  
  506. // ÑÑ Constructors/destructors
  507.  
  508.     CFormRadio(LStream * inStream);
  509.  
  510. // ÑÑ Setting up the drawing environment
  511.     virtual Boolean TrackHotSpot(Int16    inHotSpot,Point inPoint, Int16 inModifiers);
  512.     virtual void SetValue(Int32    inValue);
  513.     
  514. // Mocha
  515.     virtual void    EventMouseUp(const EventRecord& inEvent);
  516.     virtual void     ClickSelfLayer(const SMouseDownEvent    &inMouseDown); // mjc
  517.     virtual void    HotSpotResult(Int16 inHotSpot);
  518.             void    HotSpotResultCallback(Int16 inHotSpot, 
  519.                                 LO_FormElementStruct* oldRadio,
  520.                                 Int16 savedValue,
  521.                                 MWContext * context);
  522.  
  523. protected:
  524.     virtual void DrawSelf();
  525. };
  526.  
  527. /*****************************************************************************
  528.  * class CGAFormRadio
  529.  * Radio buttons used in forms. Have white background
  530.  ****************************************************************************/
  531. class CGAFormRadio: public LGARadioButton, public LFormElement, public CLayerClickCallbackMixin
  532. {
  533. public:
  534.     enum { class_ID = 'Gfrb' };
  535.     
  536.     typedef LGARadioButton super;
  537.  
  538.     
  539.                     CGAFormRadio(LStream* inStream);
  540.  
  541.     virtual Boolean TrackHotSpot(
  542.                                     Int16    inHotSpot,
  543.                                     Point    inPoint,
  544.                                     Int16 inModifiers);
  545.     virtual void    SetValue(Int32    inValue);
  546.     
  547. // Mocha
  548.     virtual void    EventMouseUp(const EventRecord& inEvent);
  549.     virtual void     ClickSelfLayer(const SMouseDownEvent    &inMouseDown); // mjc
  550.     virtual void    HotSpotResult(Int16 inHotSpot);
  551.             void    HotSpotResultCallback(Int16 inHotSpot, 
  552.                                 LO_FormElementStruct* oldRadio,
  553.                                 Int16 savedValue,
  554.                                 MWContext * context);
  555.                                 
  556. protected:
  557.     virtual void    DrawSelf();
  558. };
  559.  
  560. /*****************************************************************************
  561.  * class CFormCheckbox
  562.  * Checkboxes used in forms. Have white background.
  563.  * Very much like CFormRadio
  564.  ****************************************************************************/
  565. class CFormCheckbox: public LStdCheckBox, public LFormElement, public CLayerClickCallbackMixin {
  566.     static RgnHandle sCheckboxRgn;
  567.     void    SetupClip();
  568. public:
  569.     enum { class_ID = 'fchk' };
  570.  
  571. // ÑÑ Constructors/destructors
  572.  
  573.     CFormCheckbox(LStream * inStream);
  574.  
  575. // ÑÑ Setting up the drawing environment
  576.     virtual Boolean TrackHotSpot(Int16    inHotSpot,Point inPoint, Int16 inModifiers);
  577.     virtual void SetValue(Int32    inValue);
  578.  
  579.     virtual void    EventMouseUp(const EventRecord& inEvent);
  580.     virtual void     ClickSelfLayer(const SMouseDownEvent    &inMouseDown); // mjc
  581.     virtual void    HotSpotResult(Int16 inHotSpot);
  582.     void            HotSpotResultCallback( Int16 inHotSpot, Int16 savedValue );
  583.  
  584. protected:
  585.     virtual void DrawSelf();
  586. };
  587.  
  588. /*****************************************************************************
  589.  * class CGAFormCheckbox
  590.  * Checkboxes used in forms. Have white background.
  591.  * Very much like CFormRadio
  592.  ****************************************************************************/
  593. class CGAFormCheckbox: public LGACheckbox, public LFormElement, public CLayerClickCallbackMixin
  594. {
  595. public:
  596.     enum { class_ID = 'Gfcb' };
  597.     
  598.     typedef LGACheckbox super;
  599.     
  600.                     CGAFormCheckbox(LStream* inStream);
  601.  
  602.     virtual Boolean TrackHotSpot(
  603.                                     Int16    inHotSpot,
  604.                                     Point    inPoint,
  605.                                     Int16 inModifiers);
  606.     virtual void    SetValue(Int32    inValue);
  607.     
  608. // Mocha
  609.     virtual void    EventMouseUp(const EventRecord& inEvent);
  610.     virtual void     ClickSelfLayer(const SMouseDownEvent    &inMouseDown); // mjc
  611.     virtual void    HotSpotResult(Int16 inHotSpot);
  612.     void            HotSpotResultCallback( Int16 inHotSpot, Int16 savedValue );
  613.                                 
  614. protected:
  615.     virtual void    DrawSelf();
  616. };
  617.  
  618. /*****************************************************************************
  619.  * class CFormFile
  620.  * File upload buttons used in forms
  621.  * This element has all the smarts. It knows how to:
  622.  * Resize
  623.  * Select files
  624.  ****************************************************************************/
  625. class CFormFileEditField;
  626. class CFormFile : public LView , public LListener, public LFormElement {
  627. public:
  628.     enum { class_ID = 'ffil' };
  629.  
  630. // ÑÑ Constructors/destructors
  631.  
  632.     CFormFile(LStream * inStream);
  633.     virtual void    FinishCreateSelf();
  634.     void    SetVisibleChars(Int16 numOfChars);
  635.     void    GetFontInfo(Int32& width, Int32& height, Int32& baseline);
  636. // ÑÑ Access
  637.     Boolean GetFileSpec(FSSpec & spec);
  638.     void    SetFileSpec(FSSpec & spec);
  639.  
  640. // ÑÑ╩Misc
  641.     virtual void ListenToMessage(MessageT inMessage, void *ioParam);
  642.  
  643.     CFormFileEditField * fEditField;
  644.  
  645. private:
  646.  
  647.     FSSpec fSpec;    // Our file specs
  648.     Boolean fHasFile;
  649.     LStdButton * fButton;
  650. };
  651.  
  652. /*****************************************************************************
  653.  * CFormFileEditField
  654.  * Text field of the file upload widget.
  655.  * according to the specs it needs to be non-editable, only action you
  656.  * can do inside it is cut/delete key.
  657.  * On a click, it is always highlited
  658.  ****************************************************************************/
  659. class CFormFileEditField : public LEditField    {
  660. public:
  661.     enum { class_ID = 'ffie' };
  662.     friend class CFormFile;
  663. // ÑÑ Constructors/destructors
  664.  
  665.     CFormFileEditField(LStream * inStream);
  666.  
  667. // ÑÑ╩Misc -- overrides so that you can only click and delete
  668.     virtual    void SpendTime(const EventRecord &/*inMacEvent*/) {};  // Don't blink cursor
  669.     virtual Boolean    HandleKeyPress(const EventRecord&    inKeyEvent);
  670.     virtual void FindCommandStatus(CommandT    inCommand,
  671.                             Boolean        &outEnabled,
  672.                             Boolean        &outUsesMark,
  673.                             Char16        &outMark,
  674.                             Str255        outName);
  675.     virtual void UserChangedText();
  676.  
  677. protected:
  678.     virtual void ClickSelf(const SMouseDownEvent    &inMouseDown);
  679.     virtual void DrawSelf();
  680. };
  681.  
  682.