home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 2.ddi / OWLSRC.ZIP / STATIC.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  2.2 KB  |  70 lines

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. /* --------------------------------------------------------
  4.   STATIC.CPP
  5.   Defines type TStatic.  This defines the basic behavior
  6.   of all static controls.
  7.   -------------------------------------------------------- */
  8.  
  9. #include "static.h"
  10.  
  11. /* Constructor for a TStatic object.  Initializes its data
  12.    fields using passed parameters and default values.   By
  13.    default, an associated static control will have
  14.    left-justified text. */
  15. TStatic::TStatic(PTWindowsObject AParent, int AnId, LPSTR ATitle,
  16.                  int X, int Y, int W, int H, WORD ATextLen, PTModule AModule)
  17.         : TControl(AParent, AnId, ATitle, X, Y, W, H, AModule)
  18. {
  19.   TextLen = ATextLen;
  20.   Attr.Style = (Attr.Style | SS_LEFT) & ~WS_TABSTOP;
  21. }
  22.  
  23. /* Constructor for a TStatic to be associated with a MS-Windows
  24.   interface element created by MS-Windows from a resource definition.
  25.   Initializes its data fields using passed parameters.  Data transfer
  26.   is disabled, by default, for the TStatic. */
  27. TStatic::TStatic(PTWindowsObject AParent, int ResourceId, WORD ATextLen,
  28.                  PTModule AModule)
  29.         : TControl(AParent, ResourceId, AModule)
  30. {
  31.   TextLen = ATextLen;
  32.   DisableTransfer();
  33. }
  34.  
  35. /* Transfers state information for TStatic controls. The TransferFlag passed
  36.   specifies whether data is to be read from or written to the passed
  37.   buffer, or whether the data element size is simply to be returned. The
  38.   return value is the size (in bytes) of the transfer data. */
  39. WORD TStatic::Transfer(Pvoid DataPtr,WORD TransferFlag)
  40. {
  41.   if ( TransferFlag == TF_GETDATA )
  42.     GetText((LPSTR)DataPtr, TextLen);
  43.   else
  44.     if ( TransferFlag == TF_SETDATA )
  45.       SetText((LPSTR)DataPtr);
  46.   return TextLen;
  47. }
  48.  
  49. /* Reads an instance of TStatic from the passed ipstream. */
  50. void *TStatic::read(ipstream& is)
  51. {
  52.   TWindow::read(is);
  53.   is >> TextLen;
  54.   return this;
  55. }
  56.  
  57. /* Writes the TStatic to the passed opstream. */
  58. void TStatic::write(opstream& os)
  59. {
  60.   TWindow::write(os);
  61.   os << TextLen;
  62. }
  63.  
  64. TStreamable *TStatic::build()
  65. {
  66.   return new TStatic(streamableInit);
  67. }
  68.  
  69. TStreamableClass RegStatic("TStatic", TStatic::build, __DELTA(TStatic));
  70.