forked from n5ac/mmsstv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMacroKey.cpp
162 lines (150 loc) · 4.9 KB
/
MacroKey.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//Copyright+LGPL
//-----------------------------------------------------------------------------------------------------------------------------------------------
// Copyright 2000-2013 Makoto Mori, Nobuyuki Oba
//-----------------------------------------------------------------------------------------------------------------------------------------------
// This file is part of MMSSTV.
// MMSSTV 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 3 of the License, or (at your option) any later version.
// MMSSTV 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 MMTTY. If not, see
// <http://www.gnu.org/licenses/>.
//-----------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "MacroKey.h"
#include "ComLib.h"
//---------------------------------------------------------------------
#pragma resource "*.dfm"
//TMacroKeyDlg *MacroKeyDlg;
MACKEY mackeycom[]={
{1, "%m","My callsign", NULL},
{1, "%c","His/her callsign", NULL},
{1, "%r","His/her RSV", NULL},
{1, "%n","His/her name", NULL},
{2, "%J","His/her name (+サン)", NULL},
{1, "%q","His/her QTH", NULL},
{1, "%s","My RSV", NULL},
{1, "%R","His/her RSVのRSV部分のみ","Only the RSV part of his/her RSV"},
{1, "%N","His/her RSVのコンテストナンバ部分のみ","Only the contest number part of his/her RSV"},
{1, "%M","My RSVのコンテストナンバ部分のみ","Only the contest number part of my RSV"},
{1, "%g","GOOD MORNING/AFTERNOON/EVENING", NULL},
{1, "%f","GM/GA/GE", NULL},
{1, "%D","UTC date (e.g., 2000-SEP-05)", NULL},
{1, "%T","UTC time (e.g., 12:34)", NULL},
{1, "%t","UTC time (e.g., 1234)", NULL},
{1, "%L","Local date (e.g., 2000-SEP-05)", NULL},
{1, "%U","Local time (e.g., 12:34)", NULL},
{1, "%u","Local time (e.g., 1234)", NULL},
{1, "%B","周波数", "frequency"},
{1, "%b","バンド", "band"},
{1, "%o","Note", NULL},
{1, "%X","Receipt time(UTC) of the current image", NULL},
{1, "%v","MMSSTV version", NULL},
{1, "%V","Beta version", NULL},
{0, NULL, NULL},
};
static int intPos; //ja7ude 0521
static int TopPos;
//---------------------------------------------------------------------
__fastcall TMacroKeyDlg::TMacroKeyDlg(TComponent* AOwner)
: TForm(AOwner)
{
FormStyle = ((TForm *)AOwner)->FormStyle;
Font->Name = ((TForm *)AOwner)->Font->Name;
Font->Charset = ((TForm *)AOwner)->Font->Charset;
if( MsgEng ){
CancelBtn->Caption = "Cancel";
OKBtn->Caption = "Insert";
}
}
//---------------------------------------------------------------------
void __fastcall TMacroKeyDlg::UpdateUI(int row)
{
int r = row - 1;
if( r >= 0 ){
OKBtn->Enabled = TRUE;
}
else {
OKBtn->Enabled = FALSE;
}
}
//---------------------------------------------------------------------
int __fastcall TMacroKeyDlg::AddMacKey(MACKEY *mp, int n)
{
for( ; mp->r; mp++){
if( (mp->r == 2) && MsgEng ) continue;
mackey[n] = *mp;
n++;
}
return n;
}
//---------------------------------------------------------------------
int __fastcall TMacroKeyDlg::Execute(AnsiString &as)
{
int n = 0;
n = AddMacKey(mackeycom, n);
Grid->RowCount = 1 + n;
if( (intPos > 0) && (intPos < Grid->RowCount) ){ //ja7ude 0521
Grid->Row = intPos;
Grid->TopRow = TopPos;
}
UpdateUI(Grid->Row);
int r = ShowModal();
intPos = Grid->Row; //ja7ude 0521
TopPos = Grid->TopRow;
if( r == IDOK ){
if( intPos ){ //ja7ude 0521
r = intPos - 1;
as = mackey[r].pKey;
return TRUE;
}
}
return FALSE;
}
//---------------------------------------------------------------------
void __fastcall TMacroKeyDlg::GridDrawCell(TObject *Sender, int Col,
int Row, TRect &Rect, TGridDrawState State)
{
char bf[256];
Grid->Canvas->FillRect(Rect);
int X = Rect.Left + 4;
int Y = Rect.Top + 2;
if( Row ){
Row--;
bf[0] = 0;
LPCSTR pCom;
switch(Col){
case 0:
strcpy(bf, mackey[Row].pKey);
break;
case 1:
if( MsgEng ){
pCom = mackey[Row].pEng;
if( pCom == NULL ){
pCom = mackey[Row].pJpn;
}
}
else {
pCom = mackey[Row].pJpn;
}
strcpy(bf, pCom);
break;
}
Grid->Canvas->TextOut(X, Y, bf);
}
else { // タイトル
LPCSTR _tt[]={
"Key","Comments",
};
Grid->Canvas->TextOut(X, Y, _tt[Col]);
}
}
//---------------------------------------------------------------------------
void __fastcall TMacroKeyDlg::GridSelectCell(TObject *Sender, int Col,
int Row, bool &CanSelect)
{
UpdateUI(Row);
}
//---------------------------------------------------------------------------