merge the formfield patch from ooo-build
[ooovba.git] / basic / source / app / status.cxx
blob6a90321b0da48a1129379b85fd7bf038cc43203b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: status.cxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_basic.hxx"
34 #include "app.hxx"
35 #include "basic.hrc"
36 #include "appwin.hxx"
37 #include "status.hxx"
39 #include <vcl/decoview.hxx>
41 StatusLine::StatusLine( BasicFrame* p )
42 : TaskBar( p )
43 , pFrame( p )
45 // initialize TaskToolBox
46 TaskToolBox* pTempTaskToolBox = GetTaskToolBox();
47 pTempTaskToolBox->SetActivateTaskHdl( LINK( this, StatusLine, ActivateTask ) );
49 // initialize TaskStatusBar
50 TaskStatusBar* pTempStatusBar = GetStatusBar();
51 long nCharWidth = GetTextWidth( '0' ); // We state: All numbers has the same width
52 pTempStatusBar->InsertItem( ST_MESSAGE, GetTextWidth( 'X' ) * 20, SIB_LEFT | SIB_IN | SIB_AUTOSIZE );
53 pTempStatusBar->InsertItem( ST_LINE, 5*nCharWidth );
54 pTempStatusBar->InsertItem( ST_PROF, GetTextWidth( 'X' ) * 10 );
55 pTempStatusBar->InsertStatusField();
57 Show();
60 void StatusLine::Message( const String& s )
62 GetStatusBar()->SetItemText( ST_MESSAGE, s );
65 void StatusLine::Pos( const String& s )
67 GetStatusBar()->SetItemText( ST_LINE, s );
70 void StatusLine::SetProfileName( const String& s )
72 GetStatusBar()->SetItemText( ST_PROF, s );
76 IMPL_LINK( StatusLine, ActivateTask, TaskToolBox*, pTTB )
78 USHORT nFirstWinPos=0;
79 MenuBar* pMenu = pFrame->GetMenuBar();
80 PopupMenu* pWinMenu = pMenu->GetPopupMenu( RID_APPWINDOW );
82 while ( pWinMenu->GetItemId( nFirstWinPos ) < RID_WIN_FILE1 && nFirstWinPos < pWinMenu->GetItemCount() )
83 nFirstWinPos++;
85 nFirstWinPos += pTTB->GetItemPos( pTTB->GetCurItemId() ) / 2;
87 USHORT x;
88 x = pTTB->GetItemPos( pTTB->GetCurItemId() );
89 x = pWinMenu->GetItemId( nFirstWinPos );
90 x = pWinMenu->GetItemCount();
91 AppWin* pWin = pFrame->FindWin( pWinMenu->GetItemText( pWinMenu->GetItemId( nFirstWinPos ) ).EraseAllChars( L'~' ) );
92 if ( pWin )
94 pWin->Minimize( FALSE );
95 pWin->ToTop();
97 return 0;
100 void StatusLine::LoadTaskToolBox()
102 USHORT nFirstWinPos=0;
103 MenuBar* pMenu = pFrame->GetMenuBar();
104 PopupMenu* pWinMenu = pMenu->GetPopupMenu( RID_APPWINDOW );
106 while ( pWinMenu->GetItemId( nFirstWinPos ) < RID_WIN_FILE1 && nFirstWinPos < pWinMenu->GetItemCount() )
107 nFirstWinPos++;
109 TaskToolBox* pTaskToolBox = GetTaskToolBox();
111 pTaskToolBox->StartUpdateTask();
113 while ( nFirstWinPos < pWinMenu->GetItemCount() )
114 { // There are windows
115 Window* pWin = pFrame->FindWin( pWinMenu->GetItemId( nFirstWinPos ) );
117 if ( pWin )
118 pTaskToolBox->UpdateTask( Image(), pWin->GetText(), pWin == pFrame->pList->Last() && !( pFrame->pList->Last()->GetWinState() & TT_WIN_STATE_HIDE ) );
120 nFirstWinPos++;
123 pTaskToolBox->EndUpdateTask();
124 Resize();
125 Invalidate();