| 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 "ethereum.h" |
| 14 | #include "../dialog.h" |
| 15 | |
| 16 | static PaymentMethod *MethodEthereumFactory() |
| 17 | { |
| 18 | return new MethodEthereum(); |
| 19 | } |
| 20 | |
| 21 | Bool methodEthereumRegistered = DonateDialog::RegisterPaymentMethod(&MethodEthereumFactory); |
| 22 | |
| 23 | BoCA::MethodEthereum::MethodEthereum() : PaymentMethod("ethereum") |
| 24 | { |
| 25 | layer = NIL; |
| 26 | |
| 27 | /* Load Ethereum 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("/ethereum/logo.png")); |
| 34 | } |
| 35 | |
| 36 | BoCA::MethodEthereum::~MethodEthereum() |
| 37 | { |
| 38 | if (layer != NIL) Object::DeleteObject(layer); |
| 39 | } |
| 40 | |
| 41 | Layer *BoCA::MethodEthereum::GetLayer() |
| 42 | { |
| 43 | if (layer == NIL) layer = new LayerEthereum(); |
| 44 | |
| 45 | return layer; |
| 46 | } |
| 47 | |
| 48 | BoCA::LayerEthereum::LayerEthereum() |
| 49 | { |
| 50 | I18n *i18n = I18n::Get(); |
| 51 | |
| 52 | i18n->SetContext("Extensions::Donate::Ethereum"); |
| 53 | |
| 54 | Directory dir(Utilities::GetBoCADirectory().Append("freac.extension.donate")); |
| 55 | |
| 56 | if (!dir.Exists()) dir = Utilities::GetBoCADirectory().Append("../freac/freac.extension.donate"); |
| 57 | |
| 58 | link_qrcode = new Hyperlink(ImageLoader::Load(String(dir).Append("/ethereum/qrcode.png")), "ethereum:0xa7bac27ae9036c6f0a7ca4227b7234a79de93faf", Point(101, 4), Size(96, 96)); |
| 59 | link_qrcode->SetOrientation(OR_UPPERRIGHT); |
| 60 | |
| 61 | text_donate = new Text(i18n->TranslateString("Please scan or click the QR code or copy the following\naddress to donate Ethereum:"), Point(7, 4)); |
| 62 | |
| 63 | cursor_ether = new Cursor(Point(7, text_donate->GetUnscaledTextHeight() + 24), Size(210, 16)); |
| 64 | cursor_ether->SetText("0xa7bac27ae9036c6f0a7ca4227b7234a79de93faf"); |
| 65 | cursor_ether->SetSize(Size(cursor_ether->GetUnscaledTextWidth(), cursor_ether->GetUnscaledTextHeight()) + Size(1, 3)); |
| 66 | cursor_ether->Deactivate(); |
| 67 | |
| 68 | text_other = new Text(i18n->TranslateString("This address also accepts Ether Classic and ERC20 tokens."), Point(7, cursor_ether->GetY() + cursor_ether->GetUnscaledTextHeight() + 22)); |
| 69 | |
| 70 | cursor_ether->SetX(7 + (Math::Max(text_donate->GetUnscaledTextWidth(), text_other->GetUnscaledTextWidth()) - cursor_ether->GetWidth()) / 2); |
| 71 | |
| 72 | Add(link_qrcode); |
| 73 | |
| 74 | Add(text_donate); |
| 75 | |
| 76 | Add(cursor_ether); |
| 77 | |
| 78 | Add(text_other); |
| 79 | |
| 80 | SetSize(Size(Math::Max(text_donate->GetUnscaledTextWidth(), text_other->GetUnscaledTextWidth()) + 116, Math::Max(103, text_other->GetY() + text_other->GetUnscaledTextHeight() + 6))); |
| 81 | } |
| 82 | |
| 83 | BoCA::LayerEthereum::~LayerEthereum() |
| 84 | { |
| 85 | DeleteObject(link_qrcode); |
| 86 | |
| 87 | DeleteObject(text_donate); |
| 88 | |
| 89 | DeleteObject(cursor_ether); |
| 90 | |
| 91 | DeleteObject(text_other); |
| 92 | } |