00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <InterfaceKit.h>
00026 #include <SupportKit.h>
00027
00028
00029 #include <vlc/vlc.h>
00030 #include <vlc/intf.h>
00031
00032
00033 #include "InterfaceWindow.h"
00034 #include "MessagesWindow.h"
00035
00036
00037
00038
00039 void MessagesView::Pulse()
00040 {
00041 bool isScrolling = false;
00042 if( fScrollBar->LockLooper() )
00043 {
00044 float min, max;
00045 fScrollBar->GetRange( &min, &max );
00046 if( fScrollBar->Value() != max )
00047 isScrolling = true;
00048 fScrollBar->UnlockLooper();
00049
00050 }
00051
00052 int i_start, oldLength;
00053 char * psz_module_type = NULL;
00054 rgb_color red = { 200, 0, 0 };
00055 rgb_color gray = { 150, 150, 150 };
00056 rgb_color green = { 0, 150, 0 };
00057 rgb_color orange = { 230, 180, 00 };
00058 rgb_color color;
00059
00060 vlc_mutex_lock( p_sub->p_lock );
00061 int i_stop = *p_sub->pi_stop;
00062 vlc_mutex_unlock( p_sub->p_lock );
00063
00064 if( p_sub->i_start != i_stop )
00065 {
00066 for( i_start = p_sub->i_start;
00067 i_start != i_stop;
00068 i_start = (i_start+1) % VLC_MSG_QSIZE )
00069 {
00070
00071 switch( p_sub->p_msg[i_start].i_type )
00072 {
00073 case VLC_MSG_INFO: color = green; break;
00074 case VLC_MSG_WARN: color = orange; break;
00075 case VLC_MSG_ERR: color = red; break;
00076 case VLC_MSG_DBG: color = gray; break;
00077 }
00078
00079 switch( p_sub->p_msg[i_start].i_object_type )
00080 {
00081 case VLC_OBJECT_ROOT: psz_module_type = "root"; break;
00082 case VLC_OBJECT_VLC: psz_module_type = "vlc"; break;
00083 case VLC_OBJECT_MODULE: psz_module_type = "module"; break;
00084 case VLC_OBJECT_INTF: psz_module_type = "interface"; break;
00085 case VLC_OBJECT_PLAYLIST: psz_module_type = "playlist"; break;
00086 case VLC_OBJECT_ITEM: psz_module_type = "item"; break;
00087 case VLC_OBJECT_INPUT: psz_module_type = "input"; break;
00088 case VLC_OBJECT_DECODER: psz_module_type = "decoder"; break;
00089 case VLC_OBJECT_VOUT: psz_module_type = "video output"; break;
00090 case VLC_OBJECT_AOUT: psz_module_type = "audio output"; break;
00091 case VLC_OBJECT_SOUT: psz_module_type = "stream output"; break;
00092 }
00093
00094 if( LockLooper() )
00095 {
00096 oldLength = TextLength();
00097 BString string;
00098 string << p_sub->p_msg[i_start].psz_module
00099 << " " << psz_module_type << " : "
00100 << p_sub->p_msg[i_start].psz_msg << "\n";
00101 Insert( TextLength(), string.String(), strlen( string.String() ) );
00102 SetFontAndColor( oldLength, TextLength(), NULL, 0, &color );
00103 Draw( Bounds() );
00104 UnlockLooper();
00105 }
00106 }
00107
00108 vlc_mutex_lock( p_sub->p_lock );
00109 p_sub->i_start = i_start;
00110 vlc_mutex_unlock( p_sub->p_lock );
00111 }
00112
00113
00114 int32 start, end;
00115 GetSelection( &start, &end );
00116 if( !isScrolling && start == end && fScrollBar->LockLooper() )
00117 {
00118 float min, max;
00119 fScrollBar->GetRange( &min, &max );
00120 fScrollBar->SetValue( max );
00121 fScrollBar->UnlockLooper();
00122 }
00123
00124 BTextView::Pulse();
00125 }
00126
00127
00128
00129
00130 MessagesWindow::MessagesWindow( intf_thread_t * _p_intf,
00131 BRect frame, const char * name )
00132 : BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
00133 B_NOT_ZOOMABLE ),
00134 p_intf(_p_intf)
00135 {
00136 SetSizeLimits( 400, 2000, 200, 2000 );
00137
00138 p_sub = msg_Subscribe( p_intf );
00139
00140 BRect rect, textRect;
00141
00142 rect = Bounds();
00143 rect.right -= B_V_SCROLL_BAR_WIDTH;
00144 textRect = rect;
00145 textRect.InsetBy( 5, 5 );
00146 fMessagesView = new MessagesView( p_sub,
00147 rect, "messages", textRect,
00148 B_FOLLOW_ALL, B_WILL_DRAW );
00149 fMessagesView->MakeEditable( false );
00150 fMessagesView->SetStylable( true );
00151 fScrollView = new BScrollView( "scrollview", fMessagesView, B_WILL_DRAW,
00152 B_FOLLOW_ALL, false, true );
00153 fMessagesView->fScrollBar = fScrollView->ScrollBar( B_VERTICAL );
00154 AddChild( fScrollView );
00155
00156
00157 Hide();
00158 Show();
00159 }
00160
00161
00162
00163
00164 MessagesWindow::~MessagesWindow()
00165 {
00166 msg_Unsubscribe( p_intf, p_sub );
00167 }
00168
00169
00170
00171
00172 void MessagesWindow::FrameResized( float width, float height )
00173 {
00174 BWindow::FrameResized( width, height );
00175 BRect rect = fMessagesView->Bounds();
00176 rect.InsetBy( 5, 5 );
00177 fMessagesView->SetTextRect( rect );
00178 }
00179
00180
00181
00182
00183 bool MessagesWindow::QuitRequested()
00184 {
00185 Hide();
00186 return false;
00187 }
00188
00189
00190
00191
00192 void MessagesWindow::ReallyQuit()
00193 {
00194 Lock();
00195 Hide();
00196 Quit();
00197 }