| 1 | /* fre:ac - free audio converter |
| 2 | * Copyright (C) 2001-2021 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 <dialogs/charset.h> |
| 14 | |
| 15 | #include <config.h> |
| 16 | |
| 17 | #include <boca.h> |
| 18 | |
| 19 | freac::ChooseCharsetDialog::ChooseCharsetDialog() |
| 20 | { |
| 21 | BoCA::Config *config = BoCA::Config::Get(); |
| 22 | BoCA::I18n *i18n = BoCA::I18n::Get(); |
| 23 | |
| 24 | i18n->SetContext("Joblist::Character set"); |
| 25 | |
| 26 | mainWnd = new Window(i18n->TranslateString("Choose character set"), Point(config->GetIntValue(Config::CategorySettingsID, Config::SettingsWindowPosXID, Config::SettingsWindowPosXDefault), config->GetIntValue(Config::CategorySettingsID, Config::SettingsWindowPosYID, Config::SettingsWindowPosYDefault)) + Point(40, 40), Size(315, 128)); |
| 27 | mainWnd->SetRightToLeft(i18n->IsActiveLanguageRightToLeft()); |
| 28 | |
| 29 | mainWnd_titlebar = new Titlebar(TB_NONE); |
| 30 | divbar = new Divider(39, OR_HORZ | OR_BOTTOM); |
| 31 | |
| 32 | btn_cancel = new Button(i18n->TranslateString("Cancel"), Point(175, 29), Size()); |
| 33 | btn_cancel->onAction.Connect(&ChooseCharsetDialog::Cancel, this); |
| 34 | btn_cancel->SetOrientation(OR_LOWERRIGHT); |
| 35 | |
| 36 | btn_ok = new Button(i18n->TranslateString("OK"), Point(87, 29), Size()); |
| 37 | btn_ok->onAction.Connect(&ChooseCharsetDialog::OK, this); |
| 38 | btn_ok->SetOrientation(OR_LOWERRIGHT); |
| 39 | |
| 40 | group_charset = new GroupBox(i18n->TranslateString("Character set"), Point(7, 11), Size(293, 37)); |
| 41 | |
| 42 | text_charset = new Text(i18n->AddColon(i18n->TranslateString("Choose character set")), Point(9, 12)); |
| 43 | edit_charset = new EditBox(config->GetStringValue(Config::CategorySettingsID, Config::SettingsLastCustomCharsetID, Config::SettingsLastCustomCharsetDefault), Point(16 + text_charset->GetUnscaledTextWidth(), 9), Size(268 - text_charset->GetUnscaledTextWidth(), 0)); |
| 44 | |
| 45 | group_charset->Add(text_charset); |
| 46 | group_charset->Add(edit_charset); |
| 47 | |
| 48 | Add(mainWnd); |
| 49 | |
| 50 | mainWnd->Add(group_charset); |
| 51 | |
| 52 | mainWnd->Add(mainWnd_titlebar); |
| 53 | mainWnd->Add(divbar); |
| 54 | mainWnd->Add(btn_ok); |
| 55 | mainWnd->Add(btn_cancel); |
| 56 | |
| 57 | mainWnd->SetFlags(mainWnd->GetFlags() | WF_NOTASKBUTTON | WF_MODAL); |
| 58 | mainWnd->SetIcon(ImageLoader::Load(String(Config::Get()->resourcesPath).Append("icons/freac.png"))); |
| 59 | } |
| 60 | |
| 61 | freac::ChooseCharsetDialog::~ChooseCharsetDialog() |
| 62 | { |
| 63 | DeleteObject(mainWnd_titlebar); |
| 64 | DeleteObject(mainWnd); |
| 65 | DeleteObject(divbar); |
| 66 | DeleteObject(group_charset); |
| 67 | DeleteObject(text_charset); |
| 68 | DeleteObject(edit_charset); |
| 69 | DeleteObject(btn_ok); |
| 70 | DeleteObject(btn_cancel); |
| 71 | } |
| 72 | |
| 73 | const Error &freac::ChooseCharsetDialog::ShowDialog() |
| 74 | { |
| 75 | mainWnd->WaitUntilClosed(); |
| 76 | |
| 77 | return error; |
| 78 | } |
| 79 | |
| 80 | String freac::ChooseCharsetDialog::GetCharset() const |
| 81 | { |
| 82 | return edit_charset->GetText(); |
| 83 | } |
| 84 | |
| 85 | Void freac::ChooseCharsetDialog::OK() |
| 86 | { |
| 87 | BoCA::Config::Get()->SetStringValue(Config::CategorySettingsID, Config::SettingsLastCustomCharsetID, edit_charset->GetText()); |
| 88 | |
| 89 | mainWnd->Close(); |
| 90 | } |
| 91 | |
| 92 | Void freac::ChooseCharsetDialog::Cancel() |
| 93 | { |
| 94 | error = Error(); |
| 95 | |
| 96 | mainWnd->Close(); |
| 97 | } |