-
Notifications
You must be signed in to change notification settings - Fork 10
/
formmain.pas
1550 lines (1344 loc) · 43.2 KB
/
formmain.pas
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
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit FormMain;
interface
uses
Classes, Fgl, SysUtils, LazFileUtils, LazUTF8, Forms, Controls, Graphics,
Dialogs, StdCtrls, Menus, ExtCtrls, ComCtrls, IniFiles, LCLIntf, LCLType,
LCLProc, ActnList, ClipBrd, StdActns, Buttons, PrintersDlgs,
RichMemo, UnboundMemo, UnitUtils, UnitLib;
type
TStatuses = TFPGMap<integer, string>;
{ TMainForm }
TMainForm = class(TForm)
ToolEdit: TEdit;
IdleTimer: TIdleTimer;
Panel1: TPanel;
MainMenu: TMainMenu;
PopupMenu: TPopupMenu;
PopupTabs: TPopupMenu;
PrintDialog: TPrintDialog;
FontDialog: TFontDialog;
FontDialogNotes: TFontDialog;
OpenDialog: TOpenDialog;
SaveDialog: TSaveDialog;
ComboBox: TComboBox;
FileOpen1: TFileOpen;
EditCut1: TEditCut;
MemoBible: TUnboundMemo;
MemoCommentary: TUnboundMemo;
MemoCompare: TUnboundMemo;
MemoDictionary: TUnboundMemo;
MemoHistory: TUnboundMemo;
MemoNotes: TUnboundMemo;
MemoReference: TUnboundMemo;
MemoSearch: TUnboundMemo;
ActionAbout: THelpAction;
ActionBold: TAction;
ActionBullets: TAction;
ActionCenter: TAction;
ActionCleanHistory: TAction;
ActionCommentaries: TAction;
ActionCompare: TAction;
ActionCopyAs: TAction;
ActionCopyVerses: TAction;
ActionDecrease: TAction;
ActionDictionaries: TAction;
ActionEditCopy: TAction;
ActionEditCut: TAction;
ActionEditDel: TAction;
ActionEditFont: TAction;
ActionEditPaste: TAction;
ActionEditSelAll: TEditSelectAll;
ActionEditUndo: TAction;
ActionExit: TAction;
ActionFileNew: TAction;
ActionFileOpen: TAction;
ActionFilePrint: TAction;
ActionFileSave: TAction;
ActionFileSaveAs: TAction;
ActionFont: TAction;
ActionHistory: TAction;
ActionHistoryLeft: TAction;
ActionHistoryRight: TAction;
ActionIncrease: TAction;
ActionInterlinear: TAction;
ActionItalic: TAction;
ActionLeft: TAction;
ActionLink: TAction;
ActionList: TActionList;
ActionLookup: TAction;
ActionModules: TAction;
ActionOptions: TAction;
ActionReference: TAction;
ActionRight: TAction;
ActionSearch: TAction;
ActionSearchfor: TAction;
ActionUnderline: TAction;
ChapterBox: TListBox;
BookBox: TListBox;
Ruler: TPanel;
PanelLeft: TPanel;
Splitter1: TSplitter;
StatusBar: TStatusBar;
Images: TImageList;
PageControl: TPageControl;
TabSheetReference: TTabSheet;
TabSheetBible: TTabSheet;
TabSheetSearch: TTabSheet;
TabSheetCompare: TTabSheet;
TabSheetCommentary: TTabSheet;
TabSheetDictionary: TTabSheet;
TabSheetHistory: TTabSheet;
TabSheetNotes: TTabSheet;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
miBibleFolder: TMenuItem;
miClear: TMenuItem;
miCommentaries: TMenuItem;
miCompare: TMenuItem;
miCopy: TMenuItem;
miCopyAs: TMenuItem;
miCut: TMenuItem;
miDictionaries: TMenuItem;
miDonate: TMenuItem;
miDownload: TMenuItem;
miEdit: TMenuItem;
miExit: TMenuItem;
miHelp: TMenuItem;
miHelpAbout: TMenuItem;
miHistory: TMenuItem;
miHome: TMenuItem;
miInterlinear: TMenuItem;
miIssue: TMenuItem;
miModules: TMenuItem;
miNoteNew: TMenuItem;
miNoteOpen: TMenuItem;
miNoteSave: TMenuItem;
miNoteSaveAs: TMenuItem;
miNotes: TMenuItem;
miOptions: TMenuItem;
miPaste: TMenuItem;
miPrint: TMenuItem;
miRecent: TMenuItem;
miRrefx: TMenuItem;
miSearch: TMenuItem;
miSelectAll: TMenuItem;
miTools: TMenuItem;
miUndo: TMenuItem;
miVerses: TMenuItem;
MenuItem2: TMenuItem;
pmClose: TMenuItem;
pmCopy: TMenuItem;
pmCopyAs: TMenuItem;
pmCut: TMenuItem;
pmCleanHistory: TMenuItem;
pmLookup: TMenuItem;
pmPaste: TMenuItem;
pmSearchfor: TMenuItem;
pmSeparator2: TMenuItem;
pmSeparatorH: TMenuItem;
pmSeparator: TMenuItem;
pmVerses: TMenuItem;
StandardToolBar: TToolBar;
ToolButtonBold: TToolButton;
ToolButtonBullets: TToolButton;
ToolButtonCenter: TToolButton;
ToolButtonCommentary: TToolButton;
ToolButtonCopy: TToolButton;
ToolButtonCut: TToolButton;
ToolButtonDictionary: TToolButton;
ToolButtonFont: TToolButton;
ToolButtonHistory: TToolButton;
ToolButtonItalic: TToolButton;
ToolButtonLeft: TToolButton;
ToolButtonLink: TToolButton;
ToolButtonNew: TToolButton;
ToolButtonOpen: TToolButton;
ToolButtonPaste: TToolButton;
ToolButtonPrint: TToolButton;
ToolButtonReference: TToolButton;
ToolButtonRight: TToolButton;
ToolButtonSave: TToolButton;
ToolButtonSearch: TToolButton;
ToolButtonShelf: TToolButton;
ToolButtonUnderline: TToolButton;
ToolButtonUndo: TToolButton;
ToolButtonVerses: TToolButton;
ToolPanel: TPanel;
ToolSeparator1: TToolButton;
ToolSeparator2: TToolButton;
ToolSeparator3: TToolButton;
ToolSeparator4: TToolButton;
ToolSeparator5: TToolButton;
ToolSeparator6: TToolButton;
procedure CmdCleanHistory(Sender: TObject);
procedure CmdHistory(Sender: TObject);
procedure CmdReference(Sender: TObject);
procedure CmdCommentaries(Sender: TObject);
procedure CmdDictionaries(Sender: TObject);
procedure CmdAbout(Sender: TObject);
procedure CmdCompare(Sender: TObject);
procedure CmdCopyAs(Sender: TObject);
procedure CmdCopyVerses(Sender: TObject);
procedure CmdEdit(Sender: TObject);
procedure CmdExit(Sender: TObject);
procedure CmdFileNew(Sender: TObject);
procedure CmdFileOpen(Sender: TObject);
procedure CmdFilePrint(Sender: TObject);
procedure CmdFileSave(Sender: TObject);
procedure CmdFileSaveAs(Sender: TObject);
procedure CmdInterline(Sender: TObject);
procedure CmdOptions(Sender: TObject);
procedure CmdSearch(Sender: TObject);
procedure CmdSearchFor(Sender: TObject);
procedure CmdLookup(Sender: TObject);
procedure CmdStyle(Sender: TObject);
procedure CmdStyle2(Sender: TObject);
procedure CmdModules(Sender: TObject);
procedure ComboBoxChange(Sender: TObject);
procedure ComboBoxDrawItem(Control: TWinControl; Index: integer; ARect: TRect; State: TOwnerDrawState);
procedure MemoBibleParagraphChange(Sender: TObject);
procedure MemoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure ToolEditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure StandardToolBarPaint(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure IdleTimerTimer(Sender: TObject);
procedure BookBoxClick(Sender: TObject);
procedure ChapterBoxClick(Sender: TObject);
procedure MemoMouseLeave(Sender: TObject);
procedure MemoContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
procedure MemoMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: integer);
procedure MemoSelectionChange(Sender: TObject);
procedure miBibleFolderClick(Sender: TObject);
procedure miDownloadClick(Sender: TObject);
procedure miHomeClick(Sender: TObject);
procedure miIssueClick(Sender: TObject);
procedure miDonateClick(Sender: TObject);
procedure PageControlChange(Sender: TObject);
procedure PageControlMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure pmCloseClick(Sender: TObject);
procedure PopupMenuPopup(Sender: TObject);
procedure ToolButtonDonateClick(Sender: TObject);
procedure ToolButtonSearchClick(Sender: TObject);
private
NoteFileName: string;
RecentList: TStringArray;
Statuses: TStatuses;
IdleMessage : string;
showed : boolean;
function UnboundMemo: TUnboundMemo;
function CheckFileSave: boolean;
procedure LoadComboBox;
procedure EnableActions;
procedure FirstAppearance;
procedure UpDownButtons;
procedure SelectBook(title: string; scroll: boolean);
procedure ShowCurrVerse(select: boolean);
procedure ShowCurrBible;
procedure LoadChapter;
procedure LoadSearch(s: string);
procedure LoadCompare;
procedure LoadReference;
procedure LoadCommentary;
procedure LoadDictionary(s: string);
procedure LoadHistory;
procedure LoadStrong(s: string);
procedure LoadFootnote(s: string);
procedure MakeBookList;
procedure MakeChapterList;
procedure OnRecentClick(Sender: TObject);
procedure PerformFileOpen(const FileName: string);
procedure ReadConfig;
procedure RebuildRecentList;
procedure MakeRecentMenu;
procedure HideCursor;
procedure SaveConfig;
procedure SelectPage(page: integer);
procedure UpdateCaption(s: string);
procedure RefreshStatus;
procedure UpdateStatus(s: string);
procedure UpdateActionImage;
procedure VersesToClipboard;
procedure ShowPopup;
procedure Localize;
public
procedure AssignFont;
procedure LocalizeApplication;
end;
var
MainForm: TMainForm;
implementation
uses
{$ifdef windows} UmParseWin, {$endif}
FormAbout, FormNotify, FormSearch, FormOptions, FormCopy, FormShelf,
UnitTools, UnitLocal, UnitModule, UnitBible, UnitCommentary, UnitDictionary;
const
apBible = 0; // active page
apSearch = 1;
apCompare = 2;
apReferences = 3;
apCommentaries = 4;
apDictionaries = 5;
apHistory = 6;
apNotes = 7;
{$R *.lfm}
//=================================================================================================
// Create Main Form
//=================================================================================================
procedure TMainForm.FormCreate(Sender: TObject);
begin
Localization := TLocalization.Create;
Statuses := TStatuses.Create;
Caption := ApplicationName + ' ' + ApplicationVersion;
RecentList := [];
showed := False;
SaveDialog.InitialDir := DocumentsPath;
NoteFileName := Untitled;
ReadConfig;
AssignFont;
MakeRecentMenu;
NoteFileName := Untitled;
MemoNotes.Lines.Clear;
MemoNotes.Font.Size := Font.Size;
IdleMessage := '';
ShowCurrBible;
{$ifdef windows}
TabSheetSearch .TabVisible := False;
TabSheetReference .TabVisible := False;
TabSheetCommentary.TabVisible := False;
TabSheetDictionary.TabVisible := False;
TabSheetHistory .TabVisible := False;
IdleTimer.Interval := 50;
{$endif}
{$ifdef linux}
StandardToolBar.ParentColor := True;
ToolPanel.Color := clForm;
ActionFilePrint.Visible := False;
ActionEditUndo.Visible := False;
ActionBullets.Visible := False;
ToolSeparator6.Visible := False;
{$endif}
{$ifndef darwin} UpdateActionImage; {$endif}
end;
procedure TMainForm.FormDestroy(Sender: TObject);
begin
SaveConfig;
Statuses.Free;
Localization.Free;
end;
procedure TMainForm.FirstAppearance;
begin
LocalizeApplication;
{$ifdef linux}
TabSheetSearch .TabVisible := False;
TabSheetReference .TabVisible := False;
TabSheetCommentary.TabVisible := False;
TabSheetDictionary.TabVisible := False;
TabSheetHistory .TabVisible := False;
ShowCurrVerse(CurrVerse.number > 1);
{$endif}
end;
procedure TMainForm.FormShow(Sender: TObject);
begin
if not showed then FirstAppearance;
showed := True;
{$ifdef windows} IdleMessage := 'HideCursor'; {$endif}
end;
procedure TMainForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
{$ifdef linux}
MemoBible .Clear;
MemoCommentary.Clear;
MemoCompare .Clear;
MemoDictionary.Clear;
MemoHistory .Clear;
MemoNotes .Clear;
MemoReference .Clear;
MemoSearch .Clear;
{$endif}
end;
procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: boolean);
begin
try
CanClose := CheckFileSave;
except
CanClose := False;
end;
end;
procedure TMainForm.StandardToolBarPaint(Sender: TObject);
begin
ToolPanel.Width := StandardToolBar.Width - ToolButtonRight.Width - ToolButtonSearch.Width
- {$ifdef linux} ToolButtonRight.Left {$else} ToolButtonBullets.Left {$endif};
ToolEdit.Left := StandardToolBar.Width - ToolButtonSearch.Width - ToolEdit.Width - 4;
ToolEdit.Visible := ToolPanel.Width > ToolEdit.Width;
end;
procedure TMainForm.MemoMouseLeave(Sender: TObject);
var
Point : TPoint;
begin
if NotifyForm.Visible then
begin
Point := UnboundMemo.ScreenToClient(Mouse.CursorPos);
if (Point.x <= 0) or (Point.x >= UnboundMemo.Width - 30) or
(Point.y <= 0) or (Point.y >= UnboundMemo.Height - 30) then NotifyForm.Close;
end;
end;
procedure TMainForm.AssignFont;
begin
MemoBible.Font.Assign(Font);
MemoCommentary.Font.Assign(Font);
MemoCompare.Font.Assign(Font);
MemoDictionary.Font.Assign(Font);
MemoHistory.Font.Assign(Font);
MemoReference.Font.Assign(Font);
MemoSearch.Font.Assign(Font);
end;
procedure TMainForm.Localize;
begin
miBibleFolder.Caption := T('Bible Folder');
miClear.Caption := T('Delete');
miCommentaries.Caption := T('Commentaries');
miCompare.Caption := T('Compare');
miCopy.Caption := T('Copy');
miCopyAs.Caption := T('Copy As…');
miCut.Caption := T('Cut');
miDictionaries.Caption := T('Dictionaries');
miDonate.Caption := T('Donate');
miDownload.Caption := T('Modules Downloads');
miEdit.Caption := T('Edit');
miExit.Caption := T('Exit');
miHelp.Caption := T('Help');
miHelpAbout.Caption := T('About');
miHistory.Caption := T('History');
miHome.Caption := T('Home Page');
miInterlinear.Caption := T('Interlinear') + ' (biblehub.com)';
miIssue.Caption := T('Report an Issue');
miModules.Caption := T('Modules');
miNoteNew.Caption := T('New');
miNoteOpen.Caption := T('Open…');
miNoteSave.Caption := T('Save');
miNoteSaveAs.Caption := T('Save As…');
miNotes.Caption := T('Notes');
miOptions.Caption := T('Options');
miPaste.Caption := T('Paste');
miPrint.Caption := T('Print');
miRecent.Caption := T('Open Recent');
miRrefx.Caption := T('Cross-References');
miSearch.Caption := T('Search');
miSelectAll.Caption := T('Select All');
miTools.Caption := T('Tools');
miUndo.Caption := T('Undo');
miVerses.Caption := T('Copy Verses');
pmCleanHistory.Caption := T('Clean History');
pmClose.Caption := T('Close');
pmCopy.Caption := T('Copy');
pmCopyAs.Caption := T('Copy As…');
pmCut.Caption := T('Cut');
pmPaste.Caption := T('Paste');
pmVerses.Caption := T('Copy Verses');
TabSheetBible.Caption := T('Bible');
TabSheetCommentary.Caption := T('Commentaries');
TabSheetCompare.Caption := T('Compare');
TabSheetDictionary.Caption := T('Dictionaries');
TabSheetHistory.Caption := T('History');
TabSheetNotes.Caption := T('Notes');
TabSheetReference.Caption := T('Cross-References');
TabSheetSearch.Caption := T('Search');
ToolButtonBold.Hint := T('Bold');
ToolButtonBullets.Hint := T('Bullets');
ToolButtonCenter.Hint := T('Center');
ToolButtonCommentary.Hint := T('Commentaries');
ToolButtonCopy.Hint := T('Copy');
ToolButtonCut.Hint := T('Cut');
ToolButtonDictionary.Hint := T('Dictionaries');
ToolButtonFont.Hint := T('Font');
ToolButtonHistory.Hint := T('History');
ToolButtonItalic.Hint := T('Italic');
ToolButtonLeft.Hint := T('Align Left');
ToolButtonLink.Hint := T('Hyperlink');
ToolButtonNew.Hint := T('New');
ToolButtonOpen.Hint := T('Open');
ToolButtonPaste.Hint := T('Paste');
ToolButtonPrint.Hint := T('Print');
ToolButtonReference.Hint := T('Cross-References');
ToolButtonRight.Hint := T('Align Right');
ToolButtonSave.Hint := T('Save');
ToolButtonSearch.Hint := T('Search Options');
ToolButtonShelf.Hint := T('Modules');
ToolButtonUnderline.Hint := T('Underline');
ToolButtonUndo.Hint := T('Undo');
ToolButtonVerses.Hint := T('Copy Verses');
end;
procedure TMainForm.LocalizeApplication;
begin
MainForm .Localize;
AboutBox .Localize;
CopyForm .Localize;
OptionsForm .Localize;
SearchForm .Localize;
ShelfForm .Localize;
ShelfForm .Localize;
end;
//-------------------------------------------------------------------------------------------------
// Actions
//-------------------------------------------------------------------------------------------------
procedure TMainForm.CmdAbout(Sender: TObject);
begin
AboutBox.ShowModal;
end;
procedure TMainForm.CmdStyle(Sender: TObject);
var
fp: TFontParams;
begin
fp := MemoNotes.SelAttributes;
MemoNotes.SaveSelection;
if MemoNotes.SelLength = 0 then MemoNotes.SelectWord;
if Sender = ActionBold then
if fsBold in fp.Style then fp.Style := fp.Style - [fsBold]
else fp.Style := fp.Style + [fsBold];
if Sender = ActionItalic then
if fsItalic in fp.Style then fp.Style := fp.Style - [fsItalic]
else fp.Style := fp.Style + [fsItalic];
if Sender = ActionUnderline then
if fsUnderline in fp.Style then fp.Style := fp.Style - [fsUnderline]
else fp.Style := fp.Style + [fsUnderline];
if Sender = ActionLink then
if fp.Color = clNavy then fp.Color := clBlack
else fp.Color := clNavy;
//if Sender = ActionSuper then
// if fp.vScriptPos = vpSuperscript then fp.vScriptPos := vpNormal
// else fp.vScriptPos := vpSuperscript;
if Sender = ActionIncrease then fp.Size += 1;
if Sender = ActionDecrease then fp.Size -= 1;
if Sender = ActionFont then
begin
FontDialogNotes.Font.Name := fp.Name;
FontDialogNotes.Font.Size := fp.Size;
FontDialogNotes.Font.Style := fp.Style;
FontDialogNotes.Font.Color := fp.Color;
if FontDialogNotes.Execute then
begin
fp.Name := FontDialogNotes.Font.Name;
fp.Size := FontDialogNotes.Font.Size;
fp.Style := FontDialogNotes.Font.Style;
fp.Color := FontDialogNotes.Font.Color;
end;
end;
MemoNotes.SetTextAttributes(MemoNotes.SelStart, MemoNotes.SelLength, fp);
MemoNotes.RestoreSelection; // unselect word
MemoNotes.Repaint;
end;
procedure TMainForm.CmdStyle2(Sender: TObject);
{$ifdef windows} var pn : TParaNumbering; {$endif}
begin
with MemoNotes do
begin
if Sender = ActionLeft then SetParaAlignment(SelStart, SelLength, paLeft );
if Sender = ActionCenter then SetParaAlignment(SelStart, SelLength, paCenter );
if Sender = ActionRight then SetParaAlignment(SelStart, SelLength, paRight );
{$ifdef windows}
if Sender = ActionBullets then
begin
pn := SelParaNumbering;
if pn.Style = pnNone then pn.Style := pnBullet else pn.Style := pnNone;
SetParaNumbering(SelStart, SelLength, pn);
end;
{$endif}
end;
MemoNotes.Repaint;
end;
procedure TMainForm.ComboBoxChange(Sender: TObject);
begin
if Tools.SetCurrBible(ComboBox.Items[ComboBox.ItemIndex]) then ShowCurrBible;
end;
procedure TMainForm.ComboBoxDrawItem(Control: TWinControl; Index: integer; ARect: TRect; State: TOwnerDrawState);
begin
ComboBox.canvas.fillrect(ARect);
Canvas.TextOut(ARect.Left + 5, ARect.Top, ComboBox.Items[Index]);
Canvas.TextOut(ARect.Left + 220, ARect.Top, '[ru]');
end;
procedure TMainForm.CmdCompare(Sender: TObject);
begin
LoadCompare;
end;
procedure TMainForm.CmdInterline(Sender: TObject);
var path : string;
begin
path := BibleHubURL(CurrVerse.book, CurrVerse.chapter, CurrVerse.number);
if path <> '' then OpenURL(path);
end;
procedure TMainForm.CmdEdit(Sender: TObject);
begin
if Sender = ActionEditCopy then UnboundMemo.CopyToClipboard;
if Sender = ActionEditPaste then UnboundMemo.PasteFromClipboard;
if Sender = ActionEditDel then UnboundMemo.ClearSelection;
if Sender = ActionEditUndo then UnboundMemo.Undo;
if Sender = ActionEditSelAll then UnboundMemo.SelectAll;
if Sender = ActionEditCut then
begin
UnboundMemo.CopyToClipboard;
UnboundMemo.ClearSelection;
end;
EnableActions;
end;
procedure TMainForm.CmdCopyAs(Sender: TObject);
begin
// saving selection because of strange bug in the gtk2's richmemo
{$ifdef linux} MemoBible.SaveSelection; {$endif}
CopyForm.Memo.Font.Assign(Font);
CopyForm.ShowModal;
{$ifdef linux} MemoBible.RestoreSelection; {$endif}
end;
procedure TMainForm.CmdCopyVerses(Sender: TObject);
begin
{$ifdef unix} MemoBible.SaveSelection; {$endif}
VersesToClipboard;
{$ifdef unix} MemoBible.RestoreSelection; {$endif}
end;
procedure TMainForm.CmdSearch(Sender: TObject);
begin
ToolEdit.SetFocus;
end;
procedure TMainForm.CmdSearchFor(Sender: TObject);
begin
ToolEdit.Text := Trim(UnboundMemo.SelText);
LoadSearch(ToolEdit.Text);
end;
procedure TMainForm.CmdReference(Sender: TObject);
begin
LoadReference;
end;
procedure TMainForm.CmdHistory(Sender: TObject);
begin
LoadHistory;
end;
procedure TMainForm.CmdCleanHistory(Sender: TObject);
begin
Tools.CleanHistory;
MemoHistory.Clear;
end;
procedure TMainForm.CmdCommentaries(Sender: TObject);
var
Response : integer;
begin
if Tools.Commentaries.FootnotesOnly then
begin
Response := QuestionDlg(T('Commentaries'),
T('You don''t have any commentary modules.'), mtCustom,
[mrYes, T('Download'), mrNo, T('Cancel')], '');
if Response = idYes then OpenURL(DownloadsURL);
Exit;
end;
LoadCommentary;
end;
procedure TMainForm.CmdLookup(Sender: TObject);
begin
ToolEdit.Text := Trim(UnboundMemo.SelText);
CmdDictionaries(Sender);
end;
procedure TMainForm.CmdDictionaries(Sender: TObject);
begin
if Tools.Dictionaries.EmbeddedOnly then
begin
if QuestionDlg(T('Dictionaries'),
T('You don''t have any dictionary modules.'), mtCustom,
[mrYes, T('Download'), mrNo, T('Cancel')], '') = idYes then
OpenURL(DownloadsURL);
Exit;
end;
LoadDictionary(ToolEdit.Text);
end;
procedure TMainForm.CmdFileNew(Sender: TObject);
begin
SelectPage(apNotes);
if not CheckFileSave then Exit;
NoteFileName := Untitled;
MemoNotes.Lines.Clear;
MemoNotes.Modified := False;
UpdateCaption(NoteFileName);
end;
procedure TMainForm.CmdFileOpen(Sender: TObject);
begin
if not CheckFileSave then Exit;
if OpenDialog.Execute then
begin
PerformFileOpen(OpenDialog.FileName);
MemoNotes.ReadOnly := ofReadOnly in OpenDialog.Options;
end;
end;
procedure TMainForm.CmdFileSave(Sender: TObject);
begin
SelectPage(apNotes);
if not MemoNotes.Modified then Exit;
if NoteFileName = Untitled then
CmdFileSaveAs(Sender)
else
begin
MemoNotes.SaveToFile(NoteFileName);
MemoNotes.Modified := False;
end;
end;
procedure TMainForm.CmdFileSaveAs(Sender: TObject);
begin
SelectPage(apNotes);
if NoteFileName = Untitled then SaveDialog.InitialDir := DocumentsPath
else SaveDialog.InitialDir := ExtractFilePath(NoteFileName);
if not SaveDialog.Execute then Exit;
if not SaveDialog.FileName.Contains('.rtf') then
SaveDialog.FileName := SaveDialog.FileName + '.rtf';
if FileExists(SaveDialog.FileName) then
if QuestionDlg(' ' + T('Confirmation'),
Format(T('OK to overwrite %s?'), [SaveDialog.FileName]), mtWarning,
[mrYes, T('Yes'), mrNo, T('No'), 'IsDefault'], 0) <> idYes then Exit;
MemoNotes.SaveToFile(SaveDialog.FileName);
NoteFileName := SaveDialog.FileName;
RebuildRecentList;
MemoNotes.Modified := False;
UpdateCaption(ExtractOnlyName(NoteFileName));
end;
procedure TMainForm.CmdFilePrint(Sender: TObject);
var
Params : TPrintParams;
begin
InitPrintParams(Params{%H-});
if PrintDialog.Execute then UnboundMemo.Print(Params);
end;
procedure TMainForm.CmdModules(Sender: TObject);
begin
if ShelfForm.ShowModal = mrOk then ShowCurrBible else LoadComboBox;
if PageControl.ActivePageIndex = apCompare then LoadCompare;
end;
procedure TMainForm.CmdExit(Sender: TObject);
begin
Close;
end;
//-------------------------------------------------------------------------------------------------
// Events
//-------------------------------------------------------------------------------------------------
procedure TMainForm.BookBoxClick(Sender: TObject);
var
Book : TBook;
name : string;
begin
if BookBox.Count = 0 then Exit;
name := BookBox.Items[BookBox.ItemIndex];
Book := CurrBible.BookByName(name);
if not Assigned(Book) then Exit;
CurrVerse.Init;
CurrVerse.Book := Book.Number;
MakeChapterList;
LoadChapter;
end;
procedure TMainForm.ChapterBoxClick(Sender: TObject);
begin
CurrVerse.Chapter := ChapterBox.ItemIndex + 1;
CurrVerse.Number := 1;
CurrVerse.Count := 1;
LoadChapter;
end;
procedure TMainForm.MemoMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: integer);
var
Memo : TUnboundMemo;
Verse : TVerse;
s : string;
begin
Memo := Sender as TUnboundMemo;
if Button = mbRight then ShowPopup;
if Button <> mbLeft then Exit;
if Memo = MemoBible then Tools.AddHistory;
if Memo.hyperlink.isEmpty then Exit;
if Memo.Foreground = fgLink then
begin
if Memo = MemoHistory then
begin
s := Tools.FilenameFromHistory(Round((Memo.Breaks/2)));
if Tools.SetCurrBible(s) then ShowCurrBible;
end;
Verse := CurrBible.SrtToVerse(Memo.hyperlink);
if CurrBible.GoodLink(Verse) then
begin
CurrVerse := Verse;
ShowCurrVerse(True);
Tools.AddHistory;
end
else
if Tools.SetCurrBible(Memo.hyperlink)then ShowCurrBible;
end;
if Memo = MemoBible then
if Memo.Foreground = fgFootnote then LoadFootnote(Memo.hyperlink);
if Memo <> MemoNotes then
if Memo.Foreground = fgStrong then LoadStrong(Memo.hyperlink);
end;
procedure TMainForm.MemoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (Key = VK_APPS) or ((Key = VK_F10) and (Shift = [ssShift])) then ShowPopup;
end;
procedure TMainForm.MemoSelectionChange(Sender: TObject);
begin
EnableActions;
if Sender = MemoNotes then UpDownButtons;
end;
procedure TMainForm.MemoBibleParagraphChange(Sender: TObject);
begin
CurrVerse.Number := MemoBible.ParagraphStart;
CurrVerse.Count := MemoBible.ParagraphCount;
end;
procedure TMainForm.MemoContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
begin
Handled := True; // disable system popup menu
end;
procedure TMainForm.ToolEditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var
Verse: TVerse;
begin
if Key = VK_RETURN then
begin
Verse := CurrBible.SrtToVerse(trim(ToolEdit.Text));
if CurrBible.GoodLink(Verse) then
begin
CurrVerse := Verse;
ShowCurrVerse(True)
end
else if PageControl.ActivePageIndex = apDictionaries then LoadDictionary(ToolEdit.Text)
else LoadSearch(ToolEdit.Text);
end;
end;
//-------------------------------------------------------------------------------------------------
procedure TMainForm.LoadComboBox;
var
Item : string;
begin
ComboBox.Items.Clear;
for Item in Tools.Get_FavoriteBiles do
begin
ComboBox.Items.Add(Item);
if Item = CurrBible.name then ComboBox.ItemIndex := ComboBox.Items.Count - 1;
end;
end;
procedure TMainForm.UpdateCaption(s: string);
begin
Caption := ApplicationName + ' ' + ApplicationVersion + ' - ' + s;
end;
procedure TMainForm.RefreshStatus;
begin
try
StatusBar.SimpleText := ' ' + Statuses.KeyData[PageControl.ActivePageIndex];
except
StatusBar.SimpleText := '';
end;
end;
procedure TMainForm.UpdateStatus(s: string);
begin
Statuses.AddOrSetData(PageControl.ActivePageIndex, s);
RefreshStatus;
end;
procedure TMainForm.ShowPopup;
var
CursorPos: TPoint;
begin
GetCursorPos(CursorPos);
PopupMenu.Popup(CursorPos.X, CursorPos.Y);
end;
procedure TMainForm.SelectBook(title: string; scroll: boolean);
var
item : string;
begin
for item in BookBox.Items do
if item = title then
begin
BookBox.ItemIndex := BookBox.Items.IndexOf(item);
if scroll then BookBox.TopIndex := BookBox.ItemIndex;
end;
end;
procedure TMainForm.ShowCurrVerse(select: boolean);
var
Book : TBook;
begin
Book := CurrBible.BookByNum(CurrVerse.Book);
if not Assigned(Book) then Exit;
MakeChapterList;
LoadChapter;
SelectBook(Book.title, TModule.IsNewTestament(CurrVerse.book));
ChapterBox.ItemIndex := CurrVerse.Chapter - 1;
if select then MemoBible.SelectParagraph(CurrVerse.Number);
Repaint;
end;
procedure TMainForm.ShowCurrBible;
var