xref: /trunk/main/basctl/source/basicide/basicbox.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 //
28 #ifndef _BASICBOX_HXX
29 #define _BASICBOX_HXX
30 
31 #include "doceventnotifier.hxx"
32 #include <svl/stritem.hxx>
33 #include <svheader.hxx>
34 #include <sfx2/tbxctrl.hxx>
35 #include <vcl/lstbox.hxx>
36 
37 
38 class LibBoxControl: public SfxToolBoxControl
39 {
40 public:
41                         SFX_DECL_TOOLBOX_CONTROL();
42 
43                         LibBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx );
44                         ~LibBoxControl();
45 
46     virtual void        StateChanged( sal_uInt16 nSID, SfxItemState eState,
47                                       const SfxPoolItem* pState );
48     virtual Window*     CreateItemWindow( Window *pParent );
49 };
50 
51 /** base class for list boxes which need to update their content according to the list
52     of open documents
53 */
54 class DocListenerBox    :public ListBox
55                         ,public ::basctl::DocumentEventListener
56 {
57 protected:
58     DocListenerBox( Window* pParent );
59     ~DocListenerBox();
60 
61 protected:
62     virtual void    FillBox() = 0;
63 
64 private:
65     // DocumentEventListener
66     virtual void onDocumentCreated( const ScriptDocument& _rDocument );
67     virtual void onDocumentOpened( const ScriptDocument& _rDocument );
68     virtual void onDocumentSave( const ScriptDocument& _rDocument );
69     virtual void onDocumentSaveDone( const ScriptDocument& _rDocument );
70     virtual void onDocumentSaveAs( const ScriptDocument& _rDocument );
71     virtual void onDocumentSaveAsDone( const ScriptDocument& _rDocument );
72     virtual void onDocumentClosed( const ScriptDocument& _rDocument );
73     virtual void onDocumentTitleChanged( const ScriptDocument& _rDocument );
74     virtual void onDocumentModeChanged( const ScriptDocument& _rDocument );
75 
76 private:
77     ::basctl::DocumentEventNotifier m_aNotifier;
78 };
79 
80 //
81 
82 class BasicLibBox : public DocListenerBox
83 {
84 private:
85     String          aCurText;
86     sal_Bool            bIgnoreSelect;
87     sal_Bool            bFillBox;
88     com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
89 
90     void            ReleaseFocus();
91     void            InsertEntries( const ScriptDocument& rDocument, LibraryLocation eLocation );
92 
93     void            ClearBox();
94     void            NotifyIDE();
95 
96     // DocListenerBox
97     virtual void    FillBox();
98 
99 protected:
100     virtual void    Select();
101     virtual long    PreNotify( NotifyEvent& rNEvt );
102 
103 public:
104                     BasicLibBox( Window* pParent,
105                                  const com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame );
106                     ~BasicLibBox();
107 
108     using           Window::Update;
109     void            Update( const SfxStringItem* pItem );
110 };
111 
112 class LanguageBoxControl: public SfxToolBoxControl
113 {
114 public:
115                         SFX_DECL_TOOLBOX_CONTROL();
116 
117                         LanguageBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx );
118                         ~LanguageBoxControl();
119 
120     virtual void        StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
121     virtual Window*     CreateItemWindow( Window *pParent );
122 };
123 
124 class BasicLanguageBox : public DocListenerBox
125 {
126 private:
127     String          m_sNotLocalizedStr;
128     String          m_sDefaultLanguageStr;
129     String          m_sCurrentText;
130 
131     bool            m_bIgnoreSelect;
132 
133     void            ClearBox();
134     void            SetLanguage();
135 
136     // DocListenerBox
137     virtual void    FillBox();
138 
139 protected:
140     virtual void    Select();
141     virtual long    PreNotify( NotifyEvent& rNEvt );
142 
143 public:
144     BasicLanguageBox( Window* pParent );
145     ~BasicLanguageBox();
146 
147     using           Window::Update;
148     void            Update( const SfxStringItem* pItem );
149 };
150 
151 #endif  // _BASICBOX_HXX
152 
153