Debian Codegraph @

components/extension/donate/methods/sepa.cpp

raw symbols SCIP
1 /* fre:ac - free audio converter
2 * Copyright (C) 2001-2019 Robert Kausch <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation, either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
10 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
11 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
12
13 #include "sepa.h"
14 #include "../dialog.h"
15
16 static PaymentMethod *MethodSEPAFactory()
17 {
18 return new MethodSEPA();
19 }
20
21 Bool methodSEPARegistered = DonateDialog::RegisterPaymentMethod(&MethodSEPAFactory);
22
23 BoCA::MethodSEPA::MethodSEPA() : PaymentMethod("sepa")
24 {
25 layer = NIL;
26
27 /* Load SEPA logo.
28 */
29 Directory dir(Utilities::GetBoCADirectory().Append("freac.extension.donate"));
30
31 if (!dir.Exists()) dir = Utilities::GetBoCADirectory().Append("../freac/freac.extension.donate");
32
33 logo = ImageLoader::Load(String(dir).Append("/sepa/logo.png"));
34 }
35
36 BoCA::MethodSEPA::~MethodSEPA()
37 {
38 if (layer != NIL) Object::DeleteObject(layer);
39 }
40
41 Layer *BoCA::MethodSEPA::GetLayer()
42 {
43 if (layer == NIL) layer = new LayerSEPA();
44
45 return layer;
46 }
47
48 BoCA::LayerSEPA::LayerSEPA()
49 {
50 I18n *i18n = I18n::Get();
51
52 i18n->SetContext("Extensions::Donate::SEPA");
53
54 text_donate = new Text(i18n->TranslateString("You can donate by making an electronic transfer to the\nfollowing account:"), Point(7, 4));
55
56 Directory dir(Utilities::GetBoCADirectory().Append("freac.extension.donate"));
57
58 if (!dir.Exists()) dir = Utilities::GetBoCADirectory().Append("../freac/freac.extension.donate");
59
60 image_sepa = new Image(ImageLoader::Load(String(dir).Append("/sepa/sepa.png")), Point(101, 4), Size(96, 96));
61 image_sepa->SetOrientation(OR_UPPERRIGHT);
62
63 text_owner = new Text(i18n->TranslateString("Account holder:"), Point(15, text_donate->GetUnscaledTextHeight() + 24));
64 text_iban = new Text(i18n->TranslateString("IBAN:"), Point(15, text_owner->GetY() + text_owner->GetUnscaledTextHeight() + 5));
65 text_bic = new Text(i18n->TranslateString("BIC:"), Point(15, text_iban->GetY() + text_iban->GetUnscaledTextHeight() + 5));
66
67 cursor_owner = new Cursor(Point(15, text_owner->GetY() - 1), Size(175, text_owner->GetUnscaledTextHeight() + 4));
68 cursor_owner->SetText("Robert Kausch");
69 cursor_owner->Deactivate();
70
71 cursor_iban = new Cursor(Point(15, text_iban->GetY() - 1), Size(175, text_iban->GetUnscaledTextHeight() + 4));
72 cursor_iban->SetText("DE11 2001 0020 0851 8512 07");
73 cursor_iban->Deactivate();
74
75 cursor_bic = new Cursor(Point(15, text_bic->GetY() - 1), Size(175, text_bic->GetUnscaledTextHeight() + 4));
76 cursor_bic->SetText("PBNKDEFF");
77 cursor_bic->Deactivate();
78
79 Int maxTextSize = Math::Max(Math::Max(text_owner->GetUnscaledTextWidth(), text_iban->GetUnscaledTextWidth()), text_bic->GetUnscaledTextWidth());
80 Int maxInfoSize = Math::Max(Math::Max(cursor_owner->GetUnscaledTextWidth(), cursor_iban->GetUnscaledTextWidth()), cursor_bic->GetUnscaledTextWidth());
81
82 text_owner->SetPosition(text_donate->GetPosition() + Point((text_donate->GetUnscaledTextWidth() - (maxTextSize + maxInfoSize + 3)) / 2, text_donate->GetUnscaledTextHeight() + (88 - text_donate->GetUnscaledTextHeight() - 3 * text_owner->GetUnscaledTextHeight()) / 2));
83 text_iban->SetPosition(text_owner->GetPosition() + Point(0, text_owner->GetUnscaledTextHeight() + 5));
84 text_bic->SetPosition(text_iban->GetPosition() + Point(0, text_iban->GetUnscaledTextHeight() + 5));
85
86 cursor_owner->SetPosition(Point(text_owner->GetX() + maxTextSize + 3, text_owner->GetY() - 1));
87 cursor_iban->SetPosition(Point(cursor_owner->GetX(), text_iban->GetY() - 1));
88 cursor_bic->SetPosition(Point(cursor_owner->GetX(), text_bic->GetY() - 1));
89
90 Add(text_donate);
91
92 Add(image_sepa);
93
94 Add(text_owner);
95 Add(text_iban);
96 Add(text_bic);
97
98 Add(cursor_owner);
99 Add(cursor_iban);
100 Add(cursor_bic);
101
102 SetSize(Size(text_donate->GetUnscaledTextWidth() + 116, Math::Max(103, text_bic->GetY() + text_bic->GetUnscaledTextHeight() + 6)));
103 }
104
105 BoCA::LayerSEPA::~LayerSEPA()
106 {
107 DeleteObject(text_donate);
108
109 DeleteObject(image_sepa);
110
111 DeleteObject(text_owner);
112 DeleteObject(text_iban);
113 DeleteObject(text_bic);
114
115 DeleteObject(cursor_owner);
116 DeleteObject(cursor_iban);
117 DeleteObject(cursor_bic);
118 }