//********************************************************************************
//* File       : AnsiCmdDlg.hpp                                                  *
//* Author     : Mahlon R. Smith                                                 *
//*              Copyright (c) 2022-2026 Mahlon R. Smith, The Software Samurai   *
//*                 GNU GPL copyright notice below                               *
//* Date       : 19-Sep-2025                                                     *
//* Version    : (see AnsiCmdVersion string in AnsiCmd.cpp)                      *
//*                                                                              *
//* Description: ACDlg class definition.                                         *
//*              The AnsiCmd Dialog is a dialog window within, and controlled by *
//*              the parent ACWin-class object.                                  *
//*                                                                              *
//********************************************************************************

#if DEBUG_ANSICMD != 0 && DEBUG_LOG != 0
extern ofstream ofsdbg ;
extern gString  gsdbg ;
#endif   // DEBUG_ANSICMD && DEBUG_LOG

//* Constants used for dialogs and dialog controls *
const short dctLEN = 255 ;  // max length of dialog control text
const short dvMIN = 3 ;     // dialog vertical minimum (borders + 1 interior row)
const short dvPAD = 2 ;     // dialog vertical padding (top and bottom borders)
const short dwPAD = 4 ;     // dialog width padding (borders + 1 column on each side)
const short MAX_DLG_CTRLS = 24 ; // maximum number of controls for a dialog window
const short MAX_TIT = 128 ; // max bytes for title text

//* Type definition for callback function for external update of dialog. *
//* This is the same definition as defined for the ACWin class, but      *
//* that definition may not be seen within this module.                  *
#ifndef CUPTR
typedef wchar_t (*CUPTR)( short ctrlIndex, wchar_t wkey, bool firstTime ) ;
#endif

//******************************************************
//* Dialog window for user information or interaction. *
//* Methods and data are "protected"; that is, they are*
//* accessible only through the parent ACWin object.   *
//******************************************************
class ACDlg
{
   //** Protected Methods **
   protected:
   ~ACDlg ( void )      // destructor - release the dynamic allocation
   { if ( this->skf != NULL ) delete this->skf ; }

   ACDlg ( short hgt, short wid, short vOff, short hOff, const skForm* form, 
           const gString& text, const gString& title, LineType lnType = ltSINGLE, 
           acAttr bAttr = acaUSEDFLT, acAttr tAttr = acaUSEDFLT, 
           short tVOff = ZERO, short tHoff = 1, CUPTR callbk = NULL ) ;

   //* Default Constructor *
   ACDlg ( void ) { /* Default constructor is not used.*/ }

   //* Reset all data members to default values. *
   void reset ( void )
   {
      this->dHeight = ZERO ;              // dialog automatically sized to accomodate
      this->dWidth  = ZERO ;              //  dimensions of text in dText
      this->dtxtPos = { 0, 1 } ;          // text position is on top row and inset 
                                          //  one column from left edge of dialog
      this->lType   = ltSINGLE ;          // single-line border style
      this->bdrAttr = acaUSEDFLT ;        // use parent window text attributes by default
      this->txtAttr = acaUSEDFLT ;        // use parent window text attributes by default
      this->skf     = NULL ;              // control array not yet allocated
      this->cbptr   = NULL ;              // no callback method specified
      // dText and dTitle are initially empty strings
   }

   //** Protected Data Members **
   gString dText ;            // static dialog text
   gString dTitle ;           // dialog title text
   WinPos  dBase ;            // window-relative position of dialog
   WinPos  dtxtPos ;          // dialog-relative position of static dialog text
   short   dHeight ;          // height in rows (zero==variable height)
   short   dWidth ;           // width in columns (zero==variable width)
   LineType lType ;           // border line style: ltSINGLE or ltDUAL
   acAttr  bdrAttr ;          // border color attributes
   acAttr  txtAttr ;          // interior (text) color attributes
   skForm* skf ;              // pointer to skForm object with associated skField array
   CUPTR   cbptr ;            // pointer to callback function

   friend class ACWin ;       // ACWin class has access to protected members
} ;   // ACDlg
