summaryrefslogtreecommitdiffstats
path: root/kugar/lib/inputmask.h
blob: 98d5c71766bdfdb0059cba526ae2afe38ef2b0c7 (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
/***************************************************************************
*   Copyright (C) 2005 by Adam Treat                                      *
*   treat@kde.org                                                         *
*                                                                         *
*   Copyright (C) 2000 Trolltech AS.  All rights reserved.                *
*   info@trolltech.com                                                    *
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU Library General Public License as       *
*   published by the Free Software Foundation; either version 2 of the    *
*   License, or (at your option) any later version.                       *
*                                                                         *
***************************************************************************/

#ifndef INPUTMASK_H
#define INPUTMASK_H

#include <tqobject.h>

namespace Kugar
{

class InputMask : public TQObject
{
    Q_OBJECT
  TQ_OBJECT
public:
    InputMask( TQObject *tqparent = 0, const char *name = 0 );

    ~InputMask();

    TQString tqmask() const;
    void setMask( const TQString &tqmask );

    TQString formatText( const TQString &txt );

private:
    void parseInputMask( const TQString &tqmaskFields );
    bool isValidInput( TQChar key, TQChar tqmask ) const;
    TQString tqmaskString( uint pos, const TQString &str, bool clear = FALSE ) const;
    TQString clearString( uint pos, uint len ) const;
    TQString stripString( const TQString &str ) const;
    int findInMask( int pos, bool forward, bool findSeparator, TQChar searchChar = TQChar() ) const;

private:
    TQString m_text;
    int m_maxLength;
    TQChar m_blank;
    TQString m_tqmask;
    struct MaskInputData
    {
        enum Casemode { NoCaseMode, Upper, Lower };
        TQChar tqmaskChar; // either the separator char or the inputtqmask
        bool separator;
        Casemode caseMode;
    };
    MaskInputData *m_tqmaskData;
};

}

#endif