home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / mac / UserInterface / CInlineEditField.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.1 KB  |  128 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. #ifndef __H_CInlineEditField
  20. #define __H_CInlineEditField
  21. #pragma once
  22.  
  23. /*======================================================================================
  24.     AUTHOR:            Ted Morris <tmorris@netscape.com> - 19 SEP 96
  25.  
  26.     DESCRIPTION:    Defines a class for performing inline editing of text fields in a 
  27.                     view. Place an instance of this class into the view in Constructor.
  28.  
  29.     MODIFICATIONS:
  30.  
  31.     Date            Person            Description
  32.     ----            ------            -----------
  33. ======================================================================================*/
  34.  
  35.  
  36. /*====================================================================================*/
  37.     #pragma mark INCLUDE FILES
  38. /*====================================================================================*/
  39.  
  40. #include <LBroadcasterEditField.h>
  41.  
  42.  
  43. #pragma mark -
  44. /*====================================================================================*/
  45.     #pragma mark TYPEDEFS
  46. /*====================================================================================*/
  47.  
  48.  
  49. #pragma mark -
  50. /*====================================================================================*/
  51.     #pragma mark CONSTANTS
  52. /*====================================================================================*/
  53.  
  54.  
  55. #pragma mark -
  56. /*====================================================================================*/
  57.     #pragma mark CLASS DECLARATIONS
  58. /*====================================================================================*/
  59.  
  60. class CInlineEditField : public LBroadcasterEditField {
  61.  
  62. #if !defined(__MWERKS__) || (__MWERKS__ >= 0x2000)
  63.     typedef LBroadcasterEditField inherited;
  64. #endif
  65.  
  66. public:
  67.  
  68.                         enum { class_ID = 'InEd' };
  69.  
  70.                         CInlineEditField(LStream *inStream) :
  71.                                          LBroadcasterEditField(inStream),
  72.                                          mGivingUpTarget(false),
  73.                                          mGrowableBorder(false) {
  74.                             
  75.                             SetRefreshAllWhenResized(false);
  76.                         }
  77.                         
  78.                         // Broadcast messages
  79.                         
  80.                         enum {
  81.                             msg_HidingInlineEditField = 'hIeF'        // PaneIDT *, id of the inline edit field
  82.                                                                     // The edit field in losing the target and
  83.                                                                     // being hidden, update the real text field
  84.                                                                     // to the text contained in this edit field.
  85.                             
  86.                         ,    msg_InlineEditFieldChanged = 'iEfC'        // PaneIDT *, The text of the inline edit field 
  87.                                                                     // has been modified by the user.
  88.                         };
  89.                         
  90.                         // Constants
  91.                         
  92.                         enum {
  93.                             cRefreshMargin = 3
  94.                         ,    cEditBoxMargin = 2
  95.                         };
  96.             
  97.     virtual void        SetDescriptor(ConstStr255Param inDescriptor);
  98.     
  99.     virtual void        UpdateEdit(ConstStr255Param inEditText, const SPoint32 *inImageTopLeft,
  100.                                    SMouseDownEvent *ioMouseDown = nil);
  101.                                  
  102.             void         SetGrowableBorder(Boolean inGrowable);
  103.             Boolean     GetGrowableBorder();
  104.     
  105. protected:
  106.  
  107.     virtual void        FinishCreateSelf(void);
  108.     virtual void        ResizeFrameBy(Int16 inWidthDelta, Int16 inHeightDelta, Boolean inRefresh);
  109.     virtual Boolean        HandleKeyPress(const EventRecord &inKeyEvent);
  110.     virtual void        DontBeTarget(void);
  111.     virtual void        HideSelf(void);
  112.     virtual void        TakeOffDuty(void);
  113.     virtual void        UserChangedText(void);
  114.     
  115.     void                AdjustFrameWidthToText(void);
  116.     
  117.     // Instance variables
  118.     
  119.     Boolean                mGivingUpTarget;
  120.     Boolean                mGrowableBorder;
  121.     LStr255                mOriginalName;
  122. };
  123.  
  124.  
  125.  
  126.  
  127. #endif // __H_CInlineEditField
  128.