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