home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / powervww / pvinput.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-05  |  19.8 KB  |  887 lines

  1. //  ____________________________________________________
  2. // |                                                    |
  3. // |  Project:     POWER VIEW INTERFACE                 |
  4. // |  File:        PVINPUT.CPP                          |
  5. // |  Compiler:    WPP386 (10.6)                        |
  6. // |                                                    |
  7. // |  Subject:     Input box implementation             |
  8. // |                                                    |
  9. // |  Author:      Emil Dotchevski                      |
  10. // |____________________________________________________|
  11. //
  12. // E-mail: zajo@geocities.com
  13. // URL:    http://www.geocities.com/SiliconValley/Bay/3577
  14.  
  15. #define uses_stdio
  16. #define uses_math
  17. #define uses_string
  18. #define uses_basics
  19. #define uses_dc
  20. #define uses_dialog
  21. #define uses_hist
  22. #define uses_icons
  23. #define uses_input
  24. #define uses_lines
  25. #define uses_stddlg
  26. #define uses_system
  27.  
  28. #include "PVuses.h"
  29.  
  30.  
  31. //Tinput_editor publics:
  32.  
  33. Tinput_editor::Tinput_editor(  char *_line, int _max_len, int _xl ):
  34.   Tmemo( _line, _max_len+1, _xl, 1 )
  35. {
  36.   ~text_editor->valid_chars;
  37.   for( int i = 32; i < 256; i++ )
  38.     text_editor->valid_chars << i;
  39.   left_icon = NEW( Ticon( "|i", cmLEFT_ARROW, 0 ) );
  40.     left_icon->set_flags( bfREPEAT, 1 );
  41.     left_icon-> set_state( isHIDDEN, 1 );
  42.     put_in( left_icon, -1, 0 );
  43.   right_icon = NEW( Ticon( "|i", cmRIGHT_ARROW, 0 ) );
  44.     right_icon->set_flags( bfREPEAT, 1 );
  45.     put_in( right_icon, xl, 0 );
  46.     right_icon->set_state( isHIDDEN, 1 );
  47. }
  48.  
  49. void Tinput_editor::scroll_to( int _x, int _y )
  50. {
  51.   int l;
  52.  
  53.   l = text_editor->buf_len - _x;
  54.   if( l < xl - 1 )
  55.   {
  56.     _x += l - xl + 1;
  57.     if( _x < 0 ) _x = 0;
  58.   }
  59.   Teditor::scroll_to( _x, _y );
  60. }
  61.  
  62. //Tinput_editor protected:
  63.  
  64. void Tinput_editor::get_focused( void )
  65. {
  66.   text_editor->set_select( 0, text_editor->buf_len, 1 );
  67. }
  68.  
  69. #ifndef HGR
  70. void Tinput_editor::set_palette( void )
  71. {
  72.   Teditor::set_palette();
  73.   if( !graph_flag )
  74.   {
  75.     text_attr = rolb( text_attr, 4 );
  76.     bold_attr &= 0x0F;
  77.     bold_attr |= (char) ( text_attr & 0xF0 );
  78.   }
  79. }
  80. #endif
  81.  
  82. void Tinput_editor::event_handler( Tevent &ev )
  83. {
  84.   Teditor::event_handler( ev );
  85.   if( state( isFOCUSED ) && ( ev.code == evCOMMAND ) )
  86.   {
  87.     switch( ev.CMD_CODE )
  88.     {
  89.       case cmLEFT_ARROW:
  90.         scroll_to( delta_x - 1, 1 ); break;
  91.       case cmRIGHT_ARROW:
  92.         scroll_to( delta_x + 1, 1 ); break;
  93.       default:
  94.         goto hot;
  95.     }
  96.     redraw();
  97.     handled( ev );
  98.   }
  99. hot:
  100.   left_icon->set_state( isHIDDEN, !delta_x );
  101.   right_icon->set_state( isHIDDEN, ( text_editor->buf_len - delta_x ) < xl );
  102.   if( item_acted == this ) item_acted = owner;
  103. }
  104.  
  105. void Tinput_editor::convert_event( Tevent &ev )
  106. {
  107.   Tevent svd;
  108.  
  109.   svd = ev;
  110.   Teditor::convert_event( ev );
  111.   if( ( ev.code == evCOMMAND ) && ( ev.CMD_CODE >= cmeLINE_UP ) &&
  112.      ( ev.CMD_CODE <= cmeNEW_LINE ) ) ev = svd;
  113. }
  114.  
  115.  
  116. //Tinput publics:
  117.  
  118. Tinput::Tinput( char *_prompt, char *_line, int _max_length, int _xl ):
  119.   Tcombo_item( _prompt, _xl + 3 )
  120. {
  121.   init( _line, _max_length, _xl );
  122. #ifndef NOHIST
  123.   history_id = NULL;
  124. #endif
  125. }
  126.  
  127. #ifndef NOHIST
  128. Tinput::Tinput( char *_prompt, char *_line, int _max_length, int _xl, Tlb_list *_hist ):
  129.   Tcombo_item( _prompt, _xl + 3, _hist )
  130. {
  131.   init( _line, _max_length, _xl );
  132.   put_in( NEW( Thistory( _hist ) ), xl, 0 );
  133. }
  134. #endif
  135.  
  136. void Tinput::set_data( uint i )
  137. {
  138.   char s[256];
  139.  
  140.   gettxt( i, s );
  141.   set_txt( s );
  142. }
  143.  
  144. void Tinput::get_data( char *s )
  145. {
  146.   editor->text_editor->get_line_str( s, editor->text_editor->buf_len );
  147. }
  148.  
  149. void Tinput::set_txt( char *s )
  150. {
  151.   char tmp[256];
  152.  
  153.   strcpy( tmp, s );
  154.   if( strlen( tmp ) > editor->text_editor->buf_size ) tmp[editor->text_editor->buf_size] = 0;
  155.   editor->text_editor->set_select( 0, editor->text_editor->buf_len, 1 );
  156.   editor->text_editor->insert_string( tmp, 0 );
  157.   redraw();
  158.   item_acted = this;
  159. }
  160.  
  161. void Tinput::get_txt( char *s )
  162. {
  163.   editor->text_editor->get_line_str( s, editor->text_editor->buf_len );
  164. }
  165.  
  166. //Tinput protected:
  167.  
  168. void Tinput::draw( void )
  169. {
  170. #ifndef HGR
  171.   if( !graph_flag )
  172.   {
  173.     selected_attr = rolb( selected_attr, 4 );
  174.     text_attr = rolb( text_attr, 4 );
  175.     txtf( "|%c%s|r%c %s", state(isDISABLED)?'d':'t', i_left_line, xl - 2, i_right_line );
  176.     return;
  177.   }
  178. #endif
  179.   txtf( "%s|r%c %s", i_left_line, xl - 2, i_right_line );
  180. }
  181.  
  182. void Tinput::get_focused( void )
  183. {
  184.   editor->text_editor->set_select( 0, editor->text_editor->buf_len, 1 );
  185. }
  186.  
  187. boolean Tinput::release_focus( void )
  188. {
  189.   if( Tcombo_item::release_focus() )
  190.   {
  191.     editor->text_editor->hide_select();
  192.     return 1;
  193.   }
  194.   return 0;
  195. }
  196.  
  197. //Tinput private:
  198.  
  199. void Tinput::init( char *_line, int _max_length, int _xl )
  200. {
  201.   editor = NEW( Tinput_editor( _line, _max_length, _xl + 1 ) );
  202.   put_in( editor, 1, 0 );
  203.   put_in( NEW( Tline0( xl ) ), x, 1 );
  204.   put_in( NEW( Tline1( xl ) ), x, -1 );
  205. }
  206.  
  207.  
  208. //Tlinput publics:
  209.  
  210. Tlinput::Tlinput ( char *_prompt, long &_data, long _min, long _max ):
  211.   Tinput( _prompt, lin, len, init_len( _min, _max ) )
  212. {
  213.   init( _data, _min, _max );
  214. }
  215.  
  216. #ifndef NOHIST
  217. Tlinput::Tlinput( char *_prompt, long &_data, long _min, long _max, Tlb_list *_hist ):
  218.   Tinput( _prompt, lin, len, init_len( _min, _max ), _hist )
  219. {
  220.   init( _data, _min, _max );
  221. }
  222. #endif
  223.  
  224. boolean Tlinput::valid( uint stop_st )
  225. {
  226.   long v;
  227.   char line[256], *end_ptr;
  228.   Tcombo_item::valid( stop_st );
  229.   if( stop_st == cmCANCEL ) return 1;
  230.   get_txt( line );
  231.   v = strtol( line, &end_ptr, hex?16:10 );
  232.   if( (!v && *end_ptr) || v<min || v>max )
  233.   {
  234. #ifdef CYR
  235.     sprintf( line, "æ▓«⌐¡«▒▓▓á ¡Ñ Ñ ó὿ñ¡á.\n\n┐ ó║óÑñÑ▓Ñ ñ░│ú« ╢┐½« ╖¿▒½« ¼Ñªñ│ %%l%c ¿ %%l%c ", hex?'x':'d', hex?'x':'d' );
  236. #else
  237.     sprintf( line, "Value not within the valid range.\n\nPlease enter new integer value between %%l%c and %%l%c ", hex?'x':'d', hex?'x':'d' );
  238. #endif
  239.     focus(); _terror();
  240.     ok( line, min, max );
  241.     return 0;
  242.   }
  243.   *data = v;
  244.   return 1;
  245. }
  246.  
  247. void Tlinput::set_num( long n )
  248. {
  249.   char s[256];
  250.  
  251.   n = maxl( n, min );
  252.   n = minl( n, max );
  253.   ltoa( n, s, hex?16:10 );
  254.   set_txt( s );
  255. }
  256.  
  257. long Tlinput::get_num( void )
  258. {
  259.   char s[256];
  260.  
  261.   get_txt( s );
  262.   return atol( s );
  263. }
  264.  
  265. //Tlinput private:
  266.  
  267. char Tlinput::init_len( long _min, long _max )
  268. {
  269.   hex = __hexnum();
  270.   ltoa( _min, lin, hex?16:10 ); len = (char) strlen( lin );
  271.   ltoa( _max, lin, hex?16:10 ); if( strlen( lin ) > len ) len = (char) strlen( lin );
  272.   return len;
  273. }
  274.  
  275. void Tlinput::init( long &_data, long _min, long _max )
  276. {
  277.   ltoa( _data, lin, hex?16:10 );
  278.   set_txt( lin );
  279.   data = &_data; min = _min; max = _max;
  280.   ~editor->text_editor->valid_chars;
  281.   editor->text_editor->valid_chars << '-';
  282.   for( int i = '0'; i <= '9'; i++ )
  283.     editor->text_editor->valid_chars << i;
  284.   if( hex )
  285.   {
  286.     for( i = 'A'; i <= 'F'; i++ )
  287.       editor->text_editor->valid_chars << i;
  288.     for( i = 'a'; i <= 'f'; i++ )
  289.       editor->text_editor->valid_chars << i;
  290.   }
  291. }
  292.  
  293.  
  294. //Tiinput publics:
  295.  
  296. Tiinput::Tiinput( char *_prompt, int &_data, int _min, int _max ):
  297.   Tlinput( _prompt, tmp, _min, _max )
  298. {
  299.   set_num( _data );
  300.   tmp = _data;
  301.   dta = &_data;
  302. }
  303.  
  304. #ifndef NOHIST
  305. Tiinput::Tiinput( char *_prompt, int &_data, int _min, int _max, Tlb_list *_hist ):
  306.   Tlinput( _prompt, tmp, _min, _max, _hist )
  307. {
  308.   set_num( _data );
  309.   tmp = _data;
  310.   dta = &_data;
  311. }
  312. #endif
  313.  
  314. boolean Tiinput::valid( uint stop_st )
  315. {
  316.   boolean result;
  317.  
  318.   result = Tlinput::valid( stop_st );
  319.   *dta = tmp;
  320.   return result;
  321. }
  322.  
  323.  
  324. //Tsinput publics:
  325.  
  326. Tsinput::Tsinput( char *_prompt, short &_data, short _min, short _max ):
  327.   Tlinput( _prompt, tmp, _min, _max )
  328. {
  329.   set_num( _data );
  330.   tmp = _data;
  331.   dta = &_data;
  332. }
  333.  
  334. #ifndef NOHIST
  335. Tsinput::Tsinput( char *_prompt, short &_data, short _min, short _max, Tlb_list *_hist ):
  336.   Tlinput( _prompt, tmp, _min, _max, _hist )
  337. {
  338.   set_num( _data );
  339.   tmp = _data;
  340.   dta = &_data;
  341. }
  342. #endif
  343.  
  344. boolean Tsinput::valid( uint stop_st )
  345. {
  346.   boolean result;
  347.  
  348.   result = Tlinput::valid( stop_st );
  349.   *dta = (short) tmp;
  350.   return result;
  351. }
  352.  
  353.  
  354. //Tcinput publics:
  355.  
  356. Tcinput::Tcinput( char *_prompt, char &_data, char _min, char _max ):
  357.   Tlinput( _prompt, tmp, _min, _max )
  358. {
  359.   set_num( _data );
  360.   tmp = _data;
  361.   dta = &_data;
  362. }
  363.  
  364. #ifndef NOHIST
  365. Tcinput::Tcinput( char *_prompt, char &_data, char _min, char _max, Tlb_list *_hist ):
  366.   Tlinput( _prompt, tmp, _min, _max, _hist )
  367. {
  368.   set_num( _data );
  369.   tmp = _data;
  370.   dta = &_data;
  371. }
  372. #endif
  373.  
  374. boolean Tcinput::valid( uint stop_st )
  375. {
  376.   boolean result;
  377.  
  378.   result = Tlinput::valid( stop_st );
  379.   *dta = (char) tmp;
  380.   return result;
  381. }
  382.  
  383.  
  384. //Twinput publics:
  385.  
  386. Twinput::Twinput( char *_prompt, word &_data, word _min, word _max ):
  387.   Tlinput( _prompt, tmp, _min, _max )
  388. {
  389.   set_num( _data );
  390.   tmp = _data;
  391.   dta = &_data;
  392.   editor->text_editor->valid_chars >> '-';
  393. }
  394.  
  395. #ifndef NOHIST
  396. Twinput::Twinput( char *_prompt, word &_data, word _min, word _max, Tlb_list *_hist ):
  397.   Tlinput( _prompt, tmp, _min, _max, _hist )
  398. {
  399.   set_num( _data );
  400.   tmp = _data;
  401.   dta = &_data;
  402.   editor->text_editor->valid_chars >> '-';
  403. }
  404. #endif
  405.  
  406. boolean Twinput::valid( uint stop_st )
  407. {
  408.   boolean result;
  409.  
  410.   result = Tlinput::valid( stop_st );
  411.   *dta = (word) tmp;
  412.   return result;
  413. }
  414.  
  415.  
  416. //Tdinput publics:
  417.  
  418. #ifndef NOFLOAT
  419. Tdinput::Tdinput( char *_prompt, double &_data, double _min, double _max, char _decimals ):
  420.   Tinput( _prompt, lin, len, init_len( _data, _min, _max, _decimals ) )
  421. {
  422.   init();
  423. }
  424.  
  425. #ifndef NOHIST
  426. Tdinput::Tdinput( char *_prompt, double &_data, double _min, double _max, char _decimals, Tlb_list *_hist ):
  427.   Tinput( _prompt, lin, len, init_len( _data, _min, _max, _decimals ), _hist )
  428. {
  429.   init();
  430. }
  431. #endif
  432.  
  433. boolean Tdinput::valid( uint stop_st )
  434. {
  435.   double v;
  436.   char line[256], *err;
  437.  
  438.   if( !Tinput::valid( stop_st ) ) return 0;
  439.   if( stop_st == cmCANCEL ) return 1;
  440.   get_txt( line );
  441.   v = strtod( line, &err );
  442.   if( *err || ( v < min ) || ( v > max ) )
  443.   {
  444.     focus();
  445.     _terror();
  446. #ifdef CYR
  447.     ok( "æ▓«⌐¡«▒▓▓á ¡Ñ Ñ ó὿ñ¡á.\n\n┐ ó║óÑñÑ▓Ñ ñ░│úá ▒▓«⌐¡«▒▓ ¼Ñªñ│ %*.*f ¿ %*.*f ",
  448.       integer, decimals, min, integer, decimals, max );
  449. #else
  450.     ok( "Value not within the valid range.\n\nPlease enter new value\nbetween %*.*f and %*.*f",
  451.       integer, decimals, min, integer, decimals, max );
  452. #endif
  453.     return 0;
  454.   };
  455.   sprintf( line, "%*.*f", integer, decimals, v );
  456.   v = strtod( line, NULL );
  457.   *data = v;
  458.   return 1;
  459. }
  460.  
  461. void Tdinput::set_num( double n )
  462. {
  463.   char s[256];
  464.   sprintf( s, "%*.*f", integer*(state(isFOCUSED)==0), decimals, n );
  465.   set_txt( s );
  466. }
  467.  
  468. double Tdinput::get_num( void )
  469. {
  470.   char s[256];
  471.   get_txt( s );
  472.   return atof( s );
  473. }
  474.  
  475. //Tdinput private:
  476.  
  477. char Tdinput::init_len( double &_data, double _min, double _max, char _decimals )
  478. {
  479.   int l1,l2;
  480.   min = _min; max = _max;
  481.   decimals = _decimals;
  482.   data = &_data;
  483.   l1=sprintf( lin, "%0.*f", decimals, max );
  484.   l2=sprintf( lin, "%0.*f", decimals, min );
  485.   len=integer=::max(l1,l2);
  486.   sprintf( lin, "%*.*f", integer, decimals, *data );
  487.   return integer;
  488. }
  489.  
  490. void Tdinput::init( void )
  491. {
  492.   ~editor->text_editor->valid_chars;
  493.   for( char i = '0'; i <= '9'; i++ )
  494.     editor->text_editor->valid_chars << i;
  495.   editor->text_editor->valid_chars<<'.'<<'E'<<'e'<<'-';
  496. }
  497.  
  498. void Tdinput::get_focused( void )
  499. {
  500.   set_num(get_num());
  501.   Tinput::get_focused();
  502. }
  503.  
  504. boolean Tdinput::release_focus( void )
  505. {
  506.   char s[256];
  507.   if( !Tinput::release_focus() ) return 0;
  508.   sprintf( s, "%*.*f", integer, decimals, get_num() );
  509.   set_txt( s );
  510.   return 1;
  511. }
  512.  
  513.  
  514.  
  515. //Tfinput publics:
  516.  
  517. Tfinput::Tfinput( char *_prompt, float &_data, float _min, float _max, char _decimals ):
  518.   Tdinput( _prompt, tmp, (double) _min, (double) _max, _decimals )
  519. {
  520.   set_num( _data );
  521.   tmp = _data;
  522.   dta = &_data;
  523. }
  524.  
  525. #ifndef NOHIST
  526. Tfinput::Tfinput( char *_prompt, float &_data, float _min, float _max, char _decimals, Tlb_list *_hist ):
  527.   Tdinput( _prompt, tmp, (double) _min, (double) _max, _decimals, _hist )
  528. {
  529.   set_num( _data );
  530.   tmp = _data;
  531.   dta = &_data;
  532. }
  533. #endif
  534.  
  535. boolean Tfinput::valid( uint stop_st )
  536. {
  537.   boolean result;
  538.  
  539.   result = Tdinput::valid( stop_st );
  540.   *dta = (float) tmp;
  541.   return result;
  542. }
  543.  
  544. #endif //NOFLOAT
  545.  
  546. //PREFIXES
  547.  
  548. static void *history_ = NULL;
  549. static boolean hexnum_ = 0;
  550.  
  551. /*
  552.   Description:
  553.     Specify the text edit box to have a 'history'. Call just before construct
  554.     a text box.
  555.   Entry:
  556.     history_id - unique history identifier. Text edit boxes with same history
  557.                  identifiers share one history list.
  558. */
  559. void *_history( void *history_id )
  560. {
  561.   history_ = history_id;
  562.   return history_id;
  563. }
  564.  
  565. void *__history( void )
  566. {
  567.   void *result;
  568.  
  569.   result = history_;
  570.   history_ = NULL;
  571.   return result;
  572. }
  573.  
  574. /*
  575.   Description:
  576.     Specify the integer input box to accept hexadecimal entry.
  577. */
  578. void _hexnum( void )
  579. {
  580.   hexnum_ = 1;
  581. }
  582.  
  583. boolean __hexnum( void )
  584. {
  585.   boolean result = hexnum_;
  586.   hexnum_ = 0;
  587.   return result;
  588. }
  589.  
  590. //CONSTRUCTORS FOR USE WITH DIALOG BOXES
  591.  
  592. static void _input( Tinput *i )
  593. {
  594.   hspaces( i->prompt_len );
  595.   put_item( i, i->xl +
  596. #ifndef NOHIST
  597.     ( i->history_id != NULL ) * i_combo_open_len +
  598. #endif
  599.     1, 2 );
  600.   if( !fill() ) hspaces( -i->prompt_len );
  601. }
  602.  
  603. /*
  604.   Description:
  605.     Construct text edit box and insert it in the dialog box.
  606.   Entry:
  607.     t    - title, shortcut prefix '|~';
  608.     data - buffer that holds current value;
  609.     len  - maximum valid length of the output string;
  610.     size - number of characters to be displayed - size of the text edit box.
  611.   Exit:
  612.     Return pointer to the edit box.
  613. */
  614. Tinput *input( char *t, char *data, int len, int size )
  615. {
  616.   Tinput *i;
  617. #ifndef NOHIST
  618.   void *history_id;
  619.   Tlb_list *history;
  620.  
  621.   history_id = __history();
  622.   if( history_id != NULL )
  623.   {
  624.     history = registrate_history( history_id );
  625.     i = NEW( Tinput( t, data, len, size, history ) );
  626.     i->history_id = history_id;
  627.   }
  628.   else
  629. #endif
  630.     i = NEW( Tinput( t, data, len, size ) );
  631.   _input( i );
  632.   return i;
  633. }
  634.  
  635. /*
  636.   Description:
  637.     Construct longint edit box and insert it in the dialog box.
  638.   Entry:
  639.     t       - title, shortcut prefix '|~';
  640.     data    - buffer that holds current value;
  641.     min,max - valid number range.
  642.   Exit:
  643.     Return pointer to the edit box.
  644. */
  645. Tlinput *linput( char *t, long &data, long min, long max )
  646. {
  647.   Tlinput *i;
  648. #ifndef NOHIST
  649.   void *history_id;
  650.   Tlb_list *history;
  651.  
  652.   history_id = __history();
  653.   if( history_id != NULL )
  654.   {
  655.     history = registrate_history( history_id );
  656.     i = NEW( Tlinput( t, data, min, max, history ) );
  657.     i->history_id = history_id;
  658.   }
  659.   else
  660. #endif
  661.     i = NEW( Tlinput( t, data, min, max ) );
  662.   _input( i );
  663.   return i;
  664. }
  665.  
  666. /*
  667.   Description:
  668.     Construct integer edit box and insert it in the dialog box.
  669.   Entry:
  670.     t       - title, shortcut prefix '|~';
  671.     data    - buffer that holds current value;
  672.     min,max - valid number range.
  673.   Exit:
  674.     Return pointer to the edit box.
  675. */
  676. Tsinput *sinput( char *t, short &data, short min, short max )
  677. {
  678.   Tsinput *i;
  679. #ifndef NOHIST
  680.   void *history_id;
  681.   Tlb_list *history;
  682.  
  683.   history_id = __history();
  684.   if( history_id != NULL )
  685.   {
  686.     history = registrate_history( history_id );
  687.     i = NEW( Tsinput( t, data, min, max, history ) );
  688.     i->history_id = history_id;
  689.   }
  690.   else
  691. #endif
  692.     i = NEW( Tsinput( t, data, min, max ) );
  693.   _input( i );
  694.   return i;
  695. }
  696.  
  697. /*
  698.   Description:
  699.     Construct int edit box and insert it in the dialog box.
  700.   Entry:
  701.     t       - title, shortcut prefix '|~';
  702.     data    - buffer that holds current value;
  703.     min,max - valid number range.
  704.   Exit:
  705.     Return pointer to the edit box.
  706. */
  707. Tiinput *iinput( char *t, int &data, int min, int max )
  708. {
  709.   Tiinput *i;
  710. #ifndef NOHIST
  711.   void *history_id;
  712.   Tlb_list *history;
  713.  
  714.   history_id = __history();
  715.   if( history_id != NULL )
  716.   {
  717.     history = registrate_history( history_id );
  718.     i = NEW( Tiinput( t, data, min, max, history ) );
  719.     i->history_id = history_id;
  720.   }
  721.   else
  722. #endif
  723.     i = NEW( Tiinput( t, data, min, max ) );
  724.   _input( i );
  725.   return i;
  726. }
  727.  
  728. /*
  729.   Description:
  730.     Construct char edit box and insert it in the dialog box.
  731.   Entry:
  732.     t       - title, shortcut prefix '|~';
  733.     data    - buffer that holds current value;
  734.     min,max - valid number range.
  735.   Exit:
  736.     Return pointer to the edit box.
  737. */
  738. Tcinput *cinput( char *t, char &data, char min, char max )
  739. {
  740.   Tcinput *i;
  741. #ifndef NOHIST
  742.   void *history_id;
  743.   Tlb_list *history;
  744.  
  745.   history_id = __history();
  746.   if( history_id != NULL )
  747.   {
  748.     history = registrate_history( history_id );
  749.     i = NEW( Tcinput( t, data, min, max, history ) );
  750.     i->history_id = history_id;
  751.   }
  752.   else
  753. #endif
  754.     i = NEW( Tcinput( t, data, min, max ) );
  755.   _input( i );
  756.   return i;
  757. }
  758.  
  759. /*
  760.   Description:
  761.     Construct word edit box and insert it in the dialog box.
  762.   Entry:
  763.     t       - title, shortcut prefix '|~';
  764.     data    - buffer that holds current value;
  765.     min,max - valid number range.
  766.   Exit:
  767.     Return pointer to the edit box.
  768. */
  769. Twinput *winput( char *t, word &data, word min, word max )
  770. {
  771.   Twinput *i;
  772. #ifndef NOHIST
  773.   void *history_id;
  774.   Tlb_list *history;
  775.  
  776.   history_id = __history();
  777.   if( history_id != NULL )
  778.   {
  779.     history = registrate_history( history_id );
  780.     i = NEW( Twinput( t, data, min, max, history ) );
  781.     i->history_id = history_id;
  782.   }
  783.   else
  784. #endif
  785.     i = NEW( Twinput( t, data, min, max ) );
  786.   _input( i );
  787.   return i;
  788. }
  789.  
  790. #ifndef NOFLOAT
  791. /*
  792.   Description:
  793.     Construct double edit box and insert it in the dialog box.
  794.   Entry:
  795.     t        - title, shortcut prefix '|~';
  796.     data     - buffer that holds current value;
  797.     min,max  - valid number range;
  798.     decimals - number of digits after the point ( precision ).
  799.   Exit:
  800.     Return pointer to the edit box.
  801. */
  802. Tdinput *dinput( char *t, double &data, double min, double max, char decimals )
  803. {
  804.   Tdinput *i;
  805. #ifndef NOHIST
  806.   void *history_id;
  807.   Tlb_list *history;
  808.  
  809.   history_id = __history();
  810.   if( history_id != NULL )
  811.   {
  812.     history = registrate_history( history_id );
  813.     i = NEW( Tdinput( t, data, min, max, decimals, history ) );
  814.     i->history_id = history_id;
  815.   }
  816.   else
  817. #endif
  818.     i = NEW( Tdinput( t, data, min, max, decimals ) );
  819.   _input( i );
  820.   return i;
  821. }
  822.  
  823. /*
  824.   Description:
  825.     Construct float edit box and insert it in the dialog box.
  826.   Entry:
  827.     t        - title, shortcut prefix '|~';
  828.     data     - buffer that holds current value;
  829.     min,max  - valid number range;
  830.     decimals - number of digits after the point ( precision ).
  831.   Exit:
  832.     Return pointer to the edit box.
  833. */
  834. Tfinput *finput( char *t, float &data, float min, float max, char decimals )
  835. {
  836.   Tfinput *i;
  837. #ifndef NOHIST
  838.   void *history_id;
  839.   Tlb_list *history;
  840.  
  841.   history_id = __history();
  842.   if( history_id != NULL )
  843.   {
  844.     history = registrate_history( history_id );
  845.     i = NEW( Tfinput( t, data, min, max, decimals, history ) );
  846.     i->history_id = history_id;
  847.   }
  848.   else
  849. #endif
  850.     i = NEW( Tfinput( t, data, min, max, decimals ) );
  851.   _input( i );
  852.   return i;
  853. }
  854.  
  855. /*
  856.   Description:
  857.     Construct money edit box and insert it in the dialog box.
  858.   Entry:
  859.     t    - title, shortcut prefix '|~';
  860.     data - buffer that holds current value;
  861.     max  - maximum of the value. Minimum is 0, precision is 0.01.
  862.   Exit:
  863.     Return pointer to the edit box.
  864. */
  865. Tfinput *minput( char *t, float &data, float max )
  866. {
  867.   Tfinput *i;
  868. #ifndef NOHIST
  869.   void *history_id;
  870.   Tlb_list *history;
  871.  
  872.   history_id = __history();
  873.   if( history_id != NULL )
  874.   {
  875.     history = registrate_history( history_id );
  876.     i = NEW( Tfinput( t, data, 0, max, 2, history ) );
  877.     i->history_id = history_id;
  878.   }
  879.   else
  880. #endif
  881.     i = NEW( Tfinput( t, data, 0, max, 2 ) );
  882.   _input( i );
  883.   return i;
  884. }
  885.  
  886. #endif //NOFLOAT
  887.