1 /*****************************************************************************
2 * MessagesWindow.cpp: beos interface
3 *****************************************************************************
4 * Copyright (C) 1999, 2000, 2001 the VideoLAN team
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
25 #include <InterfaceKit.h>
26 #include <SupportKit.h>
34 #include <vlc_interface.h>
36 /* BeOS module headers */
37 #include "InterfaceWindow.h"
38 #include "MessagesWindow.h"
40 /*****************************************************************************
42 *****************************************************************************/
43 void MessagesView::Pulse()
45 bool isScrolling = false;
46 if( fScrollBar->LockLooper() )
49 fScrollBar->GetRange( &min, &max );
50 if( fScrollBar->Value() != max )
52 fScrollBar->UnlockLooper();
56 int i_start, oldLength;
57 char * psz_module_type = NULL;
58 rgb_color red = { 200, 0, 0 };
59 rgb_color gray = { 150, 150, 150 };
60 rgb_color green = { 0, 150, 0 };
61 rgb_color orange = { 230, 180, 00 };
64 vlc_mutex_lock( p_sub->p_lock );
65 int i_stop = *p_sub->pi_stop;
66 vlc_mutex_unlock( p_sub->p_lock );
68 if( p_sub->i_start != i_stop )
70 for( i_start = p_sub->i_start;
72 i_start = (i_start+1) % VLC_MSG_QSIZE )
75 switch( p_sub->p_msg[i_start].i_type )
77 case VLC_MSG_INFO: color = green; break;
78 case VLC_MSG_WARN: color = orange; break;
79 case VLC_MSG_ERR: color = red; break;
80 case VLC_MSG_DBG: color = gray; break;
83 switch( p_sub->p_msg[i_start].i_object_type )
85 case VLC_OBJECT_ROOT: psz_module_type = "root"; break;
86 case VLC_OBJECT_VLC: psz_module_type = "vlc"; break;
87 case VLC_OBJECT_MODULE: psz_module_type = "module"; break;
88 case VLC_OBJECT_INTF: psz_module_type = "interface"; break;
89 case VLC_OBJECT_PLAYLIST: psz_module_type = "playlist"; break;
90 case VLC_OBJECT_ITEM: psz_module_type = "item"; break;
91 case VLC_OBJECT_INPUT: psz_module_type = "input"; break;
92 case VLC_OBJECT_DECODER: psz_module_type = "decoder"; break;
93 case VLC_OBJECT_VOUT: psz_module_type = "video output"; break;
94 case VLC_OBJECT_AOUT: psz_module_type = "audio output"; break;
95 case VLC_OBJECT_SOUT: psz_module_type = "stream output"; break;
100 oldLength = TextLength();
102 string << p_sub->p_msg[i_start].psz_module
103 << " " << psz_module_type << " : "
104 << p_sub->p_msg[i_start].psz_msg << "\n";
105 Insert( TextLength(), string.String(), strlen( string.String() ) );
106 SetFontAndColor( oldLength, TextLength(), NULL, 0, &color );
112 vlc_mutex_lock( p_sub->p_lock );
113 p_sub->i_start = i_start;
114 vlc_mutex_unlock( p_sub->p_lock );
117 /* Scroll at the end unless the is user is scrolling or selecting something */
119 GetSelection( &start, &end );
120 if( !isScrolling && start == end && fScrollBar->LockLooper() )
123 fScrollBar->GetRange( &min, &max );
124 fScrollBar->SetValue( max );
125 fScrollBar->UnlockLooper();
131 /*****************************************************************************
132 * MessagesWindow::MessagesWindow
133 *****************************************************************************/
134 MessagesWindow::MessagesWindow( intf_thread_t * _p_intf,
135 BRect frame, const char * name )
136 : BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
140 SetSizeLimits( 400, 2000, 200, 2000 );
142 p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL );
144 BRect rect, textRect;
147 rect.right -= B_V_SCROLL_BAR_WIDTH;
149 textRect.InsetBy( 5, 5 );
150 fMessagesView = new MessagesView( p_sub,
151 rect, "messages", textRect,
152 B_FOLLOW_ALL, B_WILL_DRAW );
153 fMessagesView->MakeEditable( false );
154 fMessagesView->SetStylable( true );
155 fScrollView = new BScrollView( "scrollview", fMessagesView, B_WILL_DRAW,
156 B_FOLLOW_ALL, false, true );
157 fMessagesView->fScrollBar = fScrollView->ScrollBar( B_VERTICAL );
158 AddChild( fScrollView );
160 /* start window thread in hidden state */
165 /*****************************************************************************
166 * MessagesWindow::~MessagesWindow
167 *****************************************************************************/
168 MessagesWindow::~MessagesWindow()
170 msg_Unsubscribe( p_intf, p_sub );
173 /*****************************************************************************
174 * MessagesWindow::FrameResized
175 *****************************************************************************/
176 void MessagesWindow::FrameResized( float width, float height )
178 BWindow::FrameResized( width, height );
179 BRect rect = fMessagesView->Bounds();
180 rect.InsetBy( 5, 5 );
181 fMessagesView->SetTextRect( rect );
184 /*****************************************************************************
185 * MessagesWindow::QuitRequested
186 *****************************************************************************/
187 bool MessagesWindow::QuitRequested()
193 /*****************************************************************************
194 * MessagesWindow::ReallyQuit
195 *****************************************************************************/
196 void MessagesWindow::ReallyQuit()