]> git.sesse.net Git - vlc/blob - plugins/win32/messages.cpp
* Added a win32 interface plugin, developed with Borland C++ Builder.
[vlc] / plugins / 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 <videolan/vlc.h>\r
27 \r
28 #include "interface.h"\r
29 \r
30 #include "win32_common.h"\r
31 #include "messages.h"\r
32 \r
33 //---------------------------------------------------------------------------\r
34 #pragma package(smart_init)\r
35 #pragma resource "*.dfm"\r
36 \r
37 extern  struct intf_thread_s *p_intfGlobal;\r
38 \r
39 //---------------------------------------------------------------------------\r
40 __fastcall TMessagesDlg::TMessagesDlg( TComponent* Owner )\r
41     : TForm( Owner )\r
42 {\r
43     Icon = p_intfGlobal->p_sys->p_window->Icon;\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_intfGlobal->p_sys->p_window->MenuMessages->Checked = false;\r
54 }\r
55 //---------------------------------------------------------------------------\r
56 void __fastcall TMessagesDlg::FormShow( TObject *Sender )\r
57 {\r
58     p_intfGlobal->p_sys->p_window->MenuMessages->Checked = true;\r
59 }\r
60 //---------------------------------------------------------------------------\r
61 void __fastcall TMessagesDlg::UpdateLog()\r
62 {\r
63     intf_subscription_t *p_sub = p_intfGlobal->p_sys->p_sub;\r
64     int                 i_start;\r
65     int                 i_stop;\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) % INTF_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 INTF_MSG_ERR:\r
81                 RichEditMessages->SelAttributes->Color = clRed;\r
82                 break;\r
83             case INTF_MSG_WARN:\r
84                 RichEditMessages->SelAttributes->Color = clBlack;\r
85                 break;\r
86             default:\r
87                 RichEditMessages->SelAttributes->Color = clBlue;\r
88                 break;\r
89             }\r
90 \r
91             RichEditMessages->Lines->Add( p_sub->p_msg[i_start].psz_msg );\r
92         }\r
93 \r
94         vlc_mutex_lock( p_sub->p_lock );\r
95         p_sub->i_start = i_start;\r
96         vlc_mutex_unlock( p_sub->p_lock );\r
97     } \r
98 }\r
99 //---------------------------------------------------------------------------\r