aboutsummaryrefslogtreecommitdiffstats
path: root/apps/windoze/CBuilder5/prototype/ModTabPanel.cpp
blob: 0d39acfe15d975c9447ecd826590f5c1ce4be0ce (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
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "ModTabPanel.h"
#pragma package(smart_init)
#include <swmgr.h>
#include "TextPanel.h"
#include "CommentPanel.h"
#include "LDPanel.h"
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//

static inline void ValidCtrCheck(TModTabPanel *)
{
	new TModTabPanel(NULL);
}
//---------------------------------------------------------------------------
__fastcall TModTabPanel::TModTabPanel(TComponent* Owner, SWMgr *mgr, char *modType)
	: TPanel(Owner)
{
	this->mgr = mgr;
	this->modType = modType;
}

void __fastcall TModTabPanel::CreateWnd() {
	TPanel::CreateWnd();
	ModMap::iterator it;
	SectionMap::iterator sit;
	ConfigEntMap::iterator eit;
	char *font;
	this->DragMode = dmAutomatic;
	this->DragKind = dkDock;
	this->UseDockManager = true;
	pageControl = new TPageControl(this);
	pageControl->Parent = this;
	pageControl->Align = alClient;
	pageControl->MultiLine = True;
	pageControl->ParentFont = False;
	pageControl->ParentShowHint = False;
	pageControl->ShowHint = True;
	pageControl->TabHeight = 14;
	pageControl->TabOrder = 0;
	pageControl->OnChange = PageControl1Change;
	for (it = mgr->Modules.begin(); it != mgr->Modules.end(); it++) {
		if ((!strcmp((*it).second->Type(), "Biblical Texts")) && (!strcmp(modType.c_str(), "Biblical Texts"))) {
			font = 0;
			if ((sit = mgr->config->Sections.find((*it).second->Name())) != mgr->config->Sections.end()) {
				if ((eit = (*sit).second.find("Font")) != (*sit).second.end()) {
					font = (char *)(*eit).second.c_str();
				}
			}
			TTabSheet *newtab = new TTabSheet(this);
			newtab->Caption = (*it).second->Name();
			newtab->Hint = (*it).second->Description();
			newtab->PageControl = pageControl;
			TTextPanel *panel = new TTextPanel(this, (*it).second, font);
			panel->Parent = newtab;
			panel->Align = alClient;
//			CreateTextPane((*it).second, font);
		}
		if ((!strcmp((*it).second->Type(), "Commentaries")) && (!strcmp(modType.c_str(), "Commentaries"))) {
			TTabSheet *newtab = new TTabSheet(this);
			newtab->Caption = (*it).second->Name();
			newtab->Hint = (*it).second->Description();
			newtab->PageControl = pageControl;
			TCommentPanel *panel = new TCommentPanel(this, (*it).second, mgr);
			panel->Parent = newtab;
			panel->Align = alClient;
//			CreateCommentPane((*it).second);
		}
		if ((!strcmp((*it).second->Type(), "Lexicons / Dictionaries")) && (!strcmp(modType.c_str(), "Lexicons / Dictionaries"))) {
			TTabSheet *newtab = new TTabSheet(this);
			newtab->Caption = (*it).second->Name();
			newtab->Hint = (*it).second->Description();
			newtab->PageControl = pageControl;
			TLDPanel *panel = new TLDPanel(this, (*it).second, mgr);
			panel->Parent = newtab;
			panel->Align = alClient;
//			CreateLDPane((*it).second);
		}
	}
}
//---------------------------------------------------------------------------
namespace Modtabpanel
{
	void __fastcall PACKAGE Register()
	{
		TComponentClass classes[1] = {__classid(TModTabPanel)};
		RegisterComponents("Samples", classes, 0);
	}
}
//---------------------------------------------------------------------------
void __fastcall TModTabPanel::PageControl1Change(TObject *Sender)
{
	RefreshActiveSheet();
//	Form1->ActiveControl = PageControl1;
}


void TModTabPanel::RefreshActiveSheet()
{
	ModMap::iterator it;
	
	it = mgr->Modules.find(pageControl->ActivePage->Caption.c_str());
	if (it != mgr->Modules.end()) {
		(*it).second->Display();
//		if (logmodstate)
//			modstates.insert(modstates.begin(), new ModState(pc, pc->ActivePage, (*it).second->KeyText()));
	}
}