xref: /trunk/main/desktop/source/deployment/gui/descedit.cxx (revision e44970e361d561c4fb365c9f2d78a4d8a70d0e0d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_desktop.hxx"
24 
25 #include <vcl/scrbar.hxx>
26 #include <svtools/txtattr.hxx>
27 #include <svtools/xtextedt.hxx>
28 
29 #include "descedit.hxx"
30 
31 #include "dp_gui.hrc"
32 
33 using dp_gui::DescriptionEdit;
34 
35 // DescriptionEdit -------------------------------------------------------
36 
37 DescriptionEdit::DescriptionEdit( Window* pParent, const ResId& rResId ) :
38 
39     ExtMultiLineEdit( pParent, rResId ),
40 
41     m_bIsVerticalScrollBarHidden( true )
42 
43 {
44     Init();
45 }
46 
47 // -----------------------------------------------------------------------
48 
49 void DescriptionEdit::Init()
50 {
51     Clear();
52     // no tabstop
53     SetStyle( ( GetStyle() & ~WB_TABSTOP ) | WB_NOTABSTOP );
54     // read-only
55     SetReadOnly();
56     // no cursor
57     EnableCursor( sal_False );
58 }
59 
60 // -----------------------------------------------------------------------
61 
62 void DescriptionEdit::UpdateScrollBar()
63 {
64     if ( m_bIsVerticalScrollBarHidden )
65     {
66         ScrollBar*  pVScrBar = GetVScrollBar();
67         if ( pVScrBar && pVScrBar->GetVisibleSize() < pVScrBar->GetRangeMax() )
68         {
69             pVScrBar->Show();
70             m_bIsVerticalScrollBarHidden = false;
71         }
72     }
73 }
74 
75 // -----------------------------------------------------------------------
76 
77 void DescriptionEdit::Clear()
78 {
79     SetText( String() );
80 
81     m_bIsVerticalScrollBarHidden = true;
82     ScrollBar*  pVScrBar = GetVScrollBar();
83     if ( pVScrBar )
84         pVScrBar->Hide();
85 }
86 
87 // -----------------------------------------------------------------------
88 
89 void DescriptionEdit::SetDescription( const String& rDescription )
90 {
91     SetText( rDescription );
92     UpdateScrollBar();
93 }
94 
95 /* vim: set noet sw=4 ts=4: */
96