1 /*****************************************************************************
2 * MessagesWindow.cpp: beos interface
3 *****************************************************************************
4 * Copyright (C) 1999, 2000, 2001 VideoLAN
5 * $Id: MessagesWindow.cpp,v 1.1 2003/01/25 20:15:41 titer Exp $
7 * Authors: Eric Petit <titer@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
25 #include <InterfaceKit.h>
31 /* BeOS module headers */
32 #include "VlcWrapper.h"
33 #include "MessagesWindow.h"
35 /*****************************************************************************
36 * MessagesWindow::MessagesWindow
37 *****************************************************************************/
38 MessagesWindow::MessagesWindow( intf_thread_t * p_intf,
39 BRect frame, const char * name )
40 : BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
43 this->p_intf = p_intf;
44 p_sub = p_intf->p_sys->p_sub;
49 rect.right -= B_V_SCROLL_BAR_WIDTH;
50 rect.bottom -= B_H_SCROLL_BAR_HEIGHT;
52 rect2.InsetBy( 5, 5 );
53 fMessagesView = new BTextView( rect, "messages", rect2,
54 B_FOLLOW_ALL, B_WILL_DRAW );
55 fMessagesView->MakeEditable( false );
56 fScrollView = new BScrollView( "scrollview", fMessagesView, B_WILL_DRAW,
57 B_FOLLOW_ALL, true, true );
58 fScrollBar = fScrollView->ScrollBar( B_VERTICAL );
59 AddChild( fScrollView );
61 /* start window thread in hidden state */
66 /*****************************************************************************
67 * MessagesWindow::~MessagesWindow
68 *****************************************************************************/
69 MessagesWindow::~MessagesWindow()
73 /*****************************************************************************
74 * MessagesWindow::QuitRequested
75 *****************************************************************************/
76 bool MessagesWindow::QuitRequested()
82 /*****************************************************************************
83 * MessagesWindow::ReallyQuit
84 *****************************************************************************/
85 void MessagesWindow::ReallyQuit()
91 /*****************************************************************************
92 * MessagesWindow::UpdateMessages
93 *****************************************************************************/
94 void MessagesWindow::UpdateMessages()
98 vlc_mutex_lock( p_sub->p_lock );
99 int i_stop = *p_sub->pi_stop;
100 vlc_mutex_unlock( p_sub->p_lock );
102 if( p_sub->i_start != i_stop )
104 for( i_start = p_sub->i_start;
106 i_start = (i_start+1) % VLC_MSG_QSIZE )
108 /* Append all messages to log window */
109 /* textctrl->SetDefaultStyle( *dbg_attr );
110 (*textctrl) << p_sub->p_msg[i_start].psz_module; */
112 /* switch( p_sub->p_msg[i_start].i_type )
116 textctrl->SetDefaultStyle( *info_attr );
119 (*textctrl) << " error: ";
120 textctrl->SetDefaultStyle( *err_attr );
123 (*textctrl) << " warning: ";
124 textctrl->SetDefaultStyle( *warn_attr );
128 (*textctrl) << " debug: ";
133 fMessagesView->LockLooper();
134 fMessagesView->Insert( p_sub->p_msg[i_start].psz_msg );
135 fMessagesView->Insert( "\n" );
136 fMessagesView->UnlockLooper();
138 /* Scroll at the end */
139 fScrollBar->LockLooper();
141 fScrollBar->GetRange( &min, &max );
142 fScrollBar->SetValue( max );
143 fScrollBar->UnlockLooper();
146 vlc_mutex_lock( p_sub->p_lock );
147 p_sub->i_start = i_start;
148 vlc_mutex_unlock( p_sub->p_lock );