summaryrefslogtreecommitdiffstats
path: root/dbaccess/source/ui/inc/FieldControls.hxx
blob: 7eb88ec4e0776f657f7ddd1f49c7c542d8cff834 (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
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
#pragma once

#include "SqlNameEdit.hxx"
#include <unotools/resmgr.hxx>

namespace dbaui
{

    class OPropColumnEditCtrl : public OSQLNameEntry
    {
        short                m_nPos;
        OUString             m_strHelpText;
    public:
        OPropColumnEditCtrl(std::unique_ptr<weld::Entry> xEntry, OUString const & _rAllowedChars, TranslateId pHelpId, short nPosition);

        short GetPos() const { return m_nPos; }
        const OUString& GetHelp() const { return m_strHelpText; }
    };

    class OPropEditCtrl : public OWidgetBase
    {
        std::unique_ptr<weld::Entry> m_xEntry;
        short                m_nPos;
        OUString             m_strHelpText;

    public:
        OPropEditCtrl(std::unique_ptr<weld::Entry> xEntry, TranslateId pHelpId, short nPosition);

        void set_text(const OUString& rText) { m_xEntry->set_text(rText); }
        OUString get_text() const { return m_xEntry->get_text(); }
        void set_editable(bool bEditable) { m_xEntry->set_editable(bEditable); }

        virtual void save_value() override { m_xEntry->save_value(); }
        virtual bool get_value_changed_from_saved() const override { return m_xEntry->get_value_changed_from_saved(); }

        short GetPos() const { return m_nPos; }
        const OUString& GetHelp() const { return m_strHelpText; }
    };

    class OPropNumericEditCtrl : public OWidgetBase
    {
        std::unique_ptr<weld::SpinButton> m_xSpinButton;
        short     m_nPos;
        OUString  m_strHelpText;

    public:
        OPropNumericEditCtrl(std::unique_ptr<weld::SpinButton> xSpinButton, TranslateId pHelpId, short nPosition);

        void set_text(const OUString& rText) { m_xSpinButton->set_text(rText); }
        OUString get_text() const { return m_xSpinButton->get_text(); }

        virtual void save_value() override { m_xSpinButton->save_value(); }
        virtual bool get_value_changed_from_saved() const override { return m_xSpinButton->get_value_changed_from_saved(); }
        void set_digits(int nLen) { m_xSpinButton->set_digits(nLen); }
        void set_min(int nMin) { m_xSpinButton->set_min(nMin); }
        void set_max(int nMax) { m_xSpinButton->set_max(nMax); }
        void set_range(int nMin, int nMax) { m_xSpinButton->set_range(nMin, nMax); }
        int get_value() const { return m_xSpinButton->get_value(); }

        short GetPos() const { return m_nPos; }
        const OUString& GetHelp() const { return m_strHelpText; }

        void set_editable(bool bEditable) { m_xSpinButton->set_editable(bEditable); }
    };

    class OPropListBoxCtrl : public OWidgetBase
    {
        std::unique_ptr<weld::ComboBox> m_xComboBox;
        short     m_nPos;
        OUString  m_strHelpText;

    public:
        OPropListBoxCtrl(std::unique_ptr<weld::ComboBox> xComboBox, TranslateId pHelpId, short nPosition);
        virtual ~OPropListBoxCtrl() override
        {
            m_xComboBox->clear();
        }

        virtual void save_value() override { m_xComboBox->save_value(); }
        virtual bool get_value_changed_from_saved() const override { return m_xComboBox->get_value_changed_from_saved(); }

        weld::ComboBox& GetComboBox() { return *m_xComboBox; }

        OUString get_active_text() const { return m_xComboBox->get_active_text(); }
        void set_active_text(const OUString &rText) { m_xComboBox->set_active_text(rText); }

        int get_active() const { return m_xComboBox->get_active(); }
        void set_active(int nPos) { m_xComboBox->set_active(nPos); }

        int get_count() const { return m_xComboBox->get_count(); }

        void append_text(const OUString &rText) { m_xComboBox->append_text(rText); }
        void remove_text(const OUString &rText) { m_xComboBox->remove_text(rText); }
        int find_text(const OUString &rText) const { return m_xComboBox->find_text(rText); }

        short GetPos() const { return m_nPos; }
        const OUString& GetHelp() const { return m_strHelpText; }
    };

}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */