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