aboutsummaryrefslogtreecommitdiffstats
path: root/examples/windoze/bcowl25/multimod/swrtdlgc.cpp
blob: e3c6051f679b2e6a1398191e8f3f888342bf0b6a (plain) (blame)
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/*  Project sword

    GNU Copyleft GPL © 1996. Almost No Rights Reserved.

    SUBSYSTEM:    sword.exe Application
    FILE:         swrtdlgc.cpp
    AUTHOR:       The Sword Project Team


    OVERVIEW
    ========
    Source file for implementation of swordTDLGClient (TDialog).
*/


#include <owl\owlpch.h>
#pragma hdrstop

#include "tversedt.h"
#include "swordapp.h"
#include "swrtdlgc.h"
#include "serchdlg.h"

#include <versekey.h>
#include <rawtext.h>
#include <rawcom.h>
#include <rawld.h>
#include <tbdisp.h>


class TBLDDisp: public TBDisp {
	int nameid, keyid;
public:
	TBLDDisp(HWND iwnd, int ictrlid, int inameid = 0, int ikeyid = 0):TBDisp(iwnd, ictrlid) {
		nameid = inameid;
		keyid  = ikeyid;
	}
	virtual char Display(SWModule &imodule) {
		TBDisp::Display(imodule);
		if (nameid)
			SetDlgItemText(wnd, nameid, imodule.Description());
		if (keyid)
			SetDlgItemText(wnd,  keyid, (char *)(SWKey)imodule);
	}
};


SWDisplay   *edit1disp = 0;
SWDisplay   *edit2disp = 0;
SWDisplay   *edit3disp = 0;
VerseKey *masterkey = 0;
SWModule *webster   = 0;
SWModule *mhc       = 0;
SWModule *eastons   = 0;
SWModule *vines     = 0;

//
// Build a response table for all messages/commands handled
// by the application.
//
DEFINE_RESPONSE_TABLE1(swordTDLGClient, TDialog)
//{{swordTDLGClientRSP_TBL_BEGIN}}
    EV_BN_CLICKED(IDC_LOOKUP, BNClicked),
    EV_WM_RBUTTONDOWN,
    EV_BN_CLICKED(IDC_UPBUTTON, UpVerse),
    EV_BN_CLICKED(IDC_DOWNBUTTON, DownVerse),
    EV_COMMAND(CM_EDITFIND, SearchTxt),
//{{swordTDLGClientRSP_TBL_END}}
END_RESPONSE_TABLE;


// SWLookup This is a kludgy way to lookup, but a Module manager will do
//	this work in the future
void SWLookup(char *modname, SWKey &key)
{
	if (!stricmp(modname, eastons->Name())) {
		eastons->setKey(key);
		eastons->Display();
	}
	if (!stricmp(modname, vines->Name())) {
		vines->setKey(key);
		vines->Display();
	}
}




//{{swordTDLGClient Implementation}}


//////////////////////////////////////////////////////////
// swordTDLGClient
// ==========
// Construction/Destruction handling.
static swordTDLGClientXfer swordTDLGClientData;

swordTDLGClient::swordTDLGClient (TWindow *parent, TResId resId, TModule *module)
    : TDialog(parent, resId, module)
{
//{{swordTDLGClientXFER_USE}}
    BookCB  = new TComboBox(this, IDC_BOOK, 1);
    WebEdit = new TVerseEdit(this, IDC_VTEXT, 255);
    MHCEdit = new TVerseEdit(this, IDC_CTEXT, 255);
    LDText  = new TVerseEdit(this, IDC_DTEXT, 255);

    SetTransferBuffer(&swordTDLGClientData);
//{{swordTDLGClientXFER_USE_END}}

}


swordTDLGClient::~swordTDLGClient ()
{
    Destroy();

    delete edit1disp;
    delete edit2disp;
    delete edit3disp;
    delete webster;
    delete mhc;
    delete eastons;
    delete vines;
    delete masterkey;
}


void swordTDLGClient::SetupWindow ()
{
	char loop1, loop2;

    TDialog::SetupWindow();

	edit1disp = new TBLDDisp(HWindow, IDC_VTEXT, 0, IDC_KTEXT);
	edit2disp = new TBLDDisp(HWindow, IDC_CTEXT);
	edit3disp = new TBLDDisp(HWindow, IDC_DTEXT, IDC_LDNAME, IDC_LDKEY);
	masterkey = new VerseKey();
	webster   = new RawText("../../../../modules/texts/rawtext/webster/", "Webster", "Webster Text", edit1disp);
	mhc       = new RawCom ("../../../../modules/comments/rawcom/mhc/", "MHC", "Matthew Henry's Commentary", edit2disp);
	eastons   = new RawLD  ("../../../../modules/lexdict/rawld/eastons/eastons", "Eastons", "Easton's Bible Dictionary", edit3disp);
	vines     = new RawLD  ("../../../../modules/lexdict/rawld/vines/vines", "Vines", "Vine's Bible Dictionary", edit3disp);

	masterkey->Persist(1);
	webster->setKey(*masterkey);
	mhc->setKey(*masterkey);

	for (loop1 = 0; loop1 < 2; loop1++) {
		for (loop2 = 0; loop2 < VerseKey::BMAX[loop1]; loop2++) {
			BookCB->AddString(VerseKey::books[loop1][loop2].name);
		}
	}
	BookCB->SetSelIndex(58);
	SetDlgItemText(IDC_CHAPTER, "1");
	SetDlgItemText(IDC_VERSE, "19");
}


void swordTDLGClient::BNClicked ()
{
	char buf[80], tmpbuf[70];
	int ch, vs;

	BookCB->GetText(tmpbuf, 79);
	ch = GetDlgItemInt(IDC_CHAPTER);
	vs = GetDlgItemInt(IDC_VERSE);

	masterkey->AutoNormalize(ch && vs);	// if either chapter or verse are 0 then don't auto normalize so that we can lookup intros

	wsprintf(buf, "%s %d:%d", tmpbuf, ch, vs);
	*masterkey = buf;

	webster->Display();
	mhc->Display();

}


void swordTDLGClient::EvRButtonDown (uint modKeys, TPoint& point)
{
    TDialog::EvRButtonDown(modKeys, point);
}


void swordTDLGClient::UpVerse ()
{
	(*masterkey)--;
	webster->Display();
	mhc->Display();
}


void swordTDLGClient::DownVerse ()
{
	(*masterkey)++;
	webster->Display();
	mhc->Display();
}


void swordTDLGClient::EvPaint ()
{
    TDialog::EvPaint();

    // INSERT>> Your code here.

}


void swordTDLGClient::SearchTxt ()
{
    new SearchDlg(this)->Create();
}