update credits
[LibreOffice.git] / cui / source / dialogs / dlgname.cxx
blob650e39a532975d828bcbd987700b6acac45df8f5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <tools/shl.hxx>
21 #include <vcl/msgbox.hxx>
23 #include <cuires.hrc>
25 #include "dlgname.hxx"
26 #include "defdlgname.hxx"
27 #include <dialmgr.hxx>
29 /*************************************************************************
31 |* Dialog for editing a name
33 \************************************************************************/
35 SvxNameDialog::SvxNameDialog( Window* pWindow, const String& rName, const String& rDesc ) :
36 ModalDialog ( pWindow, "NameDialog", "cui/ui/namedialog.ui" )
38 get(pBtnOK, "ok");
39 get(pFtDescription, "description_label");
40 get(pEdtName, "name_entry");
42 pFtDescription->SetText( rDesc );
43 pEdtName->SetText( rName );
44 pEdtName->SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
45 ModifyHdl(&pEdtName);
46 pEdtName->SetModifyHdl(LINK(this, SvxNameDialog, ModifyHdl));
49 IMPL_LINK_NOARG(SvxNameDialog, ModifyHdl)
51 if(aCheckNameHdl.IsSet())
52 pBtnOK->Enable(aCheckNameHdl.Call(this) > 0);
53 return 0;
56 ///////////////////////////////////////////////////////////////////////////////////////////////
57 // #i68101#
58 // Dialog for editing Object Name
59 // plus uniqueness-callback-linkHandler
61 SvxObjectNameDialog::SvxObjectNameDialog(
62 Window* pWindow,
63 const String& rName) :
64 ModalDialog ( pWindow, "ObjectNameDialog", "cui/ui/objectnamedialog.ui" )
66 get(pBtnOK, "ok");
67 get(pEdtName, "object_name_entry");
68 // set name
69 pEdtName->SetText(rName);
71 // activate name
72 pEdtName->SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
73 ModifyHdl(&pEdtName);
74 pEdtName->SetModifyHdl(LINK(this, SvxObjectNameDialog, ModifyHdl));
77 IMPL_LINK_NOARG(SvxObjectNameDialog, ModifyHdl)
79 if(aCheckNameHdl.IsSet())
81 pBtnOK->Enable(aCheckNameHdl.Call(this) > 0);
84 return 0;
87 ///////////////////////////////////////////////////////////////////////////////////////////////
88 // #i68101#
89 // Dialog for editing Object Title and Description
91 SvxObjectTitleDescDialog::SvxObjectTitleDescDialog(
92 Window* pWindow,
93 const String& rTitle,
94 const String& rDescription) :
95 ModalDialog ( pWindow, "ObjectTitleDescDialog", "cui/ui/objecttitledescdialog.ui" )
97 get(pEdtTitle, "object_title_entry");
98 get(pEdtDescription, "desc_entry");
99 //lock height to initial height
100 pEdtDescription->set_height_request(pEdtDescription->get_preferred_size().Height());
101 // set title & desc
102 pEdtTitle->SetText(rTitle);
103 pEdtDescription->SetText(rDescription);
105 // activate title
106 pEdtTitle->SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
109 ///////////////////////////////////////////////////////////////////////////////////////////////
111 /*************************************************************************
113 |* dialog for cancelling, saving or adding
115 \************************************************************************/
117 SvxMessDialog::SvxMessDialog( Window* pWindow, const String& rText, const String& rDesc, Image* pImg )
118 : ModalDialog(pWindow, "MessBox", "cui/ui/messbox.ui")
119 , pImage(NULL)
121 get(pBtn1, "mess_box_btn1");
122 get(pBtn2, "mess_box_btn2");
123 get(pFtDescription, "mess_box_description");
124 get(pFtImage, "mess_box_image");
125 if( pImg )
127 pImage = new Image( *pImg );
128 pFtImage->SetImage( *pImage );
129 pFtImage->SetStyle( ( pFtImage->GetStyle()/* | WB_NOTABSTOP */) & ~WB_3DLOOK );
130 pFtImage->Show();
133 SetText( rText );
134 pFtDescription->SetText( rDesc );
136 pBtn1->SetClickHdl( LINK( this, SvxMessDialog, Button1Hdl ) );
137 pBtn2->SetClickHdl( LINK( this, SvxMessDialog, Button2Hdl ) );
140 SvxMessDialog::~SvxMessDialog()
142 delete pImage;
145 /*************************************************************************/
147 IMPL_LINK_NOARG_INLINE_START(SvxMessDialog, Button1Hdl)
149 EndDialog( RET_BTN_1 );
150 return 0;
152 IMPL_LINK_NOARG_INLINE_END(SvxMessDialog, Button1Hdl)
154 /*************************************************************************/
156 IMPL_LINK_NOARG_INLINE_START(SvxMessDialog, Button2Hdl)
158 EndDialog( RET_BTN_2 );
159 return 0;
161 IMPL_LINK_NOARG_INLINE_END(SvxMessDialog, Button2Hdl)
163 /*************************************************************************/
165 void SvxMessDialog::SetButtonText( sal_uInt16 nBtnId, const String& rNewTxt )
167 switch ( nBtnId )
169 case MESS_BTN_1:
170 pBtn1->SetText( rNewTxt );
171 break;
173 case MESS_BTN_2:
174 pBtn2->SetText( rNewTxt );
175 break;
177 default:
178 OSL_FAIL( "Invalid button number!!!" );
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */