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 "commonlingui.hxx"
30 : :
31 : : #include <cuires.hrc>
32 : : #include <dialmgr.hxx>
33 : : #include <vcl/decoview.hxx>
34 : : #include <sal/macros.h>
35 : :
36 : : #include "hangulhanjadlg.hrc"
37 : :
38 : : //=============================================================================
39 : : // SvxClickInfoCtr
40 : : //=============================================================================
41 : :
42 : : //-----------------------------------------------------------------------------
43 : 0 : SvxClickInfoCtr::SvxClickInfoCtr( Window* pParent, const ResId& rResId ) :
44 : : Control( pParent, rResId ),
45 [ # # ][ # # ]: 0 : aFixedInfo( this)
46 : : {
47 [ # # ]: 0 : aFixedInfo.SetSizePixel(GetOutputSizePixel());
48 [ # # ]: 0 : aFixedInfo.Show();
49 : 0 : }
50 : :
51 : : //-----------------------------------------------------------------------------
52 : 0 : void SvxClickInfoCtr::MouseButtonDown( const MouseEvent& )
53 : : {
54 : 0 : aActivateLink.Call(this);
55 : 0 : }
56 : :
57 : : //-----------------------------------------------------------------------------
58 : 0 : long SvxClickInfoCtr::PreNotify( NotifyEvent& rNEvt )
59 : : {
60 [ # # ][ # # ]: 0 : if(rNEvt.GetType()==EVENT_GETFOCUS || rNEvt.GetType()==EVENT_MOUSEBUTTONDOWN)
[ # # ]
61 : : {
62 : 0 : aActivateLink.Call(this);
63 : : }
64 : :
65 : 0 : return Control::PreNotify(rNEvt);
66 : : }
67 : :
68 : : //-----------------------------------------------------------------------------
69 : 0 : void SvxClickInfoCtr::SetText( const XubString& rStr )
70 : : {
71 : 0 : aFixedInfo.SetText(rStr );
72 : 0 : }
73 : :
74 : : //-----------------------------------------------------------------------------
75 : 0 : XubString SvxClickInfoCtr::GetText() const
76 : : {
77 : 0 : return aFixedInfo.GetText();
78 : : }
79 : :
80 : : //-----------------------------------------------------------------------------
81 [ # # ]: 0 : SvxClickInfoCtr::~SvxClickInfoCtr()
82 : : {
83 [ # # ]: 0 : }
84 : :
85 : : //=============================================================================
86 : : // SvxCommonLinguisticControl
87 : : //=============================================================================
88 : : //-----------------------------------------------------------------------------
89 : 0 : SvxCommonLinguisticControl::SvxCommonLinguisticControl( ModalDialog* _pParent )
90 : 0 : :Window( _pParent, CUI_RES( RID_SVX_WND_COMMON_LINGU ) )
91 [ # # ]: 0 : ,aWordText ( this, CUI_RES( FT_WORD ) )
92 [ # # ]: 0 : ,aAktWord ( this, CUI_RES( FT_AKTWORD ) )
93 [ # # ]: 0 : ,aNewWord ( this, CUI_RES( FT_NEWWORD ) )
94 [ # # ]: 0 : ,aNewWordED ( this, CUI_RES( ED_NEWWORD ) )
95 [ # # ]: 0 : ,aSuggestionFT ( this, CUI_RES( FT_SUGGESTION ) )
96 [ # # ]: 0 : ,aIgnoreBtn ( this, CUI_RES( BTN_IGNORE ) )
97 [ # # ]: 0 : ,aIgnoreAllBtn ( this, CUI_RES( BTN_IGNOREALL ) )
98 [ # # ]: 0 : ,aChangeBtn ( this, CUI_RES( BTN_CHANGE ) )
99 [ # # ]: 0 : ,aChangeAllBtn ( this, CUI_RES( BTN_CHANGEALL ) )
100 [ # # ]: 0 : ,aOptionsBtn ( this, CUI_RES( BTN_OPTIONS ) )
101 [ # # ]: 0 : ,aStatusText ( this, CUI_RES( FT_STATUS ) )
102 [ # # ]: 0 : ,aHelpBtn ( this, CUI_RES( BTN_SPL_HELP ) )
103 [ # # ]: 0 : ,aCancelBtn ( this, CUI_RES( BTN_SPL_CANCEL ) )
104 [ # # ][ # # ]: 0 : ,aAuditBox ( this, CUI_RES( GB_AUDIT ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
105 : : {
106 [ # # ]: 0 : FreeResource();
107 [ # # ][ # # ]: 0 : aAktWord.SetAccessibleName(aWordText.GetText());
[ # # ]
108 [ # # ]: 0 : SetPosSizePixel( Point( 0, 0 ), _pParent->GetOutputSizePixel() );
109 [ # # ]: 0 : Show();
110 : 0 : }
111 : :
112 : : // -----------------------------------------------------------------------
113 : 0 : PushButton* SvxCommonLinguisticControl::implGetButton( ButtonType _eType ) const
114 : : {
115 : 0 : const PushButton* pButton = NULL;
116 [ # # # # : 0 : switch ( _eType )
# # # ]
117 : : {
118 : 0 : case eClose: pButton = &aCancelBtn; break;
119 : 0 : case eIgnore: pButton = &aIgnoreBtn; break;
120 : 0 : case eIgnoreAll: pButton = &aIgnoreAllBtn; break;
121 : 0 : case eChange: pButton = &aChangeBtn; break;
122 : 0 : case eChangeAll: pButton = &aChangeAllBtn; break;
123 : 0 : case eOptions: pButton = &aOptionsBtn; break;
124 : : }
125 : 0 : return const_cast< PushButton* >( pButton );
126 : : }
127 : :
128 : : // -----------------------------------------------------------------------
129 : 0 : void SvxCommonLinguisticControl::SetButtonHandler( ButtonType _eType, const Link& _rHandler )
130 : : {
131 : 0 : Button* pButton = GetButton( _eType );
132 [ # # ]: 0 : if ( pButton )
133 : 0 : pButton->SetClickHdl( _rHandler );
134 : 0 : }
135 : :
136 : : // -----------------------------------------------------------------------
137 : 0 : void SvxCommonLinguisticControl::EnableButton( ButtonType _eType, sal_Bool _bEnable )
138 : : {
139 : 0 : Button* pButton = GetButton( _eType );
140 [ # # ]: 0 : if ( pButton )
141 : 0 : pButton->Enable( _bEnable );
142 : 0 : }
143 : :
144 : : // -----------------------------------------------------------------------
145 : 0 : void SvxCommonLinguisticControl::InsertControlGroup( Window& _rFirstGroupWindow, Window& _rLastGroupWindow, ControlGroup _eInsertAfter )
146 : : {
147 : 0 : Window* pInsertAfter = NULL; // will be the last window of our own "undividable" group, after which we insert the foreign group
148 [ # # # # : 0 : switch ( _eInsertAfter )
# ]
149 : : {
150 : 0 : case eLeftRightWords : pInsertAfter = &aNewWordED; break;
151 : 0 : case eSuggestionLabel : pInsertAfter = &aSuggestionFT; break;
152 : 0 : case eActionButtons : pInsertAfter = &aChangeAllBtn; break;
153 : 0 : case eDialogButtons : pInsertAfter = &aCancelBtn; break;
154 : : }
155 : :
156 : : // now loop through the remaining windows of the foreign group
157 : 0 : Window* pInsertBehind = pInsertAfter;
158 : 0 : Window* pInsert = &_rFirstGroupWindow;
159 : :
160 : : // some strange thing below: asking a window for WINDOW_NEXT or WINDOW_PREV does not take into
161 : : // account the border window, _but_ SetZOrder _does_!. Thus, when advancing through a chain
162 : : // of windows, we need to work with the border windows (WINDOW_BORDER), instead of simply
163 : : // asking for WINDOW_NEXT.
164 : :
165 : 0 : Window* pLoopEnd = _rLastGroupWindow.GetWindow( WINDOW_BORDER );
166 [ # # ][ # # ]: 0 : while ( pInsert && ( pInsertBehind != pLoopEnd ) )
[ # # ]
167 : : {
168 : : // we'll destroy the NEXT relation immediately, so remember the next window
169 : : DBG_ASSERT( pInsert->GetWindow( WINDOW_BORDER ), "SvxCommonLinguisticControl::InsertControlGroup: border window is expected to be non NULL!" );
170 : 0 : Window* pNextInsert = pInsert->GetWindow( WINDOW_BORDER )->GetWindow( WINDOW_NEXT );
171 : : // knit
172 : 0 : pInsert->SetZOrder( pInsertBehind, WINDOW_ZORDER_BEHIND );
173 : : // advance
174 : 0 : pInsertBehind = pInsert;
175 : 0 : pInsert = pNextInsert;
176 : : }
177 : : DBG_ASSERT( pInsertBehind == pLoopEnd, "SvxCommonLinguisticControl::InsertControlGroup: controls do not form a group!" );
178 : : // if we did not reach pLoopEnd, then we did not reach _rLastGroupWindow in the loop, then
179 : : // (FirstWindow, LastWindow) was no valid control group
180 : 0 : }
181 : :
182 : : //-----------------------------------------------------------------------------
183 : 0 : void SvxCommonLinguisticControl::Paint( const Rectangle& rRect )
184 : : {
185 [ # # ]: 0 : Window::Paint(rRect );
186 : :
187 : 0 : DecorationView aDecoView( this );
188 : :
189 [ # # ][ # # ]: 0 : Rectangle aRect( aAuditBox.GetPosPixel(), aAuditBox.GetSizePixel() );
[ # # ]
190 [ # # ]: 0 : aDecoView.DrawButton( aRect, BUTTON_DRAW_NOFILL );
191 : 0 : }
192 : :
193 : : //-----------------------------------------------------------------------------
194 : 0 : void SvxCommonLinguisticControl::Enlarge( sal_Int32 _nX, sal_Int32 _nY )
195 : : {
196 : 0 : Size aSize;
197 : 0 : Point aPos;
198 : :
199 : : // the controls which need to be resized
200 : : {
201 : : Window* pResize[] =
202 : : {
203 : : this, &aAuditBox, &aStatusText
204 : 0 : };
205 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < SAL_N_ELEMENTS( pResize ); ++i )
206 : : {
207 [ # # ]: 0 : aSize = pResize[i]->GetSizePixel( );
208 [ # # ]: 0 : pResize[i]->SetSizePixel( Size( aSize.Width() + _nX, aSize.Height() + _nY ) );
209 : : }
210 : : }
211 : :
212 : : // the controls which stick to the bottom of the window
213 : : {
214 : : Window* pMoveDown[] =
215 : : {
216 : : &aStatusText, &aHelpBtn, &aCancelBtn
217 : 0 : };
218 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < SAL_N_ELEMENTS( pMoveDown ); ++i )
219 : : {
220 [ # # ]: 0 : aPos = pMoveDown[i]->GetPosPixel();
221 : 0 : aPos.Y() += _nY;
222 [ # # ]: 0 : pMoveDown[i]->SetPosPixel( aPos );
223 : : }
224 : : }
225 : :
226 : : // the controls which stick to the right
227 : : {
228 : : Window* pMoveRight[] =
229 : : {
230 : : &aIgnoreBtn, &aIgnoreAllBtn, &aChangeBtn, &aChangeAllBtn, &aOptionsBtn, &aHelpBtn, &aCancelBtn
231 : 0 : };
232 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < SAL_N_ELEMENTS( pMoveRight ); ++i )
233 : : {
234 [ # # ]: 0 : aPos = pMoveRight[i]->GetPosPixel();
235 : 0 : aPos.X() += _nX;
236 [ # # ]: 0 : pMoveRight[i]->SetPosPixel( aPos );
237 : : }
238 : : }
239 : 0 : }
240 : :
241 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|