Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SVTOOLS_FILECTRL_HXX
21 : #define INCLUDED_SVTOOLS_FILECTRL_HXX
22 :
23 : #include <svtools/svtdllapi.h>
24 : #include <vcl/window.hxx>
25 : #include <vcl/edit.hxx>
26 : #include <vcl/button.hxx>
27 :
28 :
29 : #define STR_FILECTRL_BUTTONTEXT 333 // ID-Range?!
30 :
31 : // Flags for FileControl
32 : typedef sal_uInt16 FileControlMode;
33 : #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
34 :
35 :
36 : // Flags for internal use of FileControl
37 : typedef sal_uInt16 FileControlMode_Internal;
38 : #define FILECTRL_INRESIZE ((sal_uInt16)0x0001)
39 : #define FILECTRL_ORIGINALBUTTONTEXT ((sal_uInt16)0x0002)
40 :
41 :
42 : class SVT_DLLPUBLIC FileControl : public vcl::Window
43 : {
44 : private:
45 : Edit maEdit;
46 : PushButton maButton;
47 :
48 : OUString maButtonText;
49 : bool mbOpenDlg;
50 :
51 : Link maDialogCreatedHdl;
52 :
53 : FileControlMode mnFlags;
54 : FileControlMode_Internal mnInternalFlags;
55 :
56 : private:
57 : SVT_DLLPRIVATE void ImplBrowseFile( );
58 :
59 : protected:
60 : SVT_DLLPRIVATE void Resize() SAL_OVERRIDE;
61 : SVT_DLLPRIVATE void GetFocus() SAL_OVERRIDE;
62 : SVT_DLLPRIVATE void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
63 : SVT_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
64 : DECL_DLLPRIVATE_LINK( ButtonHdl, void* );
65 :
66 : public:
67 : FileControl( vcl::Window* pParent, WinBits nStyle, FileControlMode = 0 );
68 : virtual ~FileControl();
69 :
70 0 : Edit& GetEdit() { return maEdit; }
71 0 : PushButton& GetButton() { return maButton; }
72 :
73 : void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE;
74 :
75 : void SetOpenDialog( bool bOpen ) { mbOpenDlg = bOpen; }
76 : bool IsOpenDialog() const { return mbOpenDlg; }
77 :
78 : void SetText( const OUString& rStr ) SAL_OVERRIDE;
79 : OUString GetText() const SAL_OVERRIDE;
80 : OUString GetSelectedText() const { return maEdit.GetSelected(); }
81 :
82 : void SetSelection( const Selection& rSelection ) { maEdit.SetSelection( rSelection ); }
83 : Selection GetSelection() const { return maEdit.GetSelection(); }
84 :
85 : void SetReadOnly( bool bReadOnly = true ) { maEdit.SetReadOnly( bReadOnly ); }
86 : bool IsReadOnly() const { return maEdit.IsReadOnly(); }
87 :
88 :
89 : //use this to manipulate the dialog bevore executing it:
90 : void SetDialogCreatedHdl( const Link& rLink ) { maDialogCreatedHdl = rLink; }
91 : const Link& GetDialogCreatedHdl() const { return maDialogCreatedHdl; }
92 : };
93 :
94 : #endif
95 :
96 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|