]> git.sesse.net Git - vlc/blob - modules/gui/win32/misc.cpp
- about.dfm: the layout of the "About" dialog box is slightly different
[vlc] / modules / gui / win32 / misc.cpp
1 /*****************************************************************************\r
2  * misc.cpp: miscellaneous functions.\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 #include <comctrls.hpp>\r
25 #pragma hdrstop\r
26 \r
27 #include <vlc/vlc.h>\r
28 \r
29 #include "misc.h"\r
30 \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
36 {\r
37     // We must test the string because we don't want to get the default one\r
38     if( Form->Hint != "" )\r
39     {\r
40         Form->Hint = _( Form->Hint.c_str() );\r
41     }\r
42     if( Form->Caption != "" )\r
43     {\r
44         Form->Caption = _( Form->Caption.c_str() );\r
45     }\r
46 \r
47     for( int i = 0; i < Form->ComponentCount; i++ )\r
48     {\r
49         // Does this component need a translation ?\r
50         if( Form->Components[i]->Tag > 0 )\r
51         {\r
52             TComponent *Component = Form->Components[i];\r
53 \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
57 \r
58             // Hint property\r
59             if( Component->Tag & 1 )\r
60             {\r
61                 if( Component->InheritsFrom( __classid( TControl ) ) )\r
62                 {\r
63                     TControl *Object = (TControl *) Component;\r
64                     if( Object->Hint != "" )\r
65                     {\r
66                         Object->Hint = _( Object->Hint.c_str() );\r
67                     }\r
68                 }\r
69                 else if( Component->InheritsFrom( __classid( TMenuItem ) ) )\r
70                 {\r
71                     TMenuItem *Object = (TMenuItem *) Component;\r
72                     if( Object->Hint != "" )\r
73                     {\r
74                         Object->Hint = _( Object->Hint.c_str() );\r
75                     }\r
76                 }\r
77             }\r
78 \r
79             // Caption property\r
80             if( Component->Tag & 2 )\r
81             {\r
82                 if( Component->InheritsFrom( __classid( TMenuItem ) ) )\r
83                 {\r
84                     TMenuItem *Object = (TMenuItem *) Component;\r
85                     if( Object->Caption != "" )\r
86                     {\r
87                         Object->Caption = _( Object->Caption.c_str() );\r
88                     }\r
89                }\r
90                 else if( Component->InheritsFrom( __classid( TLabel ) ) )\r
91                 {\r
92                     TLabel *Object = (TLabel *) Component;\r
93                     if( Object->Caption != "" )\r
94                     {\r
95                         Object->Caption = _( Object->Caption.c_str() );\r
96                     }\r
97                 }\r
98                 else if( Component->InheritsFrom( __classid( TButton ) ) )\r
99                 {\r
100                     TButton *Object = (TButton *) Component;\r
101                     if( Object->Caption != "" )\r
102                     {\r
103                         Object->Caption = _( Object->Caption.c_str() );\r
104                     }\r
105                 }\r
106                 else if( Component->InheritsFrom( __classid( TRadioButton ) ) )\r
107                 {\r
108                     TRadioButton *Object = (TRadioButton *) Component;\r
109                     if( Object->Caption != "" )\r
110                     {\r
111                         Object->Caption = _( Object->Caption.c_str() );\r
112                     }\r
113                 }\r
114                 else if( Component->InheritsFrom( __classid( TCheckBox ) ) )\r
115                 {\r
116                     TCheckBox *Object = (TCheckBox *) Component;\r
117                     if( Object->Caption != "" )\r
118                     {\r
119                         Object->Caption = _( Object->Caption.c_str() );\r
120                     }\r
121                 }\r
122                 else if( Component->InheritsFrom( __classid( TRadioGroup ) ) )\r
123                 {\r
124                     TRadioGroup *Object = (TRadioGroup *) Component;\r
125                     if( Object->Caption != "" )\r
126                     {\r
127                         Object->Caption = _( Object->Caption.c_str() );\r
128                     }\r
129                 }\r
130                 else if( Component->InheritsFrom( __classid( TGroupBox ) ) )\r
131                 {\r
132                     TGroupBox *Object = (TGroupBox *) Component;\r
133                     if( Object->Caption != "" )\r
134                     {\r
135                         Object->Caption = _( Object->Caption.c_str() );\r
136                     }\r
137                 }\r
138                 else if( Component->InheritsFrom( __classid( TToolButton ) ) )\r
139                 {\r
140                     TToolButton *Object = (TToolButton *) Component;\r
141                     if( Object->Caption != "" )\r
142                     {\r
143                         Object->Caption = _( Object->Caption.c_str() );\r
144                     }\r
145                 }\r
146                 else if( Component->InheritsFrom( __classid( TListView ) ) )\r
147                 {\r
148                     TListView *ListView = (TListView *) Component;\r
149                     for( int iCol = 0; iCol < ListView->Columns->Count; iCol++ )\r
150                     {\r
151                         TListColumn *Object = ListView->Columns->Items[iCol];\r
152                         if( Object->Caption != "" )\r
153                         {\r
154                             Object->Caption = _( Object->Caption.c_str() );\r
155                         }\r
156                     }\r
157                 }\r
158             }\r
159         }\r
160     }\r
161 }\r
162  \r