update dev300-m58
[ooovba.git] / svtools / inc / filectrl.hxx
blobc83b3aa4be48b9c4693ce53e2e9629f5d4e2c676
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: filectrl.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SV_FILECTRL_HXX
32 #define _SV_FILECTRL_HXX
34 #include "svtools/svtdllapi.h"
35 #include <vcl/window.hxx>
36 #include <vcl/edit.hxx>
37 #ifndef _SV_BUTTON_HXX
38 #include <vcl/button.hxx>
39 #endif
42 #define STR_FILECTRL_BUTTONTEXT 333 // ID-Range?!
44 // Flags for FileControl
45 typedef USHORT FileControlMode;
46 #define FILECTRL_RESIZEBUTTONBYPATHLEN ((USHORT)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
49 // Flags for internal use of FileControl
50 typedef USHORT FileControlMode_Internal;
51 #define FILECTRL_INRESIZE ((USHORT)0x0001)
52 #define FILECTRL_ORIGINALBUTTONTEXT ((USHORT)0x0002)
55 class SVT_DLLPUBLIC FileControl : public Window
57 private:
58 Edit maEdit;
59 PushButton maButton;
61 String maButtonText;
62 BOOL mbOpenDlg;
64 Link maDialogCreatedHdl;
66 FileControlMode mnFlags;
67 FileControlMode_Internal mnInternalFlags;
69 private:
70 SVT_DLLPRIVATE void ImplBrowseFile( );
72 protected:
73 SVT_DLLPRIVATE void Resize();
74 SVT_DLLPRIVATE void GetFocus();
75 SVT_DLLPRIVATE void StateChanged( StateChangedType nType );
76 SVT_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
77 DECL_DLLPRIVATE_LINK( ButtonHdl, PushButton* );
79 public:
80 FileControl( Window* pParent, WinBits nStyle, FileControlMode = 0 );
81 ~FileControl();
83 Edit& GetEdit() { return maEdit; }
84 PushButton& GetButton() { return maButton; }
86 void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, ULONG nFlags );
88 void SetOpenDialog( BOOL bOpen ) { mbOpenDlg = bOpen; }
89 BOOL IsOpenDialog() const { return mbOpenDlg; }
91 void SetText( const XubString& rStr );
92 XubString GetText() const;
93 UniString GetSelectedText() const { return maEdit.GetSelected(); }
95 void SetSelection( const Selection& rSelection ) { maEdit.SetSelection( rSelection ); }
96 Selection GetSelection() const { return maEdit.GetSelection(); }
98 void SetReadOnly( BOOL bReadOnly = TRUE ) { maEdit.SetReadOnly( bReadOnly ); }
99 BOOL IsReadOnly() const { return maEdit.IsReadOnly(); }
101 //------
102 //manipulate the Button-Text:
103 XubString GetButtonText() const { return maButtonText; }
104 void SetButtonText( const XubString& rStr );
105 void ResetButtonText();
107 //------
108 //use this to manipulate the dialog bevore executing it:
109 void SetDialogCreatedHdl( const Link& rLink ) { maDialogCreatedHdl = rLink; }
110 const Link& GetDialogCreatedHdl() const { return maDialogCreatedHdl; }
113 #endif