📄 w32g_subwin.c
字号:
/* TiMidity++ -- MIDI to WAVE converter and player Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp> Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA w32g_subwin.c: Written by Daisuke Aoki <dai@y7.net>*/#ifdef HAVE_CONFIG_H#include "config.h"#endif /* HAVE_CONFIG_H */#include <stdio.h>#include <stdlib.h>#include <process.h>#include <stddef.h>#ifndef NO_STRING_H#include <string.h>#else#include <strings.h>#endif#include "timidity.h"#include "common.h"#include "instrum.h"#include "playmidi.h"#include "readmidi.h"#include "output.h"#include "controls.h"#include "tables.h"#include "miditrace.h"#include "reverb.h"#ifdef SUPPORT_SOUNDSPEC#include "soundspec.h"#endif /* SUPPORT_SOUNDSPEC */#include "recache.h"#include "arc.h"#include "strtab.h"#include "wrd.h"#include "mid.defs"#include "w32g.h"#include <shlobj.h>#include <commctrl.h>#include <windowsx.h>#include "w32g_res.h"#include "w32g_utl.h"#include "w32g_pref.h"#include "w32g_subwin.h"#include "w32g_ut2.h"#if defined(__CYGWIN32__) || defined(__MINGW32__)#ifndef TPM_TOPALIGN#define TPM_TOPALIGN 0x0000L#endif#endifextern void MainWndToggleConsoleButton(void);extern void MainWndUpdateConsoleButton(void);extern void MainWndToggleTracerButton(void);extern void MainWndUpdateTracerButton(void);extern void MainWndToggleListButton(void);extern void MainWndUpdateListButton(void);extern void MainWndToggleDocButton(void);extern void MainWndUpdateDocButton(void);extern void MainWndToggleWrdButton(void);extern void MainWndUpdateWrdButton(void);extern void MainWndToggleSoundSpecButton(void);extern void MainWndUpdateSoundSpecButton(void);extern void ShowSubWindow(HWND hwnd,int showflag);extern void ToggleSubWindow(HWND hwnd);extern void VprintfEditCtlWnd(HWND hwnd, char *fmt, va_list argList);extern void PrintfEditCtlWnd(HWND hwnd, char *fmt, ...);extern void PutsEditCtlWnd(HWND hwnd, char *str);extern void ClearEditCtlWnd(HWND hwnd);extern char *nkf_convert(char *si,char *so,int maxsize,char *in_mode,char *out_mode);void InitListSearchWnd(HWND hParentWnd);void ShowListSearch(void);void HideListSearch(void);// ***************************************************************************//// Console Window//// ***************************************************************************// ---------------------------------------------------------------------------// variablesstatic int ConsoleWndMaxSize = 64 * 1024;static HFONT hFontConsoleWnd = NULL;CONSOLEWNDINFO ConsoleWndInfo;// ---------------------------------------------------------------------------// prototypes of functionsstatic BOOL CALLBACK ConsoleWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam);static void ConsoleWndAllUpdate(void);static void ConsoleWndVerbosityUpdate(void);static void ConsoleWndVerbosityApply(void);static void ConsoleWndValidUpdate(void);static void ConsoleWndValidApply(void);static void ConsoleWndVerbosityApplyIncDec(int num);static int ConsoleWndInfoReset(HWND hwnd);static int ConsoleWndInfoApply(void);// ---------------------------------------------------------------------------// Global Functions// Initializationvoid InitConsoleWnd(HWND hParentWnd){ if (hConsoleWnd != NULL) { DestroyWindow(hConsoleWnd); hConsoleWnd = NULL; } INILoadConsoleWnd(); switch(PlayerLanguage){ case LANGUAGE_ENGLISH: hConsoleWnd = CreateDialog (hInst,MAKEINTRESOURCE(IDD_DIALOG_CONSOLE_EN),hParentWnd,ConsoleWndProc); break; default: case LANGUAGE_JAPANESE: hConsoleWnd = CreateDialog (hInst,MAKEINTRESOURCE(IDD_DIALOG_CONSOLE),hParentWnd,ConsoleWndProc); break; } ConsoleWndInfoReset(hConsoleWnd); ShowWindow(hConsoleWnd,SW_HIDE); ConsoleWndInfoReset(hConsoleWnd); UpdateWindow(hConsoleWnd); ConsoleWndVerbosityApplyIncDec(0); CheckDlgButton(hConsoleWnd, IDC_CHECKBOX_VALID, ConsoleWndFlag); Edit_LimitText(GetDlgItem(hConsoleWnd,IDC_EDIT), ConsoleWndMaxSize); ConsoleWndInfoApply();}// Window Procedurestatic BOOL CALLBACKConsoleWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam){ switch (uMess){ case WM_INITDIALOG: PutsConsoleWnd("Console Window\n"); ConsoleWndAllUpdate(); SetWindowPosSize(GetDesktopWindow(),hwnd,ConsoleWndInfo.PosX, ConsoleWndInfo.PosY ); return FALSE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDCLOSE: ShowWindow(hwnd, SW_HIDE); MainWndUpdateConsoleButton(); break; case IDCLEAR: ClearConsoleWnd(); break; case IDC_CHECKBOX_VALID: ConsoleWndValidApply(); break; case IDC_BUTTON_VERBOSITY: ConsoleWndVerbosityApply(); break; case IDC_BUTTON_INC: ConsoleWndVerbosityApplyIncDec(1); break; case IDC_BUTTON_DEC: ConsoleWndVerbosityApplyIncDec(-1); break; default: break; } switch (HIWORD(wParam)) { case EN_ERRSPACE: ClearConsoleWnd(); PutsConsoleWnd("### EN_ERRSPACE -> Clear! ###\n"); break; default: break; } break; case WM_SIZE: ConsoleWndAllUpdate(); return FALSE; case WM_MOVE:// ConsoleWndInfo.PosX = (int) LOWORD(lParam);// ConsoleWndInfo.PosY = (int) HIWORD(lParam); { RECT rc; GetWindowRect(hwnd,&rc); ConsoleWndInfo.PosX = rc.left; ConsoleWndInfo.PosY = rc.top; } break; // See PreDispatchMessage() in w32g2_main.c case WM_SYSKEYDOWN: case WM_KEYDOWN: { int nVirtKey = (int)wParam; switch(nVirtKey){ case VK_ESCAPE: SendMessage(hwnd,WM_CLOSE,0,0); break; } } break; case WM_DESTROY: INISaveConsoleWnd(); break; case WM_CLOSE: ShowSubWindow(hConsoleWnd,0);// ShowWindow(hConsoleWnd, SW_HIDE); MainWndUpdateConsoleButton(); break; case WM_SETFOCUS: HideCaret(hwnd); break; case WM_KILLFOCUS: ShowCaret(hwnd); break; default: return FALSE; } return FALSE;}// puts()void PutsConsoleWnd(char *str){ HWND hwnd; if(!IsWindow(hConsoleWnd) || !ConsoleWndFlag) return; hwnd = GetDlgItem(hConsoleWnd,IDC_EDIT); PutsEditCtlWnd(hwnd,str);}// printf()void PrintfConsoleWnd(char *fmt, ...){ HWND hwnd; va_list ap; if(!IsWindow(hConsoleWnd) || !ConsoleWndFlag) return; hwnd = GetDlgItem(hConsoleWnd,IDC_EDIT); va_start(ap, fmt); VprintfEditCtlWnd(hwnd,fmt,ap); va_end(ap);}// Clearvoid ClearConsoleWnd(void){ HWND hwnd; if(!IsWindow(hConsoleWnd)) return; hwnd = GetDlgItem(hConsoleWnd,IDC_EDIT); ClearEditCtlWnd(hwnd);}// ---------------------------------------------------------------------------// Static Functionsstatic void ConsoleWndAllUpdate(void){ ConsoleWndVerbosityUpdate(); ConsoleWndValidUpdate(); Edit_LimitText(GetDlgItem(hConsoleWnd,IDC_EDIT_VERBOSITY),3); Edit_LimitText(GetDlgItem(hConsoleWnd,IDC_EDIT),ConsoleWndMaxSize);}static void ConsoleWndValidUpdate(void){ if(ConsoleWndFlag) CheckDlgButton(hConsoleWnd, IDC_CHECKBOX_VALID, 1); else CheckDlgButton(hConsoleWnd, IDC_CHECKBOX_VALID, 0);}static void ConsoleWndValidApply(void){ if(IsDlgButtonChecked(hConsoleWnd,IDC_CHECKBOX_VALID)) ConsoleWndFlag = 1; else ConsoleWndFlag = 0;}static void ConsoleWndVerbosityUpdate(void){ SetDlgItemInt(hConsoleWnd,IDC_EDIT_VERBOSITY,(UINT)ctl->verbosity, TRUE);}static void ConsoleWndVerbosityApply(void){ char buffer[64]; HWND hwnd; hwnd = GetDlgItem(hConsoleWnd,IDC_EDIT_VERBOSITY); if(!IsWindow(hConsoleWnd)) return; if(Edit_GetText(hwnd,buffer,60)<=0) return; ctl->verbosity = atoi(buffer); ConsoleWndVerbosityUpdate();}static void ConsoleWndVerbosityApplyIncDec(int num){ if(!IsWindow(hConsoleWnd)) return; ctl->verbosity += num; RANGE(ctl->verbosity, -1, 4); ConsoleWndVerbosityUpdate();}static int ConsoleWndInfoReset(HWND hwnd){ memset(&ConsoleWndInfo,0,sizeof(CONSOLEWNDINFO)); ConsoleWndInfo.PosX = - 1; ConsoleWndInfo.PosY = - 1; return 0;}static int ConsoleWndInfoApply(void){ return 0;}// ****************************************************************************//// List Window//// ****************************************************************************// ---------------------------------------------------------------------------// Macros#define IDM_LISTWND_REMOVE 4101#define IDM_LISTWND_PLAY 4102#define IDM_LISTWND_REFINE 4103#define IDM_LISTWND_UNIQ 4104#define IDM_LISTWND_CLEAR 4105#define IDM_LISTWND_CHOOSEFONT 4106#define IDM_LISTWND_CURRENT 4107#define IDM_LISTWND_SEARCH 4108// ---------------------------------------------------------------------------// VariablesLISTWNDINFO ListWndInfo;HWND hListSearchWnd = NULL;// ---------------------------------------------------------------------------// Prototypesstatic BOOL CALLBACK ListWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam);static int ListWndInfoReset(HWND hwnd);static int ListWndInfoApply(void);static int ListWndSetFontListBox(char *fontName, int fontWidth, int fontHeght);static int ResetListWnd(void);static int ClearListWnd(void);static int UniqListWnd(void);static int RefineListWnd(void);static int DelListWnd(int nth);// ---------------------------------------------------------------------------// Grobal Functionsvoid InitListWnd(HWND hParentWnd){ if (hListWnd != NULL) { DestroyWindow(hListWnd); hListWnd = NULL; } ListWndInfoReset(hListWnd); INILoadListWnd(); switch(PlayerLanguage){ case LANGUAGE_ENGLISH: hListWnd = CreateDialog (hInst,MAKEINTRESOURCE(IDD_DIALOG_SIMPLE_LIST_EN),hParentWnd,ListWndProc); break; default: case LANGUAGE_JAPANESE: hListWnd = CreateDialog (hInst,MAKEINTRESOURCE(IDD_DIALOG_SIMPLE_LIST),hParentWnd,ListWndProc); break; } ListWndInfoReset(hListWnd); ListWndInfo.hPopupMenu = CreatePopupMenu(); switch(PlayerLanguage){ case LANGUAGE_JAPANESE: AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_PLAY,"墘憈"); AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDC_BUTTON_DOC,"僪僉儏儊儞僩"); AppendMenu(ListWndInfo.hPopupMenu,MF_SEPARATOR,0,0); AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_CURRENT,"尰嵼埵抲"); AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_SEARCH,"専嶕"); AppendMenu(ListWndInfo.hPopupMenu,MF_SEPARATOR,0,0); AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_REMOVE,"嶍彍"); AppendMenu(ListWndInfo.hPopupMenu,MF_SEPARATOR,0,0); AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_CHOOSEFONT,"僼僅儞僩偺慖戰"); break; default: case LANGUAGE_ENGLISH: AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_PLAY,"Play"); AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDC_BUTTON_DOC,"Doc"); AppendMenu(ListWndInfo.hPopupMenu,MF_SEPARATOR,0,0); AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_CURRENT,"Current item"); AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_SEARCH,"Search"); AppendMenu(ListWndInfo.hPopupMenu,MF_SEPARATOR,0,0); AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_REMOVE,"Remove"); AppendMenu(ListWndInfo.hPopupMenu,MF_SEPARATOR,0,0); AppendMenu(ListWndInfo.hPopupMenu,MF_STRING,IDM_LISTWND_CHOOSEFONT,"Choose Font"); break; } INILoadListWnd(); ListWndInfoApply(); ShowWindow(ListWndInfo.hwnd,SW_HIDE); UpdateWindow(ListWndInfo.hwnd); w32g_send_rc(RC_EXT_UPDATE_PLAYLIST, 0);}// ---------------------------------------------------------------------------// Static Functionsvoid SetNumListWnd(int cursel, int nfiles);#define WM_CHOOSEFONT_DIAG (WM_APP+100)#define WM_LIST_SEARCH_DIAG (WM_APP+101)#define LISTWND_HORIZONTALEXTENT 1600static BOOL CALLBACKListWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam){ static BOOL ListSearchWndShow; switch (uMess){ case WM_INITDIALOG: ListSearchWndShow = 0; InitListSearchWnd(hwnd); SendDlgItemMessage(hwnd,IDC_LISTBOX_PLAYLIST, LB_SETHORIZONTALEXTENT,(WPARAM)LISTWND_HORIZONTALEXTENT,0); w32g_send_rc(RC_EXT_UPDATE_PLAYLIST, 0); SetWindowPosSize(GetDesktopWindow(),hwnd,ListWndInfo.PosX, ListWndInfo.PosY ); return FALSE; case WM_DESTROY: { RECT rc; GetWindowRect(hwnd,&rc); ListWndInfo.Width = rc.right - rc.left; ListWndInfo.Height = rc.bottom - rc.top;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -