aboutsummaryrefslogtreecommitdiffstats
path: root/apps/windoze/CBuilder5/BibleCS/mainfrm.h
blob: 0b2c34297803754fe88afb2fac7de782aaf5ada0 (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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
//---------------------------------------------------------------------------
#ifndef mainfrmH
#define mainfrmH
//---------------------------------------------------------------------------
#include <vcl\Classes.hpp>
#include <vcl\Controls.hpp>
#include <vcl\StdCtrls.hpp>
#include <vcl\Forms.hpp>
#include <vcl\ExtCtrls.hpp>
#include <vcl\ComCtrls.hpp>
#include "biblecsmgr.h"
#include <swtext.h>
#include <strkey.h>
#include <regex.h>
#include <listkey.h>
#include <swgenbook.h>
#include "swdisprtfchap.h"
#include <AppEvnts.hpp>
#include <Buttons.hpp>
#include <DdeMan.hpp>
#include <Graphics.hpp>
#include <ImgList.hpp>
#include <Menus.hpp>
#include <ToolWin.hpp>
#include <vcl\Buttons.hpp>
#include <vcl\Menus.hpp>
#include <vcl\DdeMan.hpp>
#include <OleCtrls.hpp>
#include <ToolWin.hpp>
#include <shellapi.h>
#include <Graphics.hpp>
#include <ImgList.hpp>
#include <jpeg.hpp>
#include "RxRichEdit.hpp"
//#include "MOZILLACONTROLLib_OCX.h"
#include "SHDocVw_OCX.h"
#include <AppEvnts.hpp>
#include <TntStdCtrls.hpp>
#include <ActnList.hpp>

#ifndef USEOLDRTF
#include "RxRichEdit.hpp"
#else
#define TRxRichEdit TRichEdit
#endif    	

#include <list>
#include <vector>

#define _tr(text) LocaleMgr::systemLocaleMgr.translate(text)
#define MONITOR_CENTER     0x0001        // center rect to monitor
#define MONITOR_CLIP     0x0000        // clip rect to monitor
#define MONITOR_WORKAREA 0x0002        // use monitor work area
#define MONITOR_AREA     0x0000        // use monitor entire area


class RTFDisp : public SWDisplay {
	SWDispRTF *edit;
	static SWClass classdef;
public:
	RTFDisp(SWDispRTF *iedit) { myclass = &classdef; edit = iedit; }
	virtual SWDispRTF *editControl() { return edit; }
	RTFDisp() {}
	virtual char Display(SWModule &imodule) {
		return edit->Display(imodule);
	}
};

class RTFBookDisp : public RTFDisp {
	SWDispRTF *edit;
	TTreeView *toc;
public:
	RTFBookDisp(SWDispRTF *iedit, TTreeView *itoc) : RTFDisp(iedit) { toc = itoc;}
	RTFBookDisp() {}

	void fillTreeTOC(TreeKeyIdx treeKey, TTreeView *tree, TTreeNode *parent) {
		TTreeNode *node = tree->Items->AddChildObject(parent, treeKey.getLocalName(), (void *)treeKey.getOffset());
		if (treeKey.firstChild()) {
			fillTreeTOC(treeKey, tree, node);
			treeKey.parent();
		}
		if (treeKey.nextSibling())
			fillTreeTOC(treeKey, tree, parent);
	}

	virtual char Display(SWModule &imodule) {
		if (!toc->Items->GetFirstNode()) {
			//edit->Text = "Loading TOC...";
			imodule = TOP;
			((TreeKeyIdx *)((SWKey *)imodule))->firstChild();
			fillTreeTOC(*(TreeKeyIdx *)((SWKey *)imodule), toc, toc->Selected);
		}
		return RTFDisp::Display(imodule);
	}
};

class HREFDisp : public SWDisplay {
	TCppWebBrowser *edit;
public:
	HREFDisp(TCppWebBrowser *iedit) { edit = iedit; }
	HREFDisp() {}
	char Display(SWModule &imodule) {

		TMemoryStream *stm = new TMemoryStream();

		if ( stm == NULL )
			return 1;

		stm->Clear();
		string modText = (string)"<HTML><BODY>" + (string)imodule.RenderText() + (string)"</BODY></HTML>";
		stm->WriteBuffer(modText.c_str(), modText.length());

		IPersistStreamInit *psi = NULL;

		stm->Seek( 0, 0 );

		// If you pass soOwned instead, the stream will be freed for you
		TStreamAdapter *sa = new TStreamAdapter( stm, soReference );

		if ( sa == NULL ) {
			delete stm;
			return 1;
		}

		_di_IDispatch doc = edit->Document;
		if ( doc == NULL ) {
			TVariant url = "about:blank";
			edit->Navigate2( &url );
			while ( doc == NULL ) {
				Application->ProcessMessages();
				doc = edit->Document;
			}
		}

//		if ( doc->QueryInterface(IID_IPersistStreamInit, (void**)&psi ) == S_OK ) {
		HRESULT result = doc->QueryInterface(IID_IPersistStreamInit, (void**)&psi );
		if (result == S_OK) {
//		if ( doc->QueryInterface(IID_IWrite, (void**)"test" ) == S_OK ) {
			if ( psi )
				psi->Load( *sa );
		}
		else
			delete sa;

		delete stm;
	
//		edit->SetTextBuf("yo mama");
//		edit->RequestDoc((char *)imodule);
		return 0;
	}
};

class DispExternal : public SWDisplay {
public:
	DispExternal() {}
	char Display(SWModule &imodule) {
		SHELLEXECUTEINFO info;
		info.cbSize = sizeof(SHELLEXECUTEINFO);
		info.fMask = SEE_MASK_NOCLOSEPROCESS; //SEE_MASK_CLASSNAME;
		info.hwnd = GetFocus();
		info.lpVerb = "open";
		info.lpFile = (const char *)imodule;
		info.lpParameters = NULL;
		info.lpDirectory = NULL;
		info.nShow = 0;
//		info.lpClass = ".html";
		ShellExecuteEx(&info);
//		ShellExecute(edit->Handle, "open", (char *)imodule, NULL, NULL, SW_SHOWNORMAL);
		return 0;
	}
};


class ModState {
public:
	ModState(TPageControl *ipc, TTabSheet *iap, SWKey ikey) { pc = ipc; ap = iap; key = ikey; }
	ModState();
	TPageControl *pc;
	TTabSheet* ap;
	SWKey key;
};

//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
	TPanel *pnlTextCom;
	TSplitter *Splitter2;
	TPanel *pnlText;
	TPanel *pnlComment;
	TSplitter *Splitter1;
	TPanel *pnlDict;
	TPageControl *TextPageControl;
	TPageControl *CommentaryPageControl;
	TStatusBar *StatusBar1;
	TPageControl *LexDictPageControl;
	TMainMenu *MainMenu1;
	TMenuItem *Search1;
	TMenuItem *NewSearchWindow1;
	TMenuItem *Help1;
	TMenuItem *About1;
	TPopupMenu *PopupMenu2;
	TMenuItem *DictionaryLookup1;
	TMenuItem *File1;
	TMenuItem *SaveLayout1;
	TMenuItem *Exit1;
	TMenuItem *N1;
	TDdeServerItem *Search;
	TDdeServerItem *Lookup;
	TDdeServerConv *Bible;
	TPopupMenu *PopupMenu1;
	TMenuItem *MenuItem1;
	TMenuItem *Copy1;
	TMenuItem *CopyasBGreekTransliteration1;
	TMenuItem *Copy2;
	TMenuItem *Edit1;
	TMenuItem *Copy3;
	TPopupMenu *BookmarkPopup;
	TMenuItem *AddBookmark1;
	TMenuItem *N2;
	TMenuItem *EditBookmarks1;
	TMenuItem *Options1;
	TCoolBar *CoolBar1;
	TImageList *ImageList1;
	TImage *BackBtnImage;
	TImage *SearchBtnImage;
	TToolBar *ToolBar2;
	TToolButton *ToolButton3;
	TToolButton *ToolButton4;
	TPanel *pnlSpeed;
	TPanel *Panel1;
	TComboBox *cbBook;
	TEdit *CHBox;
	TUpDown *UpDown1;
	TEdit *VSBox;
	TUpDown *UpDown2;
	TSpeedButton *btnLookup;
	TToolBar *ToolBar1;
	TImageList *ImageList2;
	TImage *BookmarkBtnImage;
	TSpeedButton *Bookmarkbtn;
	TPopupMenu *PopupMenu3;
	TMenuItem *Copy4;
	TMenuItem *DictionaryLookup2;
	TMenuItem *N3;
	TMenuItem *EditEntry1;
	TMenuItem *DeleteEntry1;
	TMenuItem *LinktoVerse1;
	TMenuItem *Options2;
	TMenuItem *Contents1;
	TComboBox *freeHandLookup;
	TPanel *Panel2;
	TSplitter *Splitter3;
	TRichEdit *DictKeyEditOld;
	TListBox *lbDictKeysOld;
	TPopupMenu *PopupMenu4;
	TMenuItem *HideShowModules1;
	   TMenuItem *DevotionaloftheDay1;
	TMenuItem *Tools1;
	TMenuItem *InstallManager1;
	TMenuItem *SEPERATOR;
	TApplicationEvents *ApplicationEvents1;
	TMenuItem *Print1;
	TMenuItem *N5;
	TMenuItem *SearchForWord1;
	TMenuItem *SearchForWord2;
	TMenuItem *SearchForWord3;
	TActionList *ActionList1;
	TAction *Action1;
	TMenuItem *NewVer1;
	void __fastcall TextPageControlChange(TObject *Sender);
	void __fastcall btnLookupClick(TObject *Sender);
	void __fastcall CommentaryPageControlChange(TObject *Sender);
	
	
	
	void __fastcall DictKeyEditOldChange(TObject *Sender);
	void __fastcall LexDictPageControlChange(TObject *Sender);
	void __fastcall NewSearchWindow1Click(TObject *Sender);
	
	void __fastcall Exit1Click(TObject *Sender);
	void __fastcall About1Click(TObject *Sender);
	void __fastcall DictionaryLookup1Click(TObject *Sender);
	void __fastcall SaveLayout1Click(TObject *Sender);
	
	
	void __fastcall FormShow(TObject *Sender);
	
	void __fastcall LookupPokeData(TObject *Sender);
	
	void __fastcall SearchPokeData(TObject *Sender);
	void __fastcall UpDown3Click(TObject *Sender, TUDBtnType Button);
	void __fastcall UpDown1Click(TObject *Sender, TUDBtnType Button);
	
	
	void __fastcall BackbtnClick(TObject *Sender);
	void __fastcall CopyasBGreekTransliteration1Click(TObject *Sender);
	void __fastcall Copy1Click(TObject *Sender);
	
	
	
	void __fastcall AddBookmark1Click(TObject *Sender);
	void __fastcall BookmarkItemClick(TObject *Sender);
	void __fastcall BookmarkbtnClick(TObject *Sender);
	void __fastcall EditBookmarks1Click(TObject *Sender);
	
	void __fastcall FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
	void __fastcall Options1Click(TObject *Sender);
	void __fastcall cbBookChange(TObject *Sender);
	
	void __fastcall FormCreate(TObject *Sender);
	void __fastcall PopupMenuPopup(TObject *Sender);
	void __fastcall createVerseList(TObject *Sender);
	void __fastcall freeHandLookupoldKeyPress(TObject *Sender, char &Key);
	void __fastcall RTFMouseDown(TObject *Sender, TMouseButton Button,
		TShiftState Shift, int X, int Y);
	void __fastcall RTFURLClick(TObject *Sender, const AnsiString URLText, TMouseButton Button);
	void __fastcall EditEntry1Click(TObject *Sender);
	void __fastcall DeleteEntry1Click(TObject *Sender);
	void __fastcall LinktoVerse1Click(TObject *Sender);
	void __fastcall BookTOCChange(TObject* Sender, TTreeNode* Node);
	
	void __fastcall GlobalOptionChange(TObject *Sender);
	
	
	void __fastcall OptionShowVals(TObject *Sender);
	void __fastcall Contents1Click(TObject *Sender);
	void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
	void __fastcall lbDictKeysOldClick(TObject *Sender);
	void __fastcall verseLookupClick(TObject *Sender);
	void __fastcall HideShowModules1Click(TObject *Sender);
	void __fastcall DevotionaloftheDay1Click(TObject *Sender);
	void __fastcall CppWebBrowser1BeforeNavigate2(TObject *Sender,
		LPDISPATCH pDisp, TVariant *URL, TVariant *Flags,
		TVariant *TargetFrameName, TVariant *PostData, TVariant *Headers,
		TOLEBOOL *Cancel);
	void __fastcall InstallManager1Click(TObject *Sender);
	void __fastcall ApplicationEvents1Hint(TObject *Sender);
	void __fastcall ApplicationEvents1ShowHint(AnsiString &HintStr,
		bool &CanShow, THintInfo &HintInfo);
	void __fastcall Print1Click(TObject *Sender);
	void __fastcall SearchForWord1Click(TObject *Sender);
	void __fastcall Action1Execute(TObject *Sender);
	void __fastcall NewVer1Click(TObject *Sender);
private:	// User declarations
	list <SWDisplay *> displays;	// so we can delete each display we create
	list <ModState *> modstates;
	vector <ModState *> ctrlstates;
	bool logmodstate;
	bool freshdict;
	String clickText;

	char CreateTextPane(SWModule *mod);
	char CreateCommentPane(SWModule *mod);
	char CreateLDPane(SWModule *mod);
	char CreateBookPane(SWModule *mod);
	void PushState();
	void BackState();
	void ForwardState();
	void AddSectionToMenu(TMenu *menu, TMenuItem *item, TTreeNode *tree);
	void FillDictKeys();
	void AddVerseChoices(TPopupMenu *menu, const char *buf, TRxRichEdit *rtf);
	void fillVKeySelector(VerseKey *vk);
	static bool hasFeature(SWMgr *mgr, const char *modName, const char *feature);
	void NavigateVerseURL(char* verStr);
	void refreshAppearance();

public:		// User declarations
	TTntListBox *lbDictKeys;
	TTntEdit *DictKeyEdit;
	VerseKey *DefaultVSKey;
	SWKey *DefaultStrKey;
	BibleCSMGR *mainmgr;
	SWConfig *layoutconf;
	SWConfig *optionsconf;
	SWDispRTF *currentRTF;
	__fastcall TForm1(TComponent* Owner);
	__fastcall ~TForm1();
	void __fastcall DisplayHint(TObject* Sender);
	void RefreshActiveSheet(TPageControl *ts);
	void TextKeyChanged();		// updates dependents on TextKeyChanged
	void RefreshBookmarksMenu(TMenu *menu, TTreeView *tree);
	void RestoreState(ModState *state);
	void i12ize(const char *lang);
	static WideString TrimJunk(WideString src);
	void __fastcall AppMessage(tagMSG &Msg, bool &Handled);     
	static void ClipOrCenterRectToMonitor(LPRECT prc, UINT flags);
	static void ClipOrCenterWindowToMonitor(HWND hwnd, UINT flags);
	ListKey tmpVerseList;
	String tmpVerseListCaption;
	bool renderingHint;
	bool closing;
};

class TRTFHintWindow : public THintWindow {
	typedef THintWindow inherited;

protected:
	virtual void __fastcall Paint(void);
	virtual void __fastcall CreateParams(TCreateParams &Params);

public:
	__fastcall virtual TRTFHintWindow(Classes::TComponent* AOwner);
	__fastcall TRTFHintWindow(HWND ParentWindow) : THintWindow(ParentWindow) { }
	__fastcall virtual ~TRTFHintWindow(void);
	virtual void __fastcall ActivateHint(const /*Windows::*/TRect& Rect,	const AnsiString AHint);
	virtual void __fastcall ActivateHintData(const /*Windows::*/TRect& Rect, const AnsiString AHint, void* AData);
	virtual /*Windows::*/TRect __fastcall CalcHintRect(int MaxWidth, const AnsiString AHint, void* AData);
	virtual bool __fastcall IsHintMsg(tagMSG& Msg);

	__property BiDiMode ;
	__property Caption ;
	__property Color ;
	__property Canvas ;
	__property Font ;

};


//---------------------------------------------------------------------------
extern TForm1 *Form1;
//---------------------------------------------------------------------------
#endif