1 | //============================================================================ |
2 | // |
3 | // SSSS tt lll lll |
4 | // SS SS tt ll ll |
5 | // SS tttttt eeee ll ll aaaa |
6 | // SSSS tt ee ee ll ll aa |
7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" |
8 | // SS SS tt ee ll ll aa aa |
9 | // SSSS ttt eeeee llll llll aaaaa |
10 | // |
11 | // Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony |
12 | // and the Stella Team |
13 | // |
14 | // See the file "License.txt" for information on usage and redistribution of |
15 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. |
16 | //============================================================================ |
17 | |
18 | #include "Font.hxx" |
19 | #include "RomWidget.hxx" |
20 | #include "EditTextWidget.hxx" |
21 | #include "StringListWidget.hxx" |
22 | #include "ScrollBarWidget.hxx" |
23 | #include "StringParser.hxx" |
24 | #include "CartDebugWidget.hxx" |
25 | |
26 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
27 | CartDebugWidget::CartDebugWidget(GuiObject* boss, const GUI::Font& lfont, |
28 | const GUI::Font& nfont, |
29 | int x, int y, int w, int h) |
30 | : Widget(boss, lfont, x, y, w, h), |
31 | CommandSender(boss), |
32 | _nfont(nfont), |
33 | myFontWidth(lfont.getMaxCharWidth()), |
34 | myFontHeight(lfont.getFontHeight()), |
35 | myLineHeight(lfont.getLineHeight()), |
36 | myButtonHeight(myLineHeight + 4), |
37 | myDesc(nullptr) { } |
38 | |
39 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
40 | int CartDebugWidget::addBaseInformation(size_t bytes, const string& manufacturer, |
41 | const string& desc, const uInt16 maxlines) |
42 | { |
43 | const int lwidth = _font.getStringWidth("Manufacturer " ), |
44 | fwidth = _w - lwidth - 20; |
45 | EditTextWidget* w = nullptr; |
46 | ostringstream buf; |
47 | |
48 | int x = 2, y = 8; |
49 | |
50 | // Add ROM size, manufacturer and bankswitch info |
51 | new StaticTextWidget(_boss, _font, x, y + 1, "ROM Size " ); |
52 | buf << bytes << " bytes" ; |
53 | if(bytes >= 1024) |
54 | buf << " / " << (bytes/1024) << "KB" ; |
55 | |
56 | w = new EditTextWidget(_boss, _nfont, x+lwidth, y - 1, |
57 | fwidth, myLineHeight, buf.str()); |
58 | w->setEditable(false); |
59 | y += myLineHeight + 4; |
60 | |
61 | new StaticTextWidget(_boss, _font, x, y + 1, "Manufacturer " ); |
62 | w = new EditTextWidget(_boss, _nfont, x+lwidth, y - 1, |
63 | fwidth, myLineHeight, manufacturer); |
64 | w->setEditable(false); |
65 | y += myLineHeight + 4; |
66 | |
67 | StringParser bs(desc, (fwidth - kScrollBarWidth) / myFontWidth - 4); |
68 | const StringList& sl = bs.stringList(); |
69 | uInt32 lines = uInt32(sl.size()); |
70 | if(lines < 3) lines = 3; |
71 | if(lines > maxlines) lines = maxlines; |
72 | |
73 | new StaticTextWidget(_boss, _font, x, y + 1, "Description " ); |
74 | myDesc = new StringListWidget(_boss, _nfont, x+lwidth, y - 1, |
75 | fwidth, lines * myLineHeight, false); |
76 | myDesc->setEditable(false); |
77 | myDesc->setEnabled(false); |
78 | myDesc->setList(sl); |
79 | |
80 | y += myDesc->getHeight() + 4; |
81 | |
82 | return y; |
83 | } |
84 | |
85 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
86 | void CartDebugWidget::invalidate() |
87 | { |
88 | sendCommand(RomWidget::kInvalidateListing, -1, -1); |
89 | } |
90 | |
91 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
92 | void CartDebugWidget::loadConfig() |
93 | { |
94 | //myDesc->setSelected(0); |
95 | } |
96 | |