2009-03-10 22:33:03 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 01:05:47 +03:00
|
|
|
// $Id$
|
2009-03-10 22:33:03 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2013-02-02 12:49:55 +04:00
|
|
|
// Copyright (C) 2009-2013 Volker Ruppert
|
2009-03-10 22:33:03 +03:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library 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
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
#include "win32dialog.h"
|
|
|
|
|
|
|
|
#if BX_USE_TEXTCONFIG && defined(WIN32) && (BX_WITH_WIN32 || BX_WITH_SDL)
|
|
|
|
|
|
|
|
#include "bochs.h"
|
|
|
|
#include "win32res.h"
|
2013-03-18 23:08:26 +04:00
|
|
|
#include "scrollwin.h"
|
2009-03-10 22:33:03 +03:00
|
|
|
|
2013-12-09 01:22:50 +04:00
|
|
|
#define ID_LABEL 1000
|
|
|
|
#define ID_PARAM 1500
|
2009-03-10 22:33:03 +03:00
|
|
|
#define ID_BROWSE 2000
|
2013-12-09 01:22:50 +04:00
|
|
|
#define ID_UPDOWN 2500
|
|
|
|
|
|
|
|
// helper function
|
|
|
|
|
|
|
|
char *backslashes(char *s)
|
|
|
|
{
|
|
|
|
if (s != NULL) {
|
|
|
|
while (*s != 0) {
|
|
|
|
if (*s == '/') *s = '\\';
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
2009-03-15 19:24:54 +03:00
|
|
|
|
2011-10-20 20:09:28 +04:00
|
|
|
// dialog item list code
|
|
|
|
|
2009-03-15 19:24:54 +03:00
|
|
|
typedef struct _dlg_list_t {
|
|
|
|
bx_list_c *list;
|
|
|
|
UINT dlg_list_id;
|
|
|
|
UINT dlg_base_id;
|
|
|
|
struct _dlg_list_t *next;
|
|
|
|
} dlg_list_t;
|
2009-03-10 22:33:03 +03:00
|
|
|
|
2009-03-19 21:23:54 +03:00
|
|
|
HFONT DlgFont;
|
|
|
|
WNDPROC DefEditWndProc;
|
2009-03-15 19:24:54 +03:00
|
|
|
UINT nextDlgID;
|
|
|
|
dlg_list_t *dlg_lists = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
bx_bool registerDlgList(UINT lid, bx_list_c *list)
|
|
|
|
{
|
|
|
|
dlg_list_t *dlg_list;
|
|
|
|
int items;
|
|
|
|
|
|
|
|
dlg_list = (dlg_list_t *)malloc(sizeof(dlg_list_t));
|
|
|
|
if (dlg_list == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
dlg_list->list = list;
|
|
|
|
dlg_list->dlg_list_id = lid;
|
|
|
|
dlg_list->dlg_base_id = nextDlgID;
|
|
|
|
items = list->get_size();
|
|
|
|
nextDlgID += items;
|
|
|
|
dlg_list->next = NULL;
|
|
|
|
|
|
|
|
if (dlg_lists == NULL) {
|
|
|
|
dlg_lists = dlg_list;
|
|
|
|
} else {
|
|
|
|
dlg_list_t *temp = dlg_lists;
|
|
|
|
|
|
|
|
while (temp->next) {
|
|
|
|
if (temp->list == dlg_list->list) {
|
|
|
|
free(dlg_list);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
temp = temp->next;
|
|
|
|
}
|
|
|
|
temp->next = dlg_list;
|
|
|
|
}
|
|
|
|
return dlg_list->dlg_base_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT findDlgListBaseID(bx_list_c *list)
|
|
|
|
{
|
|
|
|
dlg_list_t *dlg_list;
|
|
|
|
|
|
|
|
for (dlg_list = dlg_lists; dlg_list; dlg_list = dlg_list->next) {
|
|
|
|
if (list == dlg_list->list) {
|
|
|
|
return dlg_list->dlg_base_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bx_param_c *findParamFromDlgID(UINT cid)
|
|
|
|
{
|
|
|
|
dlg_list_t *dlg_list;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (dlg_list = dlg_lists; dlg_list; dlg_list = dlg_list->next) {
|
|
|
|
if ((cid >= dlg_list->dlg_base_id) && (cid < (dlg_list->dlg_base_id + dlg_list->list->get_size()))) {
|
|
|
|
i = cid - dlg_list->dlg_base_id;
|
|
|
|
return dlg_list->list->get(i);
|
|
|
|
}
|
|
|
|
if (cid == dlg_list->dlg_list_id) {
|
|
|
|
return dlg_list->list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT findDlgIDFromParam(bx_param_c *param)
|
|
|
|
{
|
|
|
|
dlg_list_t *dlg_list;
|
|
|
|
bx_list_c *list;
|
|
|
|
UINT cid;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
list = (bx_list_c*)param->get_parent();
|
|
|
|
for (dlg_list = dlg_lists; dlg_list; dlg_list = dlg_list->next) {
|
|
|
|
if (list == dlg_list->list) {
|
|
|
|
cid = dlg_list->dlg_base_id;
|
|
|
|
for (i = 0; i < list->get_size(); i++) {
|
|
|
|
if (param == list->get(i)) {
|
|
|
|
return (cid + i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-11-27 00:09:01 +04:00
|
|
|
// second try: browse all lists (for runtime-only dialogs)
|
|
|
|
for (dlg_list = dlg_lists; dlg_list; dlg_list = dlg_list->next) {
|
|
|
|
list = dlg_list->list;
|
|
|
|
cid = dlg_list->dlg_base_id;
|
|
|
|
for (i = 0; i < list->get_size(); i++) {
|
|
|
|
if (param == list->get(i)) {
|
|
|
|
return (cid + i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-03-15 19:24:54 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cleanupDlgLists()
|
|
|
|
{
|
|
|
|
dlg_list_t *d, *next;
|
|
|
|
|
|
|
|
if (dlg_lists) {
|
|
|
|
d = dlg_lists;
|
|
|
|
while (d != NULL) {
|
|
|
|
next = d->next;
|
|
|
|
free(d);
|
|
|
|
d = next;
|
|
|
|
}
|
|
|
|
dlg_lists = NULL;
|
|
|
|
}
|
|
|
|
}
|
2009-03-10 22:33:03 +03:00
|
|
|
|
2011-10-20 20:09:28 +04:00
|
|
|
// tooltips code
|
|
|
|
|
|
|
|
HWND hwndTT, tt_hwndDlg;
|
|
|
|
HHOOK tt_hhk;
|
|
|
|
const char *tt_text;
|
|
|
|
|
2012-02-10 19:15:31 +04:00
|
|
|
BOOL CALLBACK EnumChildProc(HWND hwndCtrl, LPARAM lParam);
|
2011-10-20 20:09:28 +04:00
|
|
|
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);
|
|
|
|
|
|
|
|
BOOL CreateParamDlgTooltip(HWND hwndDlg)
|
|
|
|
{
|
|
|
|
InitCommonControls();
|
|
|
|
tt_hwndDlg = hwndDlg;
|
|
|
|
hwndTT = CreateWindowEx(0, TOOLTIPS_CLASS, (LPSTR) NULL,
|
|
|
|
TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, tt_hwndDlg, (HMENU) NULL, NULL, NULL);
|
|
|
|
|
|
|
|
if (hwndTT == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!EnumChildWindows(tt_hwndDlg, (WNDENUMPROC) EnumChildProc, 0))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
tt_hhk = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc,
|
|
|
|
(HINSTANCE) NULL, GetCurrentThreadId());
|
|
|
|
|
|
|
|
if (tt_hhk == (HHOOK) NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-02-10 19:15:31 +04:00
|
|
|
BOOL CALLBACK EnumChildProc(HWND hwndCtrl, LPARAM lParam)
|
2011-10-20 20:09:28 +04:00
|
|
|
{
|
|
|
|
TOOLINFO ti;
|
|
|
|
char szClass[64];
|
|
|
|
|
|
|
|
GetClassName(hwndCtrl, szClass, sizeof(szClass));
|
|
|
|
if (lstrcmp(szClass, "STATIC")) {
|
|
|
|
ti.cbSize = sizeof(TOOLINFO);
|
|
|
|
ti.uFlags = TTF_IDISHWND;
|
|
|
|
|
|
|
|
ti.hwnd = tt_hwndDlg;
|
2011-10-20 23:10:06 +04:00
|
|
|
ti.uId = (UINT_PTR) hwndCtrl;
|
2011-10-20 20:09:28 +04:00
|
|
|
ti.hinst = 0;
|
|
|
|
ti.lpszText = LPSTR_TEXTCALLBACK;
|
|
|
|
SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
MSG *lpmsg;
|
|
|
|
|
|
|
|
lpmsg = (MSG *) lParam;
|
|
|
|
if (nCode < 0 || !(IsChild(tt_hwndDlg, lpmsg->hwnd)))
|
|
|
|
return (CallNextHookEx(tt_hhk, nCode, wParam, lParam));
|
|
|
|
|
|
|
|
switch (lpmsg->message) {
|
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
case WM_RBUTTONUP:
|
|
|
|
if (hwndTT != NULL) {
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
msg.lParam = lpmsg->lParam;
|
|
|
|
msg.wParam = lpmsg->wParam;
|
|
|
|
msg.message = lpmsg->message;
|
|
|
|
msg.hwnd = lpmsg->hwnd;
|
|
|
|
SendMessage(hwndTT, TTM_RELAYEVENT, 0, (LPARAM) (LPMSG) &msg);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return (CallNextHookEx(tt_hhk, nCode, wParam, lParam));
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID OnWMNotify(LPARAM lParam)
|
|
|
|
{
|
|
|
|
LPTOOLTIPTEXT lpttt;
|
|
|
|
int idCtrl;
|
|
|
|
|
|
|
|
if ((((LPNMHDR) lParam)->code) == TTN_NEEDTEXT) {
|
|
|
|
idCtrl = GetDlgCtrlID((HWND) ((LPNMHDR) lParam)->idFrom);
|
|
|
|
lpttt = (LPTOOLTIPTEXT) lParam;
|
|
|
|
|
|
|
|
if ((idCtrl >= ID_PARAM) && (idCtrl < ID_BROWSE)) {
|
|
|
|
bx_param_c *param = findParamFromDlgID(idCtrl - ID_PARAM);
|
|
|
|
if (param != NULL) {
|
|
|
|
tt_text = param->get_description();
|
|
|
|
if (lstrlen(tt_text) > 0) {
|
|
|
|
lpttt->lpszText = (LPSTR)tt_text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// gui functions
|
|
|
|
|
2009-03-26 20:57:20 +03:00
|
|
|
int AskFilename(HWND hwnd, bx_param_filename_c *param, char *buffer)
|
2009-03-10 22:33:03 +03:00
|
|
|
{
|
|
|
|
OPENFILENAME ofn;
|
|
|
|
int ret;
|
|
|
|
DWORD errcode;
|
2009-03-26 20:57:20 +03:00
|
|
|
char filename[BX_PATHNAME_LEN];
|
2009-03-16 00:16:17 +03:00
|
|
|
const char *title, *ext;
|
2009-03-10 22:33:03 +03:00
|
|
|
char errtext[80];
|
|
|
|
|
2009-03-26 20:57:20 +03:00
|
|
|
if (buffer != NULL) {
|
|
|
|
lstrcpyn(filename, buffer, BX_PATHNAME_LEN);
|
|
|
|
} else {
|
|
|
|
param->get(filename, BX_PATHNAME_LEN);
|
|
|
|
}
|
2009-03-10 22:33:03 +03:00
|
|
|
// common file dialogs don't accept raw device names
|
|
|
|
if ((isalpha(filename[0])) && (filename[1] == ':') && (strlen(filename) == 2)) {
|
|
|
|
filename[0] = 0;
|
|
|
|
}
|
|
|
|
title = param->get_label();
|
2009-03-16 00:16:17 +03:00
|
|
|
ext = param->get_extension();
|
2009-03-10 22:33:03 +03:00
|
|
|
if (!title) title = param->get_name();
|
|
|
|
memset(&ofn, 0, sizeof(OPENFILENAME));
|
|
|
|
ofn.lStructSize = sizeof(OPENFILENAME);
|
|
|
|
ofn.hwndOwner = hwnd;
|
|
|
|
ofn.lpstrFile = filename;
|
|
|
|
ofn.nMaxFile = MAX_PATH;
|
|
|
|
ofn.lpstrInitialDir = bx_startup_flags.initial_dir;
|
|
|
|
ofn.lpstrTitle = title;
|
|
|
|
ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
|
|
|
|
ofn.lpstrDefExt = ext;
|
2009-03-22 12:40:18 +03:00
|
|
|
if (!lstrcmp(ext, "bxrc")) {
|
|
|
|
ofn.lpstrFilter = "Bochs config files (*.bxrc)\0*.bxrc\0All files (*.*)\0*.*\0";
|
|
|
|
} else if (!lstrcmp(ext, "img")) {
|
2009-03-16 00:16:17 +03:00
|
|
|
ofn.lpstrFilter = "Disk image files (*.img)\0*.img\0All files (*.*)\0*.*\0";
|
2009-03-10 22:33:03 +03:00
|
|
|
} else if (!lstrcmp(ext, "iso")) {
|
|
|
|
ofn.lpstrFilter = "CD-ROM image files (*.iso)\0*.iso\0All files (*.*)\0*.*\0";
|
2009-03-16 00:16:17 +03:00
|
|
|
} else if (!lstrcmp(ext, "log")) {
|
|
|
|
ofn.lpstrFilter = "Log files (*.log)\0*.log\0All files (*.*)\0*.*\0";
|
|
|
|
} else if (!lstrcmp(ext, "map")) {
|
|
|
|
ofn.lpstrFilter = "Keymap files (*.map)\0*.map\0All files (*.*)\0*.*\0";
|
2009-03-10 22:33:03 +03:00
|
|
|
} else if (!lstrcmp(ext, "txt")) {
|
|
|
|
ofn.lpstrFilter = "Text files (*.txt)\0*.txt\0All files (*.*)\0*.*\0";
|
2011-08-09 13:56:00 +04:00
|
|
|
} else if (!lstrcmp(ext, "bmp")) {
|
|
|
|
ofn.lpstrFilter = "Windows bitmap files (*.bmp)\0*.bmp\0All files (*.*)\0*.*\0";
|
2009-03-10 22:33:03 +03:00
|
|
|
} else {
|
|
|
|
ofn.lpstrFilter = "All files (*.*)\0*.*\0";
|
|
|
|
}
|
2009-03-16 00:16:17 +03:00
|
|
|
if (param->get_options() & param->SAVE_FILE_DIALOG) {
|
2009-03-10 22:33:03 +03:00
|
|
|
ofn.Flags |= OFN_OVERWRITEPROMPT;
|
|
|
|
ret = GetSaveFileName(&ofn);
|
|
|
|
} else {
|
|
|
|
ofn.Flags |= OFN_FILEMUSTEXIST;
|
|
|
|
ret = GetOpenFileName(&ofn);
|
|
|
|
}
|
2009-03-26 20:57:20 +03:00
|
|
|
if (buffer != NULL) {
|
|
|
|
lstrcpyn(buffer, filename, BX_PATHNAME_LEN);
|
|
|
|
} else {
|
|
|
|
param->set(filename);
|
|
|
|
}
|
2009-03-10 22:33:03 +03:00
|
|
|
if (ret == 0) {
|
|
|
|
errcode = CommDlgExtendedError();
|
|
|
|
if (errcode == 0) {
|
|
|
|
ret = -1;
|
|
|
|
} else {
|
|
|
|
if (errcode == 0x3002) {
|
|
|
|
wsprintf(errtext, "CommDlgExtendedError: invalid filename");
|
|
|
|
} else {
|
|
|
|
wsprintf(errtext, "CommDlgExtendedError returns 0x%04x", errcode);
|
|
|
|
}
|
|
|
|
MessageBox(hwnd, errtext, "Error", MB_ICONERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InitDlgFont(void)
|
|
|
|
{
|
|
|
|
LOGFONT LFont;
|
|
|
|
|
|
|
|
LFont.lfHeight = 8; // Default logical height of font
|
|
|
|
LFont.lfWidth = 0; // Default logical average character width
|
|
|
|
LFont.lfEscapement = 0; // angle of escapement
|
|
|
|
LFont.lfOrientation = 0; // base-line orientation angle
|
|
|
|
LFont.lfWeight = FW_NORMAL; // font weight
|
|
|
|
LFont.lfItalic = 0; // italic attribute flag
|
|
|
|
LFont.lfUnderline = 0; // underline attribute flag
|
|
|
|
LFont.lfStrikeOut = 0; // strikeout attribute flag
|
|
|
|
LFont.lfCharSet = DEFAULT_CHARSET; // character set identifier
|
|
|
|
LFont.lfOutPrecision = OUT_DEFAULT_PRECIS; // output precision
|
|
|
|
LFont.lfClipPrecision = CLIP_DEFAULT_PRECIS; // clipping precision
|
|
|
|
LFont.lfQuality = DEFAULT_QUALITY; // output quality
|
2009-03-19 21:23:54 +03:00
|
|
|
LFont.lfPitchAndFamily = DEFAULT_PITCH; // pitch and family
|
2009-03-10 22:33:03 +03:00
|
|
|
lstrcpy(LFont.lfFaceName, "Helv"); // pointer to typeface name string
|
|
|
|
DlgFont = CreateFontIndirect(&LFont);
|
|
|
|
}
|
|
|
|
|
2009-03-19 21:23:54 +03:00
|
|
|
LRESULT CALLBACK EditHexWndProc(HWND Window, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
if (msg == WM_CHAR) {
|
|
|
|
switch (wParam) {
|
|
|
|
case 0x08:
|
|
|
|
break;
|
|
|
|
case 'x':
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if ((wParam < '0') || ((wParam > '9') && (wParam < 'A')) ||
|
|
|
|
((wParam > 'F') && (wParam < 'a')) || (wParam > 'f')) {
|
|
|
|
MessageBeep(MB_OK);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return CallWindowProc(DefEditWndProc, Window, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2013-03-18 23:08:26 +04:00
|
|
|
BOOL IsScrollWindow(HWND hwnd)
|
|
|
|
{
|
|
|
|
char classname[80];
|
|
|
|
|
|
|
|
GetClassName(hwnd, classname, 80);
|
|
|
|
return (!lstrcmp(classname, "ScrollWin"));
|
|
|
|
}
|
|
|
|
|
2011-07-30 21:32:40 +04:00
|
|
|
HWND CreateLabel(HWND hDlg, UINT cid, UINT xpos, UINT ypos, UINT width, BOOL hide, const char *text)
|
2009-03-10 22:33:03 +03:00
|
|
|
{
|
|
|
|
HWND Label;
|
|
|
|
RECT r;
|
|
|
|
int code;
|
|
|
|
|
2009-03-15 19:24:54 +03:00
|
|
|
code = ID_LABEL + cid;
|
|
|
|
r.left = xpos;
|
|
|
|
r.top = ypos + 2;
|
2011-07-30 21:32:40 +04:00
|
|
|
r.right = r.left + width;
|
2011-08-14 21:07:47 +04:00
|
|
|
r.bottom = r.top + 16;
|
2013-03-18 23:08:26 +04:00
|
|
|
if (IsScrollWindow(hDlg)) {
|
|
|
|
MapDialogRect(GetParent(hDlg), &r);
|
|
|
|
} else {
|
|
|
|
MapDialogRect(hDlg, &r);
|
|
|
|
}
|
2009-03-10 22:33:03 +03:00
|
|
|
Label = CreateWindow("STATIC", text, WS_CHILD, r.left, r.top, r.right-r.left+1, r.bottom-r.top+1, hDlg, (HMENU)code, NULL, NULL);
|
2010-11-01 18:02:14 +03:00
|
|
|
SendMessage(Label, WM_SETFONT, (WPARAM)DlgFont, TRUE);
|
2009-03-15 19:24:54 +03:00
|
|
|
ShowWindow(Label, hide ? SW_HIDE : SW_SHOW);
|
2009-03-10 22:33:03 +03:00
|
|
|
return Label;
|
|
|
|
}
|
|
|
|
|
2009-03-15 19:24:54 +03:00
|
|
|
HWND CreateGroupbox(HWND hDlg, UINT cid, UINT xpos, UINT ypos, SIZE size, BOOL hide, bx_list_c *list)
|
|
|
|
{
|
|
|
|
HWND Groupbox;
|
|
|
|
RECT r;
|
|
|
|
int code;
|
|
|
|
const char *title = NULL;
|
|
|
|
|
|
|
|
code = ID_PARAM + cid;
|
|
|
|
r.left = xpos;
|
|
|
|
r.top = ypos;
|
|
|
|
r.right = r.left + size.cx;
|
|
|
|
r.bottom = r.top + size.cy;
|
|
|
|
MapDialogRect(hDlg, &r);
|
2009-03-16 00:16:17 +03:00
|
|
|
if (list->get_options() & list->USE_BOX_TITLE) {
|
2011-03-20 00:40:07 +03:00
|
|
|
title = list->get_title();
|
2009-03-15 19:24:54 +03:00
|
|
|
}
|
|
|
|
Groupbox = CreateWindow("BUTTON", title, BS_GROUPBOX | WS_CHILD, r.left, r.top,
|
|
|
|
r.right-r.left+1, r.bottom-r.top+1, hDlg, (HMENU)code, NULL, NULL);
|
2010-11-01 18:02:14 +03:00
|
|
|
SendMessage(Groupbox, WM_SETFONT, (WPARAM)DlgFont, TRUE);
|
2009-03-15 19:24:54 +03:00
|
|
|
ShowWindow(Groupbox, hide ? SW_HIDE : SW_SHOW);
|
|
|
|
return Groupbox;
|
|
|
|
}
|
|
|
|
|
|
|
|
HWND CreateTabControl(HWND hDlg, UINT cid, UINT xpos, UINT ypos, SIZE size, BOOL hide, bx_list_c *list)
|
|
|
|
{
|
|
|
|
HWND TabControl;
|
|
|
|
TC_ITEM tie;
|
|
|
|
RECT r;
|
|
|
|
int code, i;
|
|
|
|
bx_param_c *item;
|
|
|
|
|
|
|
|
code = ID_PARAM + cid;
|
|
|
|
r.left = xpos;
|
|
|
|
r.top = ypos;
|
|
|
|
r.right = r.left + size.cx;
|
|
|
|
r.bottom = r.top + size.cy;
|
|
|
|
MapDialogRect(hDlg, &r);
|
|
|
|
TabControl = CreateWindow(WC_TABCONTROL, "", WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE,
|
2011-10-20 20:09:28 +04:00
|
|
|
r.left, r.top, r.right-r.left+1, r.bottom-r.top+1, hDlg, (HMENU)code, NULL, NULL);
|
2009-03-15 19:24:54 +03:00
|
|
|
for (i = 0; i < list->get_size(); i++) {
|
|
|
|
item = list->get(i);
|
|
|
|
if (item->get_type() == BXT_LIST) {
|
2011-10-20 20:09:28 +04:00
|
|
|
tie.mask = TCIF_TEXT;
|
|
|
|
tie.pszText = ((bx_list_c*)item)->get_title();
|
2009-03-15 19:24:54 +03:00
|
|
|
TabCtrl_InsertItem(TabControl, i, &tie);
|
|
|
|
}
|
|
|
|
}
|
2009-03-16 00:16:17 +03:00
|
|
|
TabCtrl_SetCurSel(TabControl, 0);
|
2010-11-01 18:02:14 +03:00
|
|
|
SendMessage(TabControl, WM_SETFONT, (WPARAM)DlgFont, TRUE);
|
2009-03-15 19:24:54 +03:00
|
|
|
ShowWindow(TabControl, hide ? SW_HIDE : SW_SHOW);
|
|
|
|
return TabControl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-09 01:22:50 +04:00
|
|
|
HWND CreateButton(HWND hDlg, UINT id, UINT xpos, UINT ypos, BOOL hide, const char *text)
|
2009-03-10 22:33:03 +03:00
|
|
|
{
|
|
|
|
HWND Button;
|
|
|
|
RECT r;
|
|
|
|
|
2011-07-30 21:32:40 +04:00
|
|
|
r.left = xpos;
|
2009-03-15 19:24:54 +03:00
|
|
|
r.top = ypos;
|
|
|
|
r.right = r.left + 50;
|
2009-03-10 22:33:03 +03:00
|
|
|
r.bottom = r.top + 14;
|
2013-03-18 23:08:26 +04:00
|
|
|
if (IsScrollWindow(hDlg)) {
|
|
|
|
MapDialogRect(GetParent(hDlg), &r);
|
|
|
|
} else {
|
|
|
|
MapDialogRect(hDlg, &r);
|
|
|
|
}
|
2013-12-09 01:22:50 +04:00
|
|
|
Button = CreateWindow("BUTTON", text, WS_CHILD, r.left, r.top, r.right-r.left+1, r.bottom-r.top+1, hDlg, (HMENU)id, NULL, NULL);
|
2010-11-01 18:02:14 +03:00
|
|
|
SendMessage(Button, WM_SETFONT, (WPARAM)DlgFont, TRUE);
|
2009-03-15 19:24:54 +03:00
|
|
|
ShowWindow(Button, hide ? SW_HIDE : SW_SHOW);
|
2009-03-10 22:33:03 +03:00
|
|
|
return Button;
|
|
|
|
}
|
|
|
|
|
2013-12-09 01:22:50 +04:00
|
|
|
HWND CreateBrowseButton(HWND hDlg, UINT cid, UINT xpos, UINT ypos, BOOL hide)
|
|
|
|
{
|
|
|
|
return CreateButton(hDlg, ID_BROWSE + cid, xpos, ypos, hide, "Browse...");
|
|
|
|
}
|
|
|
|
|
2009-03-15 19:24:54 +03:00
|
|
|
HWND CreateCheckbox(HWND hDlg, UINT cid, UINT xpos, UINT ypos, BOOL hide, bx_param_bool_c *bparam)
|
2009-03-10 22:33:03 +03:00
|
|
|
{
|
|
|
|
HWND Checkbox;
|
|
|
|
RECT r;
|
2009-03-11 21:53:22 +03:00
|
|
|
int code, val;
|
2009-03-10 22:33:03 +03:00
|
|
|
|
2009-03-15 19:24:54 +03:00
|
|
|
code = ID_PARAM + cid;
|
2011-07-30 21:32:40 +04:00
|
|
|
r.left = xpos;
|
2009-03-15 19:24:54 +03:00
|
|
|
r.top = ypos;
|
|
|
|
r.right = r.left + 20;
|
2009-03-10 22:33:03 +03:00
|
|
|
r.bottom = r.top + 14;
|
2013-03-18 23:08:26 +04:00
|
|
|
if (IsScrollWindow(hDlg)) {
|
|
|
|
MapDialogRect(GetParent(hDlg), &r);
|
|
|
|
} else {
|
|
|
|
MapDialogRect(hDlg, &r);
|
|
|
|
}
|
2009-03-10 22:33:03 +03:00
|
|
|
Checkbox = CreateWindow("BUTTON", "", BS_AUTOCHECKBOX | WS_CHILD | WS_TABSTOP,
|
|
|
|
r.left, r.top, r.right-r.left+1, r.bottom-r.top+1,
|
|
|
|
hDlg, (HMENU)code, NULL, NULL);
|
2009-03-11 21:53:22 +03:00
|
|
|
val = bparam->get();
|
|
|
|
SendMessage(Checkbox, BM_SETCHECK, val ? BST_CHECKED : BST_UNCHECKED, 0);
|
2010-11-01 18:02:14 +03:00
|
|
|
SendMessage(Checkbox, WM_SETFONT, (WPARAM)DlgFont, TRUE);
|
2009-03-15 19:24:54 +03:00
|
|
|
ShowWindow(Checkbox, hide ? SW_HIDE : SW_SHOW);
|
2009-03-10 22:33:03 +03:00
|
|
|
return Checkbox;
|
|
|
|
}
|
|
|
|
|
2009-03-15 19:24:54 +03:00
|
|
|
HWND CreateInput(HWND hDlg, UINT cid, UINT xpos, UINT ypos, BOOL hide, bx_param_c *param)
|
2009-03-10 22:33:03 +03:00
|
|
|
{
|
2009-03-15 19:24:54 +03:00
|
|
|
HWND Input, Updown;
|
2009-03-10 22:33:03 +03:00
|
|
|
RECT r;
|
2013-02-02 12:49:55 +04:00
|
|
|
int code, style;
|
2009-03-15 19:24:54 +03:00
|
|
|
bx_param_num_c *nparam = NULL;
|
2009-03-12 22:40:41 +03:00
|
|
|
bx_param_string_c *sparam;
|
|
|
|
char buffer[512];
|
2009-03-19 21:23:54 +03:00
|
|
|
BOOL spinctrl = FALSE, hexedit = FALSE;
|
2009-03-10 22:33:03 +03:00
|
|
|
|
2009-03-15 19:24:54 +03:00
|
|
|
code = ID_PARAM + cid;
|
2009-03-10 22:33:03 +03:00
|
|
|
style = WS_CHILD | WS_TABSTOP;
|
2009-03-12 22:40:41 +03:00
|
|
|
if (param->get_type() == BXT_PARAM_STRING) {
|
|
|
|
sparam = (bx_param_string_c*)param;
|
2013-02-02 12:49:55 +04:00
|
|
|
sparam->sprint(buffer, 512, 0);
|
|
|
|
if ((sparam->get_options() & sparam->RAW_BYTES) == 0) {
|
2009-03-12 22:40:41 +03:00
|
|
|
style |= ES_AUTOHSCROLL;
|
|
|
|
}
|
2009-03-10 22:33:03 +03:00
|
|
|
} else {
|
2009-03-12 22:40:41 +03:00
|
|
|
nparam = (bx_param_num_c*)param;
|
|
|
|
if (nparam->get_base() == BASE_HEX) {
|
|
|
|
wsprintf(buffer, "0x%x", nparam->get());
|
2009-03-19 21:23:54 +03:00
|
|
|
hexedit = TRUE;
|
2009-03-12 22:40:41 +03:00
|
|
|
} else {
|
|
|
|
wsprintf(buffer, "%d", nparam->get());
|
|
|
|
style |= ES_NUMBER;
|
|
|
|
}
|
2009-03-15 19:24:54 +03:00
|
|
|
if (nparam->get_options() & nparam->USE_SPIN_CONTROL) {
|
|
|
|
spinctrl = TRUE;
|
|
|
|
}
|
2009-03-10 22:33:03 +03:00
|
|
|
}
|
2011-07-30 21:32:40 +04:00
|
|
|
r.left = xpos;
|
2009-03-15 19:24:54 +03:00
|
|
|
r.top = ypos;
|
|
|
|
r.right = r.left + 100;
|
2009-03-10 22:33:03 +03:00
|
|
|
r.bottom = r.top + 14;
|
2013-03-18 23:08:26 +04:00
|
|
|
if (IsScrollWindow(hDlg)) {
|
|
|
|
MapDialogRect(GetParent(hDlg), &r);
|
|
|
|
} else {
|
|
|
|
MapDialogRect(hDlg, &r);
|
|
|
|
}
|
2009-03-12 22:40:41 +03:00
|
|
|
Input = CreateWindowEx(WS_EX_CLIENTEDGE | WS_EX_NOPARENTNOTIFY, "EDIT", buffer,
|
2009-03-10 22:33:03 +03:00
|
|
|
style, r.left, r.top, r.right-r.left+1,
|
|
|
|
r.bottom-r.top+1, hDlg, (HMENU)code, NULL, NULL);
|
2009-03-19 21:23:54 +03:00
|
|
|
if (hexedit) {
|
2010-04-22 21:30:11 +04:00
|
|
|
DefEditWndProc = (WNDPROC)SetWindowLongPtr(Input, GWLP_WNDPROC, (LONG_PTR)EditHexWndProc);
|
2009-03-19 21:23:54 +03:00
|
|
|
}
|
2009-03-15 19:24:54 +03:00
|
|
|
if (spinctrl) {
|
|
|
|
style = WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_NOTHOUSANDS | UDS_ARROWKEYS |
|
|
|
|
UDS_ALIGNRIGHT | UDS_SETBUDDYINT;
|
|
|
|
Updown = CreateUpDownControl(style, 0, 0, 0, 0, hDlg, ID_UPDOWN + cid, NULL, Input,
|
|
|
|
(int)nparam->get_max(), (int)nparam->get_min(), (int)nparam->get());
|
|
|
|
ShowWindow(Updown, hide ? SW_HIDE : SW_SHOW);
|
|
|
|
}
|
2010-11-01 18:02:14 +03:00
|
|
|
SendMessage(Input, WM_SETFONT, (WPARAM)DlgFont, TRUE);
|
2009-03-15 19:24:54 +03:00
|
|
|
ShowWindow(Input, hide ? SW_HIDE : SW_SHOW);
|
2009-03-10 22:33:03 +03:00
|
|
|
return Input;
|
|
|
|
}
|
|
|
|
|
2009-03-15 19:24:54 +03:00
|
|
|
HWND CreateCombobox(HWND hDlg, UINT cid, UINT xpos, UINT ypos, BOOL hide, bx_param_enum_c *eparam)
|
2009-03-10 22:33:03 +03:00
|
|
|
{
|
|
|
|
HWND Combo;
|
|
|
|
RECT r;
|
2009-03-11 21:53:22 +03:00
|
|
|
int code, j;
|
|
|
|
const char *choice;
|
2009-03-10 22:33:03 +03:00
|
|
|
|
2009-03-15 19:24:54 +03:00
|
|
|
code = ID_PARAM + cid;
|
2011-07-30 21:32:40 +04:00
|
|
|
r.left = xpos;
|
2009-03-15 19:24:54 +03:00
|
|
|
r.top = ypos;
|
|
|
|
r.right = r.left + 100;
|
2012-03-15 23:34:13 +04:00
|
|
|
r.bottom = r.top + 14 * ((int)(eparam->get_max() - eparam->get_min()) + 1);
|
2013-03-18 23:08:26 +04:00
|
|
|
if (IsScrollWindow(hDlg)) {
|
|
|
|
MapDialogRect(GetParent(hDlg), &r);
|
|
|
|
} else {
|
|
|
|
MapDialogRect(hDlg, &r);
|
|
|
|
}
|
2009-03-10 22:33:03 +03:00
|
|
|
Combo = CreateWindow("COMBOBOX", "", WS_CHILD | WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWNLIST,
|
|
|
|
r.left, r.top, r.right-r.left+1, r.bottom-r.top+1, hDlg, (HMENU)code, NULL, NULL);
|
2009-03-11 21:53:22 +03:00
|
|
|
j = 0;
|
2011-12-08 10:46:52 +04:00
|
|
|
while(1) {
|
2009-03-11 21:53:22 +03:00
|
|
|
choice = eparam->get_choice(j);
|
2011-12-08 10:46:52 +04:00
|
|
|
if (choice == NULL) break;
|
2009-03-11 21:53:22 +03:00
|
|
|
SendMessage(Combo, CB_ADDSTRING, 0, (LPARAM)choice);
|
|
|
|
j++;
|
2011-12-08 10:46:52 +04:00
|
|
|
}
|
2009-03-11 21:53:22 +03:00
|
|
|
SendMessage(Combo, CB_SETCURSEL, (WPARAM)(eparam->get()-eparam->get_min()), 0);
|
2010-11-01 18:02:14 +03:00
|
|
|
SendMessage(Combo, WM_SETFONT, (WPARAM)DlgFont, TRUE);
|
2009-03-15 19:24:54 +03:00
|
|
|
ShowWindow(Combo, hide ? SW_HIDE : SW_SHOW);
|
2009-03-10 22:33:03 +03:00
|
|
|
return Combo;
|
|
|
|
}
|
|
|
|
|
2013-03-18 23:08:26 +04:00
|
|
|
|
|
|
|
HWND CreateScrollWindow(HWND hDlg, int xpos, int ypos, int width, int height)
|
|
|
|
{
|
|
|
|
RECT r;
|
|
|
|
HWND scrollwin;
|
|
|
|
|
|
|
|
r.left = xpos;
|
|
|
|
r.top = ypos;
|
|
|
|
r.right = r.left + width;
|
|
|
|
r.bottom = r.top + height;
|
|
|
|
MapDialogRect(hDlg, &r);
|
|
|
|
scrollwin = CreateWindowEx(WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT, "ScrollWin",
|
|
|
|
"scrollwin", WS_CHILD | WS_CLIPCHILDREN | WS_TABSTOP | WS_VSCROLL,
|
|
|
|
r.left, r.top, r.right-r.left+1, r.bottom-r.top+1,
|
|
|
|
hDlg, NULL, NULL, NULL);
|
|
|
|
ShowWindow(scrollwin, SW_SHOW);
|
|
|
|
return scrollwin;
|
|
|
|
}
|
|
|
|
|
2009-03-18 15:38:17 +03:00
|
|
|
void EnableParam(HWND hDlg, UINT cid, bx_param_c *param, BOOL val)
|
|
|
|
{
|
|
|
|
HWND Button, Updown;
|
|
|
|
|
|
|
|
if (cid == 0) {
|
|
|
|
cid = findDlgIDFromParam(param);
|
|
|
|
}
|
|
|
|
if (param->get_type() != BXT_LIST) {
|
2013-03-19 21:44:19 +04:00
|
|
|
bx_list_c *list = (bx_list_c*)param->get_parent();
|
|
|
|
if (list->get_options() & list->USE_SCROLL_WINDOW) {
|
|
|
|
hDlg = FindWindowEx(hDlg, NULL, "ScrollWin", NULL);
|
|
|
|
}
|
2009-03-18 15:38:17 +03:00
|
|
|
EnableWindow(GetDlgItem(hDlg, ID_LABEL + cid), val);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, ID_PARAM + cid), val);
|
|
|
|
Button = GetDlgItem(hDlg, ID_BROWSE + cid);
|
|
|
|
if (Button != NULL) {
|
|
|
|
EnableWindow(Button, val);
|
|
|
|
}
|
|
|
|
Updown = GetDlgItem(hDlg, ID_UPDOWN + cid);
|
|
|
|
if (Updown != NULL) {
|
|
|
|
EnableWindow(Updown, val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-30 21:32:40 +04:00
|
|
|
UINT GetLabelText(bx_param_c *param, bx_list_c *list, char *buffer)
|
|
|
|
{
|
2011-08-14 21:07:47 +04:00
|
|
|
const char *label, *tmpstr;
|
2011-07-30 21:32:40 +04:00
|
|
|
char tmpbuf[512];
|
2011-08-14 21:07:47 +04:00
|
|
|
int len;
|
2011-07-30 21:32:40 +04:00
|
|
|
|
|
|
|
label = param->get_label();
|
|
|
|
if (label == NULL) {
|
|
|
|
label = param->get_name();
|
|
|
|
}
|
|
|
|
if ((list->get_options() & list->SHOW_GROUP_NAME) && (param->get_group() != NULL)) {
|
|
|
|
wsprintf(tmpbuf, "%s %s", param->get_group(), label);
|
|
|
|
} else {
|
|
|
|
lstrcpyn(tmpbuf, label, 512);
|
|
|
|
}
|
|
|
|
if (buffer != NULL) {
|
|
|
|
lstrcpy(buffer, tmpbuf);
|
|
|
|
}
|
2011-08-14 21:07:47 +04:00
|
|
|
len = lstrlen(tmpbuf);
|
|
|
|
tmpstr = strchr(tmpbuf, 10);
|
|
|
|
if (tmpstr != NULL) {
|
|
|
|
if (lstrlen(tmpstr) > (len / 2)) {
|
|
|
|
len = lstrlen(tmpstr) - 1;
|
|
|
|
} else {
|
|
|
|
len -= lstrlen(tmpstr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (len * 4);
|
2011-07-30 21:32:40 +04:00
|
|
|
}
|
|
|
|
|
2009-03-15 19:24:54 +03:00
|
|
|
SIZE CreateParamList(HWND hDlg, UINT lid, UINT xpos, UINT ypos, BOOL hide, bx_list_c *list)
|
|
|
|
{
|
|
|
|
SIZE size, lsize;
|
|
|
|
bx_param_c *param;
|
|
|
|
bx_param_string_c *sparam;
|
|
|
|
char buffer[512];
|
|
|
|
int options;
|
2011-07-30 21:32:40 +04:00
|
|
|
UINT cid, i, items, lw, w1, x0, x1, x2, y;
|
2009-03-15 19:24:54 +03:00
|
|
|
BOOL ihide;
|
2013-03-18 23:08:26 +04:00
|
|
|
HWND scrollwin = NULL, hParent;
|
|
|
|
RECT vrect;
|
2009-03-15 19:24:54 +03:00
|
|
|
|
|
|
|
items = list->get_size();
|
2009-03-16 00:16:17 +03:00
|
|
|
options = list->get_options();
|
2009-03-15 19:24:54 +03:00
|
|
|
cid = registerDlgList(lid, list);
|
2011-07-30 21:32:40 +04:00
|
|
|
x0 = xpos + 5;
|
2009-03-15 19:24:54 +03:00
|
|
|
size.cx = 195;
|
|
|
|
if (options & list->USE_TAB_WINDOW) {
|
|
|
|
y = ypos + 15;
|
|
|
|
size.cy = 18;
|
2013-03-18 23:08:26 +04:00
|
|
|
} else if (options & list->USE_SCROLL_WINDOW) {
|
|
|
|
x0 = 5;
|
|
|
|
y = 5;
|
2013-03-19 23:26:04 +04:00
|
|
|
size.cy = 3;
|
2009-03-15 19:24:54 +03:00
|
|
|
} else {
|
|
|
|
y = ypos + 10;
|
|
|
|
size.cy = 13;
|
|
|
|
}
|
2011-07-30 21:32:40 +04:00
|
|
|
// find out longest label text
|
|
|
|
w1 = 78;
|
|
|
|
for (i = 0; i < items; i++) {
|
|
|
|
param = list->get(i);
|
2013-11-27 00:09:01 +04:00
|
|
|
if (!SIM->get_init_done() || param->get_runtime_param()) {
|
2011-07-30 21:32:40 +04:00
|
|
|
if (param->get_type() != BXT_LIST) {
|
|
|
|
lw = GetLabelText(param, list, NULL);
|
|
|
|
if (lw > w1) {
|
|
|
|
w1 = lw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// set columns and width
|
|
|
|
x1 = x0 + w1 + 2;
|
|
|
|
x2 = x1 + 110;
|
|
|
|
if (size.cx < (int)(x2 + 5)) {
|
|
|
|
size.cx = x2 + 5;
|
|
|
|
}
|
2013-03-18 23:08:26 +04:00
|
|
|
if ((items > 16) && (options & list->USE_SCROLL_WINDOW)) {
|
|
|
|
size.cx += 20;
|
|
|
|
scrollwin = CreateScrollWindow(hDlg, xpos, ypos, size.cx, 325);
|
|
|
|
vrect.left = vrect.top = 0;
|
|
|
|
vrect.right = size.cx;
|
|
|
|
vrect.bottom = size.cy;
|
|
|
|
hParent = scrollwin;
|
|
|
|
} else {
|
|
|
|
hParent = hDlg;
|
|
|
|
}
|
2011-07-30 21:32:40 +04:00
|
|
|
// create controls
|
2009-03-15 19:24:54 +03:00
|
|
|
for (i = 0; i < items; i++) {
|
|
|
|
param = list->get(i);
|
2013-11-27 00:09:01 +04:00
|
|
|
if (!SIM->get_init_done() || param->get_runtime_param()) {
|
2009-03-15 19:24:54 +03:00
|
|
|
ihide = hide || ((i != 0) && (options & list->USE_TAB_WINDOW));
|
|
|
|
if (param->get_type() == BXT_LIST) {
|
2011-07-30 21:32:40 +04:00
|
|
|
lsize = CreateParamList(hDlg, cid, x0 + 4, y + 1, ihide, (bx_list_c*)param);
|
2009-03-15 19:24:54 +03:00
|
|
|
if ((lsize.cx + 18) > size.cx) {
|
|
|
|
size.cx = lsize.cx + 18;
|
|
|
|
}
|
|
|
|
if (!(options & list->USE_TAB_WINDOW)) {
|
|
|
|
y += (lsize.cy + 6);
|
|
|
|
size.cy += (lsize.cy + 6);
|
|
|
|
} else {
|
|
|
|
if ((lsize.cy + 24) > size.cy) {
|
|
|
|
size.cy = lsize.cy + 24;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2011-07-30 21:32:40 +04:00
|
|
|
lw = GetLabelText(param, list, buffer);
|
2013-03-18 23:08:26 +04:00
|
|
|
CreateLabel(hParent, cid, x0, y, w1, hide, buffer);
|
2009-03-15 19:24:54 +03:00
|
|
|
if (param->get_type() == BXT_PARAM_BOOL) {
|
2013-03-18 23:08:26 +04:00
|
|
|
CreateCheckbox(hParent, cid, x1, y, hide, (bx_param_bool_c*)param);
|
2009-03-15 19:24:54 +03:00
|
|
|
} else if (param->get_type() == BXT_PARAM_ENUM) {
|
2013-03-18 23:08:26 +04:00
|
|
|
CreateCombobox(hParent, cid, x1, y, hide, (bx_param_enum_c*)param);
|
2009-03-15 19:24:54 +03:00
|
|
|
} else if (param->get_type() == BXT_PARAM_NUM) {
|
2013-03-18 23:08:26 +04:00
|
|
|
CreateInput(hParent, cid, x1, y, hide, param);
|
2009-03-15 19:24:54 +03:00
|
|
|
} else if (param->get_type() == BXT_PARAM_STRING) {
|
2013-03-18 23:08:26 +04:00
|
|
|
CreateInput(hParent, cid, x1, y, hide, param);
|
2009-03-15 19:24:54 +03:00
|
|
|
sparam = (bx_param_string_c*)param;
|
2009-03-16 00:16:17 +03:00
|
|
|
if (sparam->get_options() & sparam->IS_FILENAME) {
|
2013-03-18 23:08:26 +04:00
|
|
|
CreateBrowseButton(hParent, cid, x2, y, hide);
|
2011-07-30 21:32:40 +04:00
|
|
|
if (size.cx < (int)(x2 + 60)) {
|
|
|
|
size.cx = x2 + 60;
|
|
|
|
}
|
2009-03-15 19:24:54 +03:00
|
|
|
}
|
|
|
|
}
|
2009-03-18 15:38:17 +03:00
|
|
|
if (!param->get_enabled()) {
|
|
|
|
EnableParam(hDlg, cid, param, FALSE);
|
|
|
|
}
|
2009-03-15 19:24:54 +03:00
|
|
|
y += 20;
|
2013-03-18 23:08:26 +04:00
|
|
|
if ((scrollwin == NULL) || (i < 16)) {
|
|
|
|
size.cy += 20;
|
|
|
|
}
|
|
|
|
if (scrollwin != NULL) {
|
|
|
|
vrect.bottom += 20;
|
|
|
|
}
|
2009-03-15 19:24:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
cid++;
|
|
|
|
}
|
|
|
|
if (options & list->USE_TAB_WINDOW) {
|
|
|
|
CreateTabControl(hDlg, lid, xpos, ypos, size, hide, list);
|
2013-03-18 23:08:26 +04:00
|
|
|
} else if (scrollwin != NULL) {
|
|
|
|
MapDialogRect(hDlg, &vrect);
|
|
|
|
SendMessage(scrollwin, WM_USER, 0x1234, vrect.bottom);
|
2009-03-15 19:24:54 +03:00
|
|
|
} else {
|
|
|
|
CreateGroupbox(hDlg, lid, xpos, ypos, size, hide, list);
|
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetParamList(HWND hDlg, bx_list_c *list)
|
2009-03-10 22:33:03 +03:00
|
|
|
{
|
|
|
|
bx_param_c *param;
|
2009-03-12 22:40:41 +03:00
|
|
|
bx_param_num_c *nparam;
|
2009-03-10 22:33:03 +03:00
|
|
|
bx_param_enum_c *eparam;
|
2013-12-09 01:22:50 +04:00
|
|
|
bx_param_bool_c *bparam;
|
2009-03-10 22:33:03 +03:00
|
|
|
bx_param_string_c *sparam;
|
2010-04-22 21:30:11 +04:00
|
|
|
int j;
|
|
|
|
LRESULT val;
|
2009-03-15 19:24:54 +03:00
|
|
|
const char *src;
|
2009-03-12 22:40:41 +03:00
|
|
|
char buffer[512], rawbuf[512];
|
2009-03-15 19:24:54 +03:00
|
|
|
UINT cid, i, items, lid;
|
|
|
|
|
|
|
|
lid = findDlgListBaseID(list);
|
|
|
|
items = list->get_size();
|
2013-03-18 23:08:26 +04:00
|
|
|
if (list->get_options() & list->USE_SCROLL_WINDOW) {
|
|
|
|
hDlg = FindWindowEx(hDlg, NULL, "ScrollWin", NULL);
|
|
|
|
}
|
2009-03-15 19:24:54 +03:00
|
|
|
for (i = 0; i < items; i++) {
|
|
|
|
cid = lid + i;
|
|
|
|
param = list->get(i);
|
2009-03-22 23:18:17 +03:00
|
|
|
if (param->get_enabled() && (!SIM->get_init_done() || (SIM->get_init_done() && param->get_runtime_param()))) {
|
2009-03-18 10:59:04 +03:00
|
|
|
if (param->get_type() == BXT_LIST) {
|
|
|
|
SetParamList(hDlg, (bx_list_c*)param);
|
|
|
|
} else if (param->get_type() == BXT_PARAM_BOOL) {
|
2013-12-09 01:22:50 +04:00
|
|
|
val = (SendMessage(GetDlgItem(hDlg, ID_PARAM + cid), BM_GETCHECK, 0, 0) == BST_CHECKED);
|
|
|
|
bparam = (bx_param_bool_c*)param;
|
|
|
|
if (val != bparam->get()) {
|
|
|
|
bparam->set(val);
|
|
|
|
}
|
2009-03-18 10:59:04 +03:00
|
|
|
} else if (param->get_type() == BXT_PARAM_ENUM) {
|
|
|
|
eparam = (bx_param_enum_c*)param;
|
2013-12-09 01:22:50 +04:00
|
|
|
val = (LRESULT)(SendMessage(GetDlgItem(hDlg, ID_PARAM + cid), CB_GETCURSEL, 0, 0) + eparam->get_min());
|
|
|
|
if (val != eparam->get()) {
|
|
|
|
eparam->set(val);
|
|
|
|
}
|
2009-03-18 10:59:04 +03:00
|
|
|
} else {
|
|
|
|
if (SendMessage(GetDlgItem(hDlg, ID_PARAM + cid), EM_GETMODIFY, 0, 0)) {
|
|
|
|
if (param->get_type() == BXT_PARAM_NUM) {
|
|
|
|
nparam = (bx_param_num_c*)param;
|
|
|
|
if (nparam->get_base() == BASE_HEX) {
|
|
|
|
GetWindowText(GetDlgItem(hDlg, ID_PARAM + cid), buffer, 511);
|
|
|
|
sscanf(buffer, "%x", &val);
|
|
|
|
} else {
|
|
|
|
val = GetDlgItemInt(hDlg, ID_PARAM + cid, NULL, FALSE);
|
|
|
|
}
|
|
|
|
nparam->set(val);
|
|
|
|
} else if (param->get_type() == BXT_PARAM_STRING) {
|
2009-03-15 19:24:54 +03:00
|
|
|
GetWindowText(GetDlgItem(hDlg, ID_PARAM + cid), buffer, 511);
|
2009-03-18 10:59:04 +03:00
|
|
|
sparam = (bx_param_string_c*)param;
|
|
|
|
if (sparam->get_options() & sparam->RAW_BYTES) {
|
|
|
|
src = &buffer[0];
|
|
|
|
memset(rawbuf, 0, sparam->get_maxsize());
|
|
|
|
for (j = 0; j < sparam->get_maxsize(); j++) {
|
|
|
|
while (*src == sparam->get_separator())
|
|
|
|
src++;
|
|
|
|
if (*src == 0) break;
|
|
|
|
if (sscanf(src, "%02x", &val)) {
|
2010-11-23 17:59:36 +03:00
|
|
|
rawbuf[j] = (char) val;
|
2009-03-18 10:59:04 +03:00
|
|
|
src += 2;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
2009-03-15 19:24:54 +03:00
|
|
|
}
|
2009-03-18 10:59:04 +03:00
|
|
|
sparam->set(rawbuf);
|
|
|
|
} else {
|
|
|
|
sparam->set(buffer);
|
2009-03-15 19:24:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-03-30 00:48:17 +04:00
|
|
|
if ((i + 1) >= (UINT)list->get_size()) break;
|
2009-03-15 19:24:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShowParamList(HWND hDlg, UINT lid, BOOL show, bx_list_c *list)
|
|
|
|
{
|
|
|
|
UINT cid;
|
|
|
|
int i;
|
|
|
|
HWND Button, Updown;
|
2009-03-16 00:16:17 +03:00
|
|
|
BOOL ishow;
|
2009-03-15 19:24:54 +03:00
|
|
|
|
|
|
|
ShowWindow(GetDlgItem(hDlg, ID_PARAM + lid), show ? SW_SHOW : SW_HIDE);
|
|
|
|
cid = findDlgListBaseID(list);
|
|
|
|
for (i = 0; i < list->get_size(); i++) {
|
|
|
|
if (list->get(i)->get_type() == BXT_LIST) {
|
2009-03-16 00:16:17 +03:00
|
|
|
ishow = show;
|
|
|
|
if (list->get_options() & list->USE_TAB_WINDOW) {
|
|
|
|
ishow &= (i == 0);
|
|
|
|
}
|
|
|
|
ShowParamList(hDlg, cid + i, ishow, (bx_list_c*)list->get(i));
|
2009-03-15 19:24:54 +03:00
|
|
|
} else {
|
|
|
|
ShowWindow(GetDlgItem(hDlg, ID_LABEL + cid + i), show ? SW_SHOW : SW_HIDE);
|
|
|
|
ShowWindow(GetDlgItem(hDlg, ID_PARAM + cid + i), show ? SW_SHOW : SW_HIDE);
|
|
|
|
Button = GetDlgItem(hDlg, ID_BROWSE + cid + i);
|
|
|
|
if (Button != NULL) {
|
|
|
|
ShowWindow(Button, show ? SW_SHOW : SW_HIDE);
|
|
|
|
}
|
|
|
|
Updown = GetDlgItem(hDlg, ID_UPDOWN + cid + i);
|
|
|
|
if (Updown != NULL) {
|
|
|
|
ShowWindow(Updown, show ? SW_SHOW : SW_HIDE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-19 21:23:54 +03:00
|
|
|
void ProcessDependentList(HWND hDlg, bx_param_c *param, BOOL enabled)
|
2009-03-17 22:37:20 +03:00
|
|
|
{
|
|
|
|
UINT cid;
|
|
|
|
bx_list_c *deplist;
|
|
|
|
bx_param_c *dparam;
|
|
|
|
bx_param_enum_c *eparam;
|
|
|
|
Bit64s value;
|
|
|
|
Bit64u enable_bitmap, mask;
|
2009-03-29 15:13:49 +04:00
|
|
|
char buffer[BX_PATHNAME_LEN];
|
2009-03-17 22:37:20 +03:00
|
|
|
int i;
|
|
|
|
BOOL en;
|
|
|
|
|
2009-03-19 21:23:54 +03:00
|
|
|
deplist = param->get_dependent_list();
|
|
|
|
if (deplist != NULL) {
|
|
|
|
cid = findDlgIDFromParam(param);
|
|
|
|
if (param->get_type() == BXT_PARAM_ENUM) {
|
|
|
|
eparam = (bx_param_enum_c*)param;
|
|
|
|
value = SendMessage(GetDlgItem(hDlg, ID_PARAM + cid), CB_GETCURSEL, 0, 0);
|
|
|
|
enable_bitmap = eparam->get_dependent_bitmap(value + eparam->get_min());
|
|
|
|
mask = 0x1;
|
|
|
|
for (i = 0; i < deplist->get_size(); i++) {
|
|
|
|
dparam = deplist->get(i);
|
|
|
|
if (dparam != param) {
|
|
|
|
en = (enable_bitmap & mask) && enabled;
|
|
|
|
cid = findDlgIDFromParam(dparam);
|
2013-11-27 00:09:01 +04:00
|
|
|
if (cid != 0) {
|
|
|
|
if (en != IsWindowEnabled(GetDlgItem(hDlg, ID_PARAM + cid))) {
|
|
|
|
ProcessDependentList(hDlg, dparam, en);
|
|
|
|
EnableParam(hDlg, 0, dparam, en);
|
|
|
|
}
|
2009-03-17 22:37:20 +03:00
|
|
|
}
|
|
|
|
}
|
2009-03-19 21:23:54 +03:00
|
|
|
mask <<= 1;
|
2009-03-17 22:37:20 +03:00
|
|
|
}
|
2009-03-19 21:23:54 +03:00
|
|
|
} else if ((param->get_type() == BXT_PARAM_BOOL) ||
|
2009-03-29 15:13:49 +04:00
|
|
|
(param->get_type() == BXT_PARAM_NUM) ||
|
|
|
|
(param->get_type() == BXT_PARAM_STRING)) {
|
2009-03-19 21:23:54 +03:00
|
|
|
if (param->get_type() == BXT_PARAM_BOOL) {
|
|
|
|
value = SendMessage(GetDlgItem(hDlg, ID_PARAM + cid), BM_GETCHECK, 0, 0);
|
2009-03-29 15:13:49 +04:00
|
|
|
} else if (param->get_type() == BXT_PARAM_NUM) {
|
2009-03-19 21:23:54 +03:00
|
|
|
value = GetDlgItemInt(hDlg, ID_PARAM + cid, NULL, FALSE);
|
2009-03-29 15:13:49 +04:00
|
|
|
} else {
|
|
|
|
GetWindowText(GetDlgItem(hDlg, ID_PARAM + cid), buffer, BX_PATHNAME_LEN);
|
|
|
|
value = (lstrlen(buffer) > 0) && (strcmp(buffer, "none"));
|
2009-03-19 21:23:54 +03:00
|
|
|
}
|
|
|
|
for (i = 0; i < deplist->get_size(); i++) {
|
|
|
|
dparam = deplist->get(i);
|
|
|
|
if (dparam != param) {
|
|
|
|
en = (value && enabled);
|
|
|
|
cid = findDlgIDFromParam(dparam);
|
2013-11-27 00:09:01 +04:00
|
|
|
if (cid != 0) {
|
|
|
|
if (en != IsWindowEnabled(GetDlgItem(hDlg, ID_PARAM + cid))) {
|
|
|
|
ProcessDependentList(hDlg, dparam, en);
|
|
|
|
EnableParam(hDlg, 0, dparam, en);
|
|
|
|
}
|
2009-03-17 22:37:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-09 01:22:50 +04:00
|
|
|
void SetDefaultButtons(HWND Window, UINT xpos, UINT ypos)
|
|
|
|
{
|
|
|
|
RECT r;
|
|
|
|
|
|
|
|
r.left = xpos;
|
|
|
|
r.top = ypos;
|
|
|
|
r.right = r.left + 50;
|
|
|
|
r.bottom = r.top + 14;
|
|
|
|
MapDialogRect(Window, &r);
|
|
|
|
MoveWindow(GetDlgItem(Window, IDOK), r.left, r.top, r.right-r.left+1, r.bottom-r.top+1, FALSE);
|
|
|
|
r.left = xpos + 60;
|
|
|
|
r.top = ypos;
|
|
|
|
r.right = r.left + 50;
|
|
|
|
r.bottom = r.top + 14;
|
|
|
|
MapDialogRect(Window, &r);
|
|
|
|
MoveWindow(GetDlgItem(Window, IDCANCEL), r.left, r.top, r.right-r.left+1, r.bottom-r.top+1, FALSE);
|
|
|
|
}
|
|
|
|
|
2013-12-10 00:23:23 +04:00
|
|
|
void HandleOkCancel(HWND hDlg, UINT_PTR id, bx_list_c *list)
|
|
|
|
{
|
|
|
|
if (id == IDOK) {
|
|
|
|
SetParamList(hDlg, list);
|
|
|
|
}
|
|
|
|
cleanupDlgLists();
|
|
|
|
DestroyWindow(hwndTT);
|
|
|
|
EndDialog(hDlg, (id == IDOK) ? 1 : -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define BXPD_SET_PATH 1
|
|
|
|
#define BXPD_UPDATE_DEPS 2
|
|
|
|
|
|
|
|
UINT HandleChildWindowEvents(HWND hDlg, UINT_PTR id, UINT_PTR nc)
|
|
|
|
{
|
|
|
|
UINT i, ret = 0;
|
|
|
|
char fname[BX_PATHNAME_LEN];
|
|
|
|
|
|
|
|
if ((id >= ID_BROWSE) && (id < (ID_BROWSE + nextDlgID))) {
|
|
|
|
i = (UINT)(id - ID_BROWSE);
|
|
|
|
bx_param_string_c *sparam = (bx_param_string_c *)findParamFromDlgID(i);
|
|
|
|
if (sparam != NULL) {
|
|
|
|
GetDlgItemText(hDlg, ID_PARAM + i, fname, BX_PATHNAME_LEN);
|
|
|
|
if (AskFilename(hDlg, (bx_param_filename_c *)sparam, fname) > 0) {
|
|
|
|
SetWindowText(GetDlgItem(hDlg, ID_PARAM + i), fname);
|
|
|
|
SendMessage(GetDlgItem(hDlg, ID_PARAM + i), EM_SETMODIFY, 1, 0);
|
|
|
|
SetFocus(GetDlgItem(hDlg, ID_PARAM + i));
|
|
|
|
ret = BXPD_SET_PATH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if ((id >= ID_PARAM) && (id < (ID_PARAM + nextDlgID))) {
|
|
|
|
if ((nc == EN_CHANGE) || ((nc == CBN_SELCHANGE)) || (nc == BN_CLICKED)) {
|
|
|
|
i = (UINT)(id - ID_PARAM);
|
|
|
|
bx_param_c *param = findParamFromDlgID(i);
|
|
|
|
if (param != NULL) {
|
|
|
|
ProcessDependentList(hDlg, param, TRUE);
|
|
|
|
ret = BXPD_UPDATE_DEPS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-01-18 22:15:37 +03:00
|
|
|
static INT_PTR CALLBACK ParamDlgProc(HWND Window, UINT AMessage, WPARAM wParam, LPARAM lParam)
|
2009-03-15 19:24:54 +03:00
|
|
|
{
|
|
|
|
static bx_list_c *list = NULL;
|
2009-03-17 22:37:20 +03:00
|
|
|
bx_list_c *tmplist;
|
2010-04-22 21:30:11 +04:00
|
|
|
int cid;
|
2013-11-27 00:09:01 +04:00
|
|
|
UINT_PTR code, id, noticode;
|
2010-04-22 21:30:11 +04:00
|
|
|
UINT i, j, k;
|
2009-03-15 19:24:54 +03:00
|
|
|
RECT r, r2;
|
|
|
|
SIZE size;
|
2011-02-11 01:59:34 +03:00
|
|
|
NMHDR nmhdr;
|
2009-03-10 22:33:03 +03:00
|
|
|
|
|
|
|
switch (AMessage) {
|
|
|
|
case WM_CLOSE:
|
2013-12-10 00:23:23 +04:00
|
|
|
HandleOkCancel(Window, IDCANCEL, list);
|
2009-03-10 22:33:03 +03:00
|
|
|
break;
|
|
|
|
case WM_INITDIALOG:
|
2009-03-11 21:53:22 +03:00
|
|
|
list = (bx_list_c*)SIM->get_param((const char*)lParam);
|
2011-03-20 00:40:07 +03:00
|
|
|
SetWindowText(Window, list->get_title());
|
2009-03-15 19:24:54 +03:00
|
|
|
nextDlgID = 1;
|
|
|
|
size = CreateParamList(Window, 0, 6, 6, FALSE, list);
|
2013-12-09 01:22:50 +04:00
|
|
|
SetDefaultButtons(Window, size.cx / 2 - 50, size.cy + 12);
|
2009-03-15 19:24:54 +03:00
|
|
|
GetWindowRect(Window, &r2);
|
|
|
|
r.left = 0;
|
|
|
|
r.top = 0;
|
|
|
|
r.right = size.cx + 18;
|
|
|
|
r.bottom = size.cy + 52;
|
|
|
|
MapDialogRect(Window, &r);
|
|
|
|
MoveWindow(Window, r2.left, r2.top, r.right, r.bottom, TRUE);
|
2011-10-20 20:09:28 +04:00
|
|
|
CreateParamDlgTooltip(Window);
|
2009-03-10 22:33:03 +03:00
|
|
|
return TRUE;
|
|
|
|
case WM_COMMAND:
|
|
|
|
code = LOWORD(wParam);
|
2013-11-27 00:09:01 +04:00
|
|
|
noticode = HIWORD(wParam);
|
2009-03-10 22:33:03 +03:00
|
|
|
switch (code) {
|
|
|
|
case IDOK:
|
2013-12-10 00:23:23 +04:00
|
|
|
case IDCANCEL:
|
|
|
|
HandleOkCancel(Window, code, list);
|
2009-03-10 22:33:03 +03:00
|
|
|
break;
|
|
|
|
default:
|
2013-12-10 00:23:23 +04:00
|
|
|
HandleChildWindowEvents(Window, code, noticode);
|
2009-03-10 22:33:03 +03:00
|
|
|
}
|
|
|
|
break;
|
2009-03-15 19:24:54 +03:00
|
|
|
case WM_NOTIFY:
|
2011-02-11 01:59:34 +03:00
|
|
|
nmhdr = *(LPNMHDR)lParam;
|
|
|
|
code = nmhdr.code;
|
|
|
|
id = nmhdr.idFrom;
|
|
|
|
if (code == (UINT)TCN_SELCHANGE) {
|
|
|
|
j = (UINT)(id - ID_PARAM);
|
2009-03-15 19:24:54 +03:00
|
|
|
tmplist = (bx_list_c *)findParamFromDlgID(j);
|
|
|
|
if (tmplist != NULL) {
|
2011-02-11 01:59:34 +03:00
|
|
|
k = (UINT)TabCtrl_GetCurSel(GetDlgItem(Window, id));
|
2009-03-15 19:24:54 +03:00
|
|
|
cid = findDlgListBaseID(tmplist);
|
2011-01-18 22:15:37 +03:00
|
|
|
for (i = 0; i < (UINT)tmplist->get_size(); i++) {
|
2009-03-15 19:24:54 +03:00
|
|
|
ShowParamList(Window, cid + i, (i == k), (bx_list_c*)tmplist->get(i));
|
|
|
|
}
|
|
|
|
}
|
2011-02-11 01:59:34 +03:00
|
|
|
} else if (code == (UINT)UDN_DELTAPOS) {
|
|
|
|
if (id >= ID_UPDOWN) {
|
|
|
|
PostMessage(GetDlgItem(Window, ID_PARAM + (id - ID_UPDOWN)), EM_SETMODIFY, TRUE, 0);
|
|
|
|
}
|
2011-10-20 20:09:28 +04:00
|
|
|
} else {
|
|
|
|
OnWMNotify(lParam);
|
2009-03-15 19:24:54 +03:00
|
|
|
}
|
|
|
|
break;
|
2009-03-10 22:33:03 +03:00
|
|
|
case WM_CTLCOLOREDIT:
|
|
|
|
SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
|
2011-01-18 22:15:37 +03:00
|
|
|
return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
|
2009-03-10 22:33:03 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-12-09 01:22:50 +04:00
|
|
|
BOOL CreateImage(HWND hDlg, int sectors, const char *filename)
|
|
|
|
{
|
|
|
|
if (sectors < 1) {
|
|
|
|
MessageBox(hDlg, "The disk size is invalid.", "Invalid size", MB_ICONERROR);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (lstrlen(filename) < 1) {
|
|
|
|
MessageBox(hDlg, "You must type a file name for the new disk image.", "Bad filename", MB_ICONERROR);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
int ret = SIM->create_disk_image (filename, sectors, 0);
|
|
|
|
if (ret == -1) { // already exists
|
|
|
|
int answer = MessageBox(hDlg, "File exists. Do you want to overwrite it?",
|
|
|
|
"File exists", MB_YESNO);
|
|
|
|
if (answer == IDYES)
|
|
|
|
ret = SIM->create_disk_image (filename, sectors, 1);
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (ret == -2) {
|
|
|
|
MessageBox(hDlg, "I could not create the disk image. Check for permission problems or available disk space.", "Failed", MB_ICONERROR);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT_PTR CALLBACK FloppyParamDlgProc(HWND Window, UINT AMessage, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
static bx_list_c *list = NULL;
|
2013-12-10 00:23:23 +04:00
|
|
|
static UINT path_id, type_id, status_id;
|
2013-12-09 01:22:50 +04:00
|
|
|
bx_param_enum_c *status;
|
2013-12-10 00:23:23 +04:00
|
|
|
UINT_PTR code, noticode;
|
|
|
|
UINT ret;
|
2013-12-09 01:22:50 +04:00
|
|
|
int i;
|
|
|
|
RECT r, r2;
|
|
|
|
SIZE size;
|
|
|
|
char mesg[MAX_PATH];
|
|
|
|
char path[MAX_PATH];
|
|
|
|
|
|
|
|
switch (AMessage) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
list = (bx_list_c*)SIM->get_param((const char*)lParam);
|
|
|
|
SetWindowText(Window, list->get_title());
|
|
|
|
nextDlgID = 1;
|
|
|
|
size = CreateParamList(Window, 0, 6, 6, FALSE, list);
|
|
|
|
CreateLabel(Window, 99, 60, size.cy + 12, 160, FALSE,
|
|
|
|
"Clicking OK signals a media change for this drive.");
|
|
|
|
CreateButton(Window, IDCREATE, size.cx / 2 - 85, size.cy + 30, FALSE, "Create Image");
|
|
|
|
SetDefaultButtons(Window, size.cx / 2 - 25, size.cy + 30);
|
|
|
|
GetWindowRect(Window, &r2);
|
|
|
|
r.left = 0;
|
|
|
|
r.top = 0;
|
|
|
|
r.right = size.cx + 18;
|
|
|
|
r.bottom = size.cy + 70;
|
|
|
|
MapDialogRect(Window, &r);
|
|
|
|
MoveWindow(Window, r2.left, r2.top, r.right, r.bottom, TRUE);
|
|
|
|
CreateParamDlgTooltip(Window);
|
|
|
|
path_id = findDlgIDFromParam(list->get_by_name("path")) + ID_PARAM;
|
|
|
|
type_id = findDlgIDFromParam(list->get_by_name("type")) + ID_PARAM;
|
2013-12-10 00:23:23 +04:00
|
|
|
status_id = findDlgIDFromParam(list->get_by_name("status")) + ID_PARAM;
|
2013-12-09 01:22:50 +04:00
|
|
|
return TRUE;
|
|
|
|
case WM_COMMAND:
|
|
|
|
code = LOWORD(wParam);
|
2013-12-10 00:23:23 +04:00
|
|
|
noticode = HIWORD(wParam);
|
2013-12-09 01:22:50 +04:00
|
|
|
switch (code) {
|
|
|
|
case IDOK:
|
|
|
|
// force a media change
|
|
|
|
status = (bx_param_enum_c*)list->get_by_name("status");
|
|
|
|
status->set(BX_EJECTED);
|
2013-12-10 00:23:23 +04:00
|
|
|
case IDCANCEL:
|
|
|
|
HandleOkCancel(Window, code, list);
|
2013-12-09 01:22:50 +04:00
|
|
|
break;
|
|
|
|
case IDCREATE:
|
|
|
|
GetDlgItemText(Window, path_id, path, MAX_PATH);
|
|
|
|
backslashes(path);
|
|
|
|
i = SendMessage(GetDlgItem(Window, type_id), CB_GETCURSEL, 0, 0);
|
|
|
|
if (CreateImage(Window, floppy_type_n_sectors[i], path)) {
|
|
|
|
wsprintf(mesg, "Created a %s disk image called %s", floppy_type_names[i], path);
|
|
|
|
MessageBox(Window, mesg, "Image created", MB_OK);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
2013-12-10 00:23:23 +04:00
|
|
|
ret = HandleChildWindowEvents(Window, code, noticode);
|
|
|
|
if (ret == BXPD_SET_PATH) {
|
|
|
|
SendMessage(GetDlgItem(Window, status_id), BM_SETCHECK, BST_CHECKED, 0);
|
|
|
|
SendMessage(GetDlgItem(Window, type_id), CB_SELECTSTRING, (WPARAM)-1, (LPARAM)"auto");
|
|
|
|
EnableWindow(GetDlgItem(Window, IDCREATE), FALSE);
|
|
|
|
} else if (ret == BXPD_UPDATE_DEPS) {
|
|
|
|
if (code == path_id) {
|
|
|
|
EnableWindow(GetDlgItem(Window, IDCREATE), IsWindowEnabled(GetDlgItem(Window, type_id)));
|
|
|
|
} else if (code == type_id) {
|
|
|
|
i = SendMessage(GetDlgItem(Window, type_id), CB_GETCURSEL, 0, 0);
|
|
|
|
EnableWindow(GetDlgItem(Window, IDCREATE), (i != 0));
|
|
|
|
}
|
2013-12-09 01:22:50 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_CLOSE:
|
|
|
|
case WM_NOTIFY:
|
|
|
|
case WM_CTLCOLOREDIT:
|
|
|
|
return ParamDlgProc(Window, AMessage, wParam, lParam);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-11-10 21:36:13 +04:00
|
|
|
INT_PTR win32ParamDialog(HWND parent, const char *menu)
|
2009-03-10 22:33:03 +03:00
|
|
|
{
|
|
|
|
InitDlgFont();
|
2013-03-18 23:08:26 +04:00
|
|
|
RegisterScrollWindow(NULL);
|
2013-11-10 21:36:13 +04:00
|
|
|
INT_PTR ret = DialogBoxParam(NULL, MAKEINTRESOURCE(PARAM_DLG), parent, (DLGPROC)ParamDlgProc, (LPARAM)menu);
|
2009-03-10 22:33:03 +03:00
|
|
|
DeleteObject(DlgFont);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-12-09 01:22:50 +04:00
|
|
|
INT_PTR win32FloppyParamDialog(HWND parent, const char *menu)
|
|
|
|
{
|
|
|
|
InitDlgFont();
|
|
|
|
RegisterScrollWindow(NULL);
|
|
|
|
INT_PTR ret = DialogBoxParam(NULL, MAKEINTRESOURCE(PARAM_DLG), parent, (DLGPROC)FloppyParamDlgProc, (LPARAM)menu);
|
|
|
|
DeleteObject(DlgFont);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-03-10 22:33:03 +03:00
|
|
|
#endif // BX_USE_TEXTCONFIG && defined(WIN32)
|