1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "cuidllapi.h"
23 #include <vcl/weld.hxx>
25 /// Dialog for editing a name
26 class CUI_DLLPUBLIC SvxNameDialog
: public weld::GenericDialogController
29 std::unique_ptr
<weld::Entry
> m_xEdtName
;
30 std::unique_ptr
<weld::Label
> m_xFtDescription
;
31 std::unique_ptr
<weld::Button
> m_xBtnOK
;
33 Link
<SvxNameDialog
&, bool> m_aCheckNameHdl
;
34 Link
<SvxNameDialog
&, OUString
> m_aCheckNameTooltipHdl
;
36 DECL_LINK(ModifyHdl
, weld::Entry
&, void);
39 SvxNameDialog(weld::Window
* pWindow
, const OUString
& rName
, const OUString
& rDesc
);
41 OUString
GetName() const { return m_xEdtName
->get_text(); }
43 /** add a callback Link that is called whenever the content of the edit
44 field is changed. The Link result determines whether the OK
45 Button is enabled (> 0) or disabled (== 0).
47 @param rLink a Callback declared with DECL_DLLPRIVATE_LINK and implemented with
48 IMPL_LINK, that is executed on modification.
50 @param bCheckImmediately If true, the Link is called directly after
51 setting it. It is recommended to set this flag to true to avoid
52 an inconsistent state if the initial String (given in the CTOR)
53 does not satisfy the check condition.
55 @todo Remove the parameter bCheckImmediately and incorporate the 'true'
58 void SetCheckNameHdl(const Link
<SvxNameDialog
&, bool>& rLink
, bool bCheckImmediately
)
60 m_aCheckNameHdl
= rLink
;
61 if (bCheckImmediately
)
62 m_xBtnOK
->set_sensitive(rLink
.Call(*this));
65 void SetCheckNameTooltipHdl(const Link
<SvxNameDialog
&, OUString
>& rLink
)
67 m_aCheckNameTooltipHdl
= rLink
;
68 m_xBtnOK
->set_tooltip_text(rLink
.Call(*this));
71 void SetEditHelpId(const OUString
& aHelpId
) { m_xEdtName
->set_help_id(aHelpId
); }
75 Dialog for editing Object name
76 plus uniqueness-callback-linkHandler */
77 class SvxObjectNameDialog
: public weld::GenericDialogController
81 std::unique_ptr
<weld::Entry
> m_xEdtName
;
84 std::unique_ptr
<weld::Button
> m_xBtnOK
;
86 // callback link for name uniqueness
87 Link
<SvxObjectNameDialog
&, bool> aCheckNameHdl
;
89 DECL_LINK(ModifyHdl
, weld::Entry
&, void);
93 SvxObjectNameDialog(weld::Window
* pWindow
, const OUString
& rName
);
96 OUString
GetName() const { return m_xEdtName
->get_text(); }
99 void SetCheckNameHdl(const Link
<SvxObjectNameDialog
&, bool>& rLink
) { aCheckNameHdl
= rLink
; }
103 Dialog for editing Object Title and Description */
104 class SvxObjectTitleDescDialog
: public weld::GenericDialogController
108 std::unique_ptr
<weld::Label
> m_xTitleFT
;
109 std::unique_ptr
<weld::Entry
> m_xEdtTitle
;
112 std::unique_ptr
<weld::Label
> m_xDescriptionFT
;
113 std::unique_ptr
<weld::TextView
> m_xEdtDescription
;
115 std::unique_ptr
<weld::CheckButton
> m_xDecorativeCB
;
117 DECL_LINK(DecorativeHdl
, weld::Toggleable
&, void);
121 SvxObjectTitleDescDialog(weld::Window
* pWindow
, const OUString
& rTitle
, const OUString
& rDesc
,
124 OUString
GetTitle() const { return m_xEdtTitle
->get_text(); }
125 OUString
GetDescription() const { return m_xEdtDescription
->get_text(); }
126 bool IsDecorative() const { return m_xDecorativeCB
->get_active(); }
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */