Blame view

GUI/SW2/SRC/src/utility/PnlTxtSpn.hpp 5.38 KB
886c558b   Steve Greedy   SACAMOS Public Re...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//**************************************************************************************************
//                                         PnlTxtSpn.hpp                                           *
//                                        ---------------                                          *
// Description : This class extends wxPanel and can substitute for the wxWidgets library class     *
//               wxSpinCtrl. It adds some useful functionality :                                   *
//                - floating point or integer numbers can be displayed,                            *
//                - incrementing by orders of magnitude not just a constant,                       *
//                - variable step size incrementing.                                               *
// Started     : 2004-03-20                                                                        *
// Last Update : 2015-01-28                                                                        *
// Copyright   : (C) 2004-2016 MSWaters                                                            *
//**************************************************************************************************

//**************************************************************************************************
//                                                                                                 *
//      This program is free software; you can redistribute it and/or modify it under the          *
//      terms of the GNU General Public License as published by the Free Software Foundation;      *
//      either version 3 of the License, or (at your option) any later version.                    *
//                                                                                                 *
//**************************************************************************************************

#ifndef PNLTXTSPN_HPP
#define PNLTXTSPN_HPP

// Application Includes

#include "TypeDefs.hpp"
#include "utility/CnvtType.hpp"

// wxWidgets Includes

#include <wx/spinbutt.h>

// Local Constant Declarations

#define  SPN_MAXLEN        9  // Maximum chars. that may be entered into text ctrl.
#define  SPN_PERIOD_DEF   83  // The default spin button repeat period (in msec)
#define  SPN_PERIOD_MIN   20  // The minimum spin button repeat period (in msec)
#define  SPN_PERIOD_MAX  400  // The maximum spin button repeat period (in msec)

//**************************************************************************************************

class PnlTxtSpn : public wxPanel
{
  private :

    // Display objects
    wxTextCtrl    m_oTxtValue;
    wxSpinButton  m_oSbnValue;

    eTypeValue    m_eValType;     // The value type to be displayed
    double        m_dfDefValue;   // Default value
    double        m_dfMinValue;   // Minimum value
    double        m_dfMaxValue;   // Maximum value
    double        m_dfMinIncSz;   // Minimum increment size
    double        m_dfMaxIncSz;   // Maximum increment size

    static  uint  m_uiSpnPeriod;  // The interval between successive spin control updates

    void  DoLayout   ( void );

  public :

          PnlTxtSpn  ( void );
         ~PnlTxtSpn  ( );

    bool  bCreate    ( wxWindow * poWin, wxWindowID oWinID, int iWidth=-1 );
    bool  bIsCreated ( void )                { return( GetParent( )!=NULL ? true : false ); }

    bool  bClear     ( void );

    bool  bSetValType( eTypeValue eVType );
    bool  bSetRange  ( double dfMinValue, double dfMaxValue );
    bool  bSetIncSz  ( double dfMinIncSz, double dfMaxIncSz=-1.0 );
    bool  bSetValue  ( long liValue )        { return( bSetValue( (double) liValue ) ); }
    bool  bSetValue  ( double dfValue );
    bool  bSetValue  ( const wxString & rosValue );
    bool  bSetValDef ( double dfDefValue=NOVAL_DBL );
    bool  bSetValMin ( double dfMinValue )   { return( bSetRange(   dfMinValue, m_dfMaxValue ) ); }
    bool  bSetValMax ( double dfMaxValue )   { return( bSetRange( m_dfMinValue,   dfMaxValue ) ); }

    inline  eTypeValue eGetVType   ( void ) { return( m_eValType ); }
            long      liGetValue   ( void );
            double    dfGetValue   ( void );
    const wxString & rosGetValue   ( void );
    inline  double    dfGetValDef  ( void ) { return( m_dfDefValue ); }
    inline  double    dfGetValMin  ( void ) { return( m_dfMinValue ); }
    inline  double    dfGetValMax  ( void ) { return( m_dfMaxValue ); }
    inline  double    dfGetMinIncSz( void ) { return( m_dfMinIncSz ); }
    inline  double    dfGetMaxIncSz( void ) { return( m_dfMaxIncSz ); }

    static  bool      bSetSpnPeriod( uint uiPeriod );

    void  Print( const wxString & rosPrefix=wxT("  ") );

  private :

    // Event handlers
    void  OnTxtChar  ( wxKeyEvent     & roEvtKey );
    void  OnTxtMaxLen( wxCommandEvent & roEvtCmd );
    void  OnSbnInc   ( wxSpinEvent    & roEvtSpn );
    void  OnSbnDec   ( wxSpinEvent    & roEvtSpn );

    friend  class  PnlValue;

    // In order to be able to react to a menu command, it must be given a
    // unique identifier such as a const or an enum.
    enum ePnlItemID
    {
      ID_TXTCTRL = 1,
      ID_SPINBTN,

      ID_UNUSED,

      ID_FST = ID_TXTCTRL,
      ID_LST = ID_SPINBTN
    };

    // Leave this as the last line as private access is envoked by macro
    wxDECLARE_EVENT_TABLE( );
};

//**************************************************************************************************

#endif // PNLTXTSPN_HPP