summaryrefslogtreecommitdiff
path: root/rhtvision/include/tv/inputln.h
blob: c56b67f0c3d064c6a83e6edb75af8aa3714ecb21 (plain)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
 *      Turbo Vision - Version 2.0
 *
 *      Copyright (c) 1994 by Borland International
 *      All Rights Reserved.
 *

Modified by Robert H”hne to be used for RHIDE.
Added: TInput1Line class by SET (based on TVTools idea).
Added: modeOptions stuff by SET.

 *
 *
 */

/* ---------------------------------------------------------------------- */
/*      class TInputLine                                                  */
/*                                                                        */
/*      Palette layout                                                    */
/*        1 = Passive                                                     */
/*        2 = Active                                                      */
/*        3 = Selected                                                    */
/*        4 = Arrows                                                      */
/* ---------------------------------------------------------------------- */

#if defined( Uses_TInputLine ) && !defined( TInputLine_defined )
#define TInputLine_defined

class TRect;
struct TEvent;
class TValidator;

const unsigned ilValidatorBlocks=1;  // Don't pass the focus if the validator indicates
                                     // the data isn't valid. by SET.

class CLY_EXPORT TInputLine : public TView
{
public:

    TInputLine( const TRect& bounds, int aMaxLen, TValidator *aValid=NULL );
    ~TInputLine();

    virtual unsigned dataSize();
    virtual void draw();
    virtual void getData( void *rec );
    virtual TPalette& getPalette() const;
    virtual void handleEvent( TEvent& event );
    void selectAll( Boolean enable );
    virtual void setData( void *rec );
    virtual void setState( ushort aState, Boolean enable );
    void setValidator(TValidator *);
    virtual Boolean valid(ushort);
    virtual Boolean insertChar(char value); // Added by SET
    // This is for compatibility with the Unicode branch
    const void *getData() { return data; }; // Added by SET
    void setDataFromStr(void *value) // Added by SET
      { setData(value); };

    char* data;
    int maxLen;
    int curPos, oldCurPos;
    int firstPos, oldFirstPos;
    int selStart, oldSelStart;
    int selEnd, oldSelEnd;
    Boolean hideContent;

    // Functions to fine tune the behavior. by SET.
    unsigned setModeOptions(unsigned newOps)
      { unsigned old=modeOptions; modeOptions=newOps; return old; }
    unsigned getModeOptions()
      { return modeOptions; }
    static unsigned setDefaultModeOptions(unsigned newOps)
      { unsigned old=defaultModeOptions; defaultModeOptions=newOps; return old; }
    static unsigned getDefaultModeOptions()
      { return defaultModeOptions; }


    static char rightArrow;
    static char leftArrow;
    static char orightArrow;
 void setHide(Boolean val) { hideContent=val; }
    static char oleftArrow;

protected:
    virtual void resizeData() {}
    TValidator * validator;
    char* oldData;
    void deleteSelect();
    void makeVisible(); // Added by SET
    Boolean canScroll( int delta );
    void saveState();
    void restoreState();
    Boolean checkValid(Boolean);

    // To fine tune the behavior. SET.
    static unsigned defaultModeOptions;
    unsigned modeOptions;

private:
    int mouseDelta( TEvent& event );
    int mousePos( TEvent& event );

#if !defined( NO_STREAM )
    virtual const char *streamableName() const
        { return name; }

protected:

    TInputLine( StreamableInit );
    virtual void write( opstream& );
    virtual void *read( ipstream& );

public:

    static const char * const name;
    static TStreamable *build();
#endif // NO_STREAM
};

#if !defined( NO_STREAM )
inline ipstream& operator >> ( ipstream& is, TInputLine& cl )
    { return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TInputLine*& cl )
    { return is >> (void *&)cl; }

inline opstream& operator << ( opstream& os, TInputLine& cl )
    { return os << (TStreamable&)cl; }
inline opstream& operator << ( opstream& os, TInputLine* cl )
    { return os << (TStreamable *)cl; }
#endif // NO_STREAM

#endif  // Uses_TInputLine

#if defined( Uses_TInput1Line ) && !defined( TInput1Line_defined )
#define TInput1Line_defined
// This is based on TVTools idea, but I think is better to implement it
// in this way and not like a macro.
class CLY_EXPORT TInput1Line : public TInputLine
{
public:
 TInput1Line(int x, int y, int max, TValidator *aValid=NULL) :
   TInputLine(TRect(x,y,x+max+2,y+1), max, aValid) {};
};
#endif // Uses_TInput1Line