12ee96f1cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
32ee96f1cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
42ee96f1cSAndrew Rist * or more contributor license agreements. See the NOTICE file
52ee96f1cSAndrew Rist * distributed with this work for additional information
62ee96f1cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
72ee96f1cSAndrew Rist * to you under the Apache License, Version 2.0 (the
82ee96f1cSAndrew Rist * "License"); you may not use this file except in compliance
92ee96f1cSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
112ee96f1cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
132ee96f1cSAndrew Rist * Unless required by applicable law or agreed to in writing,
142ee96f1cSAndrew Rist * software distributed under the License is distributed on an
152ee96f1cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162ee96f1cSAndrew Rist * KIND, either express or implied. See the License for the
172ee96f1cSAndrew Rist * specific language governing permissions and limitations
182ee96f1cSAndrew Rist * under the License.
19cdf0e10cSrcweir *
202ee96f1cSAndrew Rist *************************************************************/
212ee96f1cSAndrew Rist
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_cui.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir #include <tools/ref.hxx>
26cdf0e10cSrcweir #include <tools/list.hxx>
27cdf0e10cSrcweir #include <tools/shl.hxx>
28cdf0e10cSrcweir #include <tools/debug.hxx>
29cdf0e10cSrcweir #include <vcl/msgbox.hxx>
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <cuires.hrc>
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include "dlgname.hxx"
34cdf0e10cSrcweir #include "defdlgname.hxx" //CHINA001
35cdf0e10cSrcweir #include "dlgname.hrc"
36cdf0e10cSrcweir #include <dialmgr.hxx>
37cdf0e10cSrcweir
38cdf0e10cSrcweir #define MAX_DESCRIPTION_LINES ((long)5)
39cdf0e10cSrcweir
40cdf0e10cSrcweir /*************************************************************************
41cdf0e10cSrcweir |* Dialog zum Editieren eines Namens
42cdf0e10cSrcweir \************************************************************************/
43cdf0e10cSrcweir
SvxNameDialog(Window * pWindow,const String & rName,const String & rDesc)44cdf0e10cSrcweir SvxNameDialog::SvxNameDialog( Window* pWindow, const String& rName, const String& rDesc ) :
45cdf0e10cSrcweir ModalDialog ( pWindow, CUI_RES( RID_SVXDLG_NAME ) ),
46cdf0e10cSrcweir aFtDescription ( this, CUI_RES( FT_DESCRIPTION ) ),
47cdf0e10cSrcweir aEdtName ( this, CUI_RES( EDT_STRING ) ),
48cdf0e10cSrcweir aBtnOK ( this, CUI_RES( BTN_OK ) ),
49cdf0e10cSrcweir aBtnCancel ( this, CUI_RES( BTN_CANCEL ) ),
50cdf0e10cSrcweir aBtnHelp ( this, CUI_RES( BTN_HELP ) )
51cdf0e10cSrcweir {
52cdf0e10cSrcweir FreeResource();
53cdf0e10cSrcweir
54cdf0e10cSrcweir aFtDescription.SetText( rDesc );
55cdf0e10cSrcweir aEdtName.SetText( rName );
56cdf0e10cSrcweir aEdtName.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
57cdf0e10cSrcweir ModifyHdl(&aEdtName);
58cdf0e10cSrcweir aEdtName.SetModifyHdl(LINK(this, SvxNameDialog, ModifyHdl));
59cdf0e10cSrcweir
60cdf0e10cSrcweir // dynamic height of the description field
61cdf0e10cSrcweir Size aSize = aFtDescription.GetSizePixel();
62cdf0e10cSrcweir long nTxtWidth = aFtDescription.GetCtrlTextWidth( rDesc );
63cdf0e10cSrcweir if ( nTxtWidth > aSize.Width() )
64cdf0e10cSrcweir {
65cdf0e10cSrcweir long nLines = Min( ( nTxtWidth / aSize.Width() + 1 ), MAX_DESCRIPTION_LINES );
66cdf0e10cSrcweir long nHeight = aSize.Height();
67cdf0e10cSrcweir aSize.Height() = nHeight * nLines;
68cdf0e10cSrcweir aFtDescription.SetSizePixel( aSize );
69cdf0e10cSrcweir Point aPnt = aEdtName.GetPosPixel();
70cdf0e10cSrcweir aPnt.Y() += ( aSize.Height() - nHeight );
71cdf0e10cSrcweir aEdtName.SetPosPixel( aPnt );
72cdf0e10cSrcweir }
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
75cdf0e10cSrcweir /* -----------------------------27.02.2002 15:22------------------------------
76cdf0e10cSrcweir
77cdf0e10cSrcweir ---------------------------------------------------------------------------*/
IMPL_LINK(SvxNameDialog,ModifyHdl,Edit *,EMPTYARG)78cdf0e10cSrcweir IMPL_LINK(SvxNameDialog, ModifyHdl, Edit*, EMPTYARG)
79cdf0e10cSrcweir {
80cdf0e10cSrcweir if(aCheckNameHdl.IsSet())
81cdf0e10cSrcweir aBtnOK.Enable(aCheckNameHdl.Call(this) > 0);
82cdf0e10cSrcweir return 0;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir
85cdf0e10cSrcweir // #i68101#
86cdf0e10cSrcweir // Dialog for editing Object Name
87cdf0e10cSrcweir // plus uniqueness-callback-linkHandler
88cdf0e10cSrcweir
SvxObjectNameDialog(Window * pWindow,const String & rName)89cdf0e10cSrcweir SvxObjectNameDialog::SvxObjectNameDialog(
90cdf0e10cSrcweir Window* pWindow,
91cdf0e10cSrcweir const String& rName)
92cdf0e10cSrcweir : ModalDialog(pWindow, CUI_RES(RID_SVXDLG_OBJECT_NAME)),
93cdf0e10cSrcweir aFtName(this, CUI_RES(NTD_FT_NAME)),
94cdf0e10cSrcweir aEdtName(this, CUI_RES(NTD_EDT_NAME)),
95cdf0e10cSrcweir aFlSeparator(this, CUI_RES(FL_SEPARATOR_A)),
96cdf0e10cSrcweir aBtnHelp(this, CUI_RES(BTN_HELP)),
97cdf0e10cSrcweir aBtnOK(this, CUI_RES(BTN_OK)),
98cdf0e10cSrcweir aBtnCancel(this, CUI_RES(BTN_CANCEL))
99cdf0e10cSrcweir {
100cdf0e10cSrcweir FreeResource();
101cdf0e10cSrcweir
102cdf0e10cSrcweir // set name
103cdf0e10cSrcweir aEdtName.SetText(rName);
104cdf0e10cSrcweir
105cdf0e10cSrcweir // activate name
106cdf0e10cSrcweir aEdtName.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
107cdf0e10cSrcweir ModifyHdl(&aEdtName);
108cdf0e10cSrcweir aEdtName.SetModifyHdl(LINK(this, SvxObjectNameDialog, ModifyHdl));
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
IMPL_LINK(SvxObjectNameDialog,ModifyHdl,Edit *,EMPTYARG)111cdf0e10cSrcweir IMPL_LINK(SvxObjectNameDialog, ModifyHdl, Edit*, EMPTYARG)
112cdf0e10cSrcweir {
113cdf0e10cSrcweir if(aCheckNameHdl.IsSet())
114cdf0e10cSrcweir {
115cdf0e10cSrcweir aBtnOK.Enable(aCheckNameHdl.Call(this) > 0);
116cdf0e10cSrcweir }
117cdf0e10cSrcweir
118cdf0e10cSrcweir return 0;
119cdf0e10cSrcweir }
120cdf0e10cSrcweir
121cdf0e10cSrcweir // #i68101#
122cdf0e10cSrcweir // Dialog for editing Object Title and Description
123cdf0e10cSrcweir
SvxObjectTitleDescDialog(Window * pWindow,const String & rTitle,const String & rDescription)124cdf0e10cSrcweir SvxObjectTitleDescDialog::SvxObjectTitleDescDialog(
125cdf0e10cSrcweir Window* pWindow,
126cdf0e10cSrcweir const String& rTitle,
127cdf0e10cSrcweir const String& rDescription)
128cdf0e10cSrcweir : ModalDialog(pWindow, CUI_RES(RID_SVXDLG_OBJECT_TITLE_DESC)),
129cdf0e10cSrcweir aFtTitle(this, CUI_RES(NTD_FT_TITLE)),
130cdf0e10cSrcweir aEdtTitle(this, CUI_RES(NTD_EDT_TITLE)),
131cdf0e10cSrcweir aFtDescription(this, CUI_RES(NTD_FT_DESC)),
132cdf0e10cSrcweir aEdtDescription(this, CUI_RES(NTD_EDT_DESC)),
133cdf0e10cSrcweir aFlSeparator(this, CUI_RES(FL_SEPARATOR_B)),
134cdf0e10cSrcweir aBtnHelp(this, CUI_RES(BTN_HELP)),
135cdf0e10cSrcweir aBtnOK(this, CUI_RES(BTN_OK)),
136cdf0e10cSrcweir aBtnCancel(this, CUI_RES(BTN_CANCEL))
137cdf0e10cSrcweir {
138cdf0e10cSrcweir FreeResource();
139cdf0e10cSrcweir
140cdf0e10cSrcweir // set title & desc
141cdf0e10cSrcweir aEdtTitle.SetText(rTitle);
142cdf0e10cSrcweir aEdtDescription.SetText(rDescription);
143cdf0e10cSrcweir
144cdf0e10cSrcweir // activate title
145cdf0e10cSrcweir aEdtTitle.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
146cdf0e10cSrcweir }
147cdf0e10cSrcweir
148cdf0e10cSrcweir /*************************************************************************
149*3215e17bSmseidel |* Dialog zum Abbrechen, Speichern oder Hinzufügen
150cdf0e10cSrcweir \************************************************************************/
151cdf0e10cSrcweir
SvxMessDialog(Window * pWindow,const String & rText,const String & rDesc,Image * pImg)152cdf0e10cSrcweir SvxMessDialog::SvxMessDialog( Window* pWindow, const String& rText, const String& rDesc, Image* pImg ) :
153cdf0e10cSrcweir ModalDialog ( pWindow, CUI_RES( RID_SVXDLG_MESSBOX ) ),
154cdf0e10cSrcweir aFtDescription ( this, CUI_RES( FT_DESCRIPTION ) ),
155cdf0e10cSrcweir aBtn1 ( this, CUI_RES( BTN_1 ) ),
156cdf0e10cSrcweir aBtn2 ( this, CUI_RES( BTN_2 ) ),
157cdf0e10cSrcweir aBtnCancel ( this, CUI_RES( BTN_CANCEL ) ),
158cdf0e10cSrcweir aFtImage ( this )
159cdf0e10cSrcweir {
160cdf0e10cSrcweir FreeResource();
161cdf0e10cSrcweir
162cdf0e10cSrcweir if( pImg )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir pImage = new Image( *pImg );
165cdf0e10cSrcweir aFtImage.SetImage( *pImage );
166cdf0e10cSrcweir aFtImage.SetStyle( ( aFtImage.GetStyle()/* | WB_NOTABSTOP */) & ~WB_3DLOOK );
167cdf0e10cSrcweir aFtImage.SetPosSizePixel( LogicToPixel( Point( 3, 6 ), MAP_APPFONT ),
168cdf0e10cSrcweir aFtImage.GetImage().GetSizePixel() );
169cdf0e10cSrcweir aFtImage.Show();
170cdf0e10cSrcweir }
171cdf0e10cSrcweir
172cdf0e10cSrcweir SetText( rText );
173cdf0e10cSrcweir aFtDescription.SetText( rDesc );
174cdf0e10cSrcweir
175cdf0e10cSrcweir aBtn1.SetClickHdl( LINK( this, SvxMessDialog, Button1Hdl ) );
176cdf0e10cSrcweir aBtn2.SetClickHdl( LINK( this, SvxMessDialog, Button2Hdl ) );
177cdf0e10cSrcweir }
178cdf0e10cSrcweir
~SvxMessDialog()179cdf0e10cSrcweir SvxMessDialog::~SvxMessDialog()
180cdf0e10cSrcweir {
181cdf0e10cSrcweir if( pImage )
182cdf0e10cSrcweir delete pImage;
183cdf0e10cSrcweir }
184cdf0e10cSrcweir
185cdf0e10cSrcweir /*************************************************************************/
186cdf0e10cSrcweir
IMPL_LINK_INLINE_START(SvxMessDialog,Button1Hdl,Button *,EMPTYARG)187cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvxMessDialog, Button1Hdl, Button *, EMPTYARG )
188cdf0e10cSrcweir {
189cdf0e10cSrcweir EndDialog( RET_BTN_1 );
190cdf0e10cSrcweir return 0;
191cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(SvxMessDialog,Button1Hdl,Button *,EMPTYARG)192cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvxMessDialog, Button1Hdl, Button *, EMPTYARG )
193cdf0e10cSrcweir
194cdf0e10cSrcweir /*************************************************************************/
195cdf0e10cSrcweir
196cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvxMessDialog, Button2Hdl, Button *, EMPTYARG )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir EndDialog( RET_BTN_2 );
199cdf0e10cSrcweir return 0;
200cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(SvxMessDialog,Button2Hdl,Button *,EMPTYARG)201cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvxMessDialog, Button2Hdl, Button *, EMPTYARG )
202cdf0e10cSrcweir
203cdf0e10cSrcweir /*************************************************************************/
204cdf0e10cSrcweir
205cdf0e10cSrcweir void SvxMessDialog::SetButtonText( sal_uInt16 nBtnId, const String& rNewTxt )
206cdf0e10cSrcweir {
207cdf0e10cSrcweir switch ( nBtnId )
208cdf0e10cSrcweir {
209cdf0e10cSrcweir case MESS_BTN_1:
210cdf0e10cSrcweir aBtn1.SetText( rNewTxt );
211cdf0e10cSrcweir break;
212cdf0e10cSrcweir
213cdf0e10cSrcweir case MESS_BTN_2:
214cdf0e10cSrcweir aBtn2.SetText( rNewTxt );
215cdf0e10cSrcweir break;
216cdf0e10cSrcweir
217cdf0e10cSrcweir default:
218*3215e17bSmseidel DBG_ERROR( "Wrong button number!" );
219cdf0e10cSrcweir }
220cdf0e10cSrcweir }
221cdf0e10cSrcweir
222*3215e17bSmseidel /* vim: set noet sw=4 ts=4: */
223