-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGitConduit.cpp
105 lines (97 loc) · 3.84 KB
/
GitConduit.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
//---------------------------------------------------------------------------
#include <fmx.h>
#ifdef _WIN32
#include <tchar.h>
#endif
#pragma hdrstop
#include <System.StartUpCopy.hpp>
//---------------------------------------------------------------------------
USEFORM("Main.cpp", Form2);
USEFORM("HttpModule.cpp", DataModule1); /* TDataModule: File Type */
//---------------------------------------------------------------------------
void __fastcall UpdateStyle();
void __fastcall SetListBoxItemMargins(Fmx::Types::TFmxObject* AStyle, const String AStyleLookup);
//---------------------------------------------------------------------------
extern "C" int FMXmain()
{
try
{
#if defined(_WINDOWS_)
TThread::CurrentThread->NameThreadForDebugging(System::UnicodeString("Main Thread"), TThread::CurrentThread->ThreadID);
#endif
UpdateStyle();
Application->Initialize();
Application->CreateForm(__classid(TForm2), &Form2);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
//---------------------------------------------------------------------------
void __fastcall UpdateStyle()
{
// If you call the SetStyle function in the initialization section of a unit on the main project file, before Application->Initialize, then it is applied to all forms.
// Set the style
Fmx::Types::TFmxObject* LStyle = TStyleStreaming::LoadFromResource(
(NativeUInt)HInstance, L"DATA_STYLE", RT_RCDATA);
TStyleManager::SetStyle(LStyle);
SetListBoxItemMargins(LStyle, "listboxitemnodetail");
SetListBoxItemMargins(LStyle, "listboxitembottomdetail");
}
//---------------------------------------------------------------------------
void __fastcall SetListBoxItemMargins(Fmx::Types::TFmxObject* AStyle, const String AStyleLookup)
{
Fmx::Types::TFmxObject* StyleResource = AStyle->FindStyleResource(AStyleLookup);
if(StyleResource != nullptr && StyleResource->ClassNameIs("TLayout") == true)
{
Fmx::Types::TFmxObject* GlyphStyleResource = StyleResource->FindStyleResource("glyphstyle");
if(GlyphStyleResource != nullptr && GlyphStyleResource->ClassNameIs("TGlyph") == true)
{
TGlyph* LGlyph = static_cast<TGlyph*>(GlyphStyleResource);
LGlyph->Margins->Top = 4.0f;
LGlyph->Margins->Bottom = 4.0f;
}
Fmx::Types::TFmxObject* IconStyleResource = StyleResource->FindStyleResource("icon");
if(IconStyleResource != nullptr && IconStyleResource->ClassNameIs("TImage") == true)
{
TImage* LImage = static_cast<TImage*>(IconStyleResource);
LImage->Margins->Top = 4.0f;
LImage->Margins->Bottom = 4.0f;
}
Fmx::Types::TFmxObject* CheckStyleResource = StyleResource->FindStyleResource("check");
if(CheckStyleResource != nullptr && CheckStyleResource->ClassNameIs("TCheckBox") == true)
{
TCheckBox* LCheckBox = static_cast<TCheckBox*>(CheckStyleResource);
LCheckBox->Margins->Left = 8.0f;
LCheckBox->Margins->Right = 0.0f;
}
Fmx::Types::TFmxObject* TextStyleResource = StyleResource->FindStyleResource("detail");
if(TextStyleResource != nullptr)
{
TText* LText = dynamic_cast<TText*>(TextStyleResource);
if(LText != nullptr)
{
LText->Height = 21; // Adjust height to fit font size
}
}
}
else
{
throw Exception("Style was changed, resource '" + AStyleLookup + "' is missing!");
}
}
//---------------------------------------------------------------------------