1 /*
2 TiMidity++ -- MIDI to WAVE converter and player
3 Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>
4 Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 w32g_subwin.c: Written by Daisuke Aoki <dai@y7.net>
21 */
22
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif /* HAVE_CONFIG_H */
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <process.h>
29 #include <stddef.h>
30 #ifndef NO_STRING_H
31 #include <string.h>
32 #else
33 #include <strings.h>
34 #endif
35
36 #include "timidity.h"
37 #include "common.h"
38 #include "instrum.h"
39 #include "playmidi.h"
40 #include "readmidi.h"
41 #include "output.h"
42 #include "controls.h"
43 #include "tables.h"
44 #include "miditrace.h"
45 #include "reverb.h"
46 #ifdef SUPPORT_SOUNDSPEC
47 #include "soundspec.h"
48 #endif /* SUPPORT_SOUNDSPEC */
49 #include "recache.h"
50 #include "arc.h"
51 #include "strtab.h"
52 #include "wrd.h"
53 #include "mid.defs"
54
55 #include "w32g.h"
56 #include <shlobj.h>
57 #include <commctrl.h>
58 #include <windowsx.h>
59 #include "w32g_res.h"
60 #include "w32g_utl.h"
61 #include "w32g_pref.h"
62 #include "w32g_subwin.h"
63 #include "w32g_ut2.h"
64
65 #if defined(__CYGWIN32__) || defined(__MINGW32__)
66 #ifndef TPM_TOPALIGN
67 #define TPM_TOPALIGN 0x0000L
68 #endif
69 #endif
70
71 extern void MainWndToggleConsoleButton(void);
72 extern void MainWndUpdateConsoleButton(void);
73 extern void MainWndToggleTracerButton(void);
74 extern void MainWndUpdateTracerButton(void);
75 extern void MainWndToggleListButton(void);
76 extern void MainWndUpdateListButton(void);
77 extern void MainWndToggleDocButton(void);
78 extern void MainWndUpdateDocButton(void);
79 extern void MainWndToggleWrdButton(void);
80 extern void MainWndUpdateWrdButton(void);
81 extern void MainWndToggleSoundSpecButton(void);
82 extern void MainWndUpdateSoundSpecButton(void);
83 extern void ShowSubWindow(HWND hwnd,int showflag);
84 extern void ToggleSubWindow(HWND hwnd);
85
86 extern void VprintfEditCtlWnd(HWND hwnd, char *fmt, va_list argList);
87 extern void PrintfEditCtlWnd(HWND hwnd, char *fmt, ...);
88 extern void PutsEditCtlWnd(HWND hwnd, char *str);
89 extern void ClearEditCtlWnd(HWND hwnd);
90
91 extern char *nkf_convert(char *si,char *so,int maxsize,char *in_mode,char *out_mode);
92
93 void InitListSearchWnd(HWND hParentWnd);
94 void ShowListSearch(void);
95 void HideListSearch(void);
96
97 // ***************************************************************************
98 //
99 // Console Window
100 //
101 // ***************************************************************************
102
103 // ---------------------------------------------------------------------------
104 // variables
105 static int ConsoleWndMaxSize = 64 * 1024;
106 static HFONT hFontConsoleWnd = NULL;
107 CONSOLEWNDINFO ConsoleWndInfo;
108
109 // ---------------------------------------------------------------------------
110 // prototypes of functions
111 static BOOL CALLBACK ConsoleWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam);
112 static void ConsoleWndAllUpdate(void);
113 static void ConsoleWndVerbosityUpdate(void);
114 static void ConsoleWndVerbosityApply(void);
115 static void ConsoleWndValidUpdate(void);
116 static void ConsoleWndValidApply(void);
117 static void ConsoleWndVerbosityApplyIncDec(int num);
118 static int ConsoleWndInfoReset(HWND hwnd);
119 static int ConsoleWndInfoApply(void);
120
121 // ---------------------------------------------------------------------------
122 // Global Functions
123
124 // Initialization
InitConsoleWnd(HWND hParentWnd)125 void InitConsoleWnd(HWND hParentWnd)
126 {
127 if (hConsoleWnd != NULL) {
128 DestroyWindow(hConsoleWnd);
129 hConsoleWnd = NULL;
130 }
131 INILoadConsoleWnd();
132 switch(PlayerLanguage){
133 case LANGUAGE_ENGLISH:
134 hConsoleWnd = CreateDialog
135 (hInst,MAKEINTRESOURCE(IDD_DIALOG_CONSOLE_EN),hParentWnd,ConsoleWndProc);
136 break;
137 default:
138 case LANGUAGE_JAPANESE:
139 hConsoleWnd = CreateDialog
140 (hInst,MAKEINTRESOURCE(IDD_DIALOG_CONSOLE),hParentWnd,ConsoleWndProc);
141 break;
142 }
143 ConsoleWndInfoReset(hConsoleWnd);
144 ShowWindow(hConsoleWnd,SW_HIDE);
145 ConsoleWndInfoReset(hConsoleWnd);
146 UpdateWindow(hConsoleWnd);
147 ConsoleWndVerbosityApplyIncDec(0);
148 CheckDlgButton(hConsoleWnd, IDC_CHECKBOX_VALID, ConsoleWndFlag);
149 Edit_LimitText(GetDlgItem(hConsoleWnd,IDC_EDIT), ConsoleWndMaxSize);
150 ConsoleWndInfoApply();
151 }
152
153 // Window Procedure
154 static BOOL CALLBACK
ConsoleWndProc(HWND hwnd,UINT uMess,WPARAM wParam,LPARAM lParam)155 ConsoleWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
156 {
157 switch (uMess){
158 case WM_INITDIALOG:
159 PutsConsoleWnd("Console Window\n");
160 ConsoleWndAllUpdate();
161 SetWindowPosSize(GetDesktopWindow(),hwnd,ConsoleWndInfo.PosX, ConsoleWndInfo.PosY );
162 return FALSE;
163 case WM_COMMAND:
164 switch (LOWORD(wParam)) {
165 case IDCLOSE:
166 ShowWindow(hwnd, SW_HIDE);
167 MainWndUpdateConsoleButton();
168 break;
169 case IDCLEAR:
170 ClearConsoleWnd();
171 break;
172 case IDC_CHECKBOX_VALID:
173 ConsoleWndValidApply();
174 break;
175 case IDC_BUTTON_VERBOSITY:
176 ConsoleWndVerbosityApply();
177 break;
178 case IDC_BUTTON_INC:
179 ConsoleWndVerbosityApplyIncDec(1);
180 break;
181 case IDC_BUTTON_DEC:
182 ConsoleWndVerbosityApplyIncDec(-1);
183 break;
184 default:
185 break;
186 }
187 switch (HIWORD(wParam)) {
188 case EN_ERRSPACE:
189 ClearConsoleWnd();
190 PutsConsoleWnd("### EN_ERRSPACE -> Clear! ###\n");
191 break;
192 default:
193 break;
194 }
195 break;
196 case WM_SIZE:
197 ConsoleWndAllUpdate();
198 return FALSE;
199 case WM_MOVE:
200 // ConsoleWndInfo.PosX = (int) LOWORD(lParam);
201 // ConsoleWndInfo.PosY = (int) HIWORD(lParam);
202 {
203 RECT rc;
204 GetWindowRect(hwnd,&rc);
205 ConsoleWndInfo.PosX = rc.left;
206 ConsoleWndInfo.PosY = rc.top;
207 }
208 break;
209 // See PreDispatchMessage() in w32g2_main.c
210 case WM_SYSKEYDOWN:
211 case WM_KEYDOWN:
212 {
213 int nVirtKey = (int)wParam;
214 switch(nVirtKey){
215 case VK_ESCAPE:
216 SendMessage(hwnd,WM_CLOSE,0,0);
217 break;
218 }
219 }
220 break;
221 case WM_DESTROY:
222 INISaveConsoleWnd();
223 break;
224 case WM_CLOSE:
225 ShowSubWindow(hConsoleWnd,0);
226 // ShowWindow(hConsoleWnd, SW_HIDE);
227 MainWndUpdateConsoleButton();
228 break;
229 case WM_SETFOCUS:
230 HideCaret(hwnd);
231 break;
232 case WM_KILLFOCUS:
233 ShowCaret(hwnd);
234 break;
235 default:
236 return FALSE;
237 }
238 return FALSE;
239 }
240
241 // puts()
PutsConsoleWnd(char * str)242 void PutsConsoleWnd(char *str)
243 {
244 HWND hwnd;
245 if(!IsWindow(hConsoleWnd) || !ConsoleWndFlag)
246 return;
247 hwnd = GetDlgItem(hConsoleWnd,IDC_EDIT);
248 PutsEditCtlWnd(hwnd,str);
249 }
250
251 // printf()
PrintfConsoleWnd(char * fmt,...)252 void PrintfConsoleWnd(char *fmt, ...)
253 {
254 HWND hwnd;
255 va_list ap;
256 if(!IsWindow(hConsoleWnd) || !ConsoleWndFlag)
257 return;
258 hwnd = GetDlgItem(hConsoleWnd,IDC_EDIT);
259 va_start(ap, fmt);
260 VprintfEditCtlWnd(hwnd,fmt,ap);
261 va_end(ap);
262 }
263
264 // Clear
ClearConsoleWnd(void)265 void ClearConsoleWnd(void)
266 {
267 HWND hwnd;
268 if(!IsWindow(hConsoleWnd))
269 return;
270 hwnd = GetDlgItem(hConsoleWnd,IDC_EDIT);
271 ClearEditCtlWnd(hwnd);
272 }
273
274 // ---------------------------------------------------------------------------
275 // Static Functions
276
ConsoleWndAllUpdate(void)277 static void ConsoleWndAllUpdate(void)
278 {
279 ConsoleWndVerbosityUpdate();
280 ConsoleWndValidUpdate();
281 Edit_LimitText(GetDlgItem(hConsoleWnd,IDC_EDIT_VERBOSITY),3);
282 Edit_LimitText(GetDlgItem(hConsoleWnd,IDC_EDIT),ConsoleWndMaxSize);
283 }
284
ConsoleWndValidUpdate(void)285 static void ConsoleWndValidUpdate(void)
286 {
287 if(ConsoleWndFlag)
288 CheckDlgButton(hConsoleWnd, IDC_CHECKBOX_VALID, 1);
289 else
290 CheckDlgButton(hConsoleWnd, IDC_CHECKBOX_VALID, 0);
291 }
292
ConsoleWndValidApply(void)293 static void ConsoleWndValidApply(void)
294 {
295 if(IsDlgButtonChecked(hConsoleWnd,IDC_CHECKBOX_VALID))
296 ConsoleWndFlag = 1;
297 else
298 ConsoleWndFlag = 0;
299 }
300
ConsoleWndVerbosityUpdate(void)301 static void ConsoleWndVerbosityUpdate(void)
302 {
303 SetDlgItemInt(hConsoleWnd,IDC_EDIT_VERBOSITY,(UINT)ctl->verbosity, TRUE);
304 }
305
ConsoleWndVerbosityApply(void)306 static void ConsoleWndVerbosityApply(void)
307 {
308 char buffer[64];
309 HWND hwnd;
310 hwnd = GetDlgItem(hConsoleWnd,IDC_EDIT_VERBOSITY);
311 if(!IsWindow(hConsoleWnd)) return;
312 if(Edit_GetText(hwnd,buffer,60)<=0) return;
313 ctl->verbosity = atoi(buffer);
314 ConsoleWndVerbosityUpdate();
315 }
316
ConsoleWndVerbosityApplyIncDec(int num)317 static void ConsoleWndVerbosityApplyIncDec(int num)
318 {
319 if(!IsWindow(hConsoleWnd)) return;
320 ctl->verbosity += num;
321 RANGE(ctl->verbosity, -1, 4);
322 ConsoleWndVerbosityUpdate();
323 }
324
ConsoleWndInfoReset(HWND hwnd)325 static int ConsoleWndInfoReset(HWND hwnd)
326 {
327 memset(&ConsoleWndInfo,0,sizeof(CONSOLEWNDINFO));
328 ConsoleWndInfo.PosX = - 1;
329 ConsoleWndInfo.PosY = - 1;
330 return 0;
331 }
332
ConsoleWndInfoApply(void)333 static int ConsoleWndInfoApply(void)
334 {
335 return 0;
336 }
337
338
339
340 // ****************************************************************************
341 //
342 // List Window
343 //
344 // ****************************************************************************
345
346 // ---------------------------------------------------------------------------
347 // Macros
348 #define IDM_LISTWND_REMOVE 4101
349 #define IDM_LISTWND_PLAY 4102
350 #define IDM_LISTWND_REFINE 4103
351 #define IDM_LISTWND_UNIQ 4104
352 #define IDM_LISTWND_CLEAR 4105
353 #define IDM_LISTWND_CHOOSEFONT 4106
354 #define IDM_LISTWND_CURRENT 4107
355 #define IDM_LISTWND_SEARCH 4108
356
357 // ---------------------------------------------------------------------------
358 // Variables
359 LISTWNDINFO ListWndInfo;
360 HWND hListSearchWnd = NULL;
361
362 // ---------------------------------------------------------------------------
363 // Prototypes
364 static BOOL CALLBACK ListWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam);
365 static int ListWndInfoReset(HWND hwnd);
366 static int ListWndInfoApply(void);
367 static int ListWndSetFontListBox(char *fontName, int fontWidth, int fontHeght);
368 static int ResetListWnd(void);
369 static int ClearListWnd(void);
370 static int UniqListWnd(void);
371 static int RefineListWnd(void);
372 static int DelListWnd(int nth);
373
374 // ---------------------------------------------------------------------------
375 // Grobal Functions
InitListWnd(HWND hParentWnd)376 void InitListWnd(HWND hParentWnd)
377 {
378 if (hListWnd != NULL) {
379 DestroyWindow(hListWnd);
380 hListWnd = NULL;
381 }
382 ListWndInfoReset(hListWnd);
383 INILoadListWnd();
384 switch(PlayerLanguage){
385 case LANGUAGE_ENGLISH:
386 hListWnd = CreateDialog
387 (hInst,MAKEINTRESOURCE(IDD_DIALOG_SIMPLE_LIST_EN),hParentWnd,ListWndProc);
388 break;
389 default:
390 case LANGUAGE_JAPANESE:
391 hListWnd = CreateDialog
392 (hInst,MAKEINTRESOURCE(IDD_DIALOG_SIMPLE_LIST),hParentWnd,ListWndProc);
393 break;
394 }
395 ListWndInfoReset(hListWnd);
396 ListWndInfo.hPopupMenu = CreatePopupMenu();
397 switch(PlayerLanguage){
398 case LANGUAGE_JAPANESE:
399 AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_PLAY,"���t");
400 AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDC_BUTTON_DOC,"�h�L�������g");
401 AppendMenu(ListWndInfo.hPopupMenu,MF_SEPARATOR,0,0);
402 AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_CURRENT,"���݈ʒu");
403 AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_SEARCH,"����");
404 AppendMenu(ListWndInfo.hPopupMenu,MF_SEPARATOR,0,0);
405 AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_REMOVE,"�폜");
406 AppendMenu(ListWndInfo.hPopupMenu,MF_SEPARATOR,0,0);
407 AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_CHOOSEFONT,"�t�H���g�̑I��");
408 break;
409 default:
410 case LANGUAGE_ENGLISH:
411 AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_PLAY,"Play");
412 AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDC_BUTTON_DOC,"Doc");
413 AppendMenu(ListWndInfo.hPopupMenu,MF_SEPARATOR,0,0);
414 AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_CURRENT,"Current item");
415 AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_SEARCH,"Search");
416 AppendMenu(ListWndInfo.hPopupMenu,MF_SEPARATOR,0,0);
417 AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_REMOVE,"Remove");
418 AppendMenu(ListWndInfo.hPopupMenu,MF_SEPARATOR,0,0);
419 AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_CHOOSEFONT,"Choose Font");
420 break;
421 }
422
423 INILoadListWnd();
424 ListWndInfoApply();
425 ShowWindow(ListWndInfo.hwnd,SW_HIDE);
426 UpdateWindow(ListWndInfo.hwnd);
427 w32g_send_rc(RC_EXT_UPDATE_PLAYLIST, 0);
428 }
429
430 // ---------------------------------------------------------------------------
431 // Static Functions
432
433 void SetNumListWnd(int cursel, int nfiles);
434
435 #define WM_CHOOSEFONT_DIAG (WM_APP+100)
436 #define WM_LIST_SEARCH_DIAG (WM_APP+101)
437 #define LISTWND_HORIZONTALEXTENT 1600
438
439 static BOOL CALLBACK
ListWndProc(HWND hwnd,UINT uMess,WPARAM wParam,LPARAM lParam)440 ListWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
441 {
442 static BOOL ListSearchWndShow;
443 switch (uMess){
444 case WM_INITDIALOG:
445 ListSearchWndShow = 0;
446 InitListSearchWnd(hwnd);
447 SendDlgItemMessage(hwnd,IDC_LISTBOX_PLAYLIST,
448 LB_SETHORIZONTALEXTENT,(WPARAM)LISTWND_HORIZONTALEXTENT,0);
449 w32g_send_rc(RC_EXT_UPDATE_PLAYLIST, 0);
450 SetWindowPosSize(GetDesktopWindow(),hwnd,ListWndInfo.PosX, ListWndInfo.PosY );
451 return FALSE;
452 case WM_DESTROY:
453 {
454 RECT rc;
455 GetWindowRect(hwnd,&rc);
456 ListWndInfo.Width = rc.right - rc.left;
457 ListWndInfo.Height = rc.bottom - rc.top;
458 }
459 DestroyMenu(ListWndInfo.hPopupMenu);
460 ListWndInfo.hPopupMenu = NULL;
461 INISaveListWnd();
462 break;
463 /* �}�E�X���͂��L���v�`������Ă��Ȃ����߂̏��� */
464 case WM_SETCURSOR:
465 switch(HIWORD(lParam)){
466 case WM_RBUTTONDOWN:
467 if(LOWORD(lParam)!=HTCAPTION){ // �^�C�g���o�[�ɂȂ��Ƃ�
468 POINT point;
469 int res;
470 GetCursorPos(&point);
471 SetForegroundWindow ( hwnd );
472 res = TrackPopupMenu(ListWndInfo.hPopupMenu,TPM_TOPALIGN|TPM_LEFTALIGN,
473 point.x,point.y,0,hwnd,NULL);
474 PostMessage ( hwnd, WM_NULL, 0, 0 );
475 return TRUE;
476 }
477 break;
478 default:
479 break;
480 }
481 break;
482 case WM_CHOOSEFONT_DIAG:
483 {
484 char fontName[64];
485 int fontHeight;
486 int fontWidth;
487 strcpy(fontName,ListWndInfo.fontName);
488 fontHeight = ListWndInfo.fontHeight;
489 fontWidth = ListWndInfo.fontWidth;
490 if(DlgChooseFont(hwnd,fontName,&fontHeight,&fontWidth)==0){
491 ListWndSetFontListBox(fontName,fontWidth,fontHeight);
492 }
493 }
494 break;
495 case WM_LIST_SEARCH_DIAG:
496 ShowListSearch();
497 break;
498 case WM_COMMAND:
499 switch (HIWORD(wParam)) {
500 case IDCLOSE:
501 ShowWindow(hwnd, SW_HIDE);
502 MainWndUpdateListButton();
503 break;
504 case LBN_DBLCLK:
505 SendMessage(hwnd,WM_COMMAND,(WPARAM)IDM_LISTWND_PLAY,0);
506 return FALSE;
507 case LBN_SELCHANGE:
508 {
509 int idListBox = (int) LOWORD(wParam);
510 HWND hwndListBox = (HWND) lParam;
511 int selected, nfiles, cursel;
512 w32g_get_playlist_index(&selected,&nfiles,&cursel);
513 SetNumListWnd(cursel,nfiles);
514 return FALSE;
515 }
516 default:
517 break;
518 }
519 switch (LOWORD(wParam)) {
520 case IDC_BUTTON_CLEAR:
521 if(MessageBox(hListWnd,"Clear playlist?","Playlist",
522 MB_YESNO)==IDYES)
523 w32g_send_rc(RC_EXT_CLEAR_PLAYLIST, 0);
524 return FALSE;
525 case IDC_BUTTON_REFINE:
526 if(MessageBox(hListWnd,
527 "Remove unsupported file types from the playlist?",
528 "Playlist",MB_YESNO) == IDYES)
529 w32g_send_rc(RC_EXT_REFINE_PLAYLIST, 0);
530 return FALSE;
531 case IDC_BUTTON_UNIQ:
532 if(MessageBox(hListWnd,
533 "Remove the same files from the playlist and make files of the playlist unique?",
534 "Playlist",MB_YESNO)==IDYES)
535 w32g_send_rc(RC_EXT_UNIQ_PLAYLIST, 0);
536 return FALSE;
537 case IDM_LISTWND_REMOVE:
538 w32g_send_rc(RC_EXT_DELETE_PLAYLIST, 0);
539 break;
540 case IDC_BUTTON_DOC: {
541 int cursel;
542 w32g_get_playlist_index(NULL, NULL, &cursel);
543 w32g_send_rc(RC_EXT_OPEN_DOC, cursel);
544 }
545 break;
546 case IDM_LISTWND_PLAY:
547 {
548 int new_cursel = SendDlgItemMessage(hwnd,IDC_LISTBOX_PLAYLIST,LB_GETCURSEL,0,0);
549 int selected, nfiles, cursel;
550 w32g_get_playlist_index(&selected, &nfiles, &cursel);
551 if ( nfiles <= new_cursel ) new_cursel = nfiles - 1;
552 if ( new_cursel >= 0 )
553 w32g_send_rc(RC_EXT_JUMP_FILE, new_cursel );
554 }
555 return FALSE;
556 case IDM_LISTWND_CHOOSEFONT:
557 {
558 SendMessage(hwnd,WM_CHOOSEFONT_DIAG,0,0);
559 }
560 return FALSE;
561 case IDM_LISTWND_CURRENT:
562 {
563 int selected, nfiles, cursel;
564 w32g_get_playlist_index(&selected, &nfiles, &cursel);
565 SendDlgItemMessage(hwnd,IDC_LISTBOX_PLAYLIST,
566 LB_SETCURSEL,(WPARAM)selected,0);
567 SetNumListWnd(selected,nfiles);
568 }
569 return FALSE;
570 case IDM_LISTWND_SEARCH:
571 {
572 SendMessage(hwnd,WM_LIST_SEARCH_DIAG,0,0);
573 }
574 return FALSE;
575 default:
576 break;
577 }
578 break;
579 case WM_VKEYTOITEM:
580 {
581 UINT vkey = (UINT)LOWORD(wParam);
582 int nCaretPos = (int)HIWORD(wParam);
583 switch(vkey){
584 case VK_SPACE:
585 case VK_RETURN:
586 w32g_send_rc(RC_EXT_JUMP_FILE, nCaretPos);
587 return -2;
588 case 0x50: // VK_P
589 SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_PREV,0),0);
590 return -2;
591 case 0x4e: // VK_N
592 SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_NEXT,0),0);
593 return -2;
594 case 0x45: // VK_E
595 SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_STOP,0),0);
596 return -2;
597 case 0x53: // VK_S
598 SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_PAUSE,0),0);
599 return -2;
600 case VK_ESCAPE:
601 SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(0,IDCLOSE),0);
602 return -2;
603 case 0x51: // VK_Q
604 if(MessageBox(hListWnd,"Quit TiMidity?","TiMidity",MB_ICONQUESTION|MB_YESNO)==IDYES)
605 SendMessage(hMainWnd,WM_CLOSE,0,0);
606 return -2;
607 case VK_BACK:
608 w32g_send_rc(RC_EXT_DELETE_PLAYLIST, -1);
609 return -2;
610 case 0x44: // VK_D
611 w32g_send_rc(RC_EXT_DELETE_PLAYLIST, 0);
612 return -2;
613 case VK_DELETE:
614 w32g_send_rc(RC_EXT_ROTATE_PLAYLIST, -1);
615 return -2;
616 case VK_INSERT:
617 w32g_send_rc(RC_EXT_ROTATE_PLAYLIST, 1);
618 return -2;
619 case 0x46: // VK_F
620 return -2;
621 case 0x42: // VK_B
622 return -2;
623 case 0x4D: // VK_M
624 SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(IDC_BUTTON_REFINE,0),0);
625 return -2;
626 case 0x43: // VK_C
627 SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(IDC_BUTTON_CLEAR,0),0);
628 return -2;
629 case 0x55: // VK_U
630 SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(IDC_BUTTON_UNIQ,0),0);
631 return -2;
632 case 0x56: // VK_V
633 SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(IDC_BUTTON_DOC,0),0);
634 return -2;
635 case 0x57: // VK_W
636 SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_WRD,0),0);
637 return -2;
638 case VK_F1:
639 case 0x48: // VK_H
640 if ( PlayerLanguage == LANGUAGE_JAPANESE ){
641 MessageBox(hListWnd,
642 "�L�[�R�}���h\n"
643 "���X�g�E�C���h�E�R�}���h\n"
644 " ESC: �w���v����� H: �w���v���o��\n"
645 " V: �h�L�������g������ W: WRD �E�C���h�E���J��\n"
646 "�v���C���[�R�}���h\n"
647 " SPACE/ENTER: ���t�J�n E: ��~ S: �ꎞ��~\n"
648 " P: �O�̋� N: ���̋�\n"
649 "�v���C���X�g����R�}���h\n"
650 " M: MIDI�t�@�C���ȊO���폜 U: �d���t�@�C�����폜\n"
651 " C: �v���C���X�g�̃N���A\n"
652 " D: �J�[�\���̋Ȃ��폜 BS: �J�[�\���̑O�̋Ȃ��폜\n"
653 " INS: �J�[�\���̋Ȃ����X�g�̍Ō�Ɉڂ� (Push)\n"
654 " DEL: ���X�g�̍Ō�̋Ȃ��J�[�\���̑O�ɑ}�� (Pop)\n"
655 "TiMidity �R�}���h\n"
656 " Q: �I��\n"
657 ,"�w���v", MB_OK);
658 } else {
659 MessageBox(hListWnd,
660 "Usage of key.\n"
661 "List window command.\n"
662 " ESC: Close Help H: Help\n"
663 " V: View Document W: Open WRD window\n"
664 "Player command.\n"
665 " SPACE/ENTER: PLAY E: Stop S: Pause\n"
666 " P: Prev N: Next\n"
667 "Playlist command.\n"
668 " M: Refine playlist U: Uniq playlist\n"
669 " C: Clear playlist\n"
670 " D: Remove playlist BS: Remove previous playlist\n"
671 " INS: Push Playlist DEL: Pop Playlist\n"
672 "TiMidity command.\n"
673 " Q: Quit\n"
674 ,"Help", MB_OK);
675 }
676 return -2;
677 default:
678 break;
679 }
680 return -1;
681 }
682 case WM_SIZE:
683 switch(wParam){
684 case SIZE_MAXIMIZED:
685 case SIZE_RESTORED:
686 { // �ȂӖ��Ȃ��ʓ|(^^;;
687 int x,y,cx,cy;
688 int maxHeight = 0;
689 int center, idControl;
690 HWND hwndChild;
691 RECT rcParent, rcChild, rcRest;
692 int nWidth = LOWORD(lParam);
693 int nHeight = HIWORD(lParam);
694 GetWindowRect(hwnd,&rcParent);
695 cx = rcParent.right-rcParent.left;
696 cy = rcParent.bottom-rcParent.top;
697 if(cx < 380)
698 MoveWindow(hwnd,rcParent.left,rcParent.top,380,cy,TRUE);
699 if(cy < 200)
700 MoveWindow(hwnd,rcParent.left,rcParent.top,cx,200,TRUE);
701 GetClientRect(hwnd,&rcParent);
702 rcRest.left = rcParent.left; rcRest.right = rcParent.right;
703
704 // IDC_EDIT_NUM
705 idControl = IDC_EDIT_NUM;
706 hwndChild = GetDlgItem(hwnd,idControl);
707 GetWindowRect(hwndChild,&rcChild);
708 cx = rcChild.right-rcChild.left;
709 cy = rcChild.bottom-rcChild.top;
710 x = rcParent.left;
711 y = rcParent.bottom - cy;
712 MoveWindow(hwndChild,x,y,cx,cy,TRUE);
713 if(cy>maxHeight) maxHeight = cy;
714 rcRest.left += cx;
715 // IDC_BUTTON_DOC
716 idControl = IDC_BUTTON_DOC;
717 hwndChild = GetDlgItem(hwnd,idControl);
718 GetWindowRect(hwndChild,&rcChild);
719 cx = rcChild.right-rcChild.left;
720 cy = rcChild.bottom-rcChild.top;
721 x = rcRest.left + 10;
722 y = rcParent.bottom - cy;
723 MoveWindow(hwndChild,x,y,cx,cy,TRUE);
724 if(cy>maxHeight) maxHeight = cy;
725 rcRest.left += cx;
726 // IDC_BUTTON_CLEAR
727 idControl = IDC_BUTTON_CLEAR;
728 hwndChild = GetDlgItem(hwnd,idControl);
729 GetWindowRect(hwndChild,&rcChild);
730 cx = rcChild.right-rcChild.left;
731 cy = rcChild.bottom-rcChild.top;
732 x = rcParent.right - cx - 5;
733 y = rcParent.bottom - cy ;
734 MoveWindow(hwndChild,x,y,cx,cy,TRUE);
735 if(cy>maxHeight) maxHeight = cy;
736 rcRest.right -= cx + 5;
737 // IDC_BUTTON_UNIQ
738 center = rcRest.left + (int)((rcRest.right - rcRest.left)*0.52);
739 idControl = IDC_BUTTON_UNIQ;
740 hwndChild = GetDlgItem(hwnd,idControl);
741 GetWindowRect(hwndChild,&rcChild);
742 cx = rcChild.right-rcChild.left;
743 cy = rcChild.bottom-rcChild.top;
744 x = center - cx;
745 y = rcParent.bottom - cy;
746 MoveWindow(hwndChild,x,y,cx,cy,TRUE);
747 if(cy>maxHeight) maxHeight = cy;
748 // IDC_BUTTON_REFINE
749 idControl = IDC_BUTTON_REFINE;
750 hwndChild = GetDlgItem(hwnd,idControl);
751 GetWindowRect(hwndChild,&rcChild);
752 cx = rcChild.right-rcChild.left;
753 cy = rcChild.bottom-rcChild.top;
754 x = center + 3;
755 y = rcParent.bottom - cy;
756 MoveWindow(hwndChild,x,y,cx,cy,TRUE);
757 if(cy>maxHeight) maxHeight = cy;
758 // IDC_LISTBOX_PLAYLIST
759 idControl = IDC_LISTBOX_PLAYLIST;
760 hwndChild = GetDlgItem(hwnd,idControl);
761 cx = rcParent.right - rcParent.left;
762 cy = rcParent.bottom - rcParent.top - maxHeight - 3;
763 x = rcParent.left;
764 y = rcParent.top;
765 MoveWindow(hwndChild,x,y,cx,cy,TRUE);
766 InvalidateRect(hwnd,&rcParent,FALSE);
767 UpdateWindow(hwnd);
768 GetWindowRect(hwnd,&rcParent);
769 ListWndInfo.Width = rcParent.right - rcParent.left;
770 ListWndInfo.Height = rcParent.bottom - rcParent.top;
771 break;
772 }
773 case SIZE_MINIMIZED:
774 case SIZE_MAXHIDE:
775 case SIZE_MAXSHOW:
776 default:
777 break;
778 }
779 break;
780 case WM_MOVE:
781 // ListWndInfo.PosX = (int) LOWORD(lParam);
782 // ListWndInfo.PosY = (int) HIWORD(lParam);
783 {
784 RECT rc;
785 GetWindowRect(hwnd,&rc);
786 ListWndInfo.PosX = rc.left;
787 ListWndInfo.PosY = rc.top;
788 }
789 break;
790 // See PreDispatchMessage() in w32g2_main.c
791 case WM_SYSKEYDOWN:
792 case WM_KEYDOWN:
793 {
794 int nVirtKey = (int)wParam;
795 switch(nVirtKey){
796 case VK_ESCAPE:
797 SendMessage(hwnd,WM_CLOSE,0,0);
798 break;
799 }
800 }
801 break;
802 case WM_CLOSE:
803 ShowSubWindow(hListWnd,0);
804 // ShowWindow(hListWnd, SW_HIDE);
805 MainWndUpdateListButton();
806 break;
807 case WM_SHOWWINDOW:
808 {
809 BOOL fShow = (BOOL)wParam;
810 if ( fShow ) {
811 if ( ListSearchWndShow ) {
812 ShowListSearch();
813 } else {
814 HideListSearch();
815 }
816 } else {
817 if ( IsWindowVisible ( hListSearchWnd ) )
818 ListSearchWndShow = TRUE;
819 else
820 ListSearchWndShow = FALSE;
821 HideListSearch();
822 }
823 }
824 break;
825 case WM_DROPFILES:
826 SendMessage(hMainWnd,WM_DROPFILES,wParam,lParam);
827 return 0;
828 default:
829 return FALSE;
830 }
831 return FALSE;
832 }
833
ListWndInfoReset(HWND hwnd)834 static int ListWndInfoReset(HWND hwnd)
835 {
836 memset(&ListWndInfo,0,sizeof(LISTWNDINFO));
837 ListWndInfo.PosX = - 1;
838 ListWndInfo.PosY = - 1;
839 ListWndInfo.Height = 400;
840 ListWndInfo.Width = 400;
841 ListWndInfo.hPopupMenu = NULL;
842 ListWndInfo.hwnd = hwnd;
843 if ( hwnd != NULL )
844 ListWndInfo.hwndListBox = GetDlgItem(hwnd,IDC_LISTBOX_PLAYLIST);
845 strcpy(ListWndInfo.fontNameEN,"Times New Roman");
846 strcpy(ListWndInfo.fontNameJA,"�l�r ����");
847 ListWndInfo.fontHeight = 12;
848 ListWndInfo.fontWidth = 6;
849 ListWndInfo.fontFlags = FONT_FLAGS_FIXED;
850 switch(PlayerLanguage){
851 case LANGUAGE_ENGLISH:
852 ListWndInfo.fontName = ListWndInfo.fontNameEN;
853 break;
854 default:
855 case LANGUAGE_JAPANESE:
856 ListWndInfo.fontName = ListWndInfo.fontNameJA;
857 break;
858 }
859 return 0;
860 }
ListWndInfoApply(void)861 static int ListWndInfoApply(void)
862 {
863 RECT rc;
864 HFONT hFontPre = NULL;
865 DWORD fdwPitch = (ListWndInfo.fontFlags&FONT_FLAGS_FIXED)?FIXED_PITCH:VARIABLE_PITCH;
866 DWORD fdwItalic = (ListWndInfo.fontFlags&FONT_FLAGS_ITALIC)?TRUE:FALSE;
867 HFONT hFont =
868 CreateFont(ListWndInfo.fontHeight,ListWndInfo.fontWidth,0,0,FW_DONTCARE,fdwItalic,FALSE,FALSE,
869 DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
870 fdwPitch | FF_DONTCARE,ListWndInfo.fontName);
871 if(hFont != NULL){
872 hFontPre = ListWndInfo.hFontListBox;
873 ListWndInfo.hFontListBox = hFont;
874 SendMessage(ListWndInfo.hwndListBox,WM_SETFONT,(WPARAM)ListWndInfo.hFontListBox,(LPARAM)MAKELPARAM(TRUE,0));
875 }
876 GetWindowRect(ListWndInfo.hwnd,&rc);
877 MoveWindow(ListWndInfo.hwnd,rc.left,rc.top,ListWndInfo.Width,ListWndInfo.Height,TRUE);
878 // InvalidateRect(hwnd,&rc,FALSE);
879 // UpdateWindow(hwnd);
880 if(hFontPre!=NULL) CloseHandle(hFontPre);
881 INISaveListWnd();
882 return 0;
883 }
884
ListWndSetFontListBox(char * fontName,int fontWidth,int fontHeight)885 static int ListWndSetFontListBox(char *fontName, int fontWidth, int fontHeight)
886 {
887 strcpy(ListWndInfo.fontName,fontName);
888 ListWndInfo.fontWidth = fontWidth;
889 ListWndInfo.fontHeight = fontHeight;
890 ListWndInfoApply();
891 return 0;
892 }
893
SetNumListWnd(int cursel,int nfiles)894 void SetNumListWnd(int cursel, int nfiles)
895 {
896 char buff[64];
897 sprintf(buff,"%04d/%04d",cursel+1,nfiles);
898 SetDlgItemText(hListWnd,IDC_EDIT_NUM,buff);
899 }
900
901
902 #if 0
903 // ***************************************************************************
904 // Tracer Window
905
906 BOOL CALLBACK TracerWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam);
907 void InitTracerWnd(HWND hParentWnd)
908 {
909 if (hTracerWnd != NULL) {
910 DestroyWindow(hTracerWnd);
911 hTracerWnd = NULL;
912 }
913 hTracerWnd = CreateDialog
914 (hInst,MAKEINTRESOURCE(IDD_DIALOG_TRACER),hParentWnd,TracerWndProc);
915 ShowWindow(hTracerWnd,SW_HIDE);
916 UpdateWindow(hTracerWnd);
917 }
918
919 BOOL CALLBACK
920 TracerWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
921 {
922 switch (uMess){
923 case WM_INITDIALOG:
924 return FALSE;
925 case WM_COMMAND:
926 switch (LOWORD(wParam)) {
927 case IDCLOSE:
928 ShowWindow(hwnd, SW_HIDE);
929 MainWndUpdateTracerButton();
930 break;
931 default:
932 return FALSE;
933 }
934 case WM_SIZE:
935 return FALSE;
936 case WM_CLOSE:
937 ShowWindow(hTracerWnd, SW_HIDE);
938 MainWndUpdateTracerButton();
939 break;
940 default:
941 return FALSE;
942 }
943 return FALSE;
944 }
945 #endif
946
947
948
949 //****************************************************************************
950 // Doc Window
951
952 #define IDM_DOCWND_CHOOSEFONT 4232
953 int DocWndIndependent = 0; /* Independent document viewer mode.(�Ɨ��h�L�������g�r�����[���[�h) */
954 int DocWndAutoPopup = 0;
955 DOCWNDINFO DocWndInfo;
956
957 static BOOL CALLBACK DocWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam);
958 static void InitDocEditWnd(HWND hParentWnd);
959 static void DocWndConvertText(char *in, int in_size, char *out, int out_size);
960 static void DocWndSetText(char *text, int text_size);
961 static void DocWndSetInfo(char *info, char *filename);
962 static void DocWndInfoInit(void);
963 static int DocWndInfoLock(void);
964 static void DocWndInfoUnLock(void);
965
966 void InitDocWnd(HWND hParentWnd);
967 void DocWndInfoReset(void);
968 void DocWndAddDocFile(char *filename);
969 void DocWndSetMidifile(char *filename);
970 void DocWndReadDoc(int num);
971 void DocWndReadDocNext(void);
972 void DocWndReadDocPrev(void);
973
974 static int DocWndInfoReset2(HWND hwnd);
975 static int DocWndInfoApply(void);
976 static int DocWndSetFontEdit(char *fontName, int fontWidth, int fontHeight);
977
InitDocWnd(HWND hParentWnd)978 void InitDocWnd(HWND hParentWnd)
979 {
980 HMENU hMenu;
981 HICON hIcon;
982 if (hDocWnd != NULL) {
983 DestroyWindow(hDocWnd);
984 hDocWnd = NULL;
985 }
986 DocWndInfoReset2(hDocWnd);
987 INILoadDocWnd();
988 switch(PlayerLanguage){
989 case LANGUAGE_ENGLISH:
990 hDocWnd = CreateDialog
991 (hInst,MAKEINTRESOURCE(IDD_DIALOG_DOC_EN),hParentWnd,DocWndProc);
992 break;
993 default:
994 case LANGUAGE_JAPANESE:
995 hDocWnd = CreateDialog
996 (hInst,MAKEINTRESOURCE(IDD_DIALOG_DOC),hParentWnd,DocWndProc);
997 break;
998 }
999 hIcon = LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON_TIMIDITY), IMAGE_ICON, 16, 16, 0);
1000 if (hIcon!=NULL) SendMessage(hDocWnd,WM_SETICON,FALSE,(LPARAM)hIcon);
1001 DocWndInfoReset2(hDocWnd);
1002 hMenu = GetSystemMenu(DocWndInfo.hwnd,FALSE);
1003 switch(PlayerLanguage){
1004 case LANGUAGE_JAPANESE:
1005 AppendMenu(hMenu,MF_SEPARATOR,0,0);
1006 AppendMenu(hMenu,MF_STRING,IDM_DOCWND_CHOOSEFONT,"�t�H���g�̑I��");
1007 break;
1008 default:
1009 case LANGUAGE_ENGLISH:
1010 AppendMenu(hMenu,MF_SEPARATOR,0,0);
1011 AppendMenu(hMenu,MF_STRING,IDM_DOCWND_CHOOSEFONT,"Choose Font");
1012 break;
1013 }
1014 DocWndInfoReset2(hDocWnd);
1015 INILoadDocWnd();
1016 DocWndInfoApply();
1017 ShowWindow(hDocWnd,SW_HIDE);
1018 UpdateWindow(hDocWnd);
1019 EnableWindow(GetDlgItem(hDocWnd,IDC_BUTTON_PREV),FALSE);
1020 EnableWindow(GetDlgItem(hDocWnd,IDC_BUTTON_NEXT),FALSE);
1021 }
1022
1023 static BOOL CALLBACK
DocWndProc(HWND hwnd,UINT uMess,WPARAM wParam,LPARAM lParam)1024 DocWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
1025 {
1026 switch (uMess){
1027 case WM_INITDIALOG:
1028 PutsDocWnd("Doc Window\n");
1029 DocWndInfoInit();
1030 SetWindowPosSize(GetDesktopWindow(),hwnd,DocWndInfo.PosX, DocWndInfo.PosY );
1031 return FALSE;
1032 case WM_DESTROY:
1033 {
1034 RECT rc;
1035 GetWindowRect(hwnd,&rc);
1036 DocWndInfo.Width = rc.right - rc.left;
1037 DocWndInfo.Height = rc.bottom - rc.top;
1038 }
1039 INISaveDocWnd();
1040 break;
1041 case WM_SYSCOMMAND:
1042 switch(wParam){
1043 case IDM_DOCWND_CHOOSEFONT:
1044 {
1045 char fontName[64];
1046 int fontHeight;
1047 int fontWidth;
1048 strcpy(fontName,DocWndInfo.fontName);
1049 fontHeight = DocWndInfo.fontHeight;
1050 fontWidth = DocWndInfo.fontWidth;
1051 if(DlgChooseFont(hwnd,fontName,&fontHeight,&fontWidth)==0){
1052 DocWndSetFontEdit(fontName,fontWidth,fontHeight);
1053 }
1054 break;
1055 }
1056 break;
1057 default:
1058 break;
1059 }
1060 case WM_COMMAND:
1061 switch (LOWORD(wParam)) {
1062 case IDCLOSE:
1063 ShowWindow(hwnd, SW_HIDE);
1064 MainWndUpdateDocButton();
1065 break;
1066 case IDCLEAR:
1067 ClearDocWnd();
1068 break;
1069 default:
1070 break;
1071 }
1072 switch (LOWORD(wParam)) {
1073 case IDC_BUTTON_NEXT:
1074 DocWndReadDocNext();
1075 break;
1076 case IDC_BUTTON_PREV:
1077 DocWndReadDocPrev();
1078 break;
1079 default:
1080 break;
1081 }
1082 return FALSE;
1083 // See PreDispatchMessage() in w32g2_main.c
1084 case WM_SYSKEYDOWN:
1085 case WM_KEYDOWN:
1086 {
1087 int nVirtKey = (int)wParam;
1088 switch(nVirtKey){
1089 case VK_ESCAPE:
1090 SendMessage(hwnd,WM_CLOSE,0,0);
1091 break;
1092 }
1093 }
1094 break;
1095 case WM_CLOSE:
1096 ShowSubWindow(hDocWnd,0);
1097 // ShowWindow(hDocWnd, SW_HIDE);
1098 MainWndUpdateDocButton();
1099 break;
1100 case WM_SIZE:
1101 switch(wParam){
1102 case SIZE_MAXIMIZED:
1103 case SIZE_RESTORED:
1104 { // �ȂӖ��Ȃ��ʓ|(^^;;
1105 int x,y,cx,cy;
1106 int max = 0;
1107 int width;
1108 RECT rcParent;
1109 RECT rcEDIT_INFO, rcEDIT_FILENAME, rcBUTTON_PREV, rcBUTTON_NEXT, rcEDIT;
1110 HWND hwndEDIT_INFO, hwndEDIT_FILENAME, hwndBUTTON_PREV, hwndBUTTON_NEXT, hwndEDIT;
1111 int nWidth = LOWORD(lParam);
1112 int nHeight = HIWORD(lParam);
1113 GetWindowRect(hwnd,&rcParent);
1114 cx = rcParent.right-rcParent.left;
1115 cy = rcParent.bottom-rcParent.top;
1116 if(cx < 300)
1117 MoveWindow(hwnd,rcParent.left,rcParent.top,300,cy,TRUE);
1118 if(cy < 200)
1119 MoveWindow(hwnd,rcParent.left,rcParent.top,cx,200,TRUE);
1120 GetClientRect(hwnd,&rcParent);
1121 hwndEDIT = GetDlgItem(hwnd,IDC_EDIT);
1122 hwndEDIT_INFO = GetDlgItem(hwnd,IDC_EDIT_INFO);
1123 hwndEDIT_FILENAME = GetDlgItem(hwnd,IDC_EDIT_FILENAME);
1124 hwndBUTTON_PREV = GetDlgItem(hwnd,IDC_BUTTON_PREV);
1125 hwndBUTTON_NEXT = GetDlgItem(hwnd,IDC_BUTTON_NEXT);
1126 GetWindowRect(hwndEDIT,&rcEDIT);
1127 GetWindowRect(hwndEDIT_INFO,&rcEDIT_INFO);
1128 GetWindowRect(hwndEDIT_FILENAME,&rcEDIT_FILENAME);
1129 GetWindowRect(hwndBUTTON_PREV,&rcBUTTON_PREV);
1130 GetWindowRect(hwndBUTTON_NEXT,&rcBUTTON_NEXT);
1131 width = rcParent.right - rcParent.left;
1132 cx = rcBUTTON_NEXT.right-rcBUTTON_NEXT.left;
1133 cy = rcBUTTON_NEXT.bottom-rcBUTTON_NEXT.top;
1134 x = rcParent.right - cx - 5;
1135 y = rcParent.bottom - cy;
1136 MoveWindow(hwndBUTTON_NEXT,x,y,cx,cy,TRUE);
1137 width -= cx + 5;
1138 if(cy>max) max = cy;
1139 cx = rcBUTTON_PREV.right-rcBUTTON_PREV.left;
1140 cy = rcBUTTON_PREV.bottom-rcBUTTON_PREV.top;
1141 x -= cx + 5;
1142 y = rcParent.bottom - cy;
1143 MoveWindow(hwndBUTTON_PREV,x,y,cx,cy,TRUE);
1144 width -= cx;
1145 if(cy>max) max = cy;
1146 width -= 5;
1147 // cx = rcEDIT_INFO.right-rcEDIT_INFO.left;
1148 cx = (int)(width * 0.36);
1149 cy = rcEDIT_INFO.bottom-rcEDIT_INFO.top;
1150 x = rcParent.left;
1151 y = rcParent.bottom - cy;
1152 MoveWindow(hwndEDIT_INFO,x,y,cx,cy,TRUE);
1153 if(cy>max) max = cy;
1154 x += cx + 5;
1155 // cx = rcEDIT_FILENAME.right-rcEDIT_FILENAME.left;
1156 cx = (int)(width * 0.56);
1157 cy = rcEDIT_FILENAME.bottom-rcEDIT_FILENAME.top;
1158 y = rcParent.bottom - cy;
1159 MoveWindow(hwndEDIT_FILENAME,x,y,cx,cy,TRUE);
1160 if(cy>max) max = cy;
1161 cx = rcParent.right - rcParent.left;
1162 cy = rcParent.bottom - rcParent.top - max - 5;
1163 x = rcParent.left;
1164 y = rcParent.top;
1165 MoveWindow(hwndEDIT,x,y,cx,cy,TRUE);
1166 InvalidateRect(hwnd,&rcParent,FALSE);
1167 UpdateWindow(hwnd);
1168 GetWindowRect(hwnd,&rcParent);
1169 DocWndInfo.Width = rcParent.right - rcParent.left;
1170 DocWndInfo.Height = rcParent.bottom - rcParent.top;
1171 break;
1172 }
1173 case SIZE_MINIMIZED:
1174 case SIZE_MAXHIDE:
1175 case SIZE_MAXSHOW:
1176 default:
1177 break;
1178 }
1179 break;
1180 case WM_MOVE:
1181 // DocWndInfo.PosX = (int) LOWORD(lParam);
1182 // DocWndInfo.PosY = (int) HIWORD(lParam);
1183 {
1184 RECT rc;
1185 GetWindowRect(hwnd,&rc);
1186 DocWndInfo.PosX = rc.left;
1187 DocWndInfo.PosY = rc.top;
1188 }
1189 break;
1190 default:
1191 return FALSE;
1192 }
1193 return FALSE;
1194 }
1195
DocWndInfoReset2(HWND hwnd)1196 static int DocWndInfoReset2(HWND hwnd)
1197 {
1198 // memset(&DocWndInfo,0,sizeof(DOCWNDINFO));
1199 DocWndInfo.PosX = - 1;
1200 DocWndInfo.PosY = - 1;
1201 DocWndInfo.Height = 400;
1202 DocWndInfo.Width = 400;
1203 DocWndInfo.hPopupMenu = NULL;
1204 DocWndInfo.hwnd = hwnd;
1205 if ( hwnd != NULL )
1206 DocWndInfo.hwndEdit = GetDlgItem(hwnd,IDC_EDIT);
1207 strcpy(DocWndInfo.fontNameEN,"Times New Roman");
1208 strcpy(DocWndInfo.fontNameJA,"�l�r ����");
1209 DocWndInfo.fontHeight = 12;
1210 DocWndInfo.fontWidth = 6;
1211 DocWndInfo.fontFlags = FONT_FLAGS_FIXED;
1212 switch(PlayerLanguage){
1213 case LANGUAGE_ENGLISH:
1214 DocWndInfo.fontName = DocWndInfo.fontNameEN;
1215 break;
1216 default:
1217 case LANGUAGE_JAPANESE:
1218 DocWndInfo.fontName = DocWndInfo.fontNameJA;
1219 break;
1220 }
1221 return 0;
1222 }
DocWndInfoApply(void)1223 static int DocWndInfoApply(void)
1224 {
1225 RECT rc;
1226 HFONT hFontPre = NULL;
1227 DWORD fdwPitch = (DocWndInfo.fontFlags&FONT_FLAGS_FIXED)?FIXED_PITCH:VARIABLE_PITCH;
1228 DWORD fdwItalic = (DocWndInfo.fontFlags&FONT_FLAGS_ITALIC)?TRUE:FALSE;
1229 HFONT hFont =
1230 CreateFont(DocWndInfo.fontHeight,DocWndInfo.fontWidth,0,0,FW_DONTCARE,fdwItalic,FALSE,FALSE,
1231 DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
1232 fdwPitch | FF_DONTCARE,DocWndInfo.fontName);
1233 if(hFont != NULL){
1234 hFontPre = DocWndInfo.hFontEdit;
1235 DocWndInfo.hFontEdit = hFont;
1236 SendMessage(DocWndInfo.hwndEdit,WM_SETFONT,(WPARAM)DocWndInfo.hFontEdit,(LPARAM)MAKELPARAM(TRUE,0));
1237 }
1238 GetWindowRect(DocWndInfo.hwnd,&rc);
1239 MoveWindow(DocWndInfo.hwnd,rc.left,rc.top,DocWndInfo.Width,DocWndInfo.Height,TRUE);
1240 // InvalidateRect(hwnd,&rc,FALSE);
1241 // UpdateWindow(hwnd);
1242 if(hFontPre!=NULL) CloseHandle(hFontPre);
1243 INISaveDocWnd();
1244 return 0;
1245 }
1246
DocWndSetFontEdit(char * fontName,int fontWidth,int fontHeight)1247 static int DocWndSetFontEdit(char *fontName, int fontWidth, int fontHeight)
1248 {
1249 strcpy(DocWndInfo.fontName,fontName);
1250 DocWndInfo.fontWidth = fontWidth;
1251 DocWndInfo.fontHeight = fontHeight;
1252 DocWndInfoApply();
1253 return 0;
1254 }
1255
1256 static char ControlCode[] = "@ABCDEFGHIJKLMNOPQRS";
DocWndConvertText(char * in,int in_size,char * out,int out_size)1257 static void DocWndConvertText(char *in, int in_size, char *out, int out_size)
1258 {
1259 char *buffer = (char *)safe_malloc(sizeof(char)*out_size);
1260 int buffer_size = out_size;
1261 int i=0, j=0;
1262 int nl = 0;
1263
1264 // Convert Return Code CR, LF -> CR+LF ,
1265 // Control Code -> ^? (^@, ^A, ^B, ...).
1266 // stage1:
1267 for(;;){
1268 if(i>=in_size || j>=buffer_size-1)
1269 goto stage1_end;
1270 if(nl==13){
1271 if(in[i]==13){
1272 if(j>=buffer_size-2)
1273 goto stage1_end;
1274 buffer[j++] = 13;
1275 buffer[j++] = 10;
1276 i++;
1277 nl = 13;
1278 continue;
1279 }
1280 if(in[i]==10){
1281 if(j>=buffer_size-2)
1282 goto stage1_end;
1283 buffer[j++] = 13;
1284 buffer[j++] = 10;
1285 i++;
1286 nl = 0;
1287 continue;
1288 }
1289 if(j>=buffer_size-2)
1290 goto stage1_end;
1291 buffer[j++] = 13;
1292 buffer[j++] = 10;
1293 if(in[i]>=0 && in[i]<=0x1f && in[i]!='\t'){
1294 if(j>=buffer_size-2)
1295 goto stage1_end;
1296 buffer[j++] = '^';
1297 buffer[j++] = ControlCode[in[i]];
1298 } else {
1299 if(j>=buffer_size-1)
1300 goto stage1_end;
1301 buffer[j++] = in[i];
1302 }
1303 i++;
1304 nl = 0;
1305 continue;
1306 }
1307 if(nl==10){
1308 if(in[i]==13||in[i]==10){
1309 if(j>=buffer_size-2)
1310 goto stage1_end;
1311 buffer[j++] = 13;
1312 buffer[j++] = 10;
1313 nl = in[i];
1314 i++;
1315 continue;
1316 }
1317 if(j>=buffer_size-2)
1318 goto stage1_end;
1319 buffer[j++] = 13;
1320 buffer[j++] = 10;
1321 if(in[i]>=0 && in[i]<=0x1f && in[i]!='\t'){
1322 if(j>=buffer_size-2)
1323 goto stage1_end;
1324 buffer[j++] = '^';
1325 buffer[j++] = ControlCode[in[i]];
1326 } else {
1327 if(j>=buffer_size-1)
1328 goto stage1_end;
1329 buffer[j++] = in[i];
1330 }
1331 i++;
1332 nl = 0;
1333 continue;
1334 }
1335 if(in[i]==13||in[i]==10){
1336 nl = in[i];
1337 i++;
1338 continue;
1339 }
1340 if(in[i]>=0 && in[i]<=0x1f && in[i]!='\t'){
1341 if(j>=buffer_size-2)
1342 goto stage1_end;
1343 buffer[j++] = '^';
1344 buffer[j++] = ControlCode[in[i]];
1345 } else {
1346 if(j>=buffer_size-1)
1347 goto stage1_end;
1348 buffer[j++] = in[i];
1349 }
1350 i++;
1351 nl = 0;
1352 continue;
1353 }
1354 stage1_end:
1355 buffer[j] = '\0';
1356 // Convert KANJI Code.
1357 // stage2:
1358 #ifndef MAX2
1359 #define MAX2(x,y) ((x)>=(y)?(x):(y))
1360 #endif
1361 switch(PlayerLanguage){
1362 case LANGUAGE_ENGLISH:
1363 default:
1364 strncpy(out,buffer,MAX2(buffer_size-1,out_size-1));
1365 out[out_size-1] = '\0';
1366 free(buffer);
1367 break;
1368 case LANGUAGE_JAPANESE:
1369 strncpy(out,buffer,MAX2(buffer_size-1,out_size-1));
1370 nkf_convert(buffer,out,out_size-1,NULL,"SJIS");
1371 out[out_size-1] = '\0';
1372 free(buffer);
1373 break;
1374 }
1375 }
1376
1377 #define BUFFER_SIZE (1024*64)
DocWndSetText(char * text,int text_size)1378 static void DocWndSetText(char *text, int text_size)
1379 {
1380 char buffer[BUFFER_SIZE];
1381 int buffer_size = BUFFER_SIZE;
1382 if(!IsWindow(hDocWnd) || !DocWndFlag)
1383 return;
1384 if(DocWndInfoLock()==FALSE)
1385 return;
1386 // Edit_SetText(GetDlgItem(hDocWnd,IDC_EDIT),text);
1387 DocWndConvertText(text,text_size,buffer,buffer_size);
1388 Edit_SetText(GetDlgItem(hDocWnd,IDC_EDIT),buffer);
1389 DocWndInfoUnLock();
1390 }
1391
DocWndSetInfo(char * info,char * filename)1392 static void DocWndSetInfo(char *info, char *filename)
1393 {
1394 int buffer_size = BUFFER_SIZE;
1395 if(!IsWindow(hDocWnd) || !DocWndFlag)
1396 return;
1397 if(DocWndInfoLock()==FALSE)
1398 return;
1399 Edit_SetText(GetDlgItem(hDocWnd,IDC_EDIT_INFO),info);
1400 Edit_SetText(GetDlgItem(hDocWnd,IDC_EDIT_FILENAME),filename);
1401 DocWndInfoUnLock();
1402 }
1403
1404 // *.doc *.txt *.hed archive#*.doc archive#*.txt archive#*.hed
1405
DocWndInfoInit(void)1406 static void DocWndInfoInit(void)
1407 {
1408 // DocWndInfo.hMutex = NULL;
1409 // DocWndInfo.hMutex = CreateMutex(NULL,TRUE,NULL);
1410 DocWndInfo.DocFileCur = 0;
1411 DocWndInfo.DocFileMax = 0;
1412 DocWndInfo.Text = NULL;
1413 DocWndInfo.TextSize = 0;
1414 EnableWindow(GetDlgItem(hDocWnd,IDC_BUTTON_PREV),FALSE);
1415 EnableWindow(GetDlgItem(hDocWnd,IDC_BUTTON_NEXT),FALSE);
1416 // if(DocWndInfo.hMutex!=NULL)
1417 // DocWndInfoUnLock();
1418 }
1419
1420 // Success -> TRUE Failure -> FALSE
DocWndInfoLock(void)1421 static int DocWndInfoLock(void)
1422 {
1423 #if 0
1424 DWORD dwRes;
1425 if(DocWndInfo.hMutex==NULL)
1426 return FALSE;
1427 dwRes = WaitForSingleObject(DocWndInfo.hMutex,10000);
1428 if(dwRes==WAIT_OBJECT_0 || dwRes==WAIT_ABANDONED)
1429 return TRUE;
1430 else
1431 return FALSE;
1432 #else
1433 return TRUE;
1434 #endif
1435 }
1436
DocWndInfoUnLock(void)1437 static void DocWndInfoUnLock(void)
1438 {
1439 // ReleaseMutex(DocWndInfo.hMutex);
1440 }
1441
DocWndInfoReset(void)1442 void DocWndInfoReset(void)
1443 {
1444 if(DocWndInfoLock()==FALSE)
1445 return;
1446 DocWndInfo.DocFileCur = 0;
1447 DocWndInfo.DocFileMax = 0;
1448 if(DocWndInfo.Text!=NULL){
1449 free(DocWndInfo.Text);
1450 DocWndInfo.Text = NULL;
1451 }
1452 DocWndInfo.TextSize = 0;
1453 DocWndSetInfo("","");
1454 DocWndSetText("",0);
1455 // end:
1456 DocWndInfoUnLock();
1457 }
1458
DocWndAddDocFile(char * filename)1459 void DocWndAddDocFile(char *filename)
1460 {
1461 struct timidity_file *tf = open_file(filename,0,0);
1462 #ifdef W32GUI_DEBUG
1463 PrintfDebugWnd("DocWndAddDocFile <- [%s]\n",filename);
1464 #endif
1465 if(tf==NULL)
1466 return;
1467 close_file(tf);
1468 if(DocWndInfoLock()==FALSE)
1469 return;
1470 if(DocWndInfo.DocFileMax>=DOCWND_DOCFILEMAX-1)
1471 goto end;
1472 DocWndInfo.DocFileMax++;
1473 strncpy(DocWndInfo.DocFile[DocWndInfo.DocFileMax-1],filename,MAXPATH);
1474 DocWndInfo.DocFile[DocWndInfo.DocFileMax-1][MAXPATH-1] = '\0';
1475 if(DocWndInfo.DocFileCur==1)
1476 EnableWindow(GetDlgItem(hDocWnd,IDC_BUTTON_PREV),FALSE);
1477 else
1478 EnableWindow(GetDlgItem(hDocWnd,IDC_BUTTON_PREV),TRUE);
1479 if(DocWndInfo.DocFileCur==DocWndInfo.DocFileMax)
1480 EnableWindow(GetDlgItem(hDocWnd,IDC_BUTTON_NEXT),FALSE);
1481 else
1482 EnableWindow(GetDlgItem(hDocWnd,IDC_BUTTON_NEXT),TRUE);
1483 #ifdef W32GUI_DEBUG
1484 PrintfDebugWnd("DocWndAddDocFile -> (%d)[%s]\n",DocWndInfo.DocFileMax-1,DocWndInfo.DocFile[DocWndInfo.DocFileMax-1]);
1485 #endif
1486 end:
1487 DocWndInfoUnLock();
1488 }
1489
DocWndSetMidifile(char * filename)1490 void DocWndSetMidifile(char *filename)
1491 {
1492 char buffer[MAXPATH+10];
1493 char *p;
1494 if(DocWndInfoLock()==FALSE)
1495 return;
1496 strncpy(buffer,filename,MAXPATH-1);
1497 buffer[MAXPATH-1] = '\0';
1498 p = strrchr(buffer,'.');
1499 if(p==NULL)
1500 goto end;
1501 *p = '\0';
1502 strcat(buffer,".txt");
1503 DocWndAddDocFile(buffer);
1504 *p = '\0';
1505 strcat(buffer,".doc");
1506 DocWndAddDocFile(buffer);
1507 *p = '\0';
1508 strcat(buffer,".hed");
1509 DocWndAddDocFile(buffer);
1510 p = strrchr(buffer,'#');
1511 if(p==NULL)
1512 goto end;
1513 *p = '\0';
1514 strcat(buffer,"readme.txt");
1515 DocWndAddDocFile(buffer);
1516 *p = '\0';
1517 strcat(buffer,"readme.1st");
1518 DocWndAddDocFile(buffer);
1519 *p = '\0';
1520 strcat(buffer,"�̎�.txt");
1521 DocWndAddDocFile(buffer);
1522 end:
1523 DocWndInfoUnLock();
1524 }
1525
1526 #define DOCWNDDOCSIZEMAX (64*1024)
DocWndReadDoc(int num)1527 void DocWndReadDoc(int num)
1528 {
1529 struct timidity_file *tf;
1530 if(DocWndInfoLock()==FALSE)
1531 return;
1532 if(num<1)
1533 num = 1;
1534 if(num>DocWndInfo.DocFileMax)
1535 num = DocWndInfo.DocFileMax;
1536 if(num==DocWndInfo.DocFileCur)
1537 goto end;
1538 DocWndInfo.DocFileCur = num;
1539 tf = open_file(DocWndInfo.DocFile[DocWndInfo.DocFileCur-1],1,10);
1540 if(tf==NULL)
1541 goto end;
1542 if(DocWndInfo.Text!=NULL){
1543 free(DocWndInfo.Text);
1544 DocWndInfo.Text = NULL;
1545 }
1546 DocWndInfo.Text = (char *)safe_malloc(sizeof(char)*DOCWNDDOCSIZEMAX);
1547 DocWndInfo.Text[0] = '\0';
1548 DocWndInfo.TextSize = tf_read(DocWndInfo.Text,1,DOCWNDDOCSIZEMAX-1,tf);
1549 DocWndInfo.Text[DocWndInfo.TextSize] = '\0';
1550 close_file(tf);
1551 {
1552 char info[1024];
1553 char *filename;
1554 char *p1, *p2, *p3;
1555 p1 = DocWndInfo.DocFile[DocWndInfo.DocFileCur-1];
1556 p2 = pathsep_strrchr(p1);
1557 p3 = strrchr(p1,'#');
1558 if(p3!=NULL){
1559 sprintf(info,"(%02d/%02d) %s",DocWndInfo.DocFileCur,DocWndInfo.DocFileMax,p3+1);
1560 filename = p2 + 1;
1561 } else if(p2!=NULL){
1562 sprintf(info,"(%02d/%02d) %s",DocWndInfo.DocFileCur,DocWndInfo.DocFileMax,p2+1);
1563 filename = p2 + 1;
1564 } else {
1565 sprintf(info,"(%02d/%02d) %s",DocWndInfo.DocFileCur,DocWndInfo.DocFileMax,p1+1);
1566 filename = p1;
1567 }
1568 DocWndSetInfo(info,filename);
1569 }
1570 DocWndSetText(DocWndInfo.Text,DocWndInfo.TextSize);
1571 end:
1572 if(DocWndInfo.DocFileCur==1)
1573 EnableWindow(GetDlgItem(hDocWnd,IDC_BUTTON_PREV),FALSE);
1574 else
1575 EnableWindow(GetDlgItem(hDocWnd,IDC_BUTTON_PREV),TRUE);
1576 if(DocWndInfo.DocFileCur==DocWndInfo.DocFileMax)
1577 EnableWindow(GetDlgItem(hDocWnd,IDC_BUTTON_NEXT),FALSE);
1578 else
1579 EnableWindow(GetDlgItem(hDocWnd,IDC_BUTTON_NEXT),TRUE);
1580 DocWndInfoUnLock();
1581 }
1582
DocWndReadDocNext(void)1583 void DocWndReadDocNext(void)
1584 {
1585 int num;
1586 if(DocWndInfoLock()==FALSE)
1587 return;
1588 num = DocWndInfo.DocFileCur + 1;
1589 if(num>DocWndInfo.DocFileMax)
1590 num = DocWndInfo.DocFileMax;
1591 DocWndReadDoc(num);
1592 DocWndInfoUnLock();
1593 }
1594
DocWndReadDocPrev(void)1595 void DocWndReadDocPrev(void)
1596 {
1597 int num;
1598 if(DocWndInfoLock()==FALSE)
1599 return;
1600 num = DocWndInfo.DocFileCur - 1;
1601 if(num<1)
1602 num = 1;
1603 DocWndReadDoc(num);
1604 DocWndInfoUnLock();
1605 }
1606
PutsDocWnd(char * str)1607 void PutsDocWnd(char *str)
1608 {
1609 HWND hwnd;
1610 if(!IsWindow(hDocWnd) || !DocWndFlag)
1611 return;
1612 hwnd = GetDlgItem(hDocWnd,IDC_EDIT);
1613 PutsEditCtlWnd(hwnd,str);
1614 }
1615
PrintfDocWnd(char * fmt,...)1616 void PrintfDocWnd(char *fmt, ...)
1617 {
1618 HWND hwnd;
1619 va_list ap;
1620 if(!IsWindow(hDocWnd) || !DocWndFlag)
1621 return;
1622 hwnd = GetDlgItem(hDocWnd,IDC_EDIT);
1623 va_start(ap, fmt);
1624 VprintfEditCtlWnd(hwnd,fmt,ap);
1625 va_end(ap);
1626 }
1627
ClearDocWnd(void)1628 void ClearDocWnd(void)
1629 {
1630 HWND hwnd;
1631 if(!IsWindow(hDocWnd))
1632 return;
1633 hwnd = GetDlgItem(hDocWnd,IDC_EDIT);
1634 ClearEditCtlWnd(hwnd);
1635 }
1636
1637 //****************************************************************************
1638 // List Search Dialog
1639 #define ListSearchStringMax 256
1640 static char ListSearchString[ListSearchStringMax];
1641
1642 BOOL CALLBACK ListSearchWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam);
InitListSearchWnd(HWND hParentWnd)1643 void InitListSearchWnd(HWND hParentWnd)
1644 {
1645 strcpy(ListSearchString,"");
1646 if (hListSearchWnd != NULL) {
1647 DestroyWindow(hListSearchWnd);
1648 hListSearchWnd = NULL;
1649 }
1650 switch(PlayerLanguage){
1651 case LANGUAGE_JAPANESE:
1652 hListSearchWnd = CreateDialog
1653 (hInst,MAKEINTRESOURCE(IDD_DIALOG_ONE_LINE),hParentWnd,ListSearchWndProc);
1654 break;
1655 default:
1656 case LANGUAGE_ENGLISH:
1657 hListSearchWnd = CreateDialog
1658 (hInst,MAKEINTRESOURCE(IDD_DIALOG_ONE_LINE_EN),hParentWnd,ListSearchWndProc);
1659 break;
1660 }
1661 ShowWindow(hListSearchWnd,SW_HIDE);
1662 UpdateWindow(hListSearchWnd);
1663 }
1664
1665 #define ListSearchStringBuffSize 1024*2
1666
1667 BOOL CALLBACK
ListSearchWndProc(HWND hwnd,UINT uMess,WPARAM wParam,LPARAM lParam)1668 ListSearchWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
1669 {
1670 switch (uMess){
1671 case WM_INITDIALOG:
1672 switch(PlayerLanguage){
1673 case LANGUAGE_JAPANESE:
1674 SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)"�v���C���X�g�̌���");
1675 SendMessage(GetDlgItem(hwnd,IDC_STATIC_HEAD),WM_SETTEXT,0,(LPARAM)"�����L�[���[�h�������������B");
1676 SendMessage(GetDlgItem(hwnd,IDC_STATIC_TAIL),WM_SETTEXT,0,(LPARAM)"");
1677 SendMessage(GetDlgItem(hwnd,IDC_BUTTON_1),WM_SETTEXT,0,(LPARAM)"����");
1678 SendMessage(GetDlgItem(hwnd,IDC_BUTTON_2),WM_SETTEXT,0,(LPARAM)"��������");
1679 SendMessage(GetDlgItem(hwnd,IDC_BUTTON_3),WM_SETTEXT,0,(LPARAM)"����");
1680 break;
1681 default:
1682 case LANGUAGE_ENGLISH:
1683 SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)"Playlist Search");
1684 SendMessage(GetDlgItem(hwnd,IDC_STATIC_HEAD),WM_SETTEXT,0,(LPARAM)"Enter search keyword.");
1685 SendMessage(GetDlgItem(hwnd,IDC_STATIC_TAIL),WM_SETTEXT,0,(LPARAM)"");
1686 SendMessage(GetDlgItem(hwnd,IDC_BUTTON_1),WM_SETTEXT,0,(LPARAM)"SEACH");
1687 SendMessage(GetDlgItem(hwnd,IDC_BUTTON_2),WM_SETTEXT,0,(LPARAM)"NEXT SEARCH");
1688 SendMessage(GetDlgItem(hwnd,IDC_BUTTON_3),WM_SETTEXT,0,(LPARAM)"CLOSE");
1689 break;
1690 }
1691 return FALSE;
1692 case WM_COMMAND:
1693 switch (LOWORD(wParam)) {
1694 case IDCLOSE:
1695 ShowWindow(hwnd, SW_HIDE);
1696 break;
1697 case IDC_BUTTON_1:
1698 case IDC_BUTTON_2:
1699 {
1700 int selected, nfiles, cursel;
1701 SendDlgItemMessage(hwnd,IDC_EDIT_ONE_LINE,
1702 WM_GETTEXT,(WPARAM)250,(LPARAM)ListSearchString);
1703 w32g_get_playlist_index(&selected, &nfiles, &cursel);
1704 if ( LOWORD(wParam) == IDC_BUTTON_2 )
1705 cursel++;
1706 if ( strlen ( ListSearchString ) > 0 ) {
1707 char buff[ListSearchStringBuffSize];
1708 for ( ; cursel < nfiles; cursel ++ ) {
1709 int result = SendDlgItemMessage(hListWnd,IDC_LISTBOX_PLAYLIST,
1710 LB_GETTEXTLEN,(WPARAM)cursel, 0 );
1711 if ( result < ListSearchStringBuffSize ) {
1712 result = SendDlgItemMessage(hListWnd,IDC_LISTBOX_PLAYLIST,
1713 LB_GETTEXT,(WPARAM)cursel,(LPARAM)buff);
1714 if ( result == LB_ERR ) {
1715 cursel = LB_ERR;
1716 break;
1717 }
1718 if ( strstr ( buff, ListSearchString ) != NULL ) {
1719 break;
1720 }
1721 } else if ( result == LB_ERR ) {
1722 cursel = LB_ERR;
1723 break;
1724 }
1725 }
1726 if ( cursel >= nfiles ) {
1727 cursel = LB_ERR;
1728 }
1729 } else {
1730 cursel = LB_ERR;
1731 }
1732 if ( cursel != LB_ERR ) {
1733 SendDlgItemMessage(hListWnd,IDC_LISTBOX_PLAYLIST,
1734 LB_SETCURSEL,(WPARAM)cursel,0);
1735 SetNumListWnd(cursel,nfiles);
1736 if ( LOWORD(wParam) == IDC_BUTTON_1 )
1737 HideListSearch();
1738 }
1739 }
1740 break;
1741 case IDC_BUTTON_3:
1742 HideListSearch();
1743 break;
1744 default:
1745 return FALSE;
1746 }
1747 break;
1748 case WM_CLOSE:
1749 ShowWindow(hListSearchWnd, SW_HIDE);
1750 break;
1751 default:
1752 return FALSE;
1753 }
1754 return FALSE;
1755 }
1756
ShowListSearch(void)1757 void ShowListSearch(void)
1758 {
1759 ShowWindow(hListSearchWnd, SW_SHOW);
1760 }
HideListSearch(void)1761 void HideListSearch(void)
1762 {
1763 ShowWindow(hListSearchWnd, SW_HIDE);
1764 }
1765
1766 //****************************************************************************
1767 // SoundSpec Window
1768
1769 BOOL CALLBACK SoundSpecWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam);
InitSoundSpecWnd(HWND hParentWnd)1770 void InitSoundSpecWnd(HWND hParentWnd)
1771 {
1772 if (hSoundSpecWnd != NULL) {
1773 DestroyWindow(hSoundSpecWnd);
1774 hSoundSpecWnd = NULL;
1775 }
1776 hSoundSpecWnd = CreateDialog
1777 (hInst,MAKEINTRESOURCE(IDD_DIALOG_SOUNDSPEC),hParentWnd,SoundSpecWndProc);
1778 ShowWindow(hSoundSpecWnd,SW_HIDE);
1779 UpdateWindow(hSoundSpecWnd);
1780 }
1781
1782 BOOL CALLBACK
SoundSpecWndProc(HWND hwnd,UINT uMess,WPARAM wParam,LPARAM lParam)1783 SoundSpecWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
1784 {
1785 switch (uMess){
1786 case WM_INITDIALOG:
1787 return FALSE;
1788 case WM_COMMAND:
1789 switch (LOWORD(wParam)) {
1790 case IDCLOSE:
1791 ShowWindow(hwnd, SW_HIDE);
1792 MainWndUpdateSoundSpecButton();
1793 break;
1794 default:
1795 return FALSE;
1796 }
1797 case WM_SIZE:
1798 return FALSE;
1799 case WM_CLOSE:
1800 ShowWindow(hSoundSpecWnd, SW_HIDE);
1801 MainWndUpdateSoundSpecButton();
1802 break;
1803 default:
1804 return FALSE;
1805 }
1806 return FALSE;
1807 }
1808
w32g_open_doc(int close_if_no_doc)1809 void w32g_open_doc(int close_if_no_doc)
1810 {
1811 if(close_if_no_doc==1 && DocWndInfo.DocFileMax <= 0)
1812 ShowSubWindow(hDocWnd, 0);
1813 else
1814 {
1815 DocWndReadDoc(1);
1816 if(close_if_no_doc!=2)
1817 ShowSubWindow(hDocWnd, 1);
1818 }
1819 }
1820
w32g_setup_doc(int idx)1821 void w32g_setup_doc(int idx)
1822 {
1823 char *filename;
1824
1825 DocWndInfoReset();
1826 if((filename = w32g_get_playlist(idx)) == NULL)
1827 return;
1828 DocWndSetMidifile(filename);
1829 }
1830
w32g_free_doc(void)1831 void w32g_free_doc(void)
1832 {
1833 if(DocWndInfo.Text != NULL) free(DocWndInfo.Text);
1834 }
1835