1 /*****************************************************************************
\r
2 * misc.cpp: miscellaneous functions.
\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
24 #include <comctrls.hpp>
\r
27 #include <vlc/vlc.h>
\r
31 /****************************************************************************
\r
32 * This function replaces "Hint", "Caption" and "Text" properties of each
\r
33 * component of the form by the appropriate translation.
\r
34 ****************************************************************************/
\r
35 void __fastcall Translate( TForm *Form )
\r
37 // We must test the string because we don't want to get the default one
\r
38 if( Form->Hint != "" )
\r
40 Form->Hint = _( Form->Hint.c_str() );
\r
42 if( Form->Caption != "" )
\r
44 Form->Caption = _( Form->Caption.c_str() );
\r
47 for( int i = 0; i < Form->ComponentCount; i++ )
\r
49 // Does this component need a translation ?
\r
50 if( Form->Components[i]->Tag > 0 )
\r
52 TComponent *Component = Form->Components[i];
\r
54 // Note: the Text property isn't translated, because we don't want
\r
55 // to modify the content of TEdit or TComboBox objects, which
\r
56 // may have default values
\r
59 if( Component->Tag & 1 )
\r
61 if( Component->InheritsFrom( __classid( TControl ) ) )
\r
63 TControl *Object = (TControl *) Component;
\r
64 if( Object->Hint != "" )
\r
66 Object->Hint = _( Object->Hint.c_str() );
\r
69 else if( Component->InheritsFrom( __classid( TMenuItem ) ) )
\r
71 TMenuItem *Object = (TMenuItem *) Component;
\r
72 if( Object->Hint != "" )
\r
74 Object->Hint = _( Object->Hint.c_str() );
\r
80 if( Component->Tag & 2 )
\r
82 if( Component->InheritsFrom( __classid( TMenuItem ) ) )
\r
84 TMenuItem *Object = (TMenuItem *) Component;
\r
85 if( Object->Caption != "" )
\r
87 Object->Caption = _( Object->Caption.c_str() );
\r
90 else if( Component->InheritsFrom( __classid( TLabel ) ) )
\r
92 TLabel *Object = (TLabel *) Component;
\r
93 if( Object->Caption != "" )
\r
95 Object->Caption = _( Object->Caption.c_str() );
\r
98 else if( Component->InheritsFrom( __classid( TButton ) ) )
\r
100 TButton *Object = (TButton *) Component;
\r
101 if( Object->Caption != "" )
\r
103 Object->Caption = _( Object->Caption.c_str() );
\r
106 else if( Component->InheritsFrom( __classid( TRadioButton ) ) )
\r
108 TRadioButton *Object = (TRadioButton *) Component;
\r
109 if( Object->Caption != "" )
\r
111 Object->Caption = _( Object->Caption.c_str() );
\r
114 else if( Component->InheritsFrom( __classid( TCheckBox ) ) )
\r
116 TCheckBox *Object = (TCheckBox *) Component;
\r
117 if( Object->Caption != "" )
\r
119 Object->Caption = _( Object->Caption.c_str() );
\r
122 else if( Component->InheritsFrom( __classid( TRadioGroup ) ) )
\r
124 TRadioGroup *Object = (TRadioGroup *) Component;
\r
125 if( Object->Caption != "" )
\r
127 Object->Caption = _( Object->Caption.c_str() );
\r
130 else if( Component->InheritsFrom( __classid( TGroupBox ) ) )
\r
132 TGroupBox *Object = (TGroupBox *) Component;
\r
133 if( Object->Caption != "" )
\r
135 Object->Caption = _( Object->Caption.c_str() );
\r
138 else if( Component->InheritsFrom( __classid( TToolButton ) ) )
\r
140 TToolButton *Object = (TToolButton *) Component;
\r
141 if( Object->Caption != "" )
\r
143 Object->Caption = _( Object->Caption.c_str() );
\r
146 else if( Component->InheritsFrom( __classid( TListView ) ) )
\r
148 TListView *ListView = (TListView *) Component;
\r
149 for( int iCol = 0; iCol < ListView->Columns->Count; iCol++ )
\r
151 TListColumn *Object = ListView->Columns->Items[iCol];
\r
152 if( Object->Caption != "" )
\r
154 Object->Caption = _( Object->Caption.c_str() );
\r