Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <tools/shl.hxx>
30 : : #include <vcl/msgbox.hxx>
31 : :
32 : : #include <cuires.hrc>
33 : :
34 : : #include "dlgname.hxx"
35 : : #include "defdlgname.hxx"
36 : : #include "dlgname.hrc"
37 : : #include <dialmgr.hxx>
38 : :
39 : : #define MAX_DESCRIPTION_LINES ((long)5)
40 : :
41 : : /*************************************************************************
42 : : |*
43 : : |* Dialog zum Editieren eines Namens
44 : : |*
45 : : \************************************************************************/
46 : :
47 : 0 : SvxNameDialog::SvxNameDialog( Window* pWindow, const String& rName, const String& rDesc ) :
48 : 0 : ModalDialog ( pWindow, CUI_RES( RID_SVXDLG_NAME ) ),
49 [ # # ]: 0 : aFtDescription ( this, CUI_RES( FT_DESCRIPTION ) ),
50 [ # # ]: 0 : aEdtName ( this, CUI_RES( EDT_STRING ) ),
51 [ # # ]: 0 : aBtnOK ( this, CUI_RES( BTN_OK ) ),
52 [ # # ]: 0 : aBtnCancel ( this, CUI_RES( BTN_CANCEL ) ),
53 [ # # ][ # # ]: 0 : aBtnHelp ( this, CUI_RES( BTN_HELP ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
54 : : {
55 [ # # ]: 0 : FreeResource();
56 : :
57 [ # # ]: 0 : aFtDescription.SetText( rDesc );
58 [ # # ]: 0 : aEdtName.SetText( rName );
59 [ # # ]: 0 : aEdtName.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
60 [ # # ]: 0 : ModifyHdl(&aEdtName);
61 [ # # ]: 0 : aEdtName.SetModifyHdl(LINK(this, SvxNameDialog, ModifyHdl));
62 : :
63 : : // dynamic height of the description field
64 [ # # ]: 0 : Size aSize = aFtDescription.GetSizePixel();
65 [ # # ]: 0 : long nTxtWidth = aFtDescription.GetCtrlTextWidth( rDesc );
66 [ # # ]: 0 : if ( nTxtWidth > aSize.Width() )
67 : : {
68 : 0 : long nLines = Min( ( nTxtWidth / aSize.Width() + 1 ), MAX_DESCRIPTION_LINES );
69 : 0 : long nHeight = aSize.Height();
70 : 0 : aSize.Height() = nHeight * nLines;
71 [ # # ]: 0 : aFtDescription.SetSizePixel( aSize );
72 [ # # ]: 0 : Point aPnt = aEdtName.GetPosPixel();
73 : 0 : aPnt.Y() += ( aSize.Height() - nHeight );
74 [ # # ]: 0 : aEdtName.SetPosPixel( aPnt );
75 : : }
76 : 0 : }
77 : :
78 : 0 : IMPL_LINK_NOARG(SvxNameDialog, ModifyHdl)
79 : : {
80 [ # # ]: 0 : if(aCheckNameHdl.IsSet())
81 : 0 : aBtnOK.Enable(aCheckNameHdl.Call(this) > 0);
82 : 0 : return 0;
83 : : }
84 : :
85 : : ///////////////////////////////////////////////////////////////////////////////////////////////
86 : : // #i68101#
87 : : // Dialog for editing Object Name
88 : : // plus uniqueness-callback-linkHandler
89 : :
90 : 0 : SvxObjectNameDialog::SvxObjectNameDialog(
91 : : Window* pWindow,
92 : : const String& rName)
93 : 0 : : ModalDialog(pWindow, CUI_RES(RID_SVXDLG_OBJECT_NAME)),
94 [ # # ]: 0 : aFtName(this, CUI_RES(NTD_FT_NAME)),
95 [ # # ]: 0 : aEdtName(this, CUI_RES(NTD_EDT_NAME)),
96 [ # # ]: 0 : aFlSeparator(this, CUI_RES(FL_SEPARATOR_A)),
97 [ # # ]: 0 : aBtnHelp(this, CUI_RES(BTN_HELP)),
98 [ # # ]: 0 : aBtnOK(this, CUI_RES(BTN_OK)),
99 [ # # ][ # # ]: 0 : aBtnCancel(this, CUI_RES(BTN_CANCEL))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
100 : : {
101 [ # # ]: 0 : FreeResource();
102 : :
103 : : // set name
104 [ # # ]: 0 : aEdtName.SetText(rName);
105 : :
106 : : // activate name
107 [ # # ]: 0 : aEdtName.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
108 [ # # ]: 0 : ModifyHdl(&aEdtName);
109 [ # # ]: 0 : aEdtName.SetModifyHdl(LINK(this, SvxObjectNameDialog, ModifyHdl));
110 : 0 : }
111 : :
112 : 0 : IMPL_LINK_NOARG(SvxObjectNameDialog, ModifyHdl)
113 : : {
114 [ # # ]: 0 : if(aCheckNameHdl.IsSet())
115 : : {
116 : 0 : aBtnOK.Enable(aCheckNameHdl.Call(this) > 0);
117 : : }
118 : :
119 : 0 : return 0;
120 : : }
121 : :
122 : : ///////////////////////////////////////////////////////////////////////////////////////////////
123 : : // #i68101#
124 : : // Dialog for editing Object Title and Description
125 : :
126 : 0 : SvxObjectTitleDescDialog::SvxObjectTitleDescDialog(
127 : : Window* pWindow,
128 : : const String& rTitle,
129 : : const String& rDescription)
130 : 0 : : ModalDialog(pWindow, CUI_RES(RID_SVXDLG_OBJECT_TITLE_DESC)),
131 [ # # ]: 0 : aFtTitle(this, CUI_RES(NTD_FT_TITLE)),
132 [ # # ]: 0 : aEdtTitle(this, CUI_RES(NTD_EDT_TITLE)),
133 [ # # ]: 0 : aFtDescription(this, CUI_RES(NTD_FT_DESC)),
134 [ # # ]: 0 : aEdtDescription(this, CUI_RES(NTD_EDT_DESC)),
135 [ # # ]: 0 : aFlSeparator(this, CUI_RES(FL_SEPARATOR_B)),
136 [ # # ]: 0 : aBtnHelp(this, CUI_RES(BTN_HELP)),
137 [ # # ]: 0 : aBtnOK(this, CUI_RES(BTN_OK)),
138 [ # # ][ # # ]: 0 : aBtnCancel(this, CUI_RES(BTN_CANCEL))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
139 : : {
140 [ # # ]: 0 : FreeResource();
141 : :
142 : : // set title & desc
143 [ # # ]: 0 : aEdtTitle.SetText(rTitle);
144 [ # # ]: 0 : aEdtDescription.SetText(rDescription);
145 : :
146 : : // activate title
147 [ # # ]: 0 : aEdtTitle.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
148 : 0 : }
149 : :
150 : : ///////////////////////////////////////////////////////////////////////////////////////////////
151 : :
152 : : /*************************************************************************
153 : : |*
154 : : |* dialog for cancelling, saving or adding
155 : : |*
156 : : \************************************************************************/
157 : :
158 : 0 : SvxMessDialog::SvxMessDialog( Window* pWindow, const String& rText, const String& rDesc, Image* pImg ) :
159 : 0 : ModalDialog ( pWindow, CUI_RES( RID_SVXDLG_MESSBOX ) ),
160 [ # # ]: 0 : aFtDescription ( this, CUI_RES( FT_DESCRIPTION ) ),
161 [ # # ]: 0 : aBtn1 ( this, CUI_RES( BTN_1 ) ),
162 [ # # ]: 0 : aBtn2 ( this, CUI_RES( BTN_2 ) ),
163 [ # # ]: 0 : aBtnCancel ( this, CUI_RES( BTN_CANCEL ) ),
164 [ # # ][ # # ]: 0 : aFtImage ( this )
[ # # ][ # # ]
[ # # ][ # # ]
165 : : {
166 [ # # ]: 0 : FreeResource();
167 : :
168 [ # # ]: 0 : if( pImg )
169 : : {
170 [ # # ][ # # ]: 0 : pImage = new Image( *pImg );
171 [ # # ]: 0 : aFtImage.SetImage( *pImage );
172 [ # # ][ # # ]: 0 : aFtImage.SetStyle( ( aFtImage.GetStyle()/* | WB_NOTABSTOP */) & ~WB_3DLOOK );
173 [ # # ][ # # ]: 0 : aFtImage.SetPosSizePixel( LogicToPixel( Point( 3, 6 ), MAP_APPFONT ),
174 [ # # # # ]: 0 : aFtImage.GetImage().GetSizePixel() );
[ # # ]
175 [ # # ]: 0 : aFtImage.Show();
176 : : }
177 : :
178 [ # # ]: 0 : SetText( rText );
179 [ # # ]: 0 : aFtDescription.SetText( rDesc );
180 : :
181 [ # # ]: 0 : aBtn1.SetClickHdl( LINK( this, SvxMessDialog, Button1Hdl ) );
182 [ # # ]: 0 : aBtn2.SetClickHdl( LINK( this, SvxMessDialog, Button2Hdl ) );
183 : 0 : }
184 : :
185 [ # # ][ # # ]: 0 : SvxMessDialog::~SvxMessDialog()
[ # # ][ # # ]
[ # # ]
186 : : {
187 [ # # ]: 0 : if( pImage )
188 [ # # ][ # # ]: 0 : delete pImage;
189 [ # # ]: 0 : }
190 : :
191 : : /*************************************************************************/
192 : :
193 : 0 : IMPL_LINK_NOARG_INLINE_START(SvxMessDialog, Button1Hdl)
194 : : {
195 : 0 : EndDialog( RET_BTN_1 );
196 : 0 : return 0;
197 : : }
198 : 0 : IMPL_LINK_NOARG_INLINE_END(SvxMessDialog, Button1Hdl)
199 : :
200 : : /*************************************************************************/
201 : :
202 : 0 : IMPL_LINK_NOARG_INLINE_START(SvxMessDialog, Button2Hdl)
203 : : {
204 : 0 : EndDialog( RET_BTN_2 );
205 : 0 : return 0;
206 : : }
207 : 0 : IMPL_LINK_NOARG_INLINE_END(SvxMessDialog, Button2Hdl)
208 : :
209 : : /*************************************************************************/
210 : :
211 : 0 : void SvxMessDialog::SetButtonText( sal_uInt16 nBtnId, const String& rNewTxt )
212 : : {
213 [ # # # ]: 0 : switch ( nBtnId )
214 : : {
215 : : case MESS_BTN_1:
216 : 0 : aBtn1.SetText( rNewTxt );
217 : 0 : break;
218 : :
219 : : case MESS_BTN_2:
220 : 0 : aBtn2.SetText( rNewTxt );
221 : 0 : break;
222 : :
223 : : default:
224 : : OSL_FAIL( "Falsche Button-Nummer!!!" );
225 : : }
226 : 0 : }
227 : :
228 : :
229 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|