📄 stdprop.c
字号:
/*
Copyright 2001-2003 Free Software Foundation, Inc.
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.
You may contact the author at:
mailto::camille@bluegrass.net
or by snail mail at:
David Lindauer
850 Washburn Ave Apt 99
Louisville, KY 40222
**********************************************************************
STDPROP.C holds the general properties dialog which is selected from the
'properties' item on the file menu, as well as the target properties dialog
which is selectable from the build window
**********************************************************************
*/
//
// MODTOOL
//
// Copyright (c) !998 David Lindauer (LADSOFT)
//
// see license.txt for licensing info
//
// ==============================================================
//
// PROPERTY.CPP
//
// property sheet handling
//
// each page in a property sheet is a rather boring dialog box
// which hooks WM_NOTIFY messages for the activity.
//
// I'm not commenting the dialog box internals as they are all straightforward
//
#define STRICT
#include <windows.h>
#include <commdlg.h>
#include <commctrl.h>
#include <prsht.h>
#include <stdio.h>
#include "winconst.h"
#include "header.h"
extern HWND hwndFrame;
extern PROJLIST *projectList;
extern LOGFONT EditFont;
extern HINSTANCE hInstance;
extern char szHelpPath[];
extern int HelpMode;
extern COLORREF keywordColor;
extern COLORREF numberColor;
extern COLORREF commentColor;
extern COLORREF stringColor;
extern COLORREF escapeColor;
extern COLORREF backgroundColor;
extern COLORREF textColor;
extern int tabs, editFlags;
extern char szInstallPath[];
extern int changedProject;
int custColors[16];
int browseInfo;
static HWND definehWnd;
static int defineSelected;
static int custColorsTemp[16];
static int browseInfoTemp;
static char szHelpPathTemp[1024];
static int HelpModeTemp;
static COLORREF keywordColorTemp;
static COLORREF numberColorTemp;
static COLORREF commentColorTemp;
static COLORREF stringColorTemp;
static COLORREF escapeColorTemp;
static COLORREF backgroundColorTemp;
static COLORREF textColorTemp;
static int tabsTemp, editFlagsTemp;
static char szInstallPathTemp[1024];
LRESULT CALLBACK _export colorProc(HWND hwnd, UINT iMessage, WPARAM wParam,
LPARAM lParam)
{
HDC dc;
PAINTSTRUCT paint;
RECT r;
LOGBRUSH l;
HBRUSH b;
CHOOSECOLOR c;
switch (iMessage)
{
case WM_SETCOLOR:
SetWindowLong(hwnd, 0, lParam);
InvalidateRect(hwnd, 0, 0);
break;
case WM_PAINT:
dc = BeginPaint(hwnd, &paint);
GetClientRect(hwnd, &r);
l.lbStyle = BS_SOLID;
l.lbColor = GetWindowLong(hwnd, 0);
b = CreateBrushIndirect(&l);
FillRect(dc, &r, b);
DeleteObject(b);
EndPaint(hwnd, &paint);
break;
case WM_LBUTTONDOWN:
memset(&c, 0, sizeof(c));
c.lStructSize = sizeof(CHOOSECOLOR);
c.hwndOwner = hwnd;
c.rgbResult = GetWindowLong(hwnd, 0);
c.lpCustColors = custColorsTemp;
c.Flags = CC_RGBINIT;
if (ChooseColor(&c))
{
SetWindowLong(hwnd, 0, c.rgbResult);
InvalidateRect(hwnd, 0, 0);
}
else
CommDlgExtendedError();
return 0;
case WM_RETRIEVECOLOR:
return GetWindowLong(hwnd, 0);
case WM_CREATE:
SetWindowLong(hwnd, 0, 0);
InvalidateRect(hwnd, 0, 0);
break;
case WM_DESTROY:
break;
}
DefWindowProc(hwnd, iMessage, wParam, lParam);
}
//-------------------------------------------------------------------------
void RegisterColorWindow(void)
{
WNDCLASS wc;
memset(&wc, 0, sizeof(wc));
wc.style = 0;
wc.lpfnWndProc = &colorProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(void*);
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hbrBackground = 0;
wc.lpszMenuName = 0;
wc.lpszClassName = "xccColorClass";
RegisterClass(&wc);
}
// ==============================================================
//
// property sheet constant names
//
#define EDIT_PROPERTY_SHEET_COUNT 3
#define EDITPROP 0
#define GENERALPROP 1
#define INSTALLPROP 2
static PROPSHEETPAGE editPages[EDIT_PROPERTY_SHEET_COUNT];
// the page structures
static PROPSHEETHEADER editHeader; // the header structure
// ==============================================================
//
// routine to set the result from the killactive notify message
static void SetResult(HWND hwnd, int value)
{
SetWindowLong(hwnd, DWL_MSGRESULT, value);
}
//-------------------------------------------------------------------------
void SetColor(HWND hwnd, int control, int color)
{
SendMessage(GetDlgItem(hwnd, control), WM_SETCOLOR, 0, color);
}
//-------------------------------------------------------------------------
int GetColor(HWND hwnd, int control)
{
SendMessage(GetDlgItem(hwnd, control), WM_RETRIEVECOLOR, 0, 0);
}
// ==============================================================
//
static int FAR PASCAL EditProc(HWND hwnd, UINT wmsg, WPARAM wparam, LPARAM
lparam)
{
NMHDR *nmhead;
static CHOOSEFONT ch;
static LOGFONT lf;
switch (wmsg)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch (wparam)
{
case IDC_SELECTFONT:
memset(&ch, 0, sizeof(ch));
memcpy(&lf, &EditFont, sizeof(lf));
ch.lStructSize = sizeof(ch);
ch.hwndOwner = 0;
ch.lpLogFont = &lf;
ch.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST |
CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
if (ChooseFont(&ch))
ApplyFontSettings(ch.lpLogFont);
break;
}
break;
case WM_NOTIFY:
nmhead = (NMHDR*)lparam;
switch (nmhead->code)
{
case PSN_SETACTIVE:
/* page startup */
NewFocus(hwnd, IDC_TABSTOPS);
SetEditFieldValue(hwnd, IDC_TABSTOPS, tabsTemp);
SetColor(hwnd, IDC_KEYWORDCOLOR, keywordColorTemp);
SetColor(hwnd, IDC_COMMENTCOLOR, commentColorTemp);
SetColor(hwnd, IDC_NUMBERCOLOR, numberColorTemp);
SetColor(hwnd, IDC_STRINGCOLOR, stringColorTemp);
SetColor(hwnd, IDC_ESCAPECOLOR, escapeColorTemp);
SetColor(hwnd, IDC_BACKGROUNDCOLOR, backgroundColorTemp);
SetColor(hwnd, IDC_TEXTCOLOR, textColorTemp);
SetCBField(hwnd, IDC_BACKUPFILE, !!(editFlagsTemp &BACKUP_FILES)
);
SetCBField(hwnd, IDC_BACKUPPROJ, !!(editFlagsTemp
&BACKUP_PROJECTS));
SetCBField(hwnd, IDC_TABSASSPACES, !!(editFlagsTemp
&TABS_AS_SPACES));
SetCBField(hwnd, IDC_AUTOINDENT, !(editFlagsTemp &AUTO_INDENT));
SetCBField(hwnd, IDC_AUTOFORMAT, !(editFlagsTemp &AUTO_FORMAT));
break;
case PSN_KILLACTIVE:
/* verify ok always */
tabsTemp = GetEditFieldValue(hwnd, IDC_TABSTOPS);
keywordColorTemp = GetColor(hwnd, IDC_KEYWORDCOLOR);
commentColorTemp = GetColor(hwnd, IDC_COMMENTCOLOR);
numberColorTemp = GetColor(hwnd, IDC_NUMBERCOLOR);
stringColorTemp = GetColor(hwnd, IDC_STRINGCOLOR);
escapeColorTemp = GetColor(hwnd, IDC_ESCAPECOLOR);
backgroundColorTemp = GetColor(hwnd, IDC_BACKGROUNDCOLOR);
textColorTemp = GetColor(hwnd, IDC_TEXTCOLOR);
editFlagsTemp &= !(BACKUP_FILES | BACKUP_PROJECTS |
TABS_AS_SPACES | AUTO_FORMAT | AUTO_INDENT);
editFlagsTemp |= GetCBField(hwnd, IDC_BACKUPFILE) ?
BACKUP_FILES : 0;
editFlagsTemp |= GetCBField(hwnd, IDC_BACKUPPROJ) ?
BACKUP_PROJECTS : 0;
editFlagsTemp |= GetCBField(hwnd, IDC_TABSASSPACES) ?
TABS_AS_SPACES : 0;
editFlagsTemp |= GetCBField(hwnd, IDC_AUTOINDENT) ? 0 :
AUTO_INDENT;
editFlagsTemp |= GetCBField(hwnd, IDC_AUTOFORMAT) ? 0 :
AUTO_FORMAT;
SetResult(hwnd, FALSE);
break;
case PSN_APPLY:
/* Page application */
tabs = tabsTemp;
keywordColor = keywordColorTemp;
commentColor = commentColorTemp;
numberColor = numberColorTemp;
stringColor = stringColorTemp;
escapeColor = escapeColorTemp;
backgroundColor = backgroundColorTemp;
textColor = textColorTemp;
editFlags = editFlagsTemp;
memcpy(custColors, custColorsTemp, sizeof(custColors));
ApplyEditSettings();
IntToProfile("EditFlags",editFlags) ;
break;
case PSN_HELP:
ContextHelp(120);
break;
}
break;
}
return FALSE;
}
//-------------------------------------------------------------------------
static int FAR PASCAL GeneralProc(HWND hwnd, UINT wmsg, WPARAM wparam, LPARAM
lparam)
{
NMHDR *nmhead;
int len;
switch (wmsg)
{
case WM_INITDIALOG:
return TRUE;
case WM_NOTIFY:
nmhead = (NMHDR*)lparam;
switch (nmhead->code)
{
case PSN_SETACTIVE:
/* page startup */
NewFocus(hwnd, IDC_BROWSEINFO);
SetCBField(hwnd, IDC_BROWSEINFO, browseInfoTemp);
break;
case PSN_KILLACTIVE:
/* verify ok always */
browseInfoTemp = GetCBField(hwnd, IDC_BROWSEINFO);
SetResult(hwnd, FALSE);
break;
case PSN_APPLY:
/* Page application */
browseInfo = browseInfoTemp;
break;
case PSN_HELP:
ContextHelp(125);
break;
}
break;
}
return FALSE;
}
//-------------------------------------------------------------------------
static int FAR PASCAL InstallProc(HWND hwnd, UINT wmsg, WPARAM wparam, LPARAM
lparam)
{
NMHDR *nmhead;
int len;
switch (wmsg)
{
case WM_INITDIALOG:
return TRUE;
case WM_NOTIFY:
nmhead = (NMHDR*)lparam;
switch (nmhead->code)
{
case PSN_SETACTIVE:
/* page startup */
NewFocus(hwnd, IDC_INSTALLPATH);
SetEditField(hwnd, IDC_INSTALLPATH, szInstallPathTemp);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -