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 23 24 #ifndef _SV_FILECTRL_HXX 25 #define _SV_FILECTRL_HXX 26 27 #include "svtools/svtdllapi.h" 28 #include <vcl/window.hxx> 29 #include <vcl/edit.hxx> 30 #ifndef _SV_BUTTON_HXX 31 #include <vcl/button.hxx> 32 #endif 33 34 35 #define STR_FILECTRL_BUTTONTEXT 333 // ID-Range?! 36 37 // Flags for FileControl 38 typedef sal_uInt16 FileControlMode; 39 #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 40 41 42 // Flags for internal use of FileControl 43 typedef sal_uInt16 FileControlMode_Internal; 44 #define FILECTRL_INRESIZE ((sal_uInt16)0x0001) 45 #define FILECTRL_ORIGINALBUTTONTEXT ((sal_uInt16)0x0002) 46 47 48 class SVT_DLLPUBLIC FileControl : public Window 49 { 50 private: 51 Edit maEdit; 52 PushButton maButton; 53 54 String maButtonText; 55 sal_Bool mbOpenDlg; 56 57 Link maDialogCreatedHdl; 58 59 FileControlMode mnFlags; 60 FileControlMode_Internal mnInternalFlags; 61 62 private: 63 SVT_DLLPRIVATE void ImplBrowseFile( ); 64 65 protected: 66 SVT_DLLPRIVATE void Resize(); 67 SVT_DLLPRIVATE void GetFocus(); 68 SVT_DLLPRIVATE void StateChanged( StateChangedType nType ); 69 SVT_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle ); 70 DECL_DLLPRIVATE_LINK( ButtonHdl, PushButton* ); 71 72 public: 73 FileControl( Window* pParent, WinBits nStyle, FileControlMode = 0 ); 74 ~FileControl(); 75 GetEdit()76 Edit& GetEdit() { return maEdit; } GetButton()77 PushButton& GetButton() { return maButton; } 78 79 void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); 80 SetOpenDialog(sal_Bool bOpen)81 void SetOpenDialog( sal_Bool bOpen ) { mbOpenDlg = bOpen; } IsOpenDialog() const82 sal_Bool IsOpenDialog() const { return mbOpenDlg; } 83 84 void SetText( const XubString& rStr ); 85 XubString GetText() const; GetSelectedText() const86 UniString GetSelectedText() const { return maEdit.GetSelected(); } 87 SetSelection(const Selection & rSelection)88 void SetSelection( const Selection& rSelection ) { maEdit.SetSelection( rSelection ); } GetSelection() const89 Selection GetSelection() const { return maEdit.GetSelection(); } 90 SetReadOnly(sal_Bool bReadOnly=sal_True)91 void SetReadOnly( sal_Bool bReadOnly = sal_True ) { maEdit.SetReadOnly( bReadOnly ); } IsReadOnly() const92 sal_Bool IsReadOnly() const { return maEdit.IsReadOnly(); } 93 94 //------ 95 //manipulate the Button-Text: GetButtonText() const96 XubString GetButtonText() const { return maButtonText; } 97 void SetButtonText( const XubString& rStr ); 98 void ResetButtonText(); 99 100 //------ 101 //use this to manipulate the dialog before executing it: SetDialogCreatedHdl(const Link & rLink)102 void SetDialogCreatedHdl( const Link& rLink ) { maDialogCreatedHdl = rLink; } GetDialogCreatedHdl() const103 const Link& GetDialogCreatedHdl() const { return maDialogCreatedHdl; } 104 }; 105 106 #endif 107 108