1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVTOOLS_FILECTRL_HXX
21 #define INCLUDED_SVTOOLS_FILECTRL_HXX
23 #include <svtools/svtdllapi.h>
24 #include <vcl/window.hxx>
25 #include <vcl/edit.hxx>
26 #include <vcl/button.hxx>
29 #define STR_FILECTRL_BUTTONTEXT 333 // ID-Range?!
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
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)
42 class SVT_DLLPUBLIC FileControl
: public Window
48 OUString maButtonText
;
51 Link maDialogCreatedHdl
;
53 FileControlMode mnFlags
;
54 FileControlMode_Internal mnInternalFlags
;
57 SVT_DLLPRIVATE
void ImplBrowseFile( );
60 SVT_DLLPRIVATE
void Resize();
61 SVT_DLLPRIVATE
void GetFocus();
62 SVT_DLLPRIVATE
void StateChanged( StateChangedType nType
);
63 SVT_DLLPRIVATE WinBits
ImplInitStyle( WinBits nStyle
);
64 DECL_DLLPRIVATE_LINK( ButtonHdl
, void* );
67 FileControl( Window
* pParent
, WinBits nStyle
, FileControlMode
= 0 );
70 Edit
& GetEdit() { return maEdit
; }
71 PushButton
& GetButton() { return maButton
; }
73 void Draw( OutputDevice
* pDev
, const Point
& rPos
, const Size
& rSize
, sal_uLong nFlags
);
75 void SetOpenDialog( sal_Bool bOpen
) { mbOpenDlg
= bOpen
; }
76 sal_Bool
IsOpenDialog() const { return mbOpenDlg
; }
78 void SetText( const OUString
& rStr
);
79 OUString
GetText() const;
80 OUString
GetSelectedText() const { return maEdit
.GetSelected(); }
82 void SetSelection( const Selection
& rSelection
) { maEdit
.SetSelection( rSelection
); }
83 Selection
GetSelection() const { return maEdit
.GetSelection(); }
85 void SetReadOnly( sal_Bool bReadOnly
= sal_True
) { maEdit
.SetReadOnly( bReadOnly
); }
86 sal_Bool
IsReadOnly() const { return maEdit
.IsReadOnly(); }
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
; }
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */