]> git.sesse.net Git - vlc/blob - modules/gui/win32/messages.cpp
* The stream output can't use PS with UDP
[vlc] / modules / gui / win32 / messages.cpp
1 /*****************************************************************************\r
2  * messages.cpp: log window.\r
3  *****************************************************************************\r
4  * Copyright (C) 2002 VideoLAN\r
5  *\r
6  * Authors: Olivier Teuliere <ipkiss@via.ecp.fr>\r
7  *\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
12  * \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
17  *\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
22 \r
23 #include <vcl.h>\r
24 #pragma hdrstop\r
25 \r
26 #include <vlc/vlc.h>\r
27 #include <vlc/intf.h>\r
28 \r
29 #include "messages.h"\r
30 #include "misc.h"\r
31 #include "win32_common.h"\r
32 \r
33 //---------------------------------------------------------------------------\r
34 #pragma package(smart_init)\r
35 #pragma resource "*.dfm"\r
36 \r
37 //---------------------------------------------------------------------------\r
38 __fastcall TMessagesDlg::TMessagesDlg(\r
39     TComponent* Owner, intf_thread_t *_p_intf ) : TForm( Owner )\r
40 {\r
41     p_intf = _p_intf;\r
42     Icon = p_intf->p_sys->p_window->Icon;\r
43     Translate( this );\r
44 }\r
45 //---------------------------------------------------------------------------\r
46 void __fastcall TMessagesDlg::ButtonOKClick( TObject *Sender )\r
47 {\r
48     Hide();\r
49 }\r
50 //---------------------------------------------------------------------------\r
51 void __fastcall TMessagesDlg::FormHide( TObject *Sender )\r
52 {\r
53     p_intf->p_sys->p_window->MessagesAction->Checked = false;\r
54 }\r
55 //---------------------------------------------------------------------------\r
56 void __fastcall TMessagesDlg::FormShow( TObject *Sender )\r
57 {\r
58     p_intf->p_sys->p_window->MessagesAction->Checked = true;\r
59 }\r
60 //---------------------------------------------------------------------------\r
61 void __fastcall TMessagesDlg::UpdateLog()\r
62 {\r
63     msg_subscription_t *p_sub = p_intf->p_sys->p_sub;\r
64     int                 i_start, i_stop, i_del, i_count;\r
65     int                 i_max_lines;\r
66 \r
67     vlc_mutex_lock( p_sub->p_lock );\r
68     i_stop = *p_sub->pi_stop;\r
69     vlc_mutex_unlock( p_sub->p_lock );\r
70 \r
71     if( p_sub->i_start != i_stop )\r
72     {\r
73         for( i_start = p_sub->i_start;\r
74              i_start != i_stop;\r
75              i_start = (i_start+1) % VLC_MSG_QSIZE )\r
76         {\r
77             /* Append all messages to log window */\r
78             switch( p_sub->p_msg[i_start].i_type )\r
79             {\r
80             case VLC_MSG_ERR:\r
81                 RichEditMessages->SelAttributes->Color = clRed;\r
82                 break;\r
83             case VLC_MSG_WARN:\r
84                 RichEditMessages->SelAttributes->Color = clBlue;\r
85                 break;\r
86             default:\r
87                 RichEditMessages->SelAttributes->Color = clBlack;\r
88                 break;\r
89             }\r
90 \r
91             /* Limit log size */\r
92             i_count = RichEditMessages->Lines->Count;\r
93             i_max_lines = config_GetInt( p_intf, "intfwin-max-lines" );\r
94             if( i_max_lines > 0 )\r
95             {\r
96                 for( i_del = 0; i_del <= i_count - i_max_lines; i_del++ )\r
97                 {\r
98                     RichEditMessages->Lines->Delete( 0 );\r
99                 }\r
100             }\r
101 \r
102             /* Add message */\r
103             if( i_max_lines )\r
104             {\r
105                 RichEditMessages->Lines->Add( p_sub->p_msg[i_start].psz_msg );\r
106             }\r
107         }\r
108 \r
109         vlc_mutex_lock( p_sub->p_lock );\r
110         p_sub->i_start = i_start;\r
111         vlc_mutex_unlock( p_sub->p_lock );\r
112     } \r
113 }\r
114 //---------------------------------------------------------------------------\r