home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 11.ddi / OWLSRC.PAK / INPUTDIA.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  2.4 KB  |  93 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1991, 1993 by Borland International
  3. //   source\owl\inputdia.cpp
  4. //   Defines type TInputDialog.  This defines the basic
  5. //   behavior of all input dialogs.
  6. //----------------------------------------------------------------------------
  7. #pragma hdrignore SECTION
  8. #include <owl\owlpch.h>
  9. #include <owl\inputdia.h>
  10. #include <string.h>
  11. #include <owl\edit.h>
  12. #include <owl\validate.h>
  13.  
  14. #if !defined(SECTION) || SECTION == 1
  15.  
  16. TInputDialog::TInputDialog(TWindow*        parent,
  17.                            const char far* title,
  18.                            const char far* prompt,
  19.                            char far*       buffer,
  20.                            int             bufferSize,
  21.                            TModule*        module,
  22.                            TValidator*     valid)
  23.   : TWindow(parent, title, module),
  24.     TDialog(parent, IDD_INPUTDIALOG, module)
  25. {
  26.   PRECONDITION(buffer);
  27.   SetCaption(title);
  28.   Prompt = strnewdup(prompt);
  29.   Buffer = buffer;
  30.   BufferSize = bufferSize;
  31.   if (valid)
  32.     new TEdit(this,ID_INPUT)->SetValidator(valid);
  33. }
  34.  
  35. TInputDialog::~TInputDialog()
  36. {
  37.   delete Prompt;
  38. }
  39.  
  40. //
  41. // sets and gets the values of the items (controls) of the input dialog
  42. //
  43. void
  44. TInputDialog::TransferData(TTransferDirection direction)
  45. {
  46.   if (direction == tdSetData) {
  47.     SetDlgItemText(ID_PROMPT, Prompt);
  48.     SetDlgItemText(ID_INPUT, Buffer);
  49.  
  50.   } else if (direction == tdGetData) {
  51.     GetDlgItemText(ID_INPUT, Buffer, BufferSize);
  52.   }
  53. }
  54.  
  55. //
  56. // sets the values of the items(controls) of the input dialog
  57. //
  58. void
  59. TInputDialog::SetupWindow()
  60. {
  61.   TDialog::SetupWindow();
  62.   SendDlgItemMessage(ID_INPUT, EM_LIMITTEXT, BufferSize - 1, 0);
  63. }
  64.  
  65. #endif
  66. #if !defined(SECTION) || SECTION == 2
  67.  
  68. IMPLEMENT_STREAMABLE2(TInputDialog, TDialog, TWindow);
  69.  
  70. //
  71. // reads an instance of TInputDialog from the passed ipstream
  72. //
  73. void*
  74. TInputDialog::Streamer::Read(ipstream& is, uint32 /*version*/) const
  75. {
  76.   ReadBaseObject((TDialog*)GetObject(), is);
  77.   GetObject()->Prompt = is.freadString();
  78.   return GetObject();
  79. }
  80.  
  81. //
  82. // writes the TInputDialog to the passed opstream
  83. //
  84. void
  85. TInputDialog::Streamer::Write(opstream& os) const
  86. {
  87.   WriteBaseObject((TDialog*)GetObject(), os);
  88.   os.fwriteString(GetObject()->Prompt);
  89. }
  90.  
  91.  
  92. #endif
  93.