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 SVX_COMMON_LINGUI_HXX
25 #define SVX_COMMON_LINGUI_HXX
26 
27 #include <vcl/ctrl.hxx>
28 #include <svtools/stdctrl.hxx>
29 #include <vcl/edit.hxx>
30 #include <svtools/svxbox.hxx>
31 #ifndef _SV_BUTTON_HXX
32 #include <vcl/button.hxx>
33 #endif
34 #include <vcl/group.hxx>
35 #include <vcl/dialog.hxx>
36 
37 //=============================================================================
38 // SvxClickInfoCtr
39 //=============================================================================
40 
41 class SvxClickInfoCtr: public Control
42 {
43 private:
44 	FixedInfo					aFixedInfo;
45 	Link						aActivateLink;
46 
47 public:
48 	SvxClickInfoCtr( Window* pParent, const ResId& rResId );
49 	~SvxClickInfoCtr();
50 
51 	virtual void		SetText( const XubString& rStr );
52 	virtual XubString	GetText() const;
53 
SetActivateHdl(const Link & rLink)54 	void				SetActivateHdl( const Link& rLink ) { aActivateLink = rLink; }
GetActivateHdl() const55 	const Link&			GetActivateHdl() const { return aActivateLink; }
56 
57 protected:
58 	virtual void		MouseButtonDown( const MouseEvent& rMEvt );
59 	virtual long		PreNotify( NotifyEvent& rNEvt );
60 
61 };
62 
63 //=============================================================================
64 // SvxCommonLinguisticControl
65 //=============================================================================
66 class SvxCommonLinguisticControl : public Window
67 {
68 public:
69 	enum ButtonType
70 	{
71 		eClose,
72 		eIgnore,
73 		eIgnoreAll,
74 		eChange,
75 		eChangeAll,
76 		eOptions
77 	};
78 
79 protected:
80 	FixedText       aWordText;
81 	SvxClickInfoCtr aAktWord;
82 
83     FixedText       aNewWord;
84 	Edit            aNewWordED;
85 
86 	FixedText		aSuggestionFT;
87 
88 	PushButton      aIgnoreBtn;
89 	PushButton      aIgnoreAllBtn;
90 	PushButton      aChangeBtn;
91 	PushButton      aChangeAllBtn;
92 	PushButton		aOptionsBtn;
93 
94 	FixedInfo       aStatusText;
95 	HelpButton      aHelpBtn;
96     CancelButton    aCancelBtn;
97 
98 	GroupBox        aAuditBox;
99 
100 protected:
101 	virtual void	Paint( const Rectangle& rRect );
102 
103 private:
104 	PushButton*	implGetButton( ButtonType _eType  ) const;
105 
106 public:
107 	SvxCommonLinguisticControl( ModalDialog* _pParent );
108 
109 	// handlers
SetResetWordHdl(const Link & _rLink)110 	inline void			SetResetWordHdl( const Link& _rLink )	{ aAktWord.SetActivateHdl( _rLink ); }
GetResetWordHdl() const111 	inline const Link&	GetResetWordHdl() const					{ return aAktWord.GetActivateHdl(); }
112 
113 	void	SetButtonHandler( ButtonType _eType, const Link& _rHandler );
114 	void	EnableButton( ButtonType _eType, sal_Bool _bEnable );
115 
GetButton(ButtonType _eType)116 	inline	PushButton*			GetButton( ButtonType _eType )			{ return implGetButton( _eType  ); }
GetButton(ButtonType _eType) const117 	inline	const PushButton*	GetButton( ButtonType _eType ) const	{ return implGetButton( _eType  ); }
118 
119 	// users of this class may want to insert own controls in some places, where the ordinary
120 	// Z-Order determined by construction time is not sufficient
121 	// Use the following methods for this
122 	enum ControlGroup // control groups in this window which cannot be divided (e.g. are adjacent in the Z order)
123 	{
124 		eLeftRightWords,	// the controls for the two words (original and suggestion), including the labels
125 		eSuggestionLabel,	// the label for the suggestion
126 		eActionButtons,		// the group of "ignore(all)" / "change(all)" buttons
127 		eDialogButtons		// the group of dialog control buttons (help and close)
128 	};
129 	void	InsertControlGroup( Window& _rFirstGroupWindow, Window& _rLastGroupWindow, ControlGroup _eInsertAfter );
130 
131 	/** enlarges the window
132 
133 		Some controls "stick" to the borders: The group of change/ignore buttons, for instance, sticks
134 		to the right, the dictionary list as well as the close/help buttons stick to the bottom of the
135 		window.
136 	*/
137 	void	Enlarge( sal_Int32 _nX, sal_Int32 _nY );
138 
139 	// control access methods
SetCurrentText(const String & _rText)140 	inline void		SetCurrentText( const String& _rText )	{ aAktWord.SetText( _rText ); }
GetCurrentText() const141 	inline String	GetCurrentText( ) const					{ return aAktWord.GetText(); }
142 
SetStatusText(const String & _rText)143 	inline void		SetStatusText( const String& _rText )	{ aStatusText.SetText( _rText ); }
GetStatusText() const144 	inline String	GetStatusText( ) const					{ return aStatusText.GetText(); }
145 
GetWordInputControl()146 	inline Edit&		GetWordInputControl()			{ return aNewWordED; }
GetWordInputControl() const147 	inline const Edit&	GetWordInputControl() const	{ return aNewWordED; }
148 
149 	// returns the location (upper-left corner) of the group of action buttons
GetActionButtonsLocation() const150 	inline Point	GetActionButtonsLocation( ) const { return aIgnoreBtn.GetPosPixel(); }
151 };
152 
153 
154 
155 #endif // SVX_COMMON_LINGUI_HXX
156