1 /*****************************************************************************
2 * MessagesWindow.cpp: beos interface
3 *****************************************************************************
4 * Copyright (C) 1999, 2000, 2001 VideoLAN
5 * $Id: MessagesWindow.cpp,v 1.12 2004/01/26 16:52:31 zorglub 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>
26 #include <SupportKit.h>
32 /* BeOS module headers */
33 #include "VlcWrapper.h"
34 #include "InterfaceWindow.h"
35 #include "MessagesWindow.h"
37 /*****************************************************************************
39 *****************************************************************************/
40 void MessagesView::Pulse()
42 bool isScrolling = false;
43 if( fScrollBar->LockLooper() )
46 fScrollBar->GetRange( &min, &max );
47 if( fScrollBar->Value() != max )
49 fScrollBar->UnlockLooper();
53 int i_start, oldLength;
54 char * psz_module_type = NULL;
55 rgb_color red = { 200, 0, 0 };
56 rgb_color gray = { 150, 150, 150 };
57 rgb_color green = { 0, 150, 0 };
58 rgb_color orange = { 230, 180, 00 };
61 vlc_mutex_lock( p_sub->p_lock );
62 int i_stop = *p_sub->pi_stop;
63 vlc_mutex_unlock( p_sub->p_lock );
65 if( p_sub->i_start != i_stop )
67 for( i_start = p_sub->i_start;
69 i_start = (i_start+1) % VLC_MSG_QSIZE )
72 switch( p_sub->p_msg[i_start].i_type )
74 case VLC_MSG_INFO: color = green; break;
75 case VLC_MSG_WARN: color = orange; break;
76 case VLC_MSG_ERR: color = red; break;
77 case VLC_MSG_DBG: color = gray; break;
80 switch( p_sub->p_msg[i_start].i_object_type )
82 case VLC_OBJECT_ROOT: psz_module_type = "root"; break;
83 case VLC_OBJECT_VLC: psz_module_type = "vlc"; break;
84 case VLC_OBJECT_MODULE: psz_module_type = "module"; break;
85 case VLC_OBJECT_INTF: psz_module_type = "interface"; break;
86 case VLC_OBJECT_PLAYLIST: psz_module_type = "playlist"; break;
87 case VLC_OBJECT_ITEM: psz_module_type = "item"; break;
88 case VLC_OBJECT_INPUT: psz_module_type = "input"; break;
89 case VLC_OBJECT_DECODER: psz_module_type = "decoder"; break;
90 case VLC_OBJECT_VOUT: psz_module_type = "video output"; break;
91 case VLC_OBJECT_AOUT: psz_module_type = "audio output"; break;
92 case VLC_OBJECT_SOUT: psz_module_type = "stream output"; break;
97 oldLength = TextLength();
99 string << p_sub->p_msg[i_start].psz_module
100 << " " << psz_module_type << " : "
101 << p_sub->p_msg[i_start].psz_msg << "\n";
102 Insert( TextLength(), string.String(), strlen( string.String() ) );
103 SetFontAndColor( oldLength, TextLength(), NULL, 0, &color );
109 vlc_mutex_lock( p_sub->p_lock );
110 p_sub->i_start = i_start;
111 vlc_mutex_unlock( p_sub->p_lock );
114 /* Scroll at the end unless the is user is scrolling or selecting something */
116 GetSelection( &start, &end );
117 if( !isScrolling && start == end && fScrollBar->LockLooper() )
120 fScrollBar->GetRange( &min, &max );
121 fScrollBar->SetValue( max );
122 fScrollBar->UnlockLooper();
128 /*****************************************************************************
129 * MessagesWindow::MessagesWindow
130 *****************************************************************************/
131 MessagesWindow::MessagesWindow( intf_thread_t * p_intf,
132 BRect frame, const char * name )
133 : BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
136 this->p_intf = p_intf;
138 SetSizeLimits( 400, 2000, 200, 2000 );
140 BRect rect, textRect;
143 rect.right -= B_V_SCROLL_BAR_WIDTH;
145 textRect.InsetBy( 5, 5 );
146 fMessagesView = new MessagesView( p_intf,
147 rect, "messages", textRect,
148 B_FOLLOW_ALL, B_WILL_DRAW );
149 fMessagesView->MakeEditable( false );
150 fMessagesView->SetStylable( true );
151 fScrollView = new BScrollView( "scrollview", fMessagesView, B_WILL_DRAW,
152 B_FOLLOW_ALL, false, true );
153 fMessagesView->fScrollBar = fScrollView->ScrollBar( B_VERTICAL );
154 AddChild( fScrollView );
156 /* start window thread in hidden state */
161 /*****************************************************************************
162 * MessagesWindow::~MessagesWindow
163 *****************************************************************************/
164 MessagesWindow::~MessagesWindow()
168 /*****************************************************************************
169 * MessagesWindow::FrameResized
170 *****************************************************************************/
171 void MessagesWindow::FrameResized( float width, float height )
173 BWindow::FrameResized( width, height );
174 BRect rect = fMessagesView->Bounds();
175 rect.InsetBy( 5, 5 );
176 fMessagesView->SetTextRect( rect );
179 /*****************************************************************************
180 * MessagesWindow::QuitRequested
181 *****************************************************************************/
182 bool MessagesWindow::QuitRequested()
188 /*****************************************************************************
189 * MessagesWindow::ReallyQuit
190 *****************************************************************************/
191 void MessagesWindow::ReallyQuit()