1 /*****************************************************************************
\r
2 * messages.cpp: log window.
\r
3 *****************************************************************************
\r
4 * Copyright (C) 2002 VideoLAN
\r
6 * Authors: Olivier Teuliere <ipkiss@via.ecp.fr>
\r
8 * This program is free software; you can redistribute it and/or modify
\r
9 * it under the terms of the GNU General Public License as published by
\r
10 * the Free Software Foundation; either version 2 of the License, or
\r
11 * (at your option) any later version.
\r
13 * This program is distributed in the hope that it will be useful,
\r
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
16 * GNU General Public License for more details.
\r
18 * You should have received a copy of the GNU General Public License
\r
19 * along with this program; if not, write to the Free Software
\r
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
\r
21 *****************************************************************************/
\r
26 #include <vlc/vlc.h>
\r
27 #include <vlc/intf.h>
\r
29 #include "win32_common.h"
\r
30 #include "messages.h"
\r
32 //---------------------------------------------------------------------------
\r
33 #pragma package(smart_init)
\r
34 #pragma resource "*.dfm"
\r
36 extern intf_thread_t *p_intfGlobal;
\r
38 //---------------------------------------------------------------------------
\r
39 __fastcall TMessagesDlg::TMessagesDlg( TComponent* Owner )
\r
42 Icon = p_intfGlobal->p_sys->p_window->Icon;
\r
44 //---------------------------------------------------------------------------
\r
45 void __fastcall TMessagesDlg::ButtonOKClick( TObject *Sender )
\r
49 //---------------------------------------------------------------------------
\r
50 void __fastcall TMessagesDlg::FormHide( TObject *Sender )
\r
52 p_intfGlobal->p_sys->p_window->MenuMessages->Checked = false;
\r
54 //---------------------------------------------------------------------------
\r
55 void __fastcall TMessagesDlg::FormShow( TObject *Sender )
\r
57 p_intfGlobal->p_sys->p_window->MenuMessages->Checked = true;
\r
59 //---------------------------------------------------------------------------
\r
60 void __fastcall TMessagesDlg::UpdateLog()
\r
62 msg_subscription_t *p_sub = p_intfGlobal->p_sys->p_sub;
\r
63 int i_start, i_stop, i_del, i_count;
\r
66 vlc_mutex_lock( p_sub->p_lock );
\r
67 i_stop = *p_sub->pi_stop;
\r
68 vlc_mutex_unlock( p_sub->p_lock );
\r
70 if( p_sub->i_start != i_stop )
\r
72 for( i_start = p_sub->i_start;
\r
74 i_start = (i_start+1) % VLC_MSG_QSIZE )
\r
76 /* Append all messages to log window */
\r
77 switch( p_sub->p_msg[i_start].i_type )
\r
80 RichEditMessages->SelAttributes->Color = clRed;
\r
83 RichEditMessages->SelAttributes->Color = clBlack;
\r
86 RichEditMessages->SelAttributes->Color = clBlue;
\r
90 /* Limit log size */
\r
91 i_count = RichEditMessages->Lines->Count;
\r
92 i_max_lines = config_GetInt( p_intfGlobal, "intfwin-max-lines" );
\r
93 if( i_max_lines > 0 )
\r
95 for( i_del = 0; i_del <= i_count - i_max_lines; i_del++ )
\r
97 RichEditMessages->Lines->Delete( 0 );
\r
104 RichEditMessages->Lines->Add( p_sub->p_msg[i_start].psz_msg );
\r
108 vlc_mutex_lock( p_sub->p_lock );
\r
109 p_sub->i_start = i_start;
\r
110 vlc_mutex_unlock( p_sub->p_lock );
\r
113 //---------------------------------------------------------------------------
\r