1 /*****************************************************************************
2 * MessagesWindow.cpp: beos interface
3 *****************************************************************************
4 * Copyright (C) 1999, 2000, 2001 VideoLAN
5 * $Id: MessagesWindow.cpp,v 1.10 2003/05/17 18:30: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>
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 int i_start, oldLength;
43 char * psz_module_type = NULL;
44 rgb_color red = { 200, 0, 0 };
45 rgb_color gray = { 150, 150, 150 };
46 rgb_color green = { 0, 150, 0 };
47 rgb_color orange = { 230, 180, 00 };
50 vlc_mutex_lock( p_sub->p_lock );
51 int i_stop = *p_sub->pi_stop;
52 vlc_mutex_unlock( p_sub->p_lock );
54 if( p_sub->i_start != i_stop )
56 for( i_start = p_sub->i_start;
58 i_start = (i_start+1) % VLC_MSG_QSIZE )
61 switch( p_sub->p_msg[i_start].i_type )
63 case VLC_MSG_INFO: color = green; break;
64 case VLC_MSG_WARN: color = orange; break;
65 case VLC_MSG_ERR: color = red; break;
66 case VLC_MSG_DBG: color = gray; break;
69 switch( p_sub->p_msg[i_start].i_object_type )
71 case VLC_OBJECT_ROOT: psz_module_type = "root"; break;
72 case VLC_OBJECT_VLC: psz_module_type = "vlc"; break;
73 case VLC_OBJECT_MODULE: psz_module_type = "module"; break;
74 case VLC_OBJECT_INTF: psz_module_type = "interface"; break;
75 case VLC_OBJECT_PLAYLIST: psz_module_type = "playlist"; break;
76 case VLC_OBJECT_ITEM: psz_module_type = "item"; break;
77 case VLC_OBJECT_INPUT: psz_module_type = "input"; break;
78 case VLC_OBJECT_DECODER: psz_module_type = "decoder"; break;
79 case VLC_OBJECT_VOUT: psz_module_type = "video output"; break;
80 case VLC_OBJECT_AOUT: psz_module_type = "audio output"; break;
81 case VLC_OBJECT_SOUT: psz_module_type = "stream output"; break;
86 oldLength = TextLength();
88 string << p_sub->p_msg[i_start].psz_module
89 << " " << psz_module_type << " : "
90 << p_sub->p_msg[i_start].psz_msg << "\n";
91 Insert( TextLength(), string.String(), strlen( string.String() ) );
92 SetFontAndColor( oldLength, TextLength(), NULL, 0, &color );
98 vlc_mutex_lock( p_sub->p_lock );
99 p_sub->i_start = i_start;
100 vlc_mutex_unlock( p_sub->p_lock );
103 /* Scroll at the end unless the is user is selecting something */
105 GetSelection( &start, &end );
106 if( start == end && fScrollBar->LockLooper() )
109 fScrollBar->GetRange( &min, &max );
110 fScrollBar->SetValue( max );
111 fScrollBar->UnlockLooper();
117 /*****************************************************************************
118 * MessagesWindow::MessagesWindow
119 *****************************************************************************/
120 MessagesWindow::MessagesWindow( intf_thread_t * p_intf,
121 BRect frame, const char * name )
122 : BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
125 this->p_intf = p_intf;
127 SetSizeLimits( 400, 2000, 200, 2000 );
129 BRect rect, textRect;
132 rect.right -= B_V_SCROLL_BAR_WIDTH;
134 textRect.InsetBy( 5, 5 );
135 fMessagesView = new MessagesView( p_intf,
136 rect, "messages", textRect,
137 B_FOLLOW_ALL, B_WILL_DRAW );
138 fMessagesView->MakeEditable( false );
139 fMessagesView->SetStylable( true );
140 fScrollView = new BScrollView( "scrollview", fMessagesView, B_WILL_DRAW,
141 B_FOLLOW_ALL, false, true );
142 fMessagesView->fScrollBar = fScrollView->ScrollBar( B_VERTICAL );
143 AddChild( fScrollView );
145 /* start window thread in hidden state */
150 /*****************************************************************************
151 * MessagesWindow::~MessagesWindow
152 *****************************************************************************/
153 MessagesWindow::~MessagesWindow()
157 /*****************************************************************************
158 * MessagesWindow::FrameResized
159 *****************************************************************************/
160 void MessagesWindow::FrameResized( float width, float height )
162 BWindow::FrameResized( width, height );
163 BRect rect = fMessagesView->Bounds();
164 rect.InsetBy( 5, 5 );
165 fMessagesView->SetTextRect( rect );
168 /*****************************************************************************
169 * MessagesWindow::QuitRequested
170 *****************************************************************************/
171 bool MessagesWindow::QuitRequested()
177 /*****************************************************************************
178 * MessagesWindow::ReallyQuit
179 *****************************************************************************/
180 void MessagesWindow::ReallyQuit()