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 : : #ifndef _SV_FILECTRL_HXX
30 : : #define _SV_FILECTRL_HXX
31 : :
32 : : #include "svtools/svtdllapi.h"
33 : : #include <vcl/window.hxx>
34 : : #include <vcl/edit.hxx>
35 : : #include <vcl/button.hxx>
36 : :
37 : :
38 : : #define STR_FILECTRL_BUTTONTEXT 333 // ID-Range?!
39 : :
40 : : // Flags for FileControl
41 : : typedef sal_uInt16 FileControlMode;
42 : : #define FILECTRL_RESIZEBUTTONBYPATHLEN ((sal_uInt16)0x0001)//if this is set, the button will become small as soon as the Text in the Edit Field is to long to be shown completely
43 : :
44 : :
45 : : // Flags for internal use of FileControl
46 : : typedef sal_uInt16 FileControlMode_Internal;
47 : : #define FILECTRL_INRESIZE ((sal_uInt16)0x0001)
48 : : #define FILECTRL_ORIGINALBUTTONTEXT ((sal_uInt16)0x0002)
49 : :
50 : :
51 : : class SVT_DLLPUBLIC FileControl : public Window
52 : : {
53 : : private:
54 : : Edit maEdit;
55 : : PushButton maButton;
56 : :
57 : : String maButtonText;
58 : : sal_Bool mbOpenDlg;
59 : :
60 : : Link maDialogCreatedHdl;
61 : :
62 : : FileControlMode mnFlags;
63 : : FileControlMode_Internal mnInternalFlags;
64 : :
65 : : private:
66 : : SVT_DLLPRIVATE void ImplBrowseFile( );
67 : :
68 : : protected:
69 : : SVT_DLLPRIVATE void Resize();
70 : : SVT_DLLPRIVATE void GetFocus();
71 : : SVT_DLLPRIVATE void StateChanged( StateChangedType nType );
72 : : SVT_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
73 : : DECL_DLLPRIVATE_LINK( ButtonHdl, void* );
74 : :
75 : : public:
76 : : FileControl( Window* pParent, WinBits nStyle, FileControlMode = 0 );
77 : : ~FileControl();
78 : :
79 : 0 : Edit& GetEdit() { return maEdit; }
80 : 0 : PushButton& GetButton() { return maButton; }
81 : :
82 : : void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
83 : :
84 : : void SetOpenDialog( sal_Bool bOpen ) { mbOpenDlg = bOpen; }
85 : : sal_Bool IsOpenDialog() const { return mbOpenDlg; }
86 : :
87 : : void SetText( const XubString& rStr );
88 : : XubString GetText() const;
89 : : rtl::OUString GetSelectedText() const { return maEdit.GetSelected(); }
90 : :
91 : : void SetSelection( const Selection& rSelection ) { maEdit.SetSelection( rSelection ); }
92 : : Selection GetSelection() const { return maEdit.GetSelection(); }
93 : :
94 : : void SetReadOnly( sal_Bool bReadOnly = sal_True ) { maEdit.SetReadOnly( bReadOnly ); }
95 : : sal_Bool IsReadOnly() const { return maEdit.IsReadOnly(); }
96 : :
97 : : //------
98 : : //use this to manipulate the dialog bevore executing it:
99 : : void SetDialogCreatedHdl( const Link& rLink ) { maDialogCreatedHdl = rLink; }
100 : : const Link& GetDialogCreatedHdl() const { return maDialogCreatedHdl; }
101 : : };
102 : :
103 : : #endif
104 : :
105 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|