ReactOS 0.4.15-dev-5667-ged97270
convert.c File Reference
#include "calc.h"
Include dependency graph for convert.c:

Go to the source code of this file.

Classes

struct  conv_t
 
struct  conv_category_t
 

Macros

#define DECLARE_CONV_CAT(_category)    { IDS_CONV_##_category, conv_##_category },
 
#define DECLARE_CONV_UNIT(_category, _unit, _from, _to)    { IDS_##_category##_##_unit, _from, _to },
 
#define DECLARE_CONV_END    { 0, NULL, NULL },
 

Functions

void ConvExecute (HWND hWnd)
 
void ConvAdjust (HWND hWnd, int n_cat)
 
void ConvInit (HWND hWnd)
 

Variables

static const conv_t conv_ANGLE []
 
static const conv_t conv_AREA []
 
static const conv_t conv_CONSUMPTION []
 
static const conv_t conv_CURRENCY []
 
static const conv_t conv_ENERGY []
 
static const conv_t conv_LENGTH []
 
static const conv_t conv_POWER []
 
static const conv_t conv_PRESSURE []
 
static const conv_t conv_TIME []
 
static const conv_t conv_TEMPERATURE []
 
static const conv_t conv_VELOCITY []
 
static const conv_t conv_VOLUME []
 
static const conv_t conv_WEIGHT []
 
static const conv_category_t conv_table []
 

Macro Definition Documentation

◆ DECLARE_CONV_CAT

#define DECLARE_CONV_CAT (   _category)     { IDS_CONV_##_category, conv_##_category },

Definition at line 57 of file convert.c.

◆ DECLARE_CONV_END

#define DECLARE_CONV_END    { 0, NULL, NULL },

Definition at line 63 of file convert.c.

◆ DECLARE_CONV_UNIT

#define DECLARE_CONV_UNIT (   _category,
  _unit,
  _from,
  _to 
)     { IDS_##_category##_##_unit, _from, _to },

Definition at line 60 of file convert.c.

Function Documentation

◆ ConvAdjust()

void ConvAdjust ( HWND  hWnd,
int  n_cat 
)

Definition at line 621 of file convert.c.

622{
623 TCHAR txt[128];
624 TCHAR txt_cat[128];
625 HWND hFromWnd = GetDlgItem(hWnd, IDC_COMBO_FROM);
626 HWND hToWnd = GetDlgItem(hWnd, IDC_COMBO_TO);
627 const conv_t *item;
628 unsigned int n;
629
631 for (n=0; n<SIZEOF(conv_table); n++) {
634 if (!_tcscmp(txt_cat, txt))
635 break;
636 }
637
638 SendMessage(hFromWnd, CB_RESETCONTENT, 0, 0);
639 SendMessage(hToWnd, CB_RESETCONTENT, 0, 0);
640 while (item->unit) {
641 LoadString(calc.hInstance, item->unit, txt, SIZEOF(txt));
642 SendMessage(hFromWnd, CB_ADDSTRING, 0, (LPARAM)txt);
643 SendMessage(hToWnd, CB_ADDSTRING, 0, (LPARAM)txt);
644 item++;
645 }
646 SendMessage(hFromWnd, CB_SETCURSEL, 0, 0);
647 SendMessage(hToWnd, CB_SETCURSEL, 0, 0);
648}
static const conv_category_t conv_table[]
Definition: convert.c:552
#define IDC_COMBO_TO
Definition: resource.h:109
#define IDC_COMBO_CATEGORY
Definition: resource.h:107
#define IDC_COMBO_FROM
Definition: resource.h:108
HWND hWnd
Definition: settings.c:17
#define SIZEOF(_ar)
Definition: calc.h:97
calc_t calc
Definition: winmain.c:247
GLdouble n
Definition: glext.h:7729
#define _tcscmp
Definition: tchar.h:1424
static ATOM item
Definition: dde.c:856
HINSTANCE hInstance
Definition: calc.h:167
const conv_t * items
Definition: convert.c:54
const DWORD category
Definition: convert.c:53
Definition: convert.c:46
LONG_PTR LPARAM
Definition: windef.h:208
#define CB_GETLBTEXT
Definition: winuser.h:1942
#define CB_SETCURSEL
Definition: winuser.h:1951
#define CB_RESETCONTENT
Definition: winuser.h:1949
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define CB_ADDSTRING
Definition: winuser.h:1926
#define SendMessage
Definition: winuser.h:5833
#define LoadString
Definition: winuser.h:5809
#define SendDlgItemMessage
Definition: winuser.h:5832
char TCHAR
Definition: xmlstorage.h:189

Referenced by ConvInit(), and DlgMainProc().

◆ ConvExecute()

void ConvExecute ( HWND  hWnd)

Definition at line 568 of file convert.c.

569{
571 const conv_t *items = NULL;
574 TCHAR txt_cb[128];
575 TCHAR txt[128];
576 const conv_t *item;
577
578 /* do nothing if the indexes point to the same unit */
579 if (from == to)
580 return;
581
582 /* Search correct category, since it can be sorted too */
584 for (c_cat=0; c_cat < SIZEOF(conv_table); c_cat++) {
586 if (!_tcscmp(txt_cb, txt)) {
587 items = conv_table[c_cat].items;
588 break;
589 }
590 }
591
592 /* The units can be sorted, so I must search the exact match */
593 item = items;
595 while (item->unit) {
596 LoadString(calc.hInstance, item->unit, txt, SIZEOF(txt));
597 if (!_tcscmp(txt_cb, txt)) {
598 from = item-items;
599 break;
600 }
601 item++;
602 }
604 item = items;
605 while (item->unit) {
606 LoadString(calc.hInstance, item->unit, txt, SIZEOF(txt));
607 if (!_tcscmp(txt_cb, txt)) {
608 to = item-items;
609 break;
610 }
611 item++;
612 }
613
614 calc.Convert[0].data = (char *)items[from].formula_from;
615 calc.Convert[1].data = (char *)items[to].formula_to;
619}
#define WM_HANDLE_FROM
Definition: calc.h:29
#define WM_START_CONV
Definition: calc.h:28
#define WM_HANDLE_TO
Definition: calc.h:30
#define NULL
Definition: types.h:112
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DWORD
Definition: nt_native.h:44
static TCHAR * items[]
Definition: page1.c:45
CardRegion * from
Definition: spigame.cpp:19
sequence_t Convert[2]
Definition: calc.h:196
char * data
Definition: calc.h:149
UINT wm_msg
Definition: calc.h:151
#define MAKELPARAM(l, h)
Definition: winuser.h:3998
#define PostMessage
Definition: winuser.h:5822
#define CB_GETCURSEL
Definition: winuser.h:1933

Referenced by DlgMainProc().

◆ ConvInit()

void ConvInit ( HWND  hWnd)

Definition at line 650 of file convert.c.

651{
653 TCHAR txt[128];
654 unsigned int n;
655
656 /* Fill category combo */
657 for (n=0; n<SIZEOF(conv_table); n++) {
659 SendMessage(hCatWnd, CB_ADDSTRING, 0, (LPARAM)txt);
660 }
661 SendMessage(hCatWnd, CB_SETCURSEL, 0, 0);
662 ConvAdjust(hWnd, 0);
663}
void ConvAdjust(HWND hWnd, int n_cat)
Definition: convert.c:621

Referenced by DlgMainProc().

Variable Documentation

◆ conv_ANGLE

const conv_t conv_ANGLE[]
static
Initial value:
= {
}
#define DECLARE_CONV_END
Definition: convert.c:63

Definition at line 72 of file convert.c.

◆ conv_AREA

const conv_t conv_AREA[]
static

Definition at line 116 of file convert.c.

◆ conv_CONSUMPTION

const conv_t conv_CONSUMPTION[]
static
Initial value:

Definition at line 159 of file convert.c.

◆ conv_CURRENCY

const conv_t conv_CURRENCY[]
static
Initial value:

Definition at line 167 of file convert.c.

◆ conv_ENERGY

const conv_t conv_ENERGY[]
static
Initial value:

Definition at line 204 of file convert.c.

◆ conv_LENGTH

const conv_t conv_LENGTH[]
static

Definition at line 268 of file convert.c.

◆ conv_POWER

const conv_t conv_POWER[]
static
Initial value:

Definition at line 326 of file convert.c.

◆ conv_PRESSURE

const conv_t conv_PRESSURE[]
static
Initial value:

Definition at line 344 of file convert.c.

◆ conv_table

const conv_category_t conv_table[]
static
Initial value:
= {
}

Definition at line 552 of file convert.c.

Referenced by ConvAdjust(), ConvExecute(), and ConvInit().

◆ conv_TEMPERATURE

const conv_t conv_TEMPERATURE[]
static
Initial value:

Definition at line 382 of file convert.c.

◆ conv_TIME

const conv_t conv_TIME[]
static
Initial value:

Definition at line 364 of file convert.c.

◆ conv_VELOCITY

const conv_t conv_VELOCITY[]
static
Initial value:

Definition at line 399 of file convert.c.

◆ conv_VOLUME

const conv_t conv_VOLUME[]
static

Definition at line 446 of file convert.c.

◆ conv_WEIGHT

const conv_t conv_WEIGHT[]
static
Initial value:

Definition at line 522 of file convert.c.