mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 00:54:40 +00:00
Added framework for new application - calc.
svn path=/trunk/; revision=3239
This commit is contained in:
parent
3c63d04d0d
commit
8e12d121dc
9 changed files with 845 additions and 0 deletions
210
rosapps/calc/button.c
Normal file
210
rosapps/calc/button.c
Normal file
|
@ -0,0 +1,210 @@
|
|||
/*
|
||||
* ReactOS calc
|
||||
*
|
||||
* button.c
|
||||
*
|
||||
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
||||
*
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include "button.h"
|
||||
|
||||
|
||||
COLORREF text_colour;
|
||||
COLORREF background_colour;
|
||||
COLORREF disabled_background_colour;
|
||||
COLORREF light;
|
||||
COLORREF highlight;
|
||||
COLORREF shadow;
|
||||
COLORREF dark_shadow;
|
||||
|
||||
const COLORREF CLR_BTN_WHITE = RGB(255, 255, 255);
|
||||
const COLORREF CLR_BTN_BLACK = RGB(0, 0, 0);
|
||||
const COLORREF CLR_BTN_DGREY = RGB(128, 128, 128);
|
||||
const COLORREF CLR_BTN_GREY = RGB(192, 192, 192);
|
||||
const COLORREF CLR_BTN_LLGREY = RGB(223, 223, 223);
|
||||
|
||||
const int BUTTON_IN = 0x01;
|
||||
const int BUTTON_OUT = 0x02;
|
||||
const int BUTTON_BLACK_BORDER = 0x04;
|
||||
|
||||
|
||||
void InitColours(void)
|
||||
{
|
||||
// text_colour = GetSysColor(COLOR_BTNTEXT);
|
||||
text_colour = RGB(255,0,0);
|
||||
|
||||
background_colour = GetSysColor(COLOR_BTNFACE);
|
||||
disabled_background_colour = background_colour;
|
||||
light = GetSysColor(COLOR_3DLIGHT);
|
||||
highlight = GetSysColor(COLOR_BTNHIGHLIGHT);
|
||||
shadow = GetSysColor(COLOR_BTNSHADOW);
|
||||
dark_shadow = GetSysColor(COLOR_3DDKSHADOW);
|
||||
}
|
||||
|
||||
static void FillSolidRect(HDC hDC, int x, int y, int cx, int cy, COLORREF clr)
|
||||
{
|
||||
RECT rect;
|
||||
|
||||
SetBkColor(hDC, clr);
|
||||
rect.left = x;
|
||||
rect.top = y;
|
||||
rect.right = x + cx;
|
||||
rect.bottom = y + cy;
|
||||
ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
void Draw3dRect(HDC hDC, int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight)
|
||||
{
|
||||
FillSolidRect(hDC, x, y, cx - 1, 1, clrTopLeft);
|
||||
FillSolidRect(hDC, x, y, 1, cy - 1, clrTopLeft);
|
||||
FillSolidRect(hDC, x + cx, y, -1, cy, clrBottomRight);
|
||||
FillSolidRect(hDC, x, y + cy, cx, -1, clrBottomRight);
|
||||
}
|
||||
|
||||
|
||||
void DrawFilledRect(HDC hdc, LPRECT r, COLORREF colour)
|
||||
{
|
||||
HBRUSH hBrush;
|
||||
|
||||
hBrush = CreateSolidBrush(colour);
|
||||
FillRect(hdc, r, hBrush);
|
||||
}
|
||||
|
||||
void DrawLine(HDC hdc, long sx, long sy, long ex, long ey, COLORREF colour)
|
||||
{
|
||||
HPEN new_pen;
|
||||
HPEN old_pen;
|
||||
|
||||
new_pen = CreatePen(PS_SOLID, 1, colour);
|
||||
old_pen = SelectObject(hdc, &new_pen);
|
||||
MoveToEx(hdc, sx, sy, NULL);
|
||||
LineTo(hdc, ex, ey);
|
||||
SelectObject(hdc, old_pen);
|
||||
DeleteObject(new_pen);
|
||||
}
|
||||
|
||||
void DrawFrame(HDC hdc, RECT r, int state)
|
||||
{
|
||||
COLORREF colour;
|
||||
|
||||
if (state & BUTTON_BLACK_BORDER) {
|
||||
colour = CLR_BTN_BLACK;
|
||||
DrawLine(hdc, r.left, r.top, r.right, r.top, colour); // Across top
|
||||
DrawLine(hdc, r.left, r.top, r.left, r.bottom, colour); // Down left
|
||||
DrawLine(hdc, r.left, r.bottom - 1, r.right, r.bottom - 1, colour); // Across bottom
|
||||
DrawLine(hdc, r.right - 1, r.top, r.right - 1, r.bottom, colour); // Down right
|
||||
InflateRect(&r, -1, -1);
|
||||
}
|
||||
if (state & BUTTON_OUT) {
|
||||
colour = highlight;
|
||||
DrawLine(hdc, r.left, r.top, r.right, r.top, colour); // Across top
|
||||
DrawLine(hdc, r.left, r.top, r.left, r.bottom, colour); // Down left
|
||||
colour = dark_shadow;
|
||||
DrawLine(hdc, r.left, r.bottom - 1, r.right, r.bottom - 1, colour); // Across bottom
|
||||
DrawLine(hdc, r.right - 1, r.top, r.right - 1, r.bottom, colour); // Down right
|
||||
InflateRect(&r, -1, -1);
|
||||
colour = light;
|
||||
DrawLine(hdc, r.left, r.top, r.right, r.top, colour); // Across top
|
||||
DrawLine(hdc, r.left, r.top, r.left, r.bottom, colour); // Down left
|
||||
colour = shadow;
|
||||
DrawLine(hdc, r.left, r.bottom - 1, r.right, r.bottom - 1, colour); // Across bottom
|
||||
DrawLine(hdc, r.right - 1, r.top, r.right - 1, r.bottom, colour); // Down right
|
||||
}
|
||||
if (state & BUTTON_IN) {
|
||||
colour = dark_shadow;
|
||||
DrawLine(hdc, r.left, r.top, r.right, r.top, colour); // Across top
|
||||
DrawLine(hdc, r.left, r.top, r.left, r.bottom, colour); // Down left
|
||||
DrawLine(hdc, r.left, r.bottom - 1, r.right, r.bottom - 1, colour); // Across bottom
|
||||
DrawLine(hdc, r.right - 1, r.top, r.right - 1, r.bottom, colour); // Down right
|
||||
InflateRect(&r, -1, -1);
|
||||
colour = shadow;
|
||||
DrawLine(hdc, r.left, r.top, r.right, r.top, colour); // Across top
|
||||
DrawLine(hdc, r.left, r.top, r.left, r.bottom, colour); // Down left
|
||||
DrawLine(hdc, r.left, r.bottom - 1, r.right, r.bottom - 1, colour); // Across bottom
|
||||
DrawLine(hdc, r.right - 1, r.top, r.right - 1, r.bottom, colour); // Down right
|
||||
}
|
||||
}
|
||||
|
||||
void DrawButtonText(HDC hdc, LPRECT r, LPCTSTR Buf, COLORREF text_colour)
|
||||
{
|
||||
COLORREF previous_colour;
|
||||
|
||||
previous_colour = SetTextColor(hdc, text_colour);
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
DrawText(hdc, Buf, _tcslen(Buf), r, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
|
||||
SetTextColor(hdc, previous_colour);
|
||||
}
|
||||
|
||||
#define bufSize 512
|
||||
|
||||
void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
|
||||
{
|
||||
HDC hdc;
|
||||
RECT focus_rect, button_rect, offset_button_rect;
|
||||
UINT state;
|
||||
TCHAR buffer[bufSize];
|
||||
|
||||
hdc = lpDrawItemStruct->hDC;
|
||||
state = lpDrawItemStruct->itemState;
|
||||
|
||||
CopyRect(&focus_rect, &lpDrawItemStruct->rcItem);
|
||||
CopyRect(&button_rect, &lpDrawItemStruct->rcItem);
|
||||
|
||||
// Set the focus rectangle to just past the border decoration
|
||||
focus_rect.left += 4;
|
||||
focus_rect.right -= 4;
|
||||
focus_rect.top += 4;
|
||||
focus_rect.bottom -= 4;
|
||||
|
||||
// Retrieve the button's caption
|
||||
GetWindowText(lpDrawItemStruct->hwndItem, buffer, bufSize);
|
||||
|
||||
if (state & ODS_DISABLED) {
|
||||
DrawFilledRect(hdc, &button_rect, disabled_background_colour);
|
||||
} else {
|
||||
DrawFilledRect(hdc, &button_rect, background_colour);
|
||||
}
|
||||
|
||||
if (state & ODS_SELECTED) {
|
||||
DrawFrame(hdc, button_rect, BUTTON_IN);
|
||||
} else {
|
||||
if ((state & ODS_DEFAULT) || (state & ODS_FOCUS)) {
|
||||
DrawFrame(hdc, button_rect, BUTTON_OUT | BUTTON_BLACK_BORDER);
|
||||
} else {
|
||||
DrawFrame(hdc, button_rect, BUTTON_OUT);
|
||||
}
|
||||
}
|
||||
|
||||
if (state & ODS_DISABLED) {
|
||||
offset_button_rect = button_rect;
|
||||
OffsetRect(&offset_button_rect, 1, 1);
|
||||
DrawButtonText(hdc, &offset_button_rect, buffer, CLR_BTN_WHITE);
|
||||
DrawButtonText(hdc, &button_rect, buffer, CLR_BTN_DGREY);
|
||||
} else {
|
||||
DrawButtonText(hdc, &button_rect, buffer, text_colour);
|
||||
}
|
||||
|
||||
if (state & ODS_FOCUS) {
|
||||
DrawFocusRect(lpDrawItemStruct->hDC, (LPRECT)&focus_rect);
|
||||
}
|
||||
}
|
||||
|
||||
|
44
rosapps/calc/button.h
Normal file
44
rosapps/calc/button.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* ReactOS calc
|
||||
*
|
||||
* button.h
|
||||
*
|
||||
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
||||
*
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef __BUTTON_H__
|
||||
#define __BUTTON_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
void InitColours(void);
|
||||
void Draw3dRect(HDC hDC, int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight);
|
||||
void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // __BUTTON_H__
|
164
rosapps/calc/calc.rc
Normal file
164
rosapps/calc/calc.rc
Normal file
|
@ -0,0 +1,164 @@
|
|||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#define APSTUDIO_HIDDEN_SYMBOLS
|
||||
#include "windows.h"
|
||||
#undef APSTUDIO_HIDDEN_SYMBOLS
|
||||
#include "resource.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (Australia) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_CALC_STANDARD MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&Edit"
|
||||
BEGIN
|
||||
MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY
|
||||
MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE
|
||||
END
|
||||
POPUP "&View"
|
||||
BEGIN
|
||||
MENUITEM "S&tandard", ID_VIEW_STANDARD, CHECKED
|
||||
MENUITEM "&Scientific", ID_VIEW_SCIENTIFIC
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "D&igit grouping", ID_VIEW_DIGIT_GROUPING
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&Help Topics", ID_HELP_TOPICS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&About Calculator", ID_HELP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
IDR_CALC_SCIENTIFIC MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&Edit"
|
||||
BEGIN
|
||||
MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY
|
||||
MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE
|
||||
END
|
||||
POPUP "&View"
|
||||
BEGIN
|
||||
MENUITEM "S&tandard", ID_VIEW_STANDARD
|
||||
MENUITEM "&Scientific", ID_VIEW_SCIENTIFIC, CHECKED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "D&igit grouping", ID_VIEW_DIGIT_GROUPING
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&Help Topics", ID_HELP_TOPICS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&About Calculator", ID_HELP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_STANDARD DIALOG DISCARDABLE 0, 0, 207, 160
|
||||
STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "ReactOS Calculator"
|
||||
MENU IDR_CALC_STANDARD
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
CONTROL "1",IDC_BUTTON1,"Button",BS_OWNERDRAW | WS_TABSTOP,47,99,
|
||||
19,17
|
||||
CONTROL "2",IDC_BUTTON2,"Button",BS_OWNERDRAW | WS_TABSTOP,69,99,
|
||||
19,17
|
||||
EDITTEXT IDC_EDIT1,7,7,193,15,ES_RIGHT | ES_AUTOHSCROLL |
|
||||
ES_WANTRETURN
|
||||
END
|
||||
|
||||
IDD_SCIENTIFIC DIALOG DISCARDABLE 0, 0, 325, 156
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "ReactOS Calculator"
|
||||
MENU IDR_CALC_SCIENTIFIC
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
CONTROL "1",IDC_BUTTON1,"Button",BS_OWNERDRAW | WS_TABSTOP,47,99,
|
||||
19,17
|
||||
CONTROL "2",IDC_BUTTON2,"Button",BS_OWNERDRAW | WS_TABSTOP,69,99,
|
||||
19,17
|
||||
EDITTEXT IDC_EDIT1,7,7,310,15,ES_RIGHT | ES_AUTOHSCROLL |
|
||||
ES_WANTRETURN
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_STANDARD, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 200
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 153
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // English (Australia) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
201
rosapps/calc/main.c
Normal file
201
rosapps/calc/main.c
Normal file
|
@ -0,0 +1,201 @@
|
|||
/*
|
||||
* ReactOS calc
|
||||
*
|
||||
* calc.c
|
||||
*
|
||||
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
||||
*
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "button.h"
|
||||
#include "settings.h"
|
||||
|
||||
|
||||
// Global Variables:
|
||||
HINSTANCE hInst;
|
||||
HWND hDlgWnd;
|
||||
CALC_TYPES CalcType;
|
||||
|
||||
BOOL bDigitGrouping = FALSE;
|
||||
|
||||
|
||||
#define BEGIN_CMD_MAP(a) switch(##a) {
|
||||
#define CMD_MAP_ENTRY(a, b) case a: b(); break;
|
||||
#define END_CMD_MAP(a) }
|
||||
|
||||
|
||||
BOOL OnCreate(HWND hWnd)
|
||||
{
|
||||
HMENU hMenu;
|
||||
HMENU hViewMenu;
|
||||
|
||||
hMenu = GetMenu(hDlgWnd);
|
||||
hViewMenu = GetSubMenu(hMenu, ID_MENU_VIEW);
|
||||
if (bDigitGrouping) {
|
||||
CheckMenuItem(hViewMenu, ID_VIEW_DIGIT_GROUPING, MF_BYCOMMAND|MF_CHECKED);
|
||||
}
|
||||
|
||||
//SendMessage(hDlgWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(IDI_CALC)));
|
||||
|
||||
// Initialize the Windows Common Controls DLL
|
||||
//InitCommonControls();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void OnEditCopy(void)
|
||||
{
|
||||
SendMessage(GetDlgItem(hDlgWnd, IDC_EDIT1), WM_COMMAND, MAKELONG(ID_EDIT_COPY, 0), 0);
|
||||
}
|
||||
|
||||
void OnEditPaste(void)
|
||||
{
|
||||
SendMessage(GetDlgItem(hDlgWnd, IDC_EDIT1), WM_COMMAND, MAKELONG(ID_EDIT_PASTE, 0), 0);
|
||||
}
|
||||
|
||||
void OnViewStandard(void)
|
||||
{
|
||||
CalcType = STANDARD;
|
||||
DestroyWindow(hDlgWnd);
|
||||
}
|
||||
|
||||
void OnViewScientific(void)
|
||||
{
|
||||
CalcType = SCIENTIFIC;
|
||||
DestroyWindow(hDlgWnd);
|
||||
}
|
||||
|
||||
void OnViewDigitGrouping(void)
|
||||
{
|
||||
HMENU hMenu = GetMenu(hDlgWnd);
|
||||
HMENU hViewMenu = GetSubMenu(hMenu, ID_MENU_VIEW);
|
||||
bDigitGrouping = !bDigitGrouping;
|
||||
if (bDigitGrouping) {
|
||||
CheckMenuItem(hViewMenu, ID_VIEW_DIGIT_GROUPING, MF_BYCOMMAND|MF_CHECKED);
|
||||
} else {
|
||||
CheckMenuItem(hViewMenu, ID_VIEW_DIGIT_GROUPING, MF_BYCOMMAND|MF_UNCHECKED);
|
||||
}
|
||||
}
|
||||
|
||||
void OnHelpTopics(void)
|
||||
{
|
||||
WinHelp(hDlgWnd, _T("calc"), HELP_CONTENTS, 0);
|
||||
}
|
||||
|
||||
void OnHelpAbout(void)
|
||||
{
|
||||
}
|
||||
|
||||
// Message handler for dialog box.
|
||||
LRESULT CALLBACK CalcWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message) {
|
||||
case WM_INITDIALOG:
|
||||
hDlgWnd = hDlg;
|
||||
InitColours();
|
||||
return OnCreate(hDlg);
|
||||
|
||||
case WM_DRAWITEM:
|
||||
DrawItem((LPDRAWITEMSTRUCT)lParam);
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (HIWORD(wParam) == BN_CLICKED) {
|
||||
switch (LOWORD(wParam)) {
|
||||
// case IDC_OWNERDRAW:
|
||||
// // application-defined processing
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
BEGIN_CMD_MAP(LOWORD(wParam))
|
||||
CMD_MAP_ENTRY(ID_EDIT_COPY, OnEditCopy)
|
||||
CMD_MAP_ENTRY(ID_EDIT_PASTE, OnEditPaste)
|
||||
CMD_MAP_ENTRY(ID_VIEW_STANDARD, OnViewStandard)
|
||||
CMD_MAP_ENTRY(ID_VIEW_SCIENTIFIC, OnViewScientific)
|
||||
CMD_MAP_ENTRY(ID_VIEW_DIGIT_GROUPING, OnViewDigitGrouping)
|
||||
CMD_MAP_ENTRY(ID_HELP_TOPICS, OnHelpTopics)
|
||||
CMD_MAP_ENTRY(ID_HELP_ABOUT, OnHelpAbout)
|
||||
END_CMD_MAP(0)
|
||||
break;
|
||||
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
int idctrl;
|
||||
LPNMHDR pnmh;
|
||||
idctrl = (int)wParam;
|
||||
pnmh = (LPNMHDR)lParam;
|
||||
/*
|
||||
if ((pnmh->hwndFrom == hTabWnd) &&
|
||||
(pnmh->idFrom == IDC_TAB) &&
|
||||
(pnmh->code == TCN_SELCHANGE))
|
||||
{
|
||||
_OnTabWndSelChange();
|
||||
}
|
||||
*/
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
WinHelp(hDlgWnd, _T("regedit"), HELP_QUIT, 0);
|
||||
return DefWindowProc(hDlg, message, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
CALC_TYPES CurrentCalcType;
|
||||
|
||||
// Initialize global variables
|
||||
hInst = hInstance;
|
||||
|
||||
// Load our settings from the registry
|
||||
LoadSettings();
|
||||
|
||||
do {
|
||||
CurrentCalcType = CalcType;
|
||||
switch (CalcType) {
|
||||
case HP42S:
|
||||
break;
|
||||
case SCIENTIFIC:
|
||||
DialogBox(hInst, (LPCTSTR)IDD_SCIENTIFIC, NULL, (DLGPROC)CalcWndProc);
|
||||
break;
|
||||
case STANDARD:
|
||||
default:
|
||||
DialogBox(hInst, (LPCTSTR)IDD_STANDARD, NULL, (DLGPROC)CalcWndProc);
|
||||
break;
|
||||
}
|
||||
} while (CalcType != CurrentCalcType);
|
||||
|
||||
// Save our settings to the registry
|
||||
SaveSettings();
|
||||
return 0;
|
||||
}
|
||||
|
49
rosapps/calc/main.h
Normal file
49
rosapps/calc/main.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* ReactOS calc
|
||||
*
|
||||
* main.h
|
||||
*
|
||||
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
||||
*
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef __MAIN_H__
|
||||
#define __MAIN_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
|
||||
typedef enum _CALC_TYPES { STANDARD, SCIENTIFIC, HP42S, OTHER } CALC_TYPES;
|
||||
|
||||
extern HINSTANCE hInst;
|
||||
extern HWND hDlgWnd;
|
||||
extern CALC_TYPES CalcType;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // __MAIN_H__
|
63
rosapps/calc/makefile
Normal file
63
rosapps/calc/makefile
Normal file
|
@ -0,0 +1,63 @@
|
|||
#
|
||||
# ReactOS calc
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
||||
#
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
|
||||
PATH_TO_TOP = ..
|
||||
|
||||
TARGET = calc
|
||||
|
||||
#BASE_CFLAGS = -DGCC -D_WIN32_IE=0x0400
|
||||
|
||||
#RCFLAGS = -DGCC -D_WIN32_IE=0x0400
|
||||
|
||||
|
||||
OBJS = settings.o \
|
||||
button.o \
|
||||
main.o
|
||||
|
||||
LIBS = -lgdi32 -luser32 -lkernel32 -lcomctl32
|
||||
#LIBS = -lgdi32 -luser32 -lkernel32
|
||||
|
||||
all: $(TARGET).exe
|
||||
|
||||
$(TARGET).res: $(TARGET).rc
|
||||
|
||||
$(TARGET).exe: $(OBJS) $(TARGET).coff
|
||||
$(CC) -Wl,--subsystem,windows -o $(TARGET).exe $(OBJS) $(TARGET).coff $(LIBS)
|
||||
$(NM) --numeric-sort $(TARGET).exe > $(TARGET).sym
|
||||
|
||||
|
||||
main.h: resource.h
|
||||
|
||||
main.o: main.c main.h settings.h
|
||||
|
||||
settings.o: settings.c settings.h main.h
|
||||
|
||||
button.o: button.c button.h main.h
|
||||
|
||||
|
||||
clean:
|
||||
- $(RM) $(OBJS)
|
||||
- $(RM) $(TARGET).exe
|
||||
- $(RM) $(TARGET).sym
|
||||
- $(RM) $(TARGET).coff
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
34
rosapps/calc/resource.h
Normal file
34
rosapps/calc/resource.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by calc.rc
|
||||
//
|
||||
#define ID_MENU_EDIT 0
|
||||
#define ID_MENU_VIEW 1
|
||||
#define ID_MENU_HELP 2
|
||||
#define IDD_STANDARD 101
|
||||
#define IDD_SCIENTIFIC 102
|
||||
#define IDR_CALC_STANDARD 103
|
||||
#define IDR_CALC_SCIENTIFIC 104
|
||||
#define IDC_BUTTON1 1000
|
||||
#define IDC_BUTTON2 1001
|
||||
#define IDC_EDIT1 1002
|
||||
//#define ID_EDIT_COPY 40001
|
||||
//#define ID_EDIT_PASTE 40002
|
||||
#define ID_EDIT_COPY 0xE122
|
||||
#define ID_EDIT_PASTE 0xE125
|
||||
#define ID_VIEW_STANDARD 40003
|
||||
#define ID_VIEW_SCIENTIFIC 40004
|
||||
#define ID_VIEW_DIGIT_GROUPING 40005
|
||||
#define ID_HELP_TOPICS 40006
|
||||
#define ID_HELP_ABOUT 40007
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 103
|
||||
#define _APS_NEXT_COMMAND_VALUE 40008
|
||||
#define _APS_NEXT_CONTROL_VALUE 1003
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
37
rosapps/calc/settings.c
Normal file
37
rosapps/calc/settings.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* ReactOS calc
|
||||
*
|
||||
* settings.c
|
||||
*
|
||||
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
||||
*
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <windows.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "settings.h"
|
||||
|
||||
|
||||
void LoadSettings(void)
|
||||
{
|
||||
}
|
||||
|
||||
void SaveSettings(void)
|
||||
{
|
||||
}
|
||||
|
43
rosapps/calc/settings.h
Normal file
43
rosapps/calc/settings.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* ReactOS calc
|
||||
*
|
||||
* settings.h
|
||||
*
|
||||
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
||||
*
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SETTINGS_H__
|
||||
#define __SETTINGS_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
void LoadSettings(void);
|
||||
void SaveSettings(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // __SETTINGS_H__
|
Loading…
Reference in a new issue