xref: /AOO41X/main/soldep/source/tbox.cxx (revision d9e04f7d457e8d4292f3a8dc854ee7656a676fbb)
1*d9e04f7dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*d9e04f7dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*d9e04f7dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*d9e04f7dSAndrew Rist  * distributed with this work for additional information
6*d9e04f7dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*d9e04f7dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*d9e04f7dSAndrew Rist  * "License"); you may not use this file except in compliance
9*d9e04f7dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*d9e04f7dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*d9e04f7dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*d9e04f7dSAndrew Rist  * software distributed under the License is distributed on an
15*d9e04f7dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d9e04f7dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*d9e04f7dSAndrew Rist  * specific language governing permissions and limitations
18*d9e04f7dSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*d9e04f7dSAndrew Rist  *************************************************************/
21*d9e04f7dSAndrew Rist 
22*d9e04f7dSAndrew Rist 
23cdf0e10cSrcweir #define private public
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include <tools/ref.hxx>
26cdf0e10cSrcweir #include <vcl/msgbox.hxx>
27cdf0e10cSrcweir #include <soldep/soldep.hxx>
28cdf0e10cSrcweir #include <soldep/tbox.hxx>
29cdf0e10cSrcweir #include <soldep/soldlg.hrc>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir 
SoldepToolBox(Window * pParent,const ResId & aId,sal_Bool bDAble)33cdf0e10cSrcweir SoldepToolBox::SoldepToolBox( Window* pParent, const ResId& aId, sal_Bool bDAble ) :
34cdf0e10cSrcweir 				ToolBox( pParent, aId ),
35cdf0e10cSrcweir 				bDockable( bDAble ),
36cdf0e10cSrcweir 				bCloseMode( sal_False ),
37cdf0e10cSrcweir 				bBoxIsVisible( sal_True ),
38cdf0e10cSrcweir 				bPinable( sal_True ),
39cdf0e10cSrcweir                 aPinedBitmap( DtSodResId( TID_SMALL_PIN_PINED )),     // BMP_SMALL_PIN_PINED
40cdf0e10cSrcweir                 aUnpinedBitmap( DtSodResId( TID_SMALL_PIN_UNPINED ))   // BMP_SMALL_PIN_UNPINED
41cdf0e10cSrcweir {
42cdf0e10cSrcweir     bPinable = sal_True;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir     SetAlign( WINDOWALIGN_TOP );
45cdf0e10cSrcweir     HideItem(TID_SOLDEP_BACK);    //Inital hide this item, activated in project view.
46cdf0e10cSrcweir     HideItem(TID_SOLDEP_SAVE);    // Hide this item now, not used yet
47cdf0e10cSrcweir     HideItem(TID_SOLDEP_OPEN);    // Hide this item now, not used yet
48cdf0e10cSrcweir 
49cdf0e10cSrcweir     //SetMouseDownHdl(LINK(this,SoldepToolBox,MouseDownHdl));
50cdf0e10cSrcweir 	//SetFloatingLines( nFloatingLines );
51cdf0e10cSrcweir 	//SetFloatingMode( bFloatingMode );
52cdf0e10cSrcweir 	sal_Bool bFloatingMode = sal_False;
53cdf0e10cSrcweir 	if ( bFloatingMode )
54cdf0e10cSrcweir 	{
55cdf0e10cSrcweir 		//Point aPos( sToolBoxInfo.GetToken( 4, ',' ).ToInt64(), sToolBoxInfo.GetToken( 5, ',' ).ToInt64());
56cdf0e10cSrcweir 		//SetPosPixel( aPos );
57cdf0e10cSrcweir 	}
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 	if ( bDockable ) InsertSeparator( 0 );  // Freiraum f�r Abrei�d�del schaffen
60cdf0e10cSrcweir 											// (ein Separator an 1er Pos wird
61cdf0e10cSrcweir 											// nicht gezeichnet,
62cdf0e10cSrcweir 											// schafft aber Platz.)
63cdf0e10cSrcweir 	bBoxIsVisible = sal_False;
64cdf0e10cSrcweir //	if ( sToolBoxInfo.GetToken( 3, ',' ) == "Visible" ) {
65cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < GetItemCount() && !bBoxIsVisible; i++ )
66cdf0e10cSrcweir 		{
67cdf0e10cSrcweir //			sal_uInt16 nItemId = GetItemId( i );
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 			switch ( GetItemType( i ))
70cdf0e10cSrcweir 			{
71cdf0e10cSrcweir 				case TOOLBOXITEM_SPACE:
72cdf0e10cSrcweir 					break;
73cdf0e10cSrcweir 				case TOOLBOXITEM_SEPARATOR :
74cdf0e10cSrcweir 					break;
75cdf0e10cSrcweir 				default:
76cdf0e10cSrcweir 					bBoxIsVisible = sal_True;
77cdf0e10cSrcweir 					break;
78cdf0e10cSrcweir 			}
79cdf0e10cSrcweir 		}
80cdf0e10cSrcweir //	}
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	if ( bBoxIsVisible ) {
83cdf0e10cSrcweir 		if (!bDockable)
84cdf0e10cSrcweir 			Show();
85cdf0e10cSrcweir 		else
86cdf0e10cSrcweir 			Hide();
87cdf0e10cSrcweir 	}
88cdf0e10cSrcweir 	else
89cdf0e10cSrcweir 		Hide();
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 	bOldFloatMode = IsFloatingMode();
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir /*************************************************************************
95cdf0e10cSrcweir |* SoldepToolBox::~SoldepToolBox()
96cdf0e10cSrcweir |************************************************************************/
97cdf0e10cSrcweir 
~SoldepToolBox()98cdf0e10cSrcweir SoldepToolBox::~SoldepToolBox()
99cdf0e10cSrcweir {
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir /*************************************************************************
103cdf0e10cSrcweir |* SoldepToolBox::Paint()
104cdf0e10cSrcweir |************************************************************************/
105cdf0e10cSrcweir 
Paint(const Rectangle & rRect)106cdf0e10cSrcweir void SoldepToolBox::Paint( const Rectangle& rRect )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir 		SetOutStyle(  TOOLBOX_STYLE_FLAT );
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	// Wenn wir eine Dockable ToolBox haben, ...
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 	if ( bDockable )
113cdf0e10cSrcweir 	{
114cdf0e10cSrcweir 		sal_uInt16 nItemId = GetItemId( 0 );
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 		// ... zeichnen wir den wunderbaren Abrei�d�del �ber das erste Item (Seperator)
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 		if ( !IsFloatingMode() && ( mnCurLine == 1 )) {
119cdf0e10cSrcweir 			sal_Bool bIsCloseable = (( mnWinStyle & WB_CLOSEABLE ) != 0 );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 			ShowItem( nItemId );
122cdf0e10cSrcweir 			Rectangle aRect = GetItemRect( nItemId );
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 			ToolBox::Paint( rRect );
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 			if ( bIsCloseable )
127cdf0e10cSrcweir 			{
128cdf0e10cSrcweir 				// Paint small cross button left/top of toolbar
129cdf0e10cSrcweir                 SetLineColor( Color( COL_WHITE ));
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 				DrawLine( Point( aRect.Left(), aRect.Top()), Point( aRect.Left()+6, aRect.Top()));
132cdf0e10cSrcweir 				DrawLine( Point( aRect.Left(), aRect.Top()), Point( aRect.Left(), aRect.Top()+6));
133cdf0e10cSrcweir 
134cdf0e10cSrcweir                 SetLineColor( Color( COL_GRAY ));
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 				DrawLine( Point( aRect.Left(), aRect.Top()+6), Point( aRect.Left()+6, aRect.Top()+6));
137cdf0e10cSrcweir 				DrawLine( Point( aRect.Left()+6, aRect.Top()), Point( aRect.Left()+6, aRect.Top()+6));
138cdf0e10cSrcweir 
139cdf0e10cSrcweir                 SetLineColor( Color( COL_BLACK ));
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 				DrawLine( Point( aRect.Left()+2, aRect.Top()+2), Point( aRect.Left()+4, aRect.Top()+4));
142cdf0e10cSrcweir 				DrawLine( Point( aRect.Left()+2, aRect.Top()+4), Point( aRect.Left()+4, aRect.Top()+2));
143cdf0e10cSrcweir 			}
144cdf0e10cSrcweir 			else if ( bPinable )
145cdf0e10cSrcweir 			{
146cdf0e10cSrcweir 				if ( GetPin())
147cdf0e10cSrcweir 					DrawBitmap( Point( aRect.Left(), aRect.Top()), aPinedBitmap );
148cdf0e10cSrcweir 				else
149cdf0e10cSrcweir 					DrawBitmap( Point( aRect.Left(), aRect.Top()), aUnpinedBitmap );
150cdf0e10cSrcweir 			}
151cdf0e10cSrcweir 
152cdf0e10cSrcweir             SetLineColor( Color( COL_WHITE ));
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 			if ( IsHorizontal())
155cdf0e10cSrcweir 			{
156cdf0e10cSrcweir 				if ( bIsCloseable || bPinable ) aRect = Rectangle( Point( aRect.Left(), aRect.Top()+8), Point( aRect.Right(), aRect.Bottom()));
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 				DrawLine( Point(aRect.Left(), aRect.Top()), Point(aRect.Left(), aRect.Bottom()));
159cdf0e10cSrcweir 				DrawLine( Point(aRect.Left(), aRect.Top()), Point(aRect.Left()+2, aRect.Top()));
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 				SetLineColor( Color( COL_WHITE ));
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 				DrawLine( Point(aRect.Left()+4, aRect.Top()), Point(aRect.Left()+4, aRect.Bottom()));
164cdf0e10cSrcweir 				DrawLine( Point(aRect.Left()+4, aRect.Top()), Point(aRect.Left()+6, aRect.Top()));
165cdf0e10cSrcweir 
166cdf0e10cSrcweir                 SetLineColor( Color( COL_GRAY ));//GRAY
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 				DrawLine( Point(aRect.Left()+2, aRect.Top()), Point(aRect.Left()+2, aRect.Bottom()));
169cdf0e10cSrcweir 				DrawLine( Point(aRect.Left(), aRect.Bottom()), Point(aRect.Left()+2, aRect.Bottom()));
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 				SetLineColor( Color( COL_BLACK ));
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 				DrawLine( Point(aRect.Left()+6, aRect.Top()), Point(aRect.Left()+6, aRect.Bottom()));
174cdf0e10cSrcweir 				DrawLine( Point(aRect.Left()+4, aRect.Bottom()), Point(aRect.Left()+6, aRect.Bottom()));
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 			}
177cdf0e10cSrcweir 			else
178cdf0e10cSrcweir 			{
179cdf0e10cSrcweir 				if ( bIsCloseable || bPinable ) aRect = Rectangle( Point( aRect.Left()+8, aRect.Top()), Point( aRect.Right(), aRect.Bottom()));
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 				DrawLine( Point( aRect.Left(), aRect.Top()), Point( aRect.Left(), aRect.Top()+2));
182cdf0e10cSrcweir 				DrawLine( Point( aRect.Left(), aRect.Top()), Point( aRect.Right(), aRect.Top()));
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 				DrawLine( Point( aRect.Left(), aRect.Top()+4), Point( aRect.Left(), aRect.Top()+6));
185cdf0e10cSrcweir 				DrawLine( Point( aRect.Left(), aRect.Top()+4), Point( aRect.Right(), aRect.Top()+4));
186cdf0e10cSrcweir 
187cdf0e10cSrcweir                 SetLineColor( Color( COL_GRAY ));
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 				DrawLine( Point( aRect.Left(), aRect.Top()+2), Point( aRect.Right(),aRect.Top()+2));
190cdf0e10cSrcweir 				DrawLine( Point( aRect.Right(), aRect.Top()), Point( aRect.Right(), aRect.Top()+2));
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 				DrawLine( Point( aRect.Left(), aRect.Top()+6), Point( aRect.Right(),aRect.Top()+6));
193cdf0e10cSrcweir 				DrawLine( Point( aRect.Right(), aRect.Top()+4), Point( aRect.Right(), aRect.Top()+6));
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 			}
196cdf0e10cSrcweir 		}
197cdf0e10cSrcweir 		else
198cdf0e10cSrcweir 		{
199cdf0e10cSrcweir             // Sind wir im FloatingMode, dann wollen wir keinen Abrei�d�del haben
200cdf0e10cSrcweir 			// und hiden somit das erste Item.
201cdf0e10cSrcweir 
202cdf0e10cSrcweir             //Hiden l�scht leider das erste Object der n�chsten Zeile, daher nicht
203cdf0e10cSrcweir             //l�schen
204cdf0e10cSrcweir 			HideItem( nItemId );
205cdf0e10cSrcweir 			ToolBox::Paint( rRect );
206cdf0e10cSrcweir 		}
207cdf0e10cSrcweir 	}
208cdf0e10cSrcweir 	else
209cdf0e10cSrcweir 	{
210cdf0e10cSrcweir 		ToolBox::Paint( rRect );
211cdf0e10cSrcweir 	}
212cdf0e10cSrcweir }
213cdf0e10cSrcweir 
214cdf0e10cSrcweir /*************************************************************************
215cdf0e10cSrcweir |* SoldepToolBox::MouseButtonDown()
216cdf0e10cSrcweir |************************************************************************/
217cdf0e10cSrcweir 
MouseButtonDown(const MouseEvent & rEvent)218cdf0e10cSrcweir void SoldepToolBox::MouseButtonDown(const MouseEvent& rEvent)
219cdf0e10cSrcweir {
220cdf0e10cSrcweir 	// Sind wir im DockingMode, ...
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 	if ( !IsFloatingMode() && ((( mnWinStyle & WB_CLOSEABLE ) != 0 ) || bPinable ))
223cdf0e10cSrcweir 	{
224cdf0e10cSrcweir 		// ... dann testen wir, ob am Abrei�d�del der Close-Button gedr�ckt wurde ...
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 		Rectangle aRect = GetItemRect( GetItemId( 0 ));
227cdf0e10cSrcweir 		aRect = Rectangle( aRect.TopLeft(), Point( aRect.Left()+6, aRect.Top()+6 ));
228cdf0e10cSrcweir 		if ( rEvent.IsLeft() && aRect.IsInside( rEvent.GetPosPixel()))
229cdf0e10cSrcweir 		{
230cdf0e10cSrcweir 			if ( bPinable ) {
231cdf0e10cSrcweir 				TogglePin();
232cdf0e10cSrcweir 				Invalidate();
233cdf0e10cSrcweir 			}
234cdf0e10cSrcweir 			else {
235cdf0e10cSrcweir 				bCloseMode = sal_True;
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 				// ... und zeichnen ggf. den Button gedr�ckt.
238cdf0e10cSrcweir 
239cdf0e10cSrcweir                 SetLineColor( Color( COL_WHITE ));
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 				DrawLine( Point( aRect.Left(), aRect.Bottom()), Point( aRect.Right(), aRect.Bottom()));
242cdf0e10cSrcweir 				DrawLine( Point( aRect.Right(), aRect.Bottom()), Point( aRect.Right(), aRect.Top()));
243cdf0e10cSrcweir 
244cdf0e10cSrcweir                 SetLineColor( Color( COL_GRAY ));
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 				DrawLine( Point( aRect.Left(), aRect.Top()), Point( aRect.Right(), aRect.Top()));
247cdf0e10cSrcweir 				DrawLine( Point( aRect.Left(), aRect.Top()), Point( aRect.Left(), aRect.Bottom()));
248cdf0e10cSrcweir 			}
249cdf0e10cSrcweir 		}
250cdf0e10cSrcweir 		else
251cdf0e10cSrcweir 		{
252cdf0e10cSrcweir 			ToolBox::MouseButtonDown( rEvent );
253cdf0e10cSrcweir 		}
254cdf0e10cSrcweir 	}
255cdf0e10cSrcweir 	else
256cdf0e10cSrcweir 	{
257cdf0e10cSrcweir 		ToolBox::MouseButtonDown( rEvent );
258cdf0e10cSrcweir 	}
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 	aMouseDownHdl.Call(this);
261cdf0e10cSrcweir }
262cdf0e10cSrcweir 
263cdf0e10cSrcweir /*************************************************************************
264cdf0e10cSrcweir |* SoldepToolBox::MouseButtonUp()
265cdf0e10cSrcweir |************************************************************************/
266cdf0e10cSrcweir 
MouseButtonUp(const MouseEvent & rEvent)267cdf0e10cSrcweir void SoldepToolBox::MouseButtonUp(const MouseEvent& rEvent)
268cdf0e10cSrcweir {
269cdf0e10cSrcweir 	// Wenn der Close-Button am Abrei�d�del zuvor gedr�ckt wurde, ...
270cdf0e10cSrcweir 
271cdf0e10cSrcweir 	if ( bCloseMode )
272cdf0e10cSrcweir 	{
273cdf0e10cSrcweir 		bCloseMode = sal_False;
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 		// ... so zeichen wir diesen wieder normal ...
276cdf0e10cSrcweir 
277cdf0e10cSrcweir 		Rectangle aRect = GetItemRect( GetItemId( 0 ));
278cdf0e10cSrcweir 		aRect = Rectangle( aRect.TopLeft(), Point( aRect.Left()+6, aRect.Top()+6 ));
279cdf0e10cSrcweir 
280cdf0e10cSrcweir         SetLineColor( Color( COL_WHITE ));
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 		DrawLine( Point( aRect.Left(), aRect.Top()), Point( aRect.Right(), aRect.Top()));
283cdf0e10cSrcweir 		DrawLine( Point( aRect.Left(), aRect.Top()), Point( aRect.Left(), aRect.Bottom()));
284cdf0e10cSrcweir 
285cdf0e10cSrcweir         SetLineColor( Color( COL_GRAY ));
286cdf0e10cSrcweir 
287cdf0e10cSrcweir 		DrawLine( Point( aRect.Left(), aRect.Bottom()), Point( aRect.Right(), aRect.Bottom()));
288cdf0e10cSrcweir 		DrawLine( Point( aRect.Right(), aRect.Bottom()), Point( aRect.Right(), aRect.Top()));
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 		if ( rEvent.IsLeft() && aRect.IsInside( rEvent.GetPosPixel()))
291cdf0e10cSrcweir 		{
292cdf0e10cSrcweir 			// ... und schlie�en die Box durch Aufruf der virtuellen Methode
293cdf0e10cSrcweir 			// CloseDockingMode().
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 			CloseDockingMode();
296cdf0e10cSrcweir 		}
297cdf0e10cSrcweir 		else
298cdf0e10cSrcweir 		{
299cdf0e10cSrcweir 			ToolBox::MouseButtonUp( rEvent );
300cdf0e10cSrcweir 		}
301cdf0e10cSrcweir 	}
302cdf0e10cSrcweir 	else
303cdf0e10cSrcweir 	{
304cdf0e10cSrcweir 		ToolBox::MouseButtonUp( rEvent );
305cdf0e10cSrcweir 	}
306cdf0e10cSrcweir }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir /*************************************************************************
309cdf0e10cSrcweir |* SoldepToolBox::MouseMove()
310cdf0e10cSrcweir |************************************************************************/
311cdf0e10cSrcweir 
MouseMove(const MouseEvent & rEvent)312cdf0e10cSrcweir void SoldepToolBox::MouseMove(const MouseEvent& rEvent)
313cdf0e10cSrcweir {
314cdf0e10cSrcweir 	// Wenn der Close-Button am Abrei�d�del zuvor gedr�ckt wurde, ...
315cdf0e10cSrcweir 
316cdf0e10cSrcweir 	if ( bCloseMode )
317cdf0e10cSrcweir 	{
318cdf0e10cSrcweir 		Rectangle aRect = GetItemRect( GetItemId( 0 ));
319cdf0e10cSrcweir 		aRect = Rectangle( aRect.TopLeft(), Point( aRect.Left()+6, aRect.Top()+6 ));
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 		// ... der Mouse-Zeiger jedoch den Close-Button verl��t, ...
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 		if ( !aRect.IsInside( rEvent.GetPosPixel()))
324cdf0e10cSrcweir 		{
325cdf0e10cSrcweir             SetLineColor( Color( COL_WHITE ));
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 			// ... zeichnen wir diesen halt wieder normal.
328cdf0e10cSrcweir 
329cdf0e10cSrcweir 			DrawLine( Point( aRect.Left(), aRect.Top()), Point( aRect.Right(), aRect.Top()));
330cdf0e10cSrcweir 			DrawLine( Point( aRect.Left(), aRect.Top()), Point( aRect.Left(), aRect.Bottom()));
331cdf0e10cSrcweir 
332cdf0e10cSrcweir             SetLineColor( Color( COL_GRAY ));
333cdf0e10cSrcweir 
334cdf0e10cSrcweir 				DrawLine( Point( aRect.Left(), aRect.Bottom()), Point( aRect.Right(), aRect.Bottom()));
335cdf0e10cSrcweir 			DrawLine( Point( aRect.Right(), aRect.Bottom()), Point( aRect.Right(), aRect.Top()));
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 			bCloseMode = sal_False;
338cdf0e10cSrcweir 		}
339cdf0e10cSrcweir 		else
340cdf0e10cSrcweir 		{
341cdf0e10cSrcweir 			ToolBox::MouseMove( rEvent );
342cdf0e10cSrcweir 		}
343cdf0e10cSrcweir 	}
344cdf0e10cSrcweir 	else
345cdf0e10cSrcweir 	{
346cdf0e10cSrcweir 		ToolBox::MouseMove( rEvent );
347cdf0e10cSrcweir 	}
348cdf0e10cSrcweir }
349cdf0e10cSrcweir 
350cdf0e10cSrcweir /*****************************************************************************/
ToggleFloatingMode()351cdf0e10cSrcweir void SoldepToolBox::ToggleFloatingMode()
352cdf0e10cSrcweir /*****************************************************************************/
353cdf0e10cSrcweir {
354cdf0e10cSrcweir 	ToolBox::ToggleFloatingMode();
355cdf0e10cSrcweir 	CallEventListeners( VCLEVENT_USER_TBOX_RESIZE_APP, this);
356cdf0e10cSrcweir }
357cdf0e10cSrcweir 
358cdf0e10cSrcweir /*****************************************************************************/
EndDocking(const Rectangle & rRect,sal_Bool bFloatMode)359cdf0e10cSrcweir void SoldepToolBox::EndDocking( const Rectangle& rRect, sal_Bool bFloatMode )
360cdf0e10cSrcweir /*****************************************************************************/
361cdf0e10cSrcweir {
362cdf0e10cSrcweir 	ToolBox::EndDocking( rRect, bFloatMode );
363cdf0e10cSrcweir 	if ( aResizeHdl.IsSet())
364cdf0e10cSrcweir 		CallEventListeners( VCLEVENT_USER_TBOX_RESIZE_APP, this);
365cdf0e10cSrcweir 	else
366cdf0e10cSrcweir         {
367cdf0e10cSrcweir            GetParent()->Resize();
368cdf0e10cSrcweir         }
369cdf0e10cSrcweir };
370cdf0e10cSrcweir 
371cdf0e10cSrcweir /*****************************************************************************/
Close()372cdf0e10cSrcweir sal_Bool SoldepToolBox::Close()
373cdf0e10cSrcweir /*****************************************************************************/
374cdf0e10cSrcweir {
375cdf0e10cSrcweir 	if (!ToolBox::Close()) return sal_False;
376cdf0e10cSrcweir 
377cdf0e10cSrcweir 	return sal_True;
378cdf0e10cSrcweir }
379cdf0e10cSrcweir 
380cdf0e10cSrcweir /*****************************************************************************/
Move()381cdf0e10cSrcweir void SoldepToolBox::Move()
382cdf0e10cSrcweir /*****************************************************************************/
383cdf0e10cSrcweir {
384cdf0e10cSrcweir }
385cdf0e10cSrcweir 
386cdf0e10cSrcweir /*************************************************************************
387cdf0e10cSrcweir |* SoldepToolBox::CloseDockingMode()
388cdf0e10cSrcweir |*
389cdf0e10cSrcweir |* virtuelle Methode zur Reaktion auf den Close-Button im DockinMode
390cdf0e10cSrcweir |************************************************************************/
391cdf0e10cSrcweir 
CloseDockingMode()392cdf0e10cSrcweir void SoldepToolBox::CloseDockingMode()
393cdf0e10cSrcweir {
394cdf0e10cSrcweir 	Hide();
395cdf0e10cSrcweir 	bBoxIsVisible = sal_False;
396cdf0e10cSrcweir 	CallEventListeners( VCLEVENT_USER_TBOX_RESIZE_APP, this);
397cdf0e10cSrcweir }
398cdf0e10cSrcweir 
399cdf0e10cSrcweir /*************************************************************************
400cdf0e10cSrcweir |* SoldepToolBox::Command()
401cdf0e10cSrcweir |************************************************************************/
402cdf0e10cSrcweir 
Command(const CommandEvent & rCEvt)403cdf0e10cSrcweir void SoldepToolBox::Command( const CommandEvent& rCEvt)
404cdf0e10cSrcweir {
405cdf0e10cSrcweir 	if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
406cdf0e10cSrcweir 	{
407cdf0e10cSrcweir 		if( !IsFloatingMode() && bDockable
408cdf0e10cSrcweir 			&& ( GetItemRect(GetItemId( 0 )).IsInside(rCEvt.GetMousePosPixel())))
409cdf0e10cSrcweir 		{
410cdf0e10cSrcweir             // Hier das Context-Menue fuer Abrei�d�del dynamisch erzeugen...
411cdf0e10cSrcweir 
412cdf0e10cSrcweir 			PopupMenu aPopupMenu;
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 			String sText( String::CreateFromAscii( "Floating mode" ));
415cdf0e10cSrcweir 			aPopupMenu.InsertItem( 5, sText );
416cdf0e10cSrcweir 			aPopupMenu.InsertSeparator();
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 			sText = String::CreateFromAscii( "Top" );
419cdf0e10cSrcweir 			aPopupMenu.InsertItem( 1, sText );
420cdf0e10cSrcweir 			sText = String::CreateFromAscii( "Bottom" );
421cdf0e10cSrcweir 			aPopupMenu.InsertItem( 2, sText );
422cdf0e10cSrcweir 			sText = String::CreateFromAscii( "Left" );
423cdf0e10cSrcweir 			aPopupMenu.InsertItem( 3, sText );
424cdf0e10cSrcweir 			sText = String::CreateFromAscii( "Right" );
425cdf0e10cSrcweir 			aPopupMenu.InsertItem( 4, sText );
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 			switch( GetAlign())
428cdf0e10cSrcweir 			{
429cdf0e10cSrcweir                 case WINDOWALIGN_TOP : aPopupMenu.EnableItem( 1, sal_False ); break;
430cdf0e10cSrcweir                 case WINDOWALIGN_BOTTOM : aPopupMenu.EnableItem( 2, sal_False ); break;
431cdf0e10cSrcweir                 case WINDOWALIGN_LEFT : aPopupMenu.EnableItem( 3, sal_False ); break;
432cdf0e10cSrcweir                 case WINDOWALIGN_RIGHT : aPopupMenu.EnableItem( 4, sal_False ); break;
433cdf0e10cSrcweir 			}
434cdf0e10cSrcweir 
435cdf0e10cSrcweir 			if (( mnWinStyle & WB_CLOSEABLE ) != 0 )
436cdf0e10cSrcweir 			{
437cdf0e10cSrcweir 				aPopupMenu.InsertSeparator();
438cdf0e10cSrcweir 				sText = String::CreateFromAscii( "Hide" );
439cdf0e10cSrcweir 				aPopupMenu.InsertItem( 6, sText );
440cdf0e10cSrcweir 			}
441cdf0e10cSrcweir 			else if ( bPinable ) {
442cdf0e10cSrcweir 				aPopupMenu.InsertSeparator();
443cdf0e10cSrcweir 				sText = String::CreateFromAscii( "Pin" );
444cdf0e10cSrcweir 				aPopupMenu.InsertItem( 6, sText );
445cdf0e10cSrcweir 				aPopupMenu.CheckItem( 6, GetPin());
446cdf0e10cSrcweir 			}
447cdf0e10cSrcweir 
448cdf0e10cSrcweir 			// ... und rufen.
449cdf0e10cSrcweir 
450cdf0e10cSrcweir             aPopupMenu.SetSelectHdl ( LINK ( this, SoldepToolBox, MenuSelectHdl ));
451cdf0e10cSrcweir 			aPopupMenu.Execute( this, rCEvt.GetMousePosPixel());
452cdf0e10cSrcweir 		}
453cdf0e10cSrcweir 		else if ( !GetItemId(rCEvt.GetMousePosPixel()))
454cdf0e10cSrcweir 		{
455cdf0e10cSrcweir 			CallContextMenu( this, rCEvt.GetMousePosPixel());
456cdf0e10cSrcweir 		}
457cdf0e10cSrcweir 	}
458cdf0e10cSrcweir 	else ToolBox::Command( rCEvt );
459cdf0e10cSrcweir }
460cdf0e10cSrcweir 
461cdf0e10cSrcweir /*************************************************************************
462cdf0e10cSrcweir |* SoldepToolBox::GetContextMenu()
463cdf0e10cSrcweir |************************************************************************/
464cdf0e10cSrcweir 
GetContextMenu()465cdf0e10cSrcweir PopupMenu *SoldepToolBox::GetContextMenu()
466cdf0e10cSrcweir {
467cdf0e10cSrcweir 	InitContextMenu();
468cdf0e10cSrcweir 	return &aMenu;
469cdf0e10cSrcweir }
470cdf0e10cSrcweir 
471cdf0e10cSrcweir /*************************************************************************
472cdf0e10cSrcweir |* SoldepToolBox::InitContextMenu()
473cdf0e10cSrcweir |************************************************************************/
474cdf0e10cSrcweir 
InitContextMenu()475cdf0e10cSrcweir void SoldepToolBox::InitContextMenu()
476cdf0e10cSrcweir {
477cdf0e10cSrcweir 	sal_uInt16 nStart = 0;
478cdf0e10cSrcweir 	if ( bDockable )
479cdf0e10cSrcweir 		nStart = 1;
480cdf0e10cSrcweir 
481cdf0e10cSrcweir 	aMenu.Clear();
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 	for ( sal_uInt16 i = nStart; i < GetItemCount(); i++ )
484cdf0e10cSrcweir 	{
485cdf0e10cSrcweir 		sal_uInt16 nItemId = GetItemId( i );
486cdf0e10cSrcweir 
487cdf0e10cSrcweir 		switch ( GetItemType( i ))
488cdf0e10cSrcweir 		{
489cdf0e10cSrcweir 			case TOOLBOXITEM_SPACE:
490cdf0e10cSrcweir 				break;
491cdf0e10cSrcweir 			case TOOLBOXITEM_SEPARATOR :
492cdf0e10cSrcweir 				if (!(( i < GetItemCount() - 1 ) && ( GetItemType( i + 1 ) == TOOLBOXITEM_DONTKNOW )))
493cdf0e10cSrcweir 					aMenu.InsertSeparator();
494cdf0e10cSrcweir 				break;
495cdf0e10cSrcweir 			default:
496cdf0e10cSrcweir 				aMenu.InsertItem( nItemId, GetItemText( nItemId ), GetItemImage( nItemId ));
497cdf0e10cSrcweir 				if (IsItemChecked( nItemId )) aMenu.CheckItem( nItemId, sal_True );
498cdf0e10cSrcweir 				if (!IsItemEnabled( nItemId )) aMenu.EnableItem( nItemId, sal_False );
499cdf0e10cSrcweir                 if (!IsItemVisible( nItemId )) aMenu.HideItem(nItemId);
500cdf0e10cSrcweir 				break;
501cdf0e10cSrcweir 		}
502cdf0e10cSrcweir 	}
503cdf0e10cSrcweir }
504cdf0e10cSrcweir 
505cdf0e10cSrcweir /*************************************************************************
506cdf0e10cSrcweir |* SoldepToolBox::CallContextMenu()
507cdf0e10cSrcweir |************************************************************************/
508cdf0e10cSrcweir 
CallContextMenu(Window * pWin,Point aPos)509cdf0e10cSrcweir void SoldepToolBox::CallContextMenu( Window *pWin, Point aPos )
510cdf0e10cSrcweir {
511cdf0e10cSrcweir 	if ( aMenu.IsInExecute())
512cdf0e10cSrcweir 		return;
513cdf0e10cSrcweir 
514cdf0e10cSrcweir 	InitContextMenu();
515cdf0e10cSrcweir 
516cdf0e10cSrcweir 	// ... und rufen.
517cdf0e10cSrcweir 
518cdf0e10cSrcweir     aMenu.SetSelectHdl ( LINK ( this, SoldepToolBox, MenuSelectHdl ));
519cdf0e10cSrcweir 	aMenu.Execute( pWin, aPos );
520cdf0e10cSrcweir }
521cdf0e10cSrcweir 
SetPosSizePixel(const Point & rNewPos,const Size & rNewSize)522cdf0e10cSrcweir void SoldepToolBox::SetPosSizePixel( const Point& rNewPos,
523cdf0e10cSrcweir 										 const Size& rNewSize )
524cdf0e10cSrcweir {
525cdf0e10cSrcweir //	if(rNewPos != GetPosPixel() || rNewSize != GetSizePixel())
526cdf0e10cSrcweir //	{
527cdf0e10cSrcweir 		ToolBox::SetPosSizePixel(rNewPos,rNewSize);
528cdf0e10cSrcweir //		Resize();
529cdf0e10cSrcweir //	}
530cdf0e10cSrcweir }
531cdf0e10cSrcweir 
SetDockingRects(const Rectangle & rOutRect,const Rectangle & rInRect)532cdf0e10cSrcweir void SoldepToolBox::SetDockingRects( const Rectangle& rOutRect,
533cdf0e10cSrcweir 										 const Rectangle& rInRect )
534cdf0e10cSrcweir {
535cdf0e10cSrcweir 	if(rOutRect != aOutRect || rInRect != aInRect)
536cdf0e10cSrcweir 	{
537cdf0e10cSrcweir 		ToolBox::SetDockingRects(rOutRect,rInRect);
538cdf0e10cSrcweir 		Invalidate();
539cdf0e10cSrcweir 
540cdf0e10cSrcweir 		aOutRect = rOutRect;
541cdf0e10cSrcweir 		aInRect  = rInRect;
542cdf0e10cSrcweir 	}
543cdf0e10cSrcweir }
544cdf0e10cSrcweir 
545cdf0e10cSrcweir /*****************************************************************************/
StartDocking()546cdf0e10cSrcweir void SoldepToolBox::StartDocking()
547cdf0e10cSrcweir /*****************************************************************************/
548cdf0e10cSrcweir {
549cdf0e10cSrcweir 	ToolBox::StartDocking();
550cdf0e10cSrcweir 	CallEventListeners( VCLEVENT_USER_TBOX_RESIZE_APP, this);
551cdf0e10cSrcweir };
552cdf0e10cSrcweir 
GetPin()553cdf0e10cSrcweir sal_Bool SoldepToolBox::GetPin()
554cdf0e10cSrcweir 
555cdf0e10cSrcweir {
556cdf0e10cSrcweir     return bPin;
557cdf0e10cSrcweir }
558cdf0e10cSrcweir 
TogglePin()559cdf0e10cSrcweir void SoldepToolBox::TogglePin()
560cdf0e10cSrcweir {
561cdf0e10cSrcweir      bPin = !bPin;
562cdf0e10cSrcweir }
563cdf0e10cSrcweir 
SetPin(sal_Bool bP)564cdf0e10cSrcweir void SoldepToolBox::SetPin( sal_Bool bP )
565cdf0e10cSrcweir {
566cdf0e10cSrcweir     bPin = bP;
567cdf0e10cSrcweir }
568cdf0e10cSrcweir 
569cdf0e10cSrcweir /*************************************************************************
570cdf0e10cSrcweir |* SoldepToolBox::MenuSelectHdl()
571cdf0e10cSrcweir |*
572cdf0e10cSrcweir |* Handler, der beim Execute der Context-Men�s gerufen wird
573cdf0e10cSrcweir |************************************************************************/
574cdf0e10cSrcweir 
IMPL_LINK(SoldepToolBox,MenuSelectHdl,Menu *,pMenu)575cdf0e10cSrcweir IMPL_LINK ( SoldepToolBox, MenuSelectHdl, Menu*, pMenu )
576cdf0e10cSrcweir {
577cdf0e10cSrcweir 	// Wenn die CurItemId <= 6 ist, dann wurde das Abrei�d�del-Context-Men� ausgef�hrt ...
578cdf0e10cSrcweir     sal_uIntPtr itemid;
579cdf0e10cSrcweir     itemid = pMenu->GetCurItemId();
580cdf0e10cSrcweir 
581cdf0e10cSrcweir 	if ( pMenu == &aMenu )
582cdf0e10cSrcweir 	{
583cdf0e10cSrcweir 		// ... Andernfalls wurde das Default-Context-Men� ausgef�hrt ...
584cdf0e10cSrcweir 		sal_uInt16 nTmpId = mnCurItemId;
585cdf0e10cSrcweir 		mnCurItemId = pMenu->GetCurItemId();
586cdf0e10cSrcweir 
587cdf0e10cSrcweir 		// ... und der gesetzte Handler (in soldep.cxx) wird gerufen.
588cdf0e10cSrcweir 		maSelectHdl.Call( this );
589cdf0e10cSrcweir 		mnCurItemId = nTmpId;
590cdf0e10cSrcweir 	}
591cdf0e10cSrcweir 	return 0;
592cdf0e10cSrcweir }
593