home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / PowerPlant / CDimmerCluster / Dimmer srcs / CDimmerCluster.h < prev   
Encoding:
C/C++ Source or Header  |  1995-12-01  |  3.7 KB  |  145 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        CDimmerCluster.h
  3.  
  4.     Contains:    Definitions of the dimmer cluster and dimming edittext classes.
  5.  
  6.     Written by:    Sak Wathanasin
  7.                 Network Analysis Ltd
  8.                 178 Wainbody Ave South
  9.                 Coventry CV3 6BX
  10.                 UK
  11.     Phone:        (+44) 1203 419996
  12.     E-mail:        sw@network-analysis-ltd.co.uk
  13.  
  14.     Thanks to:    Donald E. Carlile who contributed the dimmable caption
  15.                 (carlile@beachnet.gen.ca.us)
  16.     
  17.     Copyright:    © 1995 Network Analysis Ltd. All rights reserved.
  18.                 CDimCaption.cp © Donald E. Carlile
  19.  
  20.     Change History (most recent first):
  21.  
  22.     <1.1>        01/12/95    dec        Add dimmable captions
  23.     <1.0>        07/08/95    sw        First public release.
  24.  
  25.     To Do:
  26. */
  27.  
  28.  
  29. #ifndef __CDimmerCluster__
  30. #define __CDimmerCluster__
  31.  
  32. #ifndef __LView__
  33. #include "LView.h"
  34. #endif
  35.  
  36. // This implements a (transparent) view that dims its sub-panes
  37. // depending on the setting of a distinguished sub-pane (the "master").
  38. // This is often a checkbox, but any LControl sub-class can be used.
  39. // 
  40. // The idea is to use Constructor for most of the hard-work: the pane ID
  41. // of the master is put into the "user constant" field of the view,
  42. //  and each sub-pane that is to be dimmed has its user constant set to 1.
  43.  
  44. class CDimmerCluster : public LView,
  45.                        public LListener
  46. {
  47. public:
  48.     enum { class_ID = 'dimV' };
  49.     enum { cmd_DimGroup = 3000 };
  50.     CDimmerCluster();
  51.     CDimmerCluster(LStream* inStream);
  52.     CDimmerCluster(const SPaneInfo    &inPaneInfo, const SViewInfo &inViewInfo);
  53.     CDimmerCluster(const LView    &inOriginal);
  54.  
  55.     virtual                 ~CDimmerCluster();
  56.     static CDimmerCluster*     CreateDimmerStream(LStream *inStream);
  57.  
  58.     virtual void            FinishCreate();
  59.     
  60.     virtual void            ListenToMessage(MessageT inMessage, void *ioParam);
  61. protected:
  62.     enum tDimState
  63.     {
  64.      eOff, eOn, eWasDimmed
  65.     };
  66.  
  67.     
  68. private:
  69.     LControl*        FindController();
  70.     LControl*        mController;                    // the LControl that specifies whether the remainder is
  71.                                                     // dimmed or not
  72.     
  73. };
  74.  
  75. // This is a sub-class of LEditField that correctly dims the text and
  76. // removes and restores the typing focus.
  77. class CDimmableEditText : public LEditField
  78. {
  79. public:
  80.     enum { class_ID = 'dimE' };
  81.     static CDimmableEditText*
  82.                     CreateDimmableEditTextStream(LStream *inStream);
  83.                     CDimmableEditText();
  84.                     CDimmableEditText(
  85.                            const CDimmableEditText    &inOriginal);
  86.                     CDimmableEditText(
  87.                            const SPaneInfo        &inPaneInfo,
  88.                            Str255                inString,
  89.                            ResIDT                inTextTraitsID,
  90.                            Int16                inMaxChars,
  91.                            Boolean                inHasBox,
  92.                            Boolean                inHasWordWrap,
  93.                            KeyFilterFunc        inKeyFilter,
  94.                            LCommander            *inSuper);
  95.                     CDimmableEditText(
  96.                            const SPaneInfo        &inPaneInfo,
  97.                            Str255                inString,
  98.                            ResIDT                inTextTraitsID,
  99.                            Int16                inMaxChars,
  100.                            Uint8                inAttributes,
  101.                            KeyFilterFunc        inKeyFilter,
  102.                            LCommander            *inSuper);
  103.                     CDimmableEditText(
  104.                            LStream                *inStream);
  105.     virtual void    FinishCreate();
  106.     virtual void    EnableSelf();
  107.     virtual void    DisableSelf();
  108. protected:
  109.     short            mTxMode;
  110.     Boolean            mWasTarget;
  111.     Boolean            WasTarget() {return mWasTarget;}
  112. };
  113.  
  114. //Additions to CDimmerCluster to add dimmable captions
  115. // Donald E. Carlile 1995
  116. #include  <LCaption.h> //Modification by DEC 11/25/95 to dim caption text
  117. class CDimCaption : public LCaption {
  118. public:
  119.     enum { class_ID = 'dimC' };
  120.     static CDimCaption*    CreateDimCaptionStream(LStream            *inStream);
  121.  
  122.                         CDimCaption();
  123.                         CDimCaption(
  124.                                 const CDimCaption    &inCaption);
  125.                         CDimCaption(
  126.                                 const SPaneInfo    &inPaneInfo,
  127.                                 ConstStringPtr    inString,
  128.                                 ResIDT            inTextTraitsID);
  129.                         CDimCaption(
  130.                                 LStream            *inStream);
  131.     virtual                ~CDimCaption();
  132.     
  133. protected:
  134.     enum tDimState
  135.     {
  136.      eOff, eOn, eWasDimmed
  137.     };
  138.     RGBColor    mDimColor;
  139.     virtual void        EnableSelf();
  140.     virtual void        DisableSelf();
  141.     virtual void        DrawSelf();
  142. };
  143.  
  144. #endif
  145.