id
int64 0
755k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
65
| repo_stars
int64 100
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 9
values | repo_extraction_date
stringclasses 92
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
753,812
|
CapriceDevTools.cpp
|
ColinPitrat_caprice32/src/gui/src/CapriceDevTools.cpp
|
// 'DevTools' window for Caprice32
#include <algorithm>
#include <iomanip>
#include <map>
#include <string>
#include <sstream>
#include "std_ex.h"
#include "CapriceDevTools.h"
#include "devtools.h"
#include "cap32.h"
#include "log.h"
#include "stringutils.h"
#include "z80.h"
#include "z80_macros.h"
#include "z80_disassembly.h"
extern t_z80regs z80;
extern t_CPC CPC;
extern t_GateArray GateArray;
extern std::vector<Breakpoint> breakpoints;
extern std::vector<Watchpoint> watchpoints;
extern byte* pbROMlo;
extern byte* pbExpansionROM;
t_MemBankConfig memtool_membank_config;
namespace wGui {
int FormatSize(Format f)
{
switch(f)
{
case Format::Hex:
case Format::Char:
case Format::U8:
case Format::I8:
return 1;
case Format::U16:
case Format::I16:
return 2;
case Format::U32:
case Format::I32:
return 4;
};
LOG_ERROR("Missing FormatSize for " << f);
return 1;
}
std::ostream& operator<<(std::ostream& os, const Format& f)
{
switch(f)
{
case Format::Hex:
os << "hex";
break;
case Format::Char:
os << "char";
break;
case Format::U8:
os << "u8";
break;
case Format::U16:
os << "u16";
break;
case Format::U32:
os << "u32";
break;
case Format::I8:
os << "i8";
break;
case Format::I16:
os << "i16";
break;
case Format::I32:
os << "i32";
break;
default:
os << "!Unsupported!";
break;
}
return os;
}
std::ostream& operator<<(std::ostream& os, const std::vector<Format>& fs)
{
os << "[";
bool first = true;
for (auto f : fs)
{
if (!first) os << ",";
first = false;
os << f;
}
os << "]";
return os;
}
std::string RAMConfig::RAMConfigText(int i)
{
switch (i) {
case 0:
return "0 [0123]";
case 1:
return "1 [0127]";
case 2:
return "2 [4567]";
case 3:
return "3 [0327]";
case 4:
return "4 [0423]";
case 5:
return "5 [0523]";
case 6:
return "6 [0623]";
case 7:
return "7 [0723]";
default:
return "N/A";
}
}
std::string RAMConfig::RAMConfigText()
{
return RAMConfigText(RAMCfg);
}
RAMConfig RAMConfig::CurrentConfig()
{
RAMConfig result;
result.LoROMEnabled = !(GateArray.ROM_config & 4);
result.HiROMEnabled = !(GateArray.ROM_config & 8);
result.RAMBank = (GateArray.RAM_config & 0x38) >> 3;
result.RAMCfg = GateArray.RAM_config & 0x7;
return result;
}
CapriceDevTools::CapriceDevTools(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine, DevTools* devtools) :
CFrame(WindowRect, pParent, pFontEngine, "DevTools", false), m_pDevTools(devtools)
{
SetTitleBarHeight(0);
SetModal(true);
// Make this window listen to incoming CTRL_VALUECHANGE messages (used for updating scrollbar values)
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_VALUECHANGE);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_VALUECHANGING);
// Navigation bar
m_pNavigationBar = new CNavigationBar(this, CPoint(10, 5), 6, 50, 50);
m_pNavigationBar->AddItem(SNavBarItem("z80", CPC.resources_path + "/rom.bmp"));
m_pNavigationBar->AddItem(SNavBarItem("Asm", CPC.resources_path + "/asm.bmp"));
m_pNavigationBar->AddItem(SNavBarItem("Memory", CPC.resources_path + "/memory.bmp"));
m_pNavigationBar->AddItem(SNavBarItem("Video", CPC.resources_path + "/video.bmp"));
m_pNavigationBar->AddItem(SNavBarItem("Audio", CPC.resources_path + "/audio.bmp"));
m_pNavigationBar->AddItem(SNavBarItem("Char", CPC.resources_path + "/char.bmp"));
m_pNavigationBar->SelectItem(0);
m_pNavigationBar->SetIsFocusable(true);
// Groupboxes containing controls for each 'tab' (easier to make a 'tab page' visible or invisible)
m_pGroupBoxTabZ80 = new CGroupBox(CRect(CPoint(5, 60), m_ClientRect.Width() - 12, m_ClientRect.Height() - 80), this, "z80");
m_pGroupBoxTabAsm = new CGroupBox(CRect(CPoint(5, 60), m_ClientRect.Width() - 12, m_ClientRect.Height() - 80), this, "Assembly");
m_pGroupBoxTabMemory = new CGroupBox(CRect(CPoint(5, 60), m_ClientRect.Width() - 12, m_ClientRect.Height() - 80), this, "Memory");
m_pGroupBoxTabVideo = new CGroupBox(CRect(CPoint(5, 60), m_ClientRect.Width() - 12, m_ClientRect.Height() - 80), this, "Video");
m_pGroupBoxTabAudio = new CGroupBox(CRect(CPoint(5, 60), m_ClientRect.Width() - 12, m_ClientRect.Height() - 80), this, "Audio");
m_pGroupBoxTabChar = new CGroupBox(CRect(CPoint(5, 60), m_ClientRect.Width() - 12, m_ClientRect.Height() - 80), this, "Characters");
// Store associations, see EnableTab method:
TabMap["z80"] = m_pGroupBoxTabZ80;
TabMap["asm"] = m_pGroupBoxTabAsm;
TabMap["memory"] = m_pGroupBoxTabMemory;
TabMap["video"] = m_pGroupBoxTabVideo;
TabMap["audio"] = m_pGroupBoxTabAudio;
TabMap["char"] = m_pGroupBoxTabChar;
EnableTab("z80");
m_pButtonStepIn = new CButton(CRect(CPoint(m_ClientRect.Width() - 150, 5), 70, 15), this, "Step in");
m_pButtonStepIn->SetIsFocusable(true);
m_pToolTipStepIn = new CToolTip(m_pButtonStepIn, "One instruction", COLOR_BLACK);
m_pButtonStepOver = new CButton(CRect(CPoint(m_ClientRect.Width() - 150, 25), 70, 15), this, "Step over");
m_pButtonStepOver->SetIsFocusable(true);
m_pToolTipStepOver = new CToolTip(m_pButtonStepOver, "One instruction or call", COLOR_BLACK);
m_pButtonStepOut = new CButton(CRect(CPoint(m_ClientRect.Width() - 150, 45), 70, 15), this, "Step out");
m_pButtonStepOut->SetIsFocusable(true);
m_pToolTipStepOut = new CToolTip(m_pButtonStepOut, "Exit current call/interrupt", COLOR_BLACK);
m_pButtonPause = new CButton(CRect(CPoint(m_ClientRect.Width() - 70, 25), 50, 15), this, (CPC.paused ? "Resume" : "Pause"));
m_pButtonPause->SetIsFocusable(true);
m_pButtonClose = new CButton(CRect(CPoint(m_ClientRect.Width() - 70, 45), 50, 15), this, "Close");
m_pButtonClose->SetIsFocusable(true);
auto monoFontEngine = Application().GetFontEngine(CPC.resources_path + "/vera_mono.ttf", 10);
// ---------------- 'z80' screen ----------------
m_pZ80RegA = new CRegister(CRect(CPoint(10, 10), 110, 20), m_pGroupBoxTabZ80, "A");
m_pZ80RegAp = new CRegister(CRect(CPoint(150, 10), 110, 20), m_pGroupBoxTabZ80, "A'");
m_pZ80RegB = new CRegister(CRect(CPoint(10, 30), 110, 20), m_pGroupBoxTabZ80, "B");
m_pZ80RegBp = new CRegister(CRect(CPoint(150, 30), 110, 20), m_pGroupBoxTabZ80, "B'");
m_pZ80RegC = new CRegister(CRect(CPoint(10, 50), 110, 20), m_pGroupBoxTabZ80, "C");
m_pZ80RegCp = new CRegister(CRect(CPoint(150, 50), 110, 20), m_pGroupBoxTabZ80, "C'");
m_pZ80RegD = new CRegister(CRect(CPoint(10, 70), 110, 20), m_pGroupBoxTabZ80, "D");
m_pZ80RegDp = new CRegister(CRect(CPoint(150, 70), 110, 20), m_pGroupBoxTabZ80, "D'");
m_pZ80RegE = new CRegister(CRect(CPoint(10, 90), 110, 20), m_pGroupBoxTabZ80, "E");
m_pZ80RegEp = new CRegister(CRect(CPoint(150, 90), 110, 20), m_pGroupBoxTabZ80, "E'");
m_pZ80RegH = new CRegister(CRect(CPoint(10, 110), 110, 20), m_pGroupBoxTabZ80, "H");
m_pZ80RegHp = new CRegister(CRect(CPoint(150, 110), 110, 20), m_pGroupBoxTabZ80, "H'");
m_pZ80RegL = new CRegister(CRect(CPoint(10, 130), 110, 20), m_pGroupBoxTabZ80, "L");
m_pZ80RegLp = new CRegister(CRect(CPoint(150, 130), 110, 20), m_pGroupBoxTabZ80, "L'");
m_pZ80RegI = new CRegister(CRect(CPoint(10, 150), 110, 20), m_pGroupBoxTabZ80, "I");
m_pZ80RegR = new CRegister(CRect(CPoint(150, 150), 110, 20), m_pGroupBoxTabZ80, "R");
m_pZ80RegIXH = new CRegister(CRect(CPoint(10, 170), 110, 20), m_pGroupBoxTabZ80, "IXH");
m_pZ80RegIXL = new CRegister(CRect(CPoint(150, 170), 110, 20), m_pGroupBoxTabZ80, "IXL'");
m_pZ80RegIYH = new CRegister(CRect(CPoint(10, 190), 110, 20), m_pGroupBoxTabZ80, "IYH");
m_pZ80RegIYL = new CRegister(CRect(CPoint(150, 190), 110, 20), m_pGroupBoxTabZ80, "IYL");
m_pZ80RegAF = new CRegister(CRect(CPoint(10, 230), 110, 20), m_pGroupBoxTabZ80, "AF");
m_pZ80RegAFp = new CRegister(CRect(CPoint(150, 230), 110, 20), m_pGroupBoxTabZ80, "AF'");
m_pZ80RegBC = new CRegister(CRect(CPoint(10, 250), 110, 20), m_pGroupBoxTabZ80, "BC");
m_pZ80RegBCp = new CRegister(CRect(CPoint(150, 250), 110, 20), m_pGroupBoxTabZ80, "BC'");
m_pZ80RegDE = new CRegister(CRect(CPoint(10, 270), 110, 20), m_pGroupBoxTabZ80, "DE");
m_pZ80RegDEp = new CRegister(CRect(CPoint(150, 270), 110, 20), m_pGroupBoxTabZ80, "DE'");
m_pZ80RegHL = new CRegister(CRect(CPoint(10, 290), 110, 20), m_pGroupBoxTabZ80, "HL");
m_pZ80RegHLp = new CRegister(CRect(CPoint(150, 290), 110, 20), m_pGroupBoxTabZ80, "HL'");
m_pZ80RegIX = new CRegister(CRect(CPoint(10, 310), 110, 20), m_pGroupBoxTabZ80, "IX");
m_pZ80RegIY = new CRegister(CRect(CPoint(150, 310), 110, 20), m_pGroupBoxTabZ80, "IY");
m_pZ80RegSP = new CRegister(CRect(CPoint(10, 330), 110, 20), m_pGroupBoxTabZ80, "SP");
m_pZ80RegPC = new CRegister(CRect(CPoint(150, 330), 110, 20), m_pGroupBoxTabZ80, "PC");
m_pZ80StackLabel = new CLabel(CPoint(300, 10), m_pGroupBoxTabZ80, "Stack:");
m_pZ80Stack = new CListBox(CRect(CPoint(300, 20), 100, 190), m_pGroupBoxTabZ80);
m_pZ80FlagsLabel = new CLabel(CPoint(290, 222), m_pGroupBoxTabZ80, "Flags:");
m_pZ80RegF = new CRegister(CRect(CPoint(290, 235), 110, 20), m_pGroupBoxTabZ80, "F");
m_pZ80RegFp = new CRegister(CRect(CPoint(290, 255), 110, 20), m_pGroupBoxTabZ80, "F'");
m_pZ80FlagS = new CFlag(CRect(CPoint(290, 280), 35, 20), m_pGroupBoxTabZ80, "S", "Sign flag");
m_pZ80FlagZ = new CFlag(CRect(CPoint(290, 300), 35, 20), m_pGroupBoxTabZ80, "Z", "Zero flag");
m_pZ80FlagX1 = new CFlag(CRect(CPoint(290, 320), 35, 20), m_pGroupBoxTabZ80, "NU", "Unused flag");
m_pZ80FlagH = new CFlag(CRect(CPoint(290, 340), 35, 20), m_pGroupBoxTabZ80, "H", "Half carry flag");
m_pZ80FlagX2 = new CFlag(CRect(CPoint(340, 280), 35, 20), m_pGroupBoxTabZ80, "NU", "Unused flag");
m_pZ80FlagPV = new CFlag(CRect(CPoint(340, 300), 35, 20), m_pGroupBoxTabZ80, "PV", "Parity/overflow flag");
m_pZ80FlagN = new CFlag(CRect(CPoint(340, 320), 35, 20), m_pGroupBoxTabZ80, "N", "Add/substract flag");
m_pZ80FlagC = new CFlag(CRect(CPoint(340, 340), 35, 20), m_pGroupBoxTabZ80, "C", "Carry flag");
// TODO: Add information about interrupts (mode, IFF1, IFF2)
// ---------------- 'Assembly' screen ----------------
m_pAssemblyCode = new CListBox(
CRect(10, 10, 320, m_pGroupBoxTabAsm->GetClientRect().Height() - 35),
m_pGroupBoxTabAsm, /*bSingleSelection=*/true, /*iItemHeight=*/14, monoFontEngine);
m_pAssemblySearchLbl = new CLabel(CPoint(10, m_pGroupBoxTabAsm->GetClientRect().Height() - 25), m_pGroupBoxTabAsm, "Search: ");
m_pAssemblySearch = new CEditBox(CRect(CPoint(50, m_pGroupBoxTabAsm->GetClientRect().Height() - 30), 200, 20), m_pGroupBoxTabAsm);
m_pAssemblySearchPrev = new CButton(CRect(CPoint(250, m_pGroupBoxTabAsm->GetClientRect().Height() - 30), 35, 20), m_pGroupBoxTabAsm, "Prev");
m_pAssemblySearchNext = new CButton(CRect(CPoint(285, m_pGroupBoxTabAsm->GetClientRect().Height() - 30), 35, 20), m_pGroupBoxTabAsm, "Next");
m_pAssemblyRefresh = new CButton(CRect(CPoint(340, 10), 50, 15), m_pGroupBoxTabAsm, "Refresh");
m_pAssemblyStatusLabel = new CLabel(CPoint(400, 15), m_pGroupBoxTabAsm, "Status: ");
// TODO: Allow editbox to have no border and 'transparent' background (i.e dynamic labels ...)
m_pAssemblyStatus = new CEditBox(CRect(CPoint(440, 10), 170, 20), m_pGroupBoxTabAsm);
m_pAssemblyStatus->SetReadOnly(true);
m_pAssemblyEntryPointsGrp = new CGroupBox(CRect(CPoint(340, 40), 200, 120), m_pGroupBoxTabAsm, "Entry points");
m_pAssemblyEntryPoints = new CListBox(CRect(CPoint(10, 5), 50, 80), m_pAssemblyEntryPointsGrp);
m_pAssemblyRemoveEntryPoint = new CButton(CRect(CPoint(80, 5), 100, 20), m_pAssemblyEntryPointsGrp, "Remove selected");
m_pAssemblyAddPCEntryPoint = new CButton(CRect(CPoint(80, 30), 100, 20), m_pAssemblyEntryPointsGrp, "Add PC");
m_pAssemblyNewEntryPoint = new CEditBox(CRect(CPoint(80, 55), 50, 20), m_pAssemblyEntryPointsGrp);
m_pAssemblyNewEntryPoint->SetContentType(CEditBox::HEXNUMBER);
m_pAssemblyAddEntryPoint = new CButton(CRect(CPoint(140, 55), 50, 20), m_pAssemblyEntryPointsGrp, "Add");
m_pAssemblyBreakPointsGrp = new CGroupBox(CRect(CPoint(340, 170), 200, 90), m_pGroupBoxTabAsm, "Break points");
m_pAssemblyBreakPoints = new CListBox(CRect(CPoint(10, 5), 50, 50), m_pAssemblyBreakPointsGrp);
m_pAssemblyRemoveBreakPoint = new CButton(CRect(CPoint(80, 5), 100, 20), m_pAssemblyBreakPointsGrp, "Remove selected");
m_pAssemblyNewBreakPoint = new CEditBox(CRect(CPoint(80, 30), 50, 20), m_pAssemblyBreakPointsGrp);
m_pAssemblyNewBreakPoint->SetContentType(CEditBox::HEXNUMBER);
m_pAssemblyAddBreakPoint = new CButton(CRect(CPoint(140, 30), 50, 20), m_pAssemblyBreakPointsGrp, "Add");
m_pAssemblyMemConfigGrp = new CGroupBox(CRect(CPoint(340, 270), 260, 100), m_pGroupBoxTabAsm, "RAM config");
m_pAssemblyMemConfigAsmLbl = new CLabel(CPoint(10, 30), m_pAssemblyMemConfigGrp, "Asm:");
m_pAssemblyMemConfigCurLbl = new CLabel(CPoint(10, 55), m_pAssemblyMemConfigGrp, "Cur:");
m_pAssemblyMemConfigROMLbl = new CLabel(CPoint(70, 0), m_pAssemblyMemConfigGrp, "ROM");
m_pAssemblyMemConfigLoLbl = new CLabel(CPoint(60, 10), m_pAssemblyMemConfigGrp, "Lo");
m_pAssemblyMemConfigHiLbl = new CLabel(CPoint(90, 10), m_pAssemblyMemConfigGrp, "Hi");
m_pAssemblyMemConfigRAMLbl = new CLabel(CPoint(170, 0), m_pAssemblyMemConfigGrp, "RAM");
m_pAssemblyMemConfigBankLbl = new CLabel(CPoint(140, 10), m_pAssemblyMemConfigGrp, "Bank");
m_pAssemblyMemConfigConfigLbl = new CLabel(CPoint(180, 10), m_pAssemblyMemConfigGrp, "Config");
m_pAssemblyMemConfigAsmLoROM = new CCheckBox(CRect(CPoint(60, 30), 10, 10), m_pAssemblyMemConfigGrp);
m_pAssemblyMemConfigAsmLoROM->SetReadOnly(true);
m_pAssemblyMemConfigAsmHiROM = new CCheckBox(CRect(CPoint(90, 30), 10, 10), m_pAssemblyMemConfigGrp);
m_pAssemblyMemConfigAsmHiROM->SetReadOnly(true);
m_pAssemblyMemConfigAsmRAMBank = new CEditBox(CRect(CPoint(140, 25), 30, 20), m_pAssemblyMemConfigGrp);
m_pAssemblyMemConfigAsmRAMBank->SetReadOnly(true);
m_pAssemblyMemConfigAsmRAMConfig = new CEditBox(CRect(CPoint(180, 25), 60, 20), m_pAssemblyMemConfigGrp);
m_pAssemblyMemConfigAsmRAMConfig->SetReadOnly(true);
m_pAssemblyMemConfigCurLoROM = new CCheckBox(CRect(CPoint(60, 55), 10, 10), m_pAssemblyMemConfigGrp);
m_pAssemblyMemConfigCurLoROM->SetReadOnly(true);
m_pAssemblyMemConfigCurHiROM = new CCheckBox(CRect(CPoint(90, 55), 10, 10), m_pAssemblyMemConfigGrp);
m_pAssemblyMemConfigCurHiROM->SetReadOnly(true);
m_pAssemblyMemConfigCurRAMBank = new CEditBox(CRect(CPoint(140, 50), 30, 20), m_pAssemblyMemConfigGrp);
m_pAssemblyMemConfigCurRAMBank->SetReadOnly(true);
m_pAssemblyMemConfigCurRAMConfig = new CEditBox(CRect(CPoint(180, 50), 60, 20), m_pAssemblyMemConfigGrp);
m_pAssemblyMemConfigCurRAMConfig->SetReadOnly(true);
// ---------------- 'Memory' screen ----------------
m_pMemPokeAdressLabel = new CLabel( CPoint(15, 18), m_pGroupBoxTabMemory, "Adress: ");
m_pMemPokeAdress = new CEditBox(CRect(CPoint(55, 13), 35, 20), m_pGroupBoxTabMemory);
m_pMemPokeAdress->SetIsFocusable(true);
m_pMemPokeValueLabel = new CLabel( CPoint(95, 18), m_pGroupBoxTabMemory, "Value: ");
m_pMemPokeValue = new CEditBox(CRect(CPoint(130, 13), 30, 20), m_pGroupBoxTabMemory);
m_pMemPokeValue->SetIsFocusable(true);
m_pMemButtonPoke = new CButton( CRect(CPoint(175, 13), 35, 20), m_pGroupBoxTabMemory, "Poke");
m_pMemButtonPoke->SetIsFocusable(true);
m_pMemAdressLabel = new CLabel( CPoint(15, 50), m_pGroupBoxTabMemory, "Adress: ");
m_pMemAdressValue = new CEditBox(CRect(CPoint(55, 45), 35, 20), m_pGroupBoxTabMemory);
m_pMemAdressValue->SetIsFocusable(true);
m_pMemButtonDisplay = new CButton( CRect(CPoint(95, 45), 45, 20), m_pGroupBoxTabMemory, "Display");
m_pMemButtonDisplay->SetIsFocusable(true);
m_pMemBytesPerLineLbl = new CLabel( CPoint(235, 18), m_pGroupBoxTabMemory, "Bytes per line:");
m_pMemBytesPerLine = new CDropDown( CRect(CPoint(315, 13), 50, 20), m_pGroupBoxTabMemory, false);
m_pMemBytesPerLine->AddItem(SListItem("1"));
m_pMemBytesPerLine->AddItem(SListItem("2"));
m_pMemBytesPerLine->AddItem(SListItem("4"));
m_pMemBytesPerLine->AddItem(SListItem("8"));
m_pMemBytesPerLine->AddItem(SListItem("16"));
m_pMemBytesPerLine->AddItem(SListItem("32"));
m_pMemBytesPerLine->AddItem(SListItem("64"));
m_pMemBytesPerLine->SetListboxHeight(4);
m_MemBytesPerLine = 16;
m_pMemBytesPerLine->SelectItem(4);
m_pMemBytesPerLine->SetIsFocusable(true);
m_pMemFormatLbl = new CLabel( CPoint(235, 38), m_pGroupBoxTabMemory, "Format:");
m_pMemFormat = new CDropDown( CRect(CPoint(280, 33), 85, 20), m_pGroupBoxTabMemory, true);
m_pMemFormat->AddItem(SListItem("Hex"));
m_pMemFormat->AddItem(SListItem("Hex & char"));
m_pMemFormat->AddItem(SListItem("Hex & u8"));
m_pMemFormat->AddItem(SListItem("Hex & u16"));
m_pMemFormat->AddItem(SListItem("Hex & u32"));
m_pMemFormat->AddItem(SListItem("Hex & i8"));
m_pMemFormat->AddItem(SListItem("Hex & i16"));
m_pMemFormat->AddItem(SListItem("Hex & i32"));
m_pMemFormat->SetListboxHeight(4);
m_MemFormat = {Format::Hex};
m_pMemFormat->SelectItem(0);
m_pMemFormat->SetIsFocusable(true);
m_pMemFilterLabel = new CLabel( CPoint(15, 80), m_pGroupBoxTabMemory, "Byte: ");
m_pMemFilterValue = new CEditBox(CRect(CPoint(55, 75), 30, 20), m_pGroupBoxTabMemory);
m_pMemFilterValue->SetIsFocusable(true);
m_pMemButtonFilter = new CButton( CRect(CPoint(95, 75), 45, 20), m_pGroupBoxTabMemory, "Filter");
m_pMemButtonFilter->SetIsFocusable(true);
m_pMemButtonSaveFilter = new CButton( CRect(CPoint(150, 75), 90, 20), m_pGroupBoxTabMemory, "Save Filter");
m_pMemButtonSaveFilter->SetIsFocusable(true);
m_pMemButtonApplyFilter = new CButton( CRect(CPoint(250, 75), 90, 20), m_pGroupBoxTabMemory, "Apply saved");
m_pMemButtonApplyFilter->SetIsFocusable(true);
m_pMemButtonCopy = new CButton( CRect(CPoint(380, 325), 95, 20), m_pGroupBoxTabMemory, "Dump to stdout");
m_pMemButtonCopy->SetIsFocusable(true);
m_pMemTextContent = new CTextBox(CRect(CPoint(15, 105), 350, 240), m_pGroupBoxTabMemory, monoFontEngine);
m_pMemPokeAdress->SetContentType(CEditBox::HEXNUMBER);
m_pMemPokeValue->SetContentType(CEditBox::HEXNUMBER);
m_pMemAdressValue->SetContentType(CEditBox::HEXNUMBER);
m_pMemFilterValue->SetContentType(CEditBox::HEXNUMBER);
m_pMemTextContent->SetReadOnly(true);
m_MemFilterValue = -1;
m_MemDisplayValue = -1;
// TODO: Support read, write and R/W watch points
m_pMemWatchPointsGrp = new CGroupBox(CRect(CPoint(380, 13), 240, 120), m_pGroupBoxTabMemory, "Watch points");
m_pMemWatchPoints = new CListBox(CRect(CPoint(10, 5), 80, 80), m_pMemWatchPointsGrp,
/*bSingleSelection=*/false, /*iItemHeight=*/15, monoFontEngine);
m_pMemRemoveWatchPoint = new CButton(CRect(CPoint(110, 5), 100, 20), m_pMemWatchPointsGrp, "Remove selected");
m_pMemNewWatchPoint = new CEditBox(CRect(CPoint(110, 40), 50, 20), m_pMemWatchPointsGrp);
m_pMemNewWatchPoint->SetContentType(CEditBox::HEXNUMBER);
m_pMemWatchPointType = new CDropDown(CRect(CPoint(170, 40), 50, 20), m_pMemWatchPointsGrp);
m_pMemWatchPointType->AddItem(SListItem("R"));
m_pMemWatchPointType->AddItem(SListItem("W"));
m_pMemWatchPointType->AddItem(SListItem("RW"));
m_pMemWatchPointType->SelectItem(2);
m_pMemAddWatchPoint = new CButton(CRect(CPoint(110, 65), 50, 20), m_pMemWatchPointsGrp, "Add");
m_pMemConfigGrp = new CGroupBox(CRect(CPoint(380, 143), 240, 100), m_pGroupBoxTabMemory, "RAM config");
m_pMemConfigMemLbl = new CLabel(CPoint(10, 30), m_pMemConfigGrp, "Mem:");
m_pMemConfigCurLbl = new CLabel(CPoint(10, 55), m_pMemConfigGrp, "Cur:");
m_pMemConfigROMLbl = new CLabel(CPoint(60, 0), m_pMemConfigGrp, "ROM");
m_pMemConfigLoLbl = new CLabel(CPoint(50, 10), m_pMemConfigGrp, "Lo");
m_pMemConfigHiLbl = new CLabel(CPoint(80, 10), m_pMemConfigGrp, "Hi");
m_pMemConfigRAMLbl = new CLabel(CPoint(150, 0), m_pMemConfigGrp, "RAM");
m_pMemConfigBankLbl = new CLabel(CPoint(120, 10), m_pMemConfigGrp, "Bank");
m_pMemConfigConfigLbl = new CLabel(CPoint(160, 10), m_pMemConfigGrp, "Config");
// TODO: Distinct button to dump to stdout and copy to clipboard
// TODO: Save memory dump to a file (same as dump to stdout but with a messagebox asking for a filename)
m_pMemConfigMemLoROM = new CCheckBox(CRect(CPoint(50, 30), 10, 10), m_pMemConfigGrp);
m_pMemConfigMemHiROM = new CCheckBox(CRect(CPoint(80, 30), 10, 10), m_pMemConfigGrp);
m_pMemConfigMemRAMBank = new CDropDown(CRect(CPoint(110, 25), 40, 20), m_pMemConfigGrp);
int nb_banks = (CPC.ram_size == 64) ? 1 : ((CPC.ram_size / 64)-1);
for (int i = 0; i < nb_banks; i++) m_pMemConfigMemRAMBank->AddItem(SListItem(std::to_string(i)));
// TODO: Default to RAMBank & RAMConfig that are currently used
m_pMemConfigMemRAMBank->SelectItem(0);
m_pMemConfigMemRAMConfig = new CDropDown(CRect(CPoint(160, 25), 70, 20), m_pMemConfigGrp);
int nb_configs = (CPC.ram_size == 64) ? 1 : 8;
for (int i = 0; i < nb_configs; i++) m_pMemConfigMemRAMConfig->AddItem(SListItem(RAMConfig::RAMConfigText(i)));
m_pMemConfigMemRAMConfig->SelectItem(0);
m_pMemConfigCurLoROM = new CCheckBox(CRect(CPoint(50, 55), 10, 10), m_pMemConfigGrp);
m_pMemConfigCurLoROM->SetReadOnly(true);
m_pMemConfigCurHiROM = new CCheckBox(CRect(CPoint(80, 55), 10, 10), m_pMemConfigGrp);
m_pMemConfigCurHiROM->SetReadOnly(true);
m_pMemConfigCurRAMBank = new CEditBox(CRect(CPoint(110, 50), 40, 20), m_pMemConfigGrp);
m_pMemConfigCurRAMBank->SetReadOnly(true);
m_pMemConfigCurRAMConfig = new CEditBox(CRect(CPoint(160, 50), 70, 20), m_pMemConfigGrp);
m_pMemConfigCurRAMConfig->SetReadOnly(true);
// ---------------- 'Video' screen ----------------
m_pVidLabel = new CLabel(CPoint(10, 10), m_pGroupBoxTabVideo, "Work in progress ... Nothing to see here yet, but come back later for video (CRTC & GateArray info).");
// ---------------- 'Audio' screen ----------------
m_pAudLabel = new CLabel(CPoint(10, 10), m_pGroupBoxTabAudio, "Work in progress ... Nothing to see here yet, but come back later for sound (tone and volume envelopes, etc ...).");
// TODO: PSG registers, envelopes, noise, channel curve? ...
// ---------------- 'Characters' screen ----------------
m_pChrLabel = new CLabel(CPoint(10, 10), m_pGroupBoxTabChar, "Work in progress ... Nothing to see here yet, but come back later for charmap.");
// TODO: A 'Graphics' screen displaying memory as graphics (sprites) with choice of mode (0, 1 or 2), width and start address.
// Moved to an explicit call by the caller to allow constructing
// CapriceDevTools with less constraints in tests.
//UpdateAll();
}
CapriceDevTools::~CapriceDevTools() = default;
void CapriceDevTools::UpdateDisassemblyPos()
{
auto lines = m_pAssemblyCode->GetAllItems();
SListItem toFind("ignored", reinterpret_cast<void*>(_PC));
auto curpos = std::lower_bound(lines.begin(), lines.end(), toFind, [](auto x, auto y) {
return x.pItemData < y.pItemData;
});
int idx = std::distance(lines.begin(), curpos);
// TODO: Provide a way to jump to an address. Main problem is finding some space for the editbox and button
// One option: Move "Disassembling / SUCCESS" down as some status bar (below the main group box).
// TODO: Think about providing a way to trace execution (have all addresses through which the execution went).
// Maybe only record call / jps / jrs / rst / ret destinations?
// TODO: Would be nice to have a list of labels and be able to jump to code using them
// TODO: Would be nice to be able to add / edit labels
m_pAssemblyCode->SetPosition(idx, CListBox::CENTER);
if (!lines.empty() && curpos->pItemData == toFind.pItemData) {
// Skip over address labels
while ((curpos = std::next(curpos))->pItemData == toFind.pItemData) idx++;
// TODO: Do not allow to select another line
m_pAssemblyCode->SetSelection(idx, /*bSelected=*/true, /*bNotify=*/false);
} else {
m_pAssemblyCode->SetAllSelections(false);
m_pAssemblyCode->Draw();
}
m_pAssemblyMemConfigAsmLoROM->SetCheckBoxState(m_AsmRAMConfig.LoROMEnabled ? CCheckBox::CHECKED : CCheckBox::UNCHECKED);
m_pAssemblyMemConfigAsmHiROM->SetCheckBoxState(m_AsmRAMConfig.HiROMEnabled ? CCheckBox::CHECKED : CCheckBox::UNCHECKED);
m_pAssemblyMemConfigAsmRAMBank->SetWindowText(std::to_string(m_AsmRAMConfig.RAMBank));
m_pAssemblyMemConfigAsmRAMConfig->SetWindowText(m_AsmRAMConfig.RAMConfigText());
RAMConfig CurConfig = RAMConfig::CurrentConfig();
m_pAssemblyMemConfigCurLoROM->SetCheckBoxState(CurConfig.LoROMEnabled ? CCheckBox::CHECKED : CCheckBox::UNCHECKED);
m_pAssemblyMemConfigCurHiROM->SetCheckBoxState(CurConfig.HiROMEnabled ? CCheckBox::CHECKED : CCheckBox::UNCHECKED);
m_pAssemblyMemConfigCurRAMBank->SetWindowText(std::to_string(CurConfig.RAMBank));
m_pAssemblyMemConfigCurRAMConfig->SetWindowText(CurConfig.RAMConfigText());
}
std::string FormatSymbol(const std::map<word, std::string>::iterator& symbol_it)
{
std::ostringstream oss;
oss << symbol_it->second << ": [" << std::hex << std::setw(4) << std::setfill('0') << symbol_it->first << "]";
return oss.str();
}
void CapriceDevTools::AsmSearch(SearchFrom from, SearchDir dir)
{
const auto& lines = m_pAssemblyCode->GetAllItems();
std::vector<SListItem>::const_iterator start_line, end_line;
auto pos = m_pAssemblyCode->getFirstSelectedIndex();
if (pos == -1) {
from = SearchFrom::Start;
}
int delta = dir == SearchDir::Forward ? 1 : -1;
switch (from)
{
case SearchFrom::PositionIncluded:
break;
case SearchFrom::PositionExcluded:
pos += delta;
break;
case SearchFrom::Start:
if (dir == SearchDir::Forward) {
pos = 0;
} else {
pos = lines.size() - 1;
}
break;
}
start_line = lines.begin() + pos;
if (dir == SearchDir::Forward) {
end_line = lines.end();
} else {
end_line = lines.begin()-1;
}
std::string to_find = m_pAssemblySearch->GetWindowText();
for (auto l = start_line; l != end_line; l += delta)
{
if (l->sItemText.find(to_find) != std::string::npos) {
m_pAssemblyCode->SetAllSelections(false);
m_pAssemblyCode->SetPosition(pos, CListBox::CENTER);
m_pAssemblyCode->SetSelection(pos, /*bSelected=*/true, /*bNotify=*/true);
break;
}
pos += delta;
}
}
void CapriceDevTools::SetDisassembly(std::vector<SListItem> items)
{
m_pAssemblyCode->ClearItems();
m_pAssemblyCode->AddItems(items);
}
std::vector<SListItem> CapriceDevTools::GetSelectedAssembly()
{
// TODO: This code should really be in CListBox!!
std::vector<SListItem> result;
for(unsigned int i = 0; i < m_pAssemblyCode->Size(); i++)
{
if (m_pAssemblyCode->IsSelected(i)) {
result.push_back(m_pAssemblyCode->GetItem(i));
}
}
return result;
}
void CapriceDevTools::SetAssemblySearch(const std::string& text)
{
m_pAssemblySearch->SetWindowText(text);
}
void CapriceDevTools::RefreshDisassembly()
{
std::vector<SListItem> items;
std::map<word, std::string> symbols = m_Symfile.Symbols();
std::map<word, std::string>::iterator symbols_it = symbols.begin();
for (const auto& line : m_Disassembled.lines) {
while (symbols_it != symbols.end() && symbols_it->first <= line.address_) {
items.emplace_back(FormatSymbol(symbols_it), reinterpret_cast<void*>(symbols_it->first), COLOR_BLUE);
symbols_it++;
}
std::ostringstream oss;
oss << std::hex << " " << std::setw(4) << std::setfill('0') << line.address_ << ": ";
if (line.opcode_ <= 0xFF) {
oss << " " << std::setw(2) << std::setfill('0') << line.opcode_;
} else if (line.opcode_ <= 0xFFFF) {
oss << " " << std::setw(4) << std::setfill('0') << line.opcode_;
} else if (line.opcode_ <= 0xFFFFFF) {
oss << " " << std::setw(6) << std::setfill('0') << line.opcode_;
} else if (line.opcode_ <= 0xFFFFFFFF) {
oss << " " << std::setw(8) << std::setfill('0') << line.opcode_;
} else {
oss << std::setw(10) << std::setfill('0') << line.opcode_;
}
oss << " " << line.instruction_;
std::string instruction = oss.str();
std::map<word, std::string>::iterator it;
if (!line.ref_address_string_.empty() &&
((it = symbols.find(line.ref_address_)) != symbols.end())) {
instruction = stringutils::replace(instruction, line.ref_address_string_, it->second);
}
// TODO: smart use of colors. Ideas:
// - labels, jumps & calls, ...
// - source of disassembling (from PC, from one entry point or another ...)
auto color = COLOR_BLACK;
if (std::any_of(breakpoints.begin(), breakpoints.end(), [&](const auto& b) {
return (b.address == line.address_);
})) {
color = COLOR_RED;
} else if (line.instruction_ == "ret") {
color = COLOR_BLUE;
}/* else if (!line.ref_address_string_.empty()) {
color = COLOR_DARKGREEN;
}*/
items.emplace_back(instruction, reinterpret_cast<void*>(line.address_), color);
}
SetDisassembly(items);
UpdateDisassemblyPos();
}
void CapriceDevTools::UpdateDisassembly()
{
// TODO: Disassemble in a thread
m_pAssemblyStatus->SetWindowText("Disassembling...");
// We need to force the repaint for the status to be displayed.
m_pParentWindow->HandleMessage(new CMessage(CMessage::APP_PAINT, GetAncestor(ROOT), this));
m_Disassembled = disassemble(m_EntryPoints);
m_AsmRAMConfig = RAMConfig::CurrentConfig();
RefreshDisassembly();
// TODO: Report inconsistent disassembling
m_pAssemblyStatus->SetWindowText("SUCCESS");
}
void CapriceDevTools::UpdateZ80()
{
m_pZ80RegA->SetValue(z80.AF.b.h);
m_pZ80RegAp->SetValue(z80.AFx.b.h);
m_pZ80RegF->SetValue(z80.AF.b.l);
m_pZ80RegFp->SetValue(z80.AFx.b.l);
m_pZ80RegB->SetValue(z80.BC.b.h);
m_pZ80RegBp->SetValue(z80.BCx.b.h);
m_pZ80RegC->SetValue(z80.BC.b.l);
m_pZ80RegCp->SetValue(z80.BCx.b.l);
m_pZ80RegD->SetValue(z80.DE.b.h);
m_pZ80RegDp->SetValue(z80.DEx.b.h);
m_pZ80RegE->SetValue(z80.DE.b.l);
m_pZ80RegEp->SetValue(z80.DEx.b.l);
m_pZ80RegH->SetValue(z80.HL.b.h);
m_pZ80RegHp->SetValue(z80.HLx.b.h);
m_pZ80RegL->SetValue(z80.HL.b.l);
m_pZ80RegLp->SetValue(z80.HLx.b.l);
m_pZ80RegI->SetValue(z80.I);
m_pZ80RegR->SetValue(z80.R);
m_pZ80RegIXH->SetValue(z80.IX.b.h);
m_pZ80RegIXL->SetValue(z80.IX.b.l);
m_pZ80RegIYH->SetValue(z80.IY.b.h);
m_pZ80RegIYL->SetValue(z80.IY.b.l);
m_pZ80RegAF->SetValue(z80.AF.w.l);
m_pZ80RegAFp->SetValue(z80.AFx.w.l);
m_pZ80RegBC->SetValue(z80.BC.w.l);
m_pZ80RegBCp->SetValue(z80.BCx.w.l);
m_pZ80RegDE->SetValue(z80.DE.w.l);
m_pZ80RegDEp->SetValue(z80.DEx.w.l);
m_pZ80RegHL->SetValue(z80.HL.w.l);
m_pZ80RegHLp->SetValue(z80.HLx.w.l);
m_pZ80RegIX->SetValue(z80.IX.w.l);
m_pZ80RegIY->SetValue(z80.IY.w.l);
m_pZ80RegSP->SetValue(z80.SP.w.l);
m_pZ80RegPC->SetValue(z80.PC.w.l);
m_pZ80FlagS->SetValue((z80.AF.b.l & Sflag) ? "1" : "0");
m_pZ80FlagZ->SetValue((z80.AF.b.l & Zflag) ? "1" : "0");
m_pZ80FlagX1->SetValue((z80.AF.b.l & X1flag) ? "1" : "0");
m_pZ80FlagH->SetValue((z80.AF.b.l & Hflag) ? "1" : "0");
m_pZ80FlagX2->SetValue((z80.AF.b.l & X2flag) ? "1" : "0");
m_pZ80FlagPV->SetValue((z80.AF.b.l & Pflag) ? "1" : "0");
m_pZ80FlagN->SetValue((z80.AF.b.l & Nflag) ? "1" : "0");
m_pZ80FlagC->SetValue((z80.AF.b.l & Cflag) ? "1" : "0");
m_pZ80Stack->ClearItems();
// Don't show more than 50 values in the stack if not paused as this slows
// down everything.
auto last_address = 0xC000;
if (!CPC.paused) {
last_address = std::min(0xC000, z80.SP.w.l + 100);
}
for (word addr = z80.SP.w.l; addr < last_address; addr += 2) {
std::ostringstream oss;
word val = (z80_read_mem(addr+1) << 8) + z80_read_mem(addr);
oss << std::hex << std::setw(4) << std::setfill('0') << val
<< " (" << std::dec << val << ")";
m_pZ80Stack->AddItem(SListItem(oss.str()));
}
}
void CapriceDevTools::UpdateEntryPointsList()
{
m_pAssemblyEntryPoints->ClearItems();
for(word ep : m_EntryPoints) {
std::ostringstream oss;
oss << std::hex << std::setw(4) << std::setfill('0') << ep;
m_pAssemblyEntryPoints->AddItem(SListItem(oss.str()));
}
UpdateDisassembly();
}
void CapriceDevTools::UpdateBreakPointsList()
{
m_pAssemblyBreakPoints->ClearItems();
for(const auto& bp : breakpoints) {
std::ostringstream oss;
oss << std::hex << std::setw(4) << std::setfill('0') << bp.address;
m_pAssemblyBreakPoints->AddItem(SListItem(oss.str()));
}
// Ensure the lines corresponding to the breakpoints are colored
RefreshDisassembly();
}
void CapriceDevTools::UpdateWatchPointsList()
{
m_pMemWatchPoints->ClearItems();
for(const auto& bp : watchpoints) {
std::ostringstream oss;
oss << std::hex << std::setw(4) << std::setfill('0') << bp.address << " "
<< ((bp.type & READ) ? "R" : "")
<< ((bp.type & WRITE) ? "W" : "");
m_pMemWatchPoints->AddItem(SListItem(oss.str()));
}
}
void CapriceDevTools::UpdateMemConfig()
{
RAMConfig CurConfig = RAMConfig::CurrentConfig();
m_pMemConfigCurLoROM->SetCheckBoxState(CurConfig.LoROMEnabled ? CCheckBox::CHECKED : CCheckBox::UNCHECKED);
m_pMemConfigCurHiROM->SetCheckBoxState(CurConfig.HiROMEnabled ? CCheckBox::CHECKED : CCheckBox::UNCHECKED);
m_pMemConfigCurRAMBank->SetWindowText(std::to_string(CurConfig.RAMBank));
m_pMemConfigCurRAMConfig->SetWindowText(CurConfig.RAMConfigText());
}
void CapriceDevTools::PrepareMemBankConfig()
{
ga_init_banking(memtool_membank_config, m_pMemConfigMemRAMBank->GetSelectedIndex());
if (m_pMemConfigMemLoROM->GetCheckBoxState() == CCheckBox::CHECKED) {
for (int i = 0; i < 8; i++) memtool_membank_config[i][GateArray.lower_ROM_bank] = pbROMlo;
}
// TODO: Provide option to have register page on if on the CPC+
if (m_pMemConfigMemHiROM->GetCheckBoxState() == CCheckBox::CHECKED) {
for (int i = 0; i < 8; i++) memtool_membank_config[i][3] = pbExpansionROM;
}
}
byte CapriceDevTools::ReadMem(word address)
{
return memtool_membank_config[m_pMemConfigMemRAMConfig->GetSelectedIndex()][address >> 14][address & 0x3fff];
}
void CapriceDevTools::WriteMem(word address, byte value)
{
memtool_membank_config[m_pMemConfigMemRAMConfig->GetSelectedIndex()][address >> 14][address & 0x3fff] = value;
}
void CapriceDevTools::UpdateTextMemory()
{
PrepareMemBankConfig();
m_currentlyDisplayed.clear();
std::ostringstream memText;
for(unsigned int i = 0; i < 65536/m_MemBytesPerLine; i++) {
if (!m_currentlyFiltered.empty() &&
!std::binary_search(m_currentlyFiltered.begin(), m_currentlyFiltered.end(), i)) {
continue;
}
std::ostringstream memLine;
memLine << std::uppercase << std::setfill('0') << std::setw(4) << std::hex << i*m_MemBytesPerLine << " : ";
bool displayLine = false;
bool filterAdress = (m_MemDisplayValue >= 0 && m_MemDisplayValue <= 65535);
bool filterValue = (m_MemFilterValue >= 0 && m_MemFilterValue <= 255);
bool first = true;
for(auto f : m_MemFormat) {
if (!first) {
memLine << " | ";
}
first = false;
for(unsigned int j = 0; j < m_MemBytesPerLine; j+=FormatSize(f)) {
switch (f) {
case Format::Hex:
{
unsigned int val = ReadMem(i*m_MemBytesPerLine+j);
memLine << std::setfill('0') << std::setw(2) << std::hex << val << " ";
break;
}
case Format::Char:
{
char val = ReadMem(i*m_MemBytesPerLine+j);
if (val >= 32) {
memLine << val;
} else {
memLine << ".";
}
break;
}
case Format::U8:
{
unsigned int val = ReadMem(i*m_MemBytesPerLine+j);
memLine << std::setfill(' ') << std::setw(3) << std::dec << val << " ";
break;
}
case Format::U16:
{
unsigned int val = static_cast<uint32_t>(ReadMem(i*m_MemBytesPerLine+j)) +
(static_cast<uint32_t>(ReadMem(i*m_MemBytesPerLine+j+1) << 8));
memLine << std::setfill(' ') << std::setw(5) << std::dec << val << " ";
break;
}
case Format::U32:
{
unsigned int val = static_cast<uint32_t>(ReadMem(i*m_MemBytesPerLine+j)) +
(static_cast<uint32_t>(ReadMem(i*m_MemBytesPerLine+j+1) << 8)) +
(static_cast<uint32_t>(ReadMem(i*m_MemBytesPerLine+j+2) << 16)) +
(static_cast<uint32_t>(ReadMem(i*m_MemBytesPerLine+j+3) << 24));
memLine << std::setfill(' ') << std::setw(10) << std::dec << val << " ";
break;
}
case Format::I8:
{
int8_t val = static_cast<int8_t>(ReadMem(i*m_MemBytesPerLine+j));
memLine << std::setfill(' ') << std::setw(4) << std::dec << val << " ";
break;
}
case Format::I16:
{
int16_t val = static_cast<uint16_t>(ReadMem(i*m_MemBytesPerLine+j)) +
(static_cast<uint16_t>(ReadMem(i*m_MemBytesPerLine+j+1) << 8));
memLine << std::setfill(' ') << std::setw(6) << std::dec << val << " ";
break;
}
case Format::I32:
{
int32_t val = static_cast<int32_t>(ReadMem(i*m_MemBytesPerLine+j)) +
(static_cast<int32_t>(ReadMem(i*m_MemBytesPerLine+j+1) << 8)) +
(static_cast<int32_t>(ReadMem(i*m_MemBytesPerLine+j+2) << 16)) +
(static_cast<int32_t>(ReadMem(i*m_MemBytesPerLine+j+3) << 24));
memLine << std::setfill(' ') << std::setw(11) << std::dec << val << " ";
break;
}
}
}
if(!filterAdress && !filterValue) {
displayLine = true;
} else {
for(unsigned int j = 0; j < m_MemBytesPerLine; j++) {
unsigned int val = ReadMem(i*m_MemBytesPerLine+j);
if(filterValue && static_cast<int>(val) == m_MemFilterValue) {
displayLine = true;
}
if(filterAdress && (i*m_MemBytesPerLine+j == static_cast<unsigned int>(m_MemDisplayValue))) {
displayLine = true;
}
}
}
}
if(displayLine) {
m_currentlyDisplayed.push_back(i);
}
if(displayLine) {
memText << memLine.str() << "\n";
}
}
m_pMemTextContent->SetWindowText(memText.str().substr(0, memText.str().size()-1));
}
void CapriceDevTools::PauseExecution()
{
CPC.paused = true;
m_pButtonPause->SetWindowText("Resume");
}
void CapriceDevTools::ResumeExecution()
{
CPC.paused = false;
m_pButtonPause->SetWindowText("Pause");
}
void CapriceDevTools::LoadSymbols(const std::string& filename)
{
m_Symfile = Symfile(filename);
for (auto breakpoint : m_Symfile.Breakpoints()) {
if (std::find_if(breakpoints.begin(), breakpoints.end(),
[&](const auto& bp) { return bp.address == breakpoint; } ) != breakpoints.end()) continue;
breakpoints.emplace_back(breakpoint);
}
for (auto entrypoint : m_Symfile.Entrypoints()) {
if (std::find(m_EntryPoints.begin(), m_EntryPoints.end(), entrypoint) != m_EntryPoints.end()) continue;
m_EntryPoints.push_back(entrypoint);
}
UpdateEntryPointsList();
UpdateBreakPointsList();
RefreshDisassembly();
}
void CapriceDevTools::RemoveEphemeralBreakpoints()
{
breakpoints.erase(
std::remove_if(breakpoints.begin(), breakpoints.end(),
[](const auto& x){ return x.type & EPHEMERAL; }),
breakpoints.end());
}
void CapriceDevTools::PreUpdate()
{
static bool wasRunning;
// Pause on breakpoints and watchpoints.
// Before updating display so that we can update differently: faster if not
// paused, more details if paused.
if (!breakpoints.empty() || !watchpoints.empty()) {
if (z80.watchpoint_reached || z80.breakpoint_reached) {
PauseExecution();
RemoveEphemeralBreakpoints();
};
}
if (CPC.paused) {
m_pButtonPause->SetWindowText("Resume");
} else {
m_pButtonPause->SetWindowText("Pause");
}
// Do not update if we're paused.
// This is particularly needed for disassembly pos as otherwise it's not
// possible to scroll in the disassembled code.
if (wasRunning) {
wasRunning = !CPC.paused;
switch (m_pNavigationBar->getSelectedIndex()) {
case 0 : { // 'z80'
UpdateZ80();
break;
}
case 1 : { // 'Assembly'
UpdateDisassemblyPos();
break;
}
case 2 : { // 'Memory'
UpdateMemConfig();
break;
}
case 3 : { // 'Video'
break;
}
case 4 : { // 'Audio'
break;
}
case 5 : { // 'Characters'
break;
}
}
} else {
wasRunning = !CPC.paused;
}
}
void CapriceDevTools::PostUpdate()
{
if (z80.step_in > 1) {
PauseExecution();
z80.step_in = 0;
}
}
void CapriceDevTools::UpdateAll()
{
UpdateZ80();
UpdateBreakPointsList();
//UpdateDisassembly();
UpdateDisassemblyPos();
UpdateTextMemory();
UpdateWatchPointsList();
}
bool CapriceDevTools::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::CTRL_SINGLELCLICK:
{
if (pMessage->Destination() == this)
{
if (pMessage->Source() == m_pButtonClose) {
CloseFrame();
bHandled = true;
break;
}
if (pMessage->Source() == m_pButtonPause) {
if (CPC.paused) {
ResumeExecution();
} else {
PauseExecution();
}
break;
}
if (pMessage->Source() == m_pButtonStepIn) {
z80.step_in = 1;
ResumeExecution();
break;
}
if (pMessage->Source() == m_pButtonStepOver) {
// Like StepIn except if the instruction is a call
std::vector<dword> unused_entrypoints;
DisassembledCode unused_code;
auto current_line = disassemble_one(z80.PC.d, unused_code, unused_entrypoints);
if (current_line.instruction_.rfind("call", 0) == 0) {
breakpoints.emplace_back(z80.PC.d + current_line.Size(), EPHEMERAL);
} else {
z80.step_in = 1;
}
ResumeExecution();
break;
}
if (pMessage->Source() == m_pButtonStepOut) {
z80.step_out = 1;
z80.step_out_addresses.clear();
ResumeExecution();
break;
}
}
if (pMessage->Destination() == m_pGroupBoxTabAsm) {
if (pMessage->Source() == m_pAssemblyRefresh) {
UpdateDisassembly();
break;
}
if (pMessage->Source() == m_pAssemblySearchPrev) {
AsmSearch(SearchFrom::PositionExcluded, SearchDir::Backward);
}
if (pMessage->Source() == m_pAssemblySearchNext) {
AsmSearch(SearchFrom::PositionExcluded, SearchDir::Forward);
}
}
if (pMessage->Destination() == m_pAssemblyEntryPointsGrp) {
if (pMessage->Source() == m_pAssemblyAddEntryPoint) {
// stol can throw on empty string or invalid value
try
{
m_EntryPoints.push_back(static_cast<word>(std::stol(m_pAssemblyNewEntryPoint->GetWindowText(), nullptr, 16)));
UpdateEntryPointsList();
} catch(...) {}
break;
}
if (pMessage->Source() == m_pAssemblyAddPCEntryPoint) {
m_EntryPoints.push_back(_PC);
UpdateEntryPointsList();
break;
}
if (pMessage->Source() == m_pAssemblyRemoveEntryPoint) {
for (int i = static_cast<int>(m_pAssemblyEntryPoints->Size()) - 1; i >= 0; i--) {
if (m_pAssemblyEntryPoints->IsSelected(i)) {
m_EntryPoints.erase(m_EntryPoints.begin() + i);
}
}
UpdateEntryPointsList();
break;
}
}
if (pMessage->Destination() == m_pAssemblyBreakPointsGrp) {
if (pMessage->Source() == m_pAssemblyAddBreakPoint) {
// stol can throw on empty string or invalid value
try
{
breakpoints.emplace_back(static_cast<word>(std::stol(m_pAssemblyNewBreakPoint->GetWindowText(), nullptr, 16)));
UpdateBreakPointsList();
} catch(...) {}
break;
}
if (pMessage->Source() == m_pAssemblyRemoveBreakPoint) {
for (int i = static_cast<int>(m_pAssemblyBreakPoints->Size()) - 1; i >= 0; i--) {
if (m_pAssemblyBreakPoints->IsSelected(i)) {
breakpoints.erase(breakpoints.begin() + i);
}
}
UpdateBreakPointsList();
break;
}
}
if (pMessage->Destination() == m_pGroupBoxTabMemory)
{
if (pMessage->Source() == m_pMemButtonPoke) {
PrepareMemBankConfig();
std::string adress = m_pMemPokeAdress->GetWindowText();
std::string value = m_pMemPokeValue->GetWindowText();
unsigned int pokeAdress = strtol(adress.c_str(), nullptr, 16);
int pokeValue = strtol(value.c_str(), nullptr, 16);
if(!adress.empty() && !value.empty() && pokeAdress < 65536 && pokeValue >= -128 && pokeValue <= 255) {
std::cout << "Poking " << pokeAdress << " with " << pokeValue << std::endl;
WriteMem(pokeAdress, pokeValue);
UpdateTextMemory();
} else {
std::cout << "Cannot poke " << adress << "(" << pokeAdress << ") with " << value << "(" << pokeValue << ")" << std::endl;
}
bHandled = true;
break;
}
if (pMessage->Source() == m_pMemButtonDisplay) {
std::string display = m_pMemAdressValue->GetWindowText();
if(display.empty()) {
m_MemDisplayValue = -1;
} else {
m_MemDisplayValue = strtol(display.c_str(), nullptr, 16);
}
m_MemFilterValue = -1;
std::cout << "Displaying adress " << m_MemDisplayValue << " in memory." << std::endl;
UpdateTextMemory();
bHandled = true;
break;
}
if (pMessage->Source() == m_pMemButtonFilter) {
m_currentlyFiltered.clear();
m_MemDisplayValue = -1;
std::string filter = m_pMemFilterValue->GetWindowText();
if(filter.empty()) {
m_MemFilterValue = -1;
} else {
m_MemFilterValue = strtol(filter.c_str(), nullptr, 16);
}
std::cout << "Filtering value " << m_MemFilterValue << " in memory." << std::endl;
UpdateTextMemory();
bHandled = true;
break;
}
if (pMessage->Source() == m_pMemButtonSaveFilter) {
m_savedFilter = m_currentlyDisplayed;
bHandled = true;
break;
}
if (pMessage->Source() == m_pMemButtonApplyFilter) {
m_currentlyFiltered = m_savedFilter;
UpdateTextMemory();
bHandled = true;
break;
}
if (pMessage->Source() == m_pMemButtonCopy) {
std::cout << m_pMemTextContent->GetWindowText() << std::endl;
if(SDL_SetClipboardText(m_pMemTextContent->GetWindowText().c_str()) < 0) {
LOG_ERROR("Error while copying data to clipboard: " << SDL_GetError());
}
bHandled = true;
break;
}
}
if (pMessage->Destination() == m_pMemWatchPointsGrp) {
if (pMessage->Source() == m_pMemAddWatchPoint) {
// stol can throw on empty string or invalid value
try
{
WatchpointType type = WatchpointType(m_pMemWatchPointType->GetSelectedIndex() + 1);
watchpoints.emplace_back(static_cast<word>(std::stol(m_pMemNewWatchPoint->GetWindowText(), nullptr, 16)), type);
UpdateWatchPointsList();
} catch(...) {}
break;
}
if (pMessage->Source() == m_pMemRemoveWatchPoint) {
for (int i = static_cast<int>(m_pMemWatchPoints->Size()) - 1; i >= 0; i--) {
if (m_pMemWatchPoints->IsSelected(i)) {
watchpoints.erase(watchpoints.begin() + i);
}
}
UpdateWatchPointsList();
break;
}
}
break;
}
case CMessage::CTRL_VALUECHANGE:
if (pMessage->Destination() == this) {
if (pMessage->Source() == m_pNavigationBar) {
switch (m_pNavigationBar->getSelectedIndex()) {
case 0 : { // 'z80'
EnableTab("z80");
UpdateZ80();
break;
}
case 1 : { // 'Assembly'
EnableTab("asm");
UpdateDisassemblyPos();
break;
}
case 2 : { // 'Memory'
EnableTab("memory");
UpdateTextMemory();
UpdateWatchPointsList();
break;
}
case 3 : { // 'Video'
EnableTab("video");
break;
}
case 4 : { // 'Audio'
EnableTab("audio");
break;
}
case 5 : { // 'Characters'
EnableTab("char");
break;
}
}
}
}
if (pMessage->Destination() == m_pGroupBoxTabAsm) {
if (pMessage->Source() == m_pAssemblySearch) {
AsmSearch(SearchFrom::PositionIncluded, SearchDir::Forward);
}
}
if (pMessage->Destination() == m_pGroupBoxTabMemory) {
if (pMessage->Source() == m_pMemBytesPerLine) {
m_MemBytesPerLine = 1 << m_pMemBytesPerLine->GetSelectedIndex();
// Note: Any saved filter doesn't make sense anymore but we keep it
// just in case the user wants to come back to the previous
// BytesPerLine.
// It would be nice to have a mechanism to warn the user if the
// filter is not aligned with the BytesPerLine setting.
UpdateTextMemory();
}
if (pMessage->Source() == m_pMemFormat) {
m_MemFormat.clear();
for (auto f : stringutils::split(m_pMemFormat->GetWindowText(), '&')) {
f = stringutils::lower(stringutils::trim(f, ' '));
if (f == "hex") {
m_MemFormat.push_back(Format::Hex);
} else if (f == "char") {
m_MemFormat.push_back(Format::Char);
} else if (f == "u8") {
m_MemFormat.push_back(Format::U8);
} else if (f == "u16") {
m_MemFormat.push_back(Format::U16);
} else if (f == "u32") {
m_MemFormat.push_back(Format::U32);
} else if (f == "i8") {
m_MemFormat.push_back(Format::I8);
} else if (f == "i16") {
m_MemFormat.push_back(Format::I16);
} else if (f == "i32") {
m_MemFormat.push_back(Format::I32);
} else {
LOG_WARNING("Unknown format token '" << f << "', skipping.");
continue;
}
}
if (m_MemFormat.empty()) {
LOG_ERROR("No valid format provided in '" << m_pMemFormat->GetWindowText() << "', defaulting to 'Hex'.");
m_MemFormat.push_back(Format::Hex);
}
UpdateTextMemory();
}
}
#if __GNUC__ >= 7
[[gnu::fallthrough]];
#endif
case CMessage::CTRL_VALUECHANGING:
if (pMessage->Destination() == m_pGroupBoxTabZ80) {
// TODO: Handle scrollbars
}
break;
default :
break;
}
}
if (!bHandled) {
bHandled = CFrame::HandleMessage(pMessage);
}
return bHandled;
}
// Enable a 'tab', i.e. make the corresponding CGroupBox (and its content) visible.
void CapriceDevTools::EnableTab(std::string sTabName) {
std::map<std::string, CGroupBox*>::const_iterator iter;
for (iter=TabMap.begin(); iter != TabMap.end(); ++iter) {
iter->second->SetVisible(iter->first == sTabName);
}
}
void CapriceDevTools::CloseFrame() {
// Exit gui
Application().MessageServer()->QueueMessage(new CMessage(CMessage::APP_EXIT, GetAncestor(ROOT), this));
m_pDevTools->Deactivate();
}
} // namespace wGui
| 54,520
|
C++
|
.cpp
| 1,180
| 38.718644
| 183
| 0.623035
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,813
|
wg_message_client.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_message_client.cpp
|
// wg_message_client.cpp
//
// CMessageClient class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_message_client.h"
#include "wg_application.h"
namespace wGui
{
CMessageClient::CMessageClient(CApplication& pApplication) :
m_pApplication(pApplication) {}
CMessageClient::~CMessageClient() // virtual
{
auto message_server = Application().MessageServer();
// Exceptionnally, MessageServer() can return null because we may be in the
// destructor of the parent CMessageClient of CApplication
if (message_server == nullptr) return;
message_server->DeregisterMessageClient(this);
}
}
| 1,393
|
C++
|
.cpp
| 37
| 36.054054
| 77
| 0.77266
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,814
|
wg_menu.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_menu.cpp
|
// wg_menu.cpp
//
// CMenu implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_menu.h"
#include "std_ex.h"
#include "wg_application.h"
#include "wg_message_server.h"
#include "wg_view.h"
#include "wg_error.h"
namespace wGui
{
// CMenuBase
CMenuBase::CMenuBase(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine) :
CWindow(WindowRect, pParent),
m_pHighlightedItem(nullptr),
m_bCachedRectsValid(false),
m_pActivePopup(nullptr),
m_hRightArrowBitmap(Application(), WGRES_RIGHT_ARROW_BITMAP),
m_HighlightColor(DEFAULT_BACKGROUND_COLOR),
m_pPopupTimer(nullptr)
{
if (pFontEngine)
{
m_pFontEngine = pFontEngine;
}
else
{
m_pFontEngine = Application().GetDefaultFontEngine();
}
m_HighlightColor = Application().GetDefaultSelectionColor();
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_MOVE);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_SINGLELCLICK);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_TIMER);
m_pPopupTimer = new CTimer(pParent->Application(), this);
}
CMenuBase::~CMenuBase()
{
delete m_pPopupTimer;
m_pPopupTimer = nullptr;
}
void CMenuBase::InsertMenuItem(const SMenuItem& MenuItem, int iPosition)
{
m_MenuItems.insert((iPosition == -1) ? m_MenuItems.end() : m_MenuItems.begin() + iPosition,
s_MenuItemInfo(MenuItem, CRenderedString(m_pFontEngine, MenuItem.sItemText, CRenderedString::VALIGN_TOP), CRect()));
m_bCachedRectsValid = false;
// Draw();
}
void CMenuBase::RemoveMenuItem(int iPosition)
{
m_MenuItems.erase(m_MenuItems.begin() + iPosition);
m_bCachedRectsValid = false;
Draw();
}
void CMenuBase::HideActivePopup()
{
if (m_pActivePopup)
{
m_pActivePopup->Hide();
m_pActivePopup = nullptr;
}
}
bool CMenuBase::OnMouseButtonDown(CPoint Point, unsigned int Button)
{
// We can't do quite the same thing as normal since children of menus don't appear inside their bounds
bool bResult = false;
if (m_bVisible)
{
for (auto iter = m_ChildWindows.rbegin(); iter != m_ChildWindows.rend(); ++iter)
{
bResult = (*iter)->OnMouseButtonDown(Point, Button);
if (bResult)
{
break;
}
}
}
return bResult;
}
bool CMenuBase::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::MOUSE_MOVE:
{
CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);
if (m_bVisible && pMouseMessage &&
m_WindowRect.SizeRect().HitTest(ViewToWindow(pMouseMessage->Point)) == CRect::RELPOS_INSIDE)
{
UpdateCachedRects();
const SMenuItem* pOldHighlight = m_pHighlightedItem;
m_pHighlightedItem = nullptr;
CPoint WindowPoint(ViewToWindow(pMouseMessage->Point));
for (const auto &item : m_MenuItems)
{
if (item.Rect.HitTest(WindowPoint) == CRect::RELPOS_INSIDE && !item.MenuItem.bSpacer)
{
m_pHighlightedItem = &(item.MenuItem);
break;
}
}
if (pOldHighlight != m_pHighlightedItem)
{
m_pPopupTimer->StopTimer();
if (m_pHighlightedItem && m_pHighlightedItem->pPopup)
{
m_pPopupTimer->StartTimer(1000);
}
Draw();
}
}
else if (m_pHighlightedItem != nullptr)
{
m_pPopupTimer->StopTimer();
m_pHighlightedItem = nullptr;
Draw();
}
break;
}
case CMessage::CTRL_SINGLELCLICK:
{
TIntMessage* pCtrlMessage = dynamic_cast<TIntMessage*>(pMessage);
if (pCtrlMessage && pCtrlMessage->Destination() == this)
{
for (const auto &item : m_MenuItems)
{
if (pCtrlMessage->Source() == item.MenuItem.pPopup)
{
Application().MessageServer()->QueueMessage(new TIntMessage(CMessage::CTRL_SINGLELCLICK, m_pParentWindow,
this, pCtrlMessage->Value()));
bHandled = true;
break;
}
}
}
break;
}
case CMessage::CTRL_TIMER:
{
if (pMessage->Destination() == this)
{
bHandled = true;
}
break;
}
default :
bHandled = CWindow::HandleMessage(pMessage);
break;
}
}
return bHandled;
}
// CMenu
CMenu::CMenu(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine) :
CMenuBase(WindowRect, pParent, pFontEngine)
{
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_MOVE);
Draw();
}
CMenu::~CMenu() = default;
void CMenu::InsertMenuItem(const SMenuItem& MenuItem, int iPosition)
{
m_MenuItems.insert((iPosition == -1) ? m_MenuItems.end() : m_MenuItems.begin() + iPosition,
s_MenuItemInfo(MenuItem, CRenderedString(m_pFontEngine, MenuItem.sItemText, CRenderedString::VALIGN_NORMAL), CRect()));
m_bCachedRectsValid = false;
if (MenuItem.pPopup)
{
MenuItem.pPopup->SetParentMenu(this);
}
Draw();
}
void CMenu::Draw() const
{
CWindow::Draw();
if (m_pSDLSurface)
{
CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
UpdateCachedRects();
for (const auto &item : m_MenuItems)
{
if (m_pHighlightedItem == &(item.MenuItem))
{
Painter.DrawRect(item.Rect, true, m_HighlightColor, m_HighlightColor);
}
CRect TextRect(item.Rect);
TextRect.Grow(-2);
if (item.MenuItem.bSpacer)
{
Painter.DrawVLine(TextRect.Top(), TextRect.Bottom(), TextRect.Left(), COLOR_LIGHTGRAY);
Painter.DrawVLine(TextRect.Top(), TextRect.Bottom(), TextRect.Right(), COLOR_DARKGRAY);
}
else
item.RenderedString.Draw(m_pSDLSurface, TextRect, CPoint(TextRect.Left(), (TextRect.Top() + TextRect.Bottom()) * 3 / 4));
}
}
}
bool CMenu::OnMouseButtonDown(CPoint Point, unsigned int Button)
{
bool bResult = CMenuBase::OnMouseButtonDown(Point, Button);
if (!bResult && m_bVisible && (Button == CMouseMessage::LEFT) &&
(m_WindowRect.SizeRect().HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE))
{
UpdateCachedRects();
for (const auto &item : m_MenuItems)
{
if (item.Rect.HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE && !item.MenuItem.bSpacer)
{
HideActivePopup();
if (item.MenuItem.pPopup)
{
CPopupMenu* pPopup = dynamic_cast<CPopupMenu*>(item.MenuItem.pPopup);
if (pPopup)
{
m_pActivePopup = pPopup;
ShowActivePopup(item.Rect, GetAncestor(ROOT)->GetClientRect());
}
}
else
{
Application().MessageServer()->QueueMessage(new TIntMessage(CMessage::CTRL_SINGLELCLICK, m_pParentWindow, this, item.MenuItem.iItemId));
}
break;
}
}
bResult = true;
}
return bResult;
}
bool CMenu::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::MOUSE_MOVE:
{
CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);
if (m_bVisible && pMouseMessage &&
m_WindowRect.SizeRect().HitTest(ViewToWindow(pMouseMessage->Point)) == CRect::RELPOS_INSIDE)
{
UpdateCachedRects();
const SMenuItem* pOldHighlight = m_pHighlightedItem;
m_pHighlightedItem = nullptr;
CPoint WindowPoint(ViewToWindow(pMouseMessage->Point));
for (const auto &item : m_MenuItems)
{
if (item.Rect.HitTest(WindowPoint) == CRect::RELPOS_INSIDE && !item.MenuItem.bSpacer)
{
m_pHighlightedItem = &(item.MenuItem);
break;
}
}
if (pOldHighlight != m_pHighlightedItem)
{
Draw();
}
}
else if (m_pHighlightedItem != nullptr)
{
m_pHighlightedItem = nullptr;
Draw();
}
break;
}
default :
bHandled = CMenuBase::HandleMessage(pMessage);
break;
}
}
return bHandled;
}
void CMenu::UpdateCachedRects() const
{
if (!m_bCachedRectsValid)
{
CRect SubRect(m_WindowRect.SizeRect());
SubRect.Grow(-2);
int iWidth = 5;
for (auto &item : m_MenuItems)
{
if (item.MenuItem.bSpacer)
{
CRect TextRect(SubRect.Left() + iWidth, SubRect.Top() + 2, SubRect.Left() + iWidth + 1, SubRect.Bottom() - 2);
TextRect.Grow(2);
item.Rect = TextRect;
iWidth += 9;
}
else
{
CPoint Dims;
item.RenderedString.GetMetrics(&Dims, nullptr, nullptr);
CRect TextRect(SubRect.Left() + iWidth, SubRect.Top() + 2, SubRect.Left() + iWidth + Dims.XPos(), SubRect.Bottom() - 2);
TextRect.Grow(2);
item.Rect = TextRect;
iWidth += Dims.XPos() + 8;
}
}
m_bCachedRectsValid = true;
}
}
void CMenu::ShowActivePopup(const CRect& ParentRect, const CRect& BoundingRect)
{
// TODO: Add bounds checking for all edges. Apply this same bounds checking logic to the popup root menu too.
if (!m_pActivePopup)
{
throw(Wg_Ex_App("Trying to show active popup menu when pActivePopup is NULL!", "CMenu::ShowActivePopup"));
}
CRect MenuRect = m_pActivePopup->GetWindowRect();
if (BoundingRect.HitTest(ParentRect.BottomLeft() + CPoint(MenuRect.Width(), 0)) & CRect::RELPOS_RIGHT)
{
int xDelta = BoundingRect.Right() - ParentRect.Left() + MenuRect.Width();
if (!(BoundingRect.HitTest(ParentRect.BottomLeft() + CPoint(xDelta, 0)) & CRect::RELPOS_LEFT))
{
m_pActivePopup->Show(ParentRect.BottomLeft() + CPoint(xDelta, 5));
}
}
else
{
m_pActivePopup->Show(ParentRect.BottomLeft() + CPoint(0, 5));
}
// Pop the popup to the top of the draw order and everything
m_pActivePopup->SetNewParent(m_pActivePopup->GetAncestor(PARENT));
}
// CPopupMenu
CPopupMenu::CPopupMenu(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine) :
CMenuBase(WindowRect, pParent, pFontEngine),
m_pParentMenu(nullptr)
{
m_bVisible = false;
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_BUTTONDOWN);
Draw();
}
CPopupMenu::~CPopupMenu() = default;
void CPopupMenu::Show(CPoint Position)
{
if (m_bVisible)
{
Hide();
}
int iHeight = 4;
for (const auto &item : m_MenuItems)
{
if (item.MenuItem.bSpacer)
iHeight += 6;
else
{
CPoint Dims;
item.RenderedString.GetMetrics(&Dims, nullptr, nullptr);
iHeight += Dims.YPos() + 5;
}
}
//Bounds checking for menus, so that we don't draw off screen, since we can't.
CRect TestRect = GetAncestor(ROOT)->GetWindowRect();
if ( Position.XPos() < 0 )
{
Position.SetX(0);
}
if ( Position.YPos() < 0 )
{
Position.SetY(0);
}
if ( Position.XPos() + m_WindowRect.Width() > TestRect.Width() )
{
Position.SetX(Position.XPos() - ((Position.XPos() + m_WindowRect.Width()) - TestRect.Width()));
}
if ( Position.YPos() + m_WindowRect.Height() > TestRect.Height() )
{
Position.SetY(Position.YPos() - ((Position.YPos() + m_WindowRect.Height()) - TestRect.Bottom()));
}
SetWindowRect(GetAncestor(PARENT)->ViewToClient(CRect(Position, Position + CPoint(m_WindowRect.Width() - 1, iHeight + 2))));
m_bVisible = true;
CView* pView = GetView();
if (pView && !dynamic_cast<CPopupMenu*>(m_pParentWindow))
{
pView->SetFloatingWindow(this);
}
Draw();
}
void CPopupMenu::Hide()
{
HideActivePopup();
m_bVisible = false;
m_bCachedRectsValid = false;
CView* pView = GetView();
if (!dynamic_cast<CPopupMenu*>(m_pParentWindow) && pView && pView->GetFloatingWindow() == this)
{
pView->SetFloatingWindow(nullptr);
}
Application().MessageServer()->QueueMessage(new CMessage(CMessage::APP_PAINT, nullptr, this));
m_pHighlightedItem = nullptr;
Draw();
}
void CPopupMenu::HideAll()
{
CPopupMenu* pParentPopup = dynamic_cast<CPopupMenu*>(m_pParentWindow);
if (pParentPopup)
{
pParentPopup->HideAll();
}
else
{
CMenu* pRootMenu = dynamic_cast<CMenu*>(m_pParentWindow);
if (pRootMenu)
{
pRootMenu->HideActivePopup();
}
else
{
Hide();
}
}
}
bool CPopupMenu::IsInsideChild(const CPoint& Point) const
{
if (m_WindowRect.SizeRect().HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE)
{
return true;
}
if (!m_pActivePopup)
{
return false;
}
return m_pActivePopup->IsInsideChild(Point);
}
void CPopupMenu::Draw() const
{
CWindow::Draw();
if (m_pSDLSurface)
{
CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
Painter.DrawRect(m_WindowRect.SizeRect(), false, COLOR_LIGHTGRAY);
Painter.DrawHLine(0, m_WindowRect.Width(), m_WindowRect.Height(), COLOR_DARKGRAY);
Painter.DrawVLine(0, m_WindowRect.Height(), m_WindowRect.Width(), COLOR_DARKGRAY);
UpdateCachedRects();
for (const auto &item : m_MenuItems)
{
if (m_pHighlightedItem == &(item.MenuItem))
{
Painter.DrawRect(item.Rect, true, m_HighlightColor, m_HighlightColor);
}
CRect TextRect(item.Rect);
TextRect.Grow(-2);
if (item.MenuItem.bSpacer)
{
Painter.DrawHLine(TextRect.Left(), TextRect.Right(), TextRect.Top(), COLOR_LIGHTGRAY);
Painter.DrawHLine(TextRect.Left(), TextRect.Right(), TextRect.Bottom(), COLOR_DARKGRAY);
}
else
item.RenderedString.Draw(m_pSDLSurface, TextRect, TextRect.TopLeft());
if (item.MenuItem.pPopup)
{
CRect ArrowRect(item.Rect);
ArrowRect.SetLeft(ArrowRect.Right() - m_hRightArrowBitmap.Bitmap()->w);
SDL_Rect SourceRect;
SourceRect.x = stdex::safe_static_cast<short int>(0);
SourceRect.y = stdex::safe_static_cast<short int>((m_hRightArrowBitmap.Bitmap()->h - ArrowRect.Height()) / 2 < 0 ?
0 : (m_hRightArrowBitmap.Bitmap()->h - ArrowRect.Height()) / 2);
SourceRect.w = stdex::safe_static_cast<short int>(m_hRightArrowBitmap.Bitmap()->w);
SourceRect.h = stdex::safe_static_cast<short int>(std::min(ArrowRect.Height(), m_hRightArrowBitmap.Bitmap()->h));
SDL_Rect DestRect;
DestRect.x = stdex::safe_static_cast<short int>(ArrowRect.Left());
DestRect.y = stdex::safe_static_cast<short int>((ArrowRect.Height() - m_hRightArrowBitmap.Bitmap()->h) / 2 < 0 ?
ArrowRect.Top() : ArrowRect.Top() + (ArrowRect.Height() - m_hRightArrowBitmap.Bitmap()->h) / 2);
DestRect.w = stdex::safe_static_cast<short int>(m_hRightArrowBitmap.Bitmap()->w);
DestRect.h = stdex::safe_static_cast<short int>(std::min(ArrowRect.Height(), m_hRightArrowBitmap.Bitmap()->h));
SDL_BlitSurface(m_hRightArrowBitmap.Bitmap(), &SourceRect, m_pSDLSurface, &DestRect);
}
}
}
}
void CPopupMenu::PaintToSurface(SDL_Surface& /*ScreenSurface*/, SDL_Surface& FloatingSurface, const CPoint& Offset) const
{
if (m_bVisible)
{
SDL_Rect SourceRect = CRect(m_WindowRect.SizeRect()).SDLRect();
SDL_Rect DestRect = CRect(m_WindowRect + Offset).SDLRect();
SDL_BlitSurface(m_pSDLSurface, &SourceRect, &FloatingSurface, &DestRect);
CPoint NewOffset = m_ClientRect.TopLeft() + m_WindowRect.TopLeft() + Offset;
for (const auto& child : m_ChildWindows)
{
child->PaintToSurface(FloatingSurface, FloatingSurface, NewOffset);
}
}
}
bool CPopupMenu::OnMouseButtonDown(CPoint Point, unsigned int Button)
{
bool bResult = CMenuBase::OnMouseButtonDown(Point, Button);
CPoint WindowPoint(ViewToWindow(Point));
if (!bResult && m_bVisible && (m_WindowRect.SizeRect().HitTest(WindowPoint) == CRect::RELPOS_INSIDE))
{
UpdateCachedRects();
for (const auto &item : m_MenuItems)
{
if (item.Rect.HitTest(WindowPoint) == CRect::RELPOS_INSIDE && !item.MenuItem.bSpacer)
{
if (!item.MenuItem.pPopup)
{
CMessageClient* pDestination = m_pParentWindow;
if (m_pParentMenu)
{
pDestination = m_pParentMenu;
}
Application().MessageServer()->QueueMessage(new TIntMessage(CMessage::CTRL_SINGLELCLICK, pDestination, this, item.MenuItem.iItemId));
HideAll();
}
else
{
HideActivePopup();
m_pActivePopup = item.MenuItem.pPopup;
ShowActivePopup(item.Rect, GetAncestor(ROOT)->GetClientRect());
}
break;
}
}
bResult = true;
}
return bResult;
}
bool CPopupMenu::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::MOUSE_BUTTONDOWN:
{
CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);
if (m_bVisible && pMouseMessage &&
m_WindowRect.SizeRect().HitTest(ViewToWindow(pMouseMessage->Point)) != CRect::RELPOS_INSIDE)
{
// If the user clicked outside the window, we just want to hide the window,
// and then pass the message on (bHandled = false)
// But we only want the root popup to do this, and only if none of it's children were hit
if (!dynamic_cast<CPopupMenu*>(m_pParentWindow) && !IsInsideChild(pMouseMessage->Point) &&
!(m_pParentMenu && m_pParentMenu->GetWindowRect().SizeRect().HitTest(
m_pParentMenu->ViewToWindow(pMouseMessage->Point)) == CRect::RELPOS_INSIDE))
{
HideAll();
}
}
break;
}
case CMessage::CTRL_TIMER:
{
if (pMessage->Destination() == this)
{
CRect ItemRect;
for (const auto &item : m_MenuItems)
{
if (m_pHighlightedItem == &(item.MenuItem))
{
ItemRect = item.Rect;
break;
}
}
if (m_pHighlightedItem && m_pHighlightedItem->pPopup)
{
HideActivePopup();
m_pActivePopup = m_pHighlightedItem->pPopup;
ShowActivePopup(ItemRect, GetAncestor(ROOT)->GetClientRect());
}
bHandled = true;
}
break;
}
default :
bHandled = CMenuBase::HandleMessage(pMessage);
break;
}
}
return bHandled;
}
void CPopupMenu::UpdateCachedRects() const
{
if (!m_bCachedRectsValid)
{
CRect SubRect(m_WindowRect.SizeRect());
SubRect.Grow(-2);
int iHeight = 4;
for (auto &item : m_MenuItems)
{
if (item.MenuItem.bSpacer)
{
CRect TextRect(SubRect.Left() + 3, SubRect.Top() + iHeight, SubRect.Right() - 3, SubRect.Top() + iHeight + 1);
TextRect.Grow(2);
item.Rect = TextRect;
iHeight += 6;
}
else
{
CPoint Dims;
item.RenderedString.GetMetrics(&Dims, nullptr, nullptr);
CRect TextRect(SubRect.Left() + 3, SubRect.Top() + iHeight, SubRect.Right() - 3, SubRect.Top() + iHeight + Dims.YPos());
TextRect.Grow(2);
item.Rect = TextRect;
iHeight += Dims.YPos() + 5;
}
}
m_bCachedRectsValid = true;
}
}
void CPopupMenu::ShowActivePopup(const CRect& ParentRect, const CRect& BoundingRect)
{
// TODO: Add bounds checking for all edges. Apply this same bounds checking logic to the popup root menu too.
if (!m_pActivePopup)
{
throw(Wg_Ex_App("Trying to show active popup menu when pActivePopup is NULL!", "CPopupMenu::ShowActivePopup"));
}
CRect MenuRect = m_pActivePopup->GetWindowRect();
//Test to see if we're going to draw the menu off the right side of the screen, if we are, then we'll correct it to draw to the left of the menu
if (BoundingRect.HitTest(ParentRect.TopRight() + CPoint(5, 0) + CPoint(MenuRect.Width(), 0)) & CRect::RELPOS_RIGHT)
{
m_pActivePopup->Show(ClientToView(ParentRect.TopLeft() - CPoint(MenuRect.Width() + 5, 0)) - m_ClientRect.TopLeft());
}
else
{
m_pActivePopup->Show(ClientToView(ParentRect.TopRight() + CPoint(5, 0)) - m_ClientRect.TopLeft());
}
}
}
| 19,373
|
C++
|
.cpp
| 643
| 26.830482
| 145
| 0.705841
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,815
|
CapriceLoadSave.cpp
|
ColinPitrat_caprice32/src/gui/src/CapriceLoadSave.cpp
|
// 'Load/save' box for Caprice32
// Inherited from CMessageBox
#include "CapriceLoadSave.h"
#include "cap32.h"
#include "slotshandler.h"
#include "cartridge.h"
#include "stringutils.h"
#include "log.h"
#include "wg_messagebox.h"
#include <iostream>
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>
#ifdef WINDOWS
#define realpath(N,R) _fullpath((R),(N),_MAX_PATH)
#endif
// CPC emulation properties, defined in cap32.h:
extern t_CPC CPC;
extern t_drive driveA;
extern t_drive driveB;
namespace wGui {
CapriceLoadSave::CapriceLoadSave(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine) :
CFrame(WindowRect, pParent, pFontEngine, "Load / Save", false)
{
SetModal(true);
// Make this window listen to incoming CTRL_VALUECHANGE messages (used for updating drop down values)
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_VALUECHANGE);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_VALUECHANGING);
// File type (.SNA, .DSK, .TAP, .VOC)
m_pTypeLabel = new CLabel( CPoint(15, 25), this, "File type: ");
m_pTypeValue = new CDropDown( CRect(CPoint(80, 20), 150, 20), this, false);
#ifndef WITH_IPF
m_pTypeValue->AddItem(SListItem("Drive A (.dsk)"));
m_pTypeValue->AddItem(SListItem("Drive B (.dsk)"));
#else
m_pTypeValue->AddItem(SListItem("Drive A (.dsk/.ipf)"));
m_pTypeValue->AddItem(SListItem("Drive B (.dsk/.ipf)"));
#endif
m_pTypeValue->AddItem(SListItem("Snapshot (.sna)"));
m_pTypeValue->AddItem(SListItem("Tape (.cdt/.voc)"));
m_pTypeValue->AddItem(SListItem("Cartridge (.cpr)"));
m_pTypeValue->SetListboxHeight(5);
m_pTypeValue->SelectItem(0);
m_pTypeValue->SetIsFocusable(true);
m_fileSpec = { ".dsk", ".zip" };
// Action: load / save
m_pActionLabel = new CLabel( CPoint(15, 55), this, "Action: ");
m_pActionValue = new CDropDown( CRect(CPoint(80, 50), 150, 20), this, false);
m_pActionValue->AddItem(SListItem("Load"));
m_pActionValue->AddItem(SListItem("Save"));
m_pActionValue->SetListboxHeight(2);
m_pActionValue->SelectItem(0);
m_pActionValue->SetIsFocusable(true);
// Directory
m_pDirectoryLabel = new CLabel( CPoint(15, 85), this, "Directory: ");
m_pDirectoryValue = new CEditBox( CRect( CPoint(80, 80), 150, 20), this);
m_pDirectoryValue->SetWindowText(simplifyDirPath(CPC.current_dsk_path));
m_pDirectoryValue->SetReadOnly(true);
// File list
m_pFilesList = new CListBox(CRect(CPoint(80, 115), 150, 80), this, true);
m_pFilesList->SetIsFocusable(true);
UpdateFilesList();
// File name
m_pFileNameLabel = new CLabel( CPoint(15, 215), this, "File: ");
m_pFileNameValue = new CEditBox( CRect( CPoint(80, 210), 150, 20), this);
m_pFileNameValue->SetWindowText("");
m_pFileNameValue->SetReadOnly(true);
// Buttons
m_pCancelButton = new CButton( CRect( CPoint(250, 180), 50, 20), this, "Cancel");
m_pCancelButton->SetIsFocusable(true);
m_pLoadSaveButton = new CButton( CRect( CPoint(250, 210), 50, 20), this, "Load");
m_pLoadSaveButton->SetIsFocusable(true);
}
CapriceLoadSave::~CapriceLoadSave() = default;
bool CapriceLoadSave::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::CTRL_SINGLELCLICK:
{
if (pMessage->Destination() == this)
{
if (pMessage->Source() == m_pCancelButton) {
CloseFrame();
bHandled = true;
break;
}
if (pMessage->Source() == m_pLoadSaveButton) {
bool actionDone = false;
std::string filename = m_pFileNameValue->GetWindowText();
if(!filename.empty()) {
std::string directory = m_pDirectoryValue->GetWindowText();
filename = directory + '/' + filename;
switch (m_pActionValue->GetSelectedIndex()) {
case 0: // Load
{
DRIVE drive;
switch (m_pTypeValue->GetSelectedIndex()) {
case 0: // Drive A
drive = DSK_A;
actionDone = true;
CPC.current_dsk_path = directory;
break;
case 1: // Drive B
drive = DSK_B;
actionDone = true;
CPC.current_dsk_path = directory;
break;
case 2: // Snapshot
drive = OTHER;
actionDone = true;
CPC.current_snap_path = directory;
break;
case 3: // Tape
drive = OTHER;
actionDone = true;
CPC.current_tape_path = directory;
break;
case 4: // Cartridge
drive = OTHER;
actionDone = true;
CPC.current_cart_path = directory;
break;
}
if (actionDone) {
file_load(filename, drive);
}
if (m_pTypeValue->GetSelectedIndex() == 4) {
emulator_reset();
}
break;
}
case 1: // Save
// TODO(cpitrat): Ensure the proper extension is present in the filename, otherwise add it.
switch (m_pTypeValue->GetSelectedIndex()) {
case 0: // Drive A
std::cout << "Save dsk A: " << filename << std::endl;
dsk_save(filename, &driveA);
actionDone = true;
break;
case 1: // Drive B
std::cout << "Save dsk B: " << filename << std::endl;
dsk_save(filename, &driveB);
actionDone = true;
break;
case 2: // Snapshot
std::cout << "Save snapshot: " << filename << std::endl;
snapshot_save(filename);
actionDone = true;
break;
case 3: // Tape
{
std::cout << "Save tape: " << filename << std::endl;
// Unsupported
wGui::CMessageBox *pMessageBox = new wGui::CMessageBox(CRect(CPoint(m_ClientRect.Width() /2 - 125, m_ClientRect.Height() /2 - 30), 250, 60), this, nullptr, "Not implemented", "Saving tape not yet implemented", CMessageBox::BUTTON_OK);
pMessageBox->SetModal(true);
//tape_save(filename);
break;
}
case 4: // Cartridge
{
std::cout << "Save cartridge: " << filename << std::endl;
// Unsupported
wGui::CMessageBox *pMessageBox = new wGui::CMessageBox(CRect(CPoint(m_ClientRect.Width() /2 - 125, m_ClientRect.Height() /2 - 30), 250, 60), this, nullptr, "Not implemented", "Saving cartridge not yet implemented", CMessageBox::BUTTON_OK);
pMessageBox->SetModal(true);
//cpr_save(filename);
break;
}
}
break;
}
}
if(actionDone) {
CloseFrame();
}
bHandled = true;
break;
}
}
}
break;
case CMessage::CTRL_VALUECHANGE:
if (pMessage->Destination() == m_pActionValue) {
switch (m_pActionValue->GetSelectedIndex()) {
case 0: // Load
m_pLoadSaveButton->SetWindowText("Load");
m_pFileNameValue->SetReadOnly(true);
break;
case 1: // Save
m_pLoadSaveButton->SetWindowText("Save");
m_pFileNameValue->SetReadOnly(false);
break;
}
}
if (pMessage->Destination() == m_pTypeValue) {
switch (m_pTypeValue->GetSelectedIndex()) {
case 0: // Drive A
m_pDirectoryValue->SetWindowText(simplifyDirPath(CPC.current_dsk_path));
#ifndef WITH_IPF
m_fileSpec = { ".dsk", ".zip" };
#else
m_fileSpec = { ".dsk", ".ipf", ".zip" };
#endif
UpdateFilesList();
break;
case 1: // Drive B
m_pDirectoryValue->SetWindowText(simplifyDirPath(CPC.current_dsk_path));
m_fileSpec = { ".dsk", ".zip" };
UpdateFilesList();
break;
case 2: // Snapshot
m_pDirectoryValue->SetWindowText(simplifyDirPath(CPC.current_snap_path));
m_fileSpec = { ".sna", ".zip" };
UpdateFilesList();
break;
case 3: // Tape
m_pDirectoryValue->SetWindowText(simplifyDirPath(CPC.current_tape_path));
m_fileSpec = { ".cdt", ".voc", ".zip" };
UpdateFilesList();
break;
case 4: // Cartridge
m_pDirectoryValue->SetWindowText(simplifyDirPath(CPC.current_cart_path));
m_fileSpec = { ".cpr", ".zip" };
UpdateFilesList();
break;
}
}
if (pMessage->Source() == m_pFilesList) {
int idx = m_pFilesList->getFirstSelectedIndex();
std::string fn;
if (idx != -1) {
fn = m_pFilesList->GetItem(idx).sItemText;
}
if(!fn.empty() && fn[fn.size()-1] == '/') {
m_pDirectoryValue->SetWindowText(simplifyDirPath(m_pDirectoryValue->GetWindowText() + '/' + fn));
m_pFileNameValue->SetWindowText("");
UpdateFilesList();
} else {
m_pFileNameValue->SetWindowText(fn);
}
}
break;
default :
break;
}
}
if (!bHandled) {
bHandled = CFrame::HandleMessage(pMessage);
}
return bHandled;
}
std::string CapriceLoadSave::simplifyDirPath(std::string path)
{
#ifdef WINDOWS
char simplepath[_MAX_PATH+1];
#else
char simplepath[PATH_MAX+1];
#endif
if(realpath(path.c_str(), simplepath) == nullptr) {
LOG_ERROR("Couldn't simplify path '" << path << "': " << strerror(errno));
return ".";
}
struct stat entry_infos;
if(stat(simplepath, &entry_infos) != 0) {
LOG_ERROR("Could not retrieve info on " << simplepath << ": " << strerror(errno));
return ".";
}
if(!S_ISDIR(entry_infos.st_mode)) {
LOG_ERROR(simplepath << " is not a directory.");
return ".";
}
return std::string(simplepath);
}
bool CapriceLoadSave::MatchCurrentFileSpec(const char* filename)
{
for(const auto &ext : m_fileSpec) {
size_t lenFileName = strlen(filename);
if (lenFileName < ext.size()) continue;
if (strncasecmp(&(filename[lenFileName-ext.size()]), ext.c_str(), ext.size()) == 0) {
return true;
}
}
return false;
}
void CapriceLoadSave::UpdateFilesList()
{
m_pFilesList->ClearItems();
DIR *dp;
struct dirent *ep;
dp = opendir(m_pDirectoryValue->GetWindowText().c_str());
if(dp == nullptr) {
LOG_ERROR("Could not open " << m_pDirectoryValue->GetWindowText() << ": " << strerror(errno));
} else {
std::vector<std::string> directories;
std::vector<std::string> files;
while((ep = readdir(dp)) != nullptr) {
std::string entry_name = ep->d_name;
// ep->d_type is always set to DT_UNKNOWN on my computer => use a call to stat to determine if it's a directory
struct stat entry_infos;
std::string full_name = m_pDirectoryValue->GetWindowText() + "/" + entry_name;
if(stat(full_name.c_str(), &entry_infos) != 0) {
LOG_ERROR("Could not retrieve info on " << full_name << ": " << strerror(errno));
}
if(/*ep->d_type == DT_DIR*/S_ISDIR(entry_infos.st_mode) && (ep->d_name[0] != '.' || entry_name == "..")) {
directories.push_back(entry_name + "/");
} else if(/*ep->d_type == DT_REG*/S_ISREG(entry_infos.st_mode) && MatchCurrentFileSpec(ep->d_name)) {
files.push_back(entry_name);
}
}
if(closedir(dp) != 0) {
LOG_ERROR("Could not close directory: " << strerror(errno));
}
std::sort(directories.begin(), directories.end(), stringutils::caseInsensitiveCompare);
std::sort(files.begin(), files.end(), stringutils::caseInsensitiveCompare);
for(const auto &directory : directories) {
m_pFilesList->AddItem(SListItem(directory));
}
for(const auto &file : files) {
m_pFilesList->AddItem(SListItem(file));
}
}
}
}
| 13,258
|
C++
|
.cpp
| 330
| 29.309091
| 265
| 0.539755
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,816
|
CapriceLeavingWithoutSavingView.cpp
|
ColinPitrat_caprice32/src/gui/src/CapriceLeavingWithoutSavingView.cpp
|
#include "CapriceLeavingWithoutSavingView.h"
CapriceLeavingWithoutSavingView::CapriceLeavingWithoutSavingView(CApplication& application, SDL_Surface* surface, SDL_Surface* backSurface, const CRect& WindowRect) : CView(application, surface, backSurface, WindowRect)
{
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_MESSAGEBOXRETURN);
m_pMessageBox = new wGui::CMessageBox(CRect(CPoint(m_ClientRect.Width() /2 - 125, m_ClientRect.Height() /2 - 40), 250, 80), this, nullptr, "Quit without saving?", "Unsaved changes. Do you really want to quit?", CMessageBox::BUTTON_YES | CMessageBox::BUTTON_NO);
m_pMessageBox->SetModal(true);
}
bool CapriceLeavingWithoutSavingView::Confirmed() const
{
return confirmed;
}
void CapriceLeavingWithoutSavingView::PaintToSurface(SDL_Surface& ScreenSurface, SDL_Surface& FloatingSurface, const CPoint& Offset) const
{
if (m_bVisible)
{
// Reset backgound
SDL_BlitSurface(m_pBackSurface, nullptr, &ScreenSurface, nullptr);
// Draw all child windows recursively
for (const auto child : m_ChildWindows)
{
if (child)
{
child->PaintToSurface(ScreenSurface, FloatingSurface, Offset);
}
}
}
}
bool CapriceLeavingWithoutSavingView::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::APP_DESTROY_FRAME:
{
// Exit gui
Application().MessageServer()->QueueMessage(new CMessage(CMessage::APP_EXIT, nullptr, this));
break;
}
case CMessage::CTRL_MESSAGEBOXRETURN:
{
wGui::CValueMessage<CMessageBox::EButton> *pValueMessage = dynamic_cast<CValueMessage<CMessageBox::EButton>*>(pMessage);
if (pValueMessage && pValueMessage->Value() == CMessageBox::BUTTON_YES)
{
confirmed = true;
}
// Exit gui
Application().MessageServer()->QueueMessage(new CMessage(CMessage::APP_EXIT, nullptr, this));
break;
}
default :
break;
}
}
if (!bHandled) {
bHandled = CView::HandleMessage(pMessage);
}
return bHandled;
}
| 2,184
|
C++
|
.cpp
| 60
| 30.866667
| 263
| 0.697543
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,817
|
wg_textbox.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_textbox.cpp
|
// wg_textbox.cpp
//
// CTextBox class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_textbox.h"
#include "wg_message_server.h"
#include "wg_application.h"
#include "wg_view.h"
#include "wg_error.h"
#include "std_ex.h"
#include <string>
namespace wGui
{
CTextBox::CTextBox(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine) :
CWindow(WindowRect, pParent),
m_SelStart(0),
m_SelLength(0),
m_DragStart(0),
m_bReadOnly(false),
m_bMouseDown(false),
m_bLastMouseMoveInside(false),
m_pVerticalScrollBar(nullptr),
m_pHorizontalScrollBar(nullptr),
m_iLineCount(0),
m_iRowHeight(0),
m_iMaxWidth(0),
m_bDrawCursor(true),
m_bScrollToCursor(false)
{
m_BackgroundColor = COLOR_WHITE;
m_ClientRect = CRect(3, 3, m_WindowRect.Width() - 17, m_WindowRect.Height() - 17);
if (pFontEngine)
{
m_pFontEngine = pFontEngine;
}
else
{
m_pFontEngine = Application().GetDefaultFontEngine();
}
m_pDblClickTimer = new CTimer(pParent->Application());
m_pCursorTimer = new CTimer(pParent->Application(), this);
m_ClientRect.Grow(-3);
m_pVerticalScrollBar = new CScrollBar(
CRect(m_WindowRect.Width() - 12, 1, m_WindowRect.Width(), m_WindowRect.Height() - 12) - m_ClientRect.TopLeft(), this, CScrollBar::VERTICAL);
m_pHorizontalScrollBar = new CScrollBar(
CRect(1, m_WindowRect.Height() - 12, m_WindowRect.Width() - 12, m_WindowRect.Height()) - m_ClientRect.TopLeft(), this, CScrollBar::HORIZONTAL);
m_ScrollBarVisibilityMap[CScrollBar::VERTICAL] = SCROLLBAR_VIS_AUTO;
m_ScrollBarVisibilityMap[CScrollBar::HORIZONTAL] = SCROLLBAR_VIS_AUTO;
PrepareWindowText("");
Application().MessageServer()->RegisterMessageClient(this, CMessage::KEYBOARD_KEYDOWN);
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_BUTTONUP);
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_MOVE);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_VALUECHANGE);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_VALUECHANGING);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_DOUBLELCLICK);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_TIMER);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_GAININGKEYFOCUS);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_LOSINGKEYFOCUS);
Application().MessageServer()->RegisterMessageClient(this, CMessage::TEXTINPUT);
Draw();
}
CTextBox::~CTextBox() // virtual
{
for(const auto *str : m_vpRenderedString)
delete str;
m_vpRenderedString.clear();
delete m_pCursorTimer;
delete m_pDblClickTimer;
}
void CTextBox::SetReadOnly(bool bReadOnly) // virtual
{
m_BackgroundColor = bReadOnly ? COLOR_LIGHTGRAY : COLOR_WHITE;
m_bReadOnly = bReadOnly;
Draw();
}
std::string CTextBox::GetSelText() const // virtual
{
std::string sSelText;
if (m_SelLength != 0)
{
std::string::size_type SelStartNorm = 0;
std::string::size_type SelLenNorm = abs(m_SelLength);
if (m_SelLength < 0)
{
SelStartNorm = m_SelStart + m_SelLength;
}
else
{
SelStartNorm = m_SelStart;
}
sSelText = m_sWindowText.substr(SelStartNorm, SelLenNorm);
}
return sSelText;
}
void CTextBox::SetSelection(std::string::size_type iSelStart, int iSelLength) // virtual
{
if (iSelStart < m_sWindowText.length())
{
m_SelStart = iSelStart;
if (iSelStart + iSelLength <= m_sWindowText.length())
m_SelLength = iSelLength;
else
m_SelLength = stdex::safe_static_cast<int>(m_sWindowText.length() - iSelStart);
}
else
{
m_SelStart = 0;
m_SelLength = 0;
}
}
void CTextBox::SetScrollBarVisibility(CScrollBar::EScrollBarType ScrollBarType, EScrollBarVisibility Visibility) // virtual
{
m_ScrollBarVisibilityMap[ScrollBarType] = Visibility;
UpdateScrollBars();
}
void CTextBox::Draw() const
{
CWindow::Draw();
if (m_pSDLSurface)
{
CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
Painter.DrawRect(m_WindowRect.SizeRect(), false, COLOR_BLACK);
CPoint FontCenterPoint = m_WindowRect.Center();
CRGBColor FontColor = m_bReadOnly ? DEFAULT_DISABLED_LINE_COLOR : DEFAULT_LINE_COLOR;
if (Application().GetKeyFocus() == dynamic_cast<const CWindow*>(this) && !m_bReadOnly)
{
// first normalize the selection
std::string::size_type SelStartNorm = 0;
std::string::size_type SelLenNorm = abs(m_SelLength);
if (m_SelLength < 0)
{
SelStartNorm = m_SelStart + m_SelLength;
}
else
{
SelStartNorm = m_SelStart;
}
CPoint SelStartPoint(RowColFromIndex(SelStartNorm));
CPoint SelEndPoint(RowColFromIndex(SelStartNorm + SelLenNorm));
// now get the dimensions for each character
std::vector<CPoint> vOffsets;
std::vector<CPoint> vBoundingDimensions;
std::vector<std::vector<CRect> > vCharRects;
int iIndex = 0;
for(const auto *str : m_vpRenderedString)
{
CPoint BoundingDimensions;
CPoint Offset;
std::vector<CRect> CharRects;
str->GetMetrics(&BoundingDimensions, &Offset, &CharRects);
vBoundingDimensions.push_back(BoundingDimensions);
vOffsets.push_back(Offset);
vCharRects.push_back(CharRects);
++iIndex;
}
// move the cursor into view by scrolling if necessary
int CursorPos = vCharRects.at(SelStartPoint.YPos()).at(SelStartPoint.XPos()).Left() +
vOffsets.at(SelStartPoint.YPos()).XPos() + m_ClientRect.Left() - m_pHorizontalScrollBar->GetValue() * 10;
if (m_bScrollToCursor)
{
if (CursorPos < m_ClientRect.Left())
{
m_pHorizontalScrollBar->SetValue(m_pHorizontalScrollBar->GetValue() - (m_ClientRect.Left() - CursorPos) / 10 - 1);
CursorPos = vCharRects.at(SelStartPoint.YPos()).at(SelStartPoint.XPos()).Left() +
vOffsets.at(SelStartPoint.YPos()).XPos() + m_ClientRect.Left() - m_pHorizontalScrollBar->GetValue() * 10;
}
if (CursorPos > m_ClientRect.Right())
{
m_pHorizontalScrollBar->SetValue(m_pHorizontalScrollBar->GetValue() + (CursorPos - m_ClientRect.Right()) / 10 + 1);
CursorPos = vCharRects.at(SelStartPoint.YPos()).at(SelStartPoint.XPos()).Left() +
vOffsets.at(SelStartPoint.YPos()).XPos() + m_ClientRect.Left() - m_pHorizontalScrollBar->GetValue() * 10;
}
if (SelStartPoint.YPos() < m_pVerticalScrollBar->GetValue())
{
m_pVerticalScrollBar->SetValue(SelStartPoint.YPos());
}
if (SelStartPoint.YPos() > stdex::safe_static_cast<int>(m_pVerticalScrollBar->GetValue() + m_ClientRect.Height() / m_iRowHeight))
{
m_pVerticalScrollBar->SetValue(SelStartPoint.YPos() - m_ClientRect.Height() / m_iRowHeight);
}
m_bScrollToCursor = false;
}
// draw the selection
if (m_SelLength != 0 && SelEndPoint.YPos() >= m_pVerticalScrollBar->GetValue())
{
for (int CurLine = SelStartPoint.YPos(); CurLine <= SelEndPoint.YPos(); ++CurLine)
{
CPoint TopLeft = m_ClientRect.TopLeft() + CPoint(0, m_iRowHeight * (CurLine - m_pVerticalScrollBar->GetValue()));
CRect SelRect(TopLeft, TopLeft + CPoint(vBoundingDimensions.at(CurLine).XPos(), m_iRowHeight - 2));
if (CurLine == SelStartPoint.YPos())
{
SelRect.SetLeft(vCharRects.at(CurLine).at(SelStartPoint.XPos()).Left() +
vOffsets.at(CurLine).XPos() + m_ClientRect.Left() - m_pHorizontalScrollBar->GetValue() * 10);
}
if (CurLine == SelEndPoint.YPos())
{
SelRect.SetRight(vCharRects.at(CurLine).at(SelEndPoint.XPos() - 1).Right() +
vOffsets.at(CurLine).XPos() + m_ClientRect.Left() - m_pHorizontalScrollBar->GetValue() * 10);
}
SelRect.ClipTo(m_ClientRect);
Painter.DrawRect(SelRect, true, Application().GetDefaultSelectionColor(), Application().GetDefaultSelectionColor());
}
}
// draw the cursor
if (m_SelLength == 0 && SelStartPoint.YPos() >= m_pVerticalScrollBar->GetValue() && m_bDrawCursor)
{
if (CursorPos >= m_ClientRect.Left() && CursorPos <= m_ClientRect.Right())
{
Painter.DrawVLine(m_ClientRect.Top() + m_iRowHeight * (SelStartPoint.YPos() - m_pVerticalScrollBar->GetValue()) - 1,
m_ClientRect.Top() + m_iRowHeight * (SelStartPoint.YPos() - m_pVerticalScrollBar->GetValue() + 1) - 1, CursorPos, COLOR_BLACK);
}
}
}
// finally, draw the text
CPoint LineOrigin = m_ClientRect.TopLeft() - CPoint(m_pHorizontalScrollBar->GetValue() * 10, 0);
for(auto iter = m_vpRenderedString.begin() + m_pVerticalScrollBar->GetValue();
iter != m_vpRenderedString.end() && LineOrigin.YPos() < m_ClientRect.Bottom(); ++iter) {
(*iter)->Draw(m_pSDLSurface, m_ClientRect, LineOrigin, FontColor);
LineOrigin.SetY(LineOrigin.YPos() + m_iRowHeight);
}
}
}
void CTextBox::SetWindowText(const std::string& sText) // virtual
{
m_SelStart = 0;
m_SelLength = 0;
PrepareWindowText(sText);
CWindow::SetWindowText(sText);
}
void CTextBox::SetWindowRect(const CRect& WindowRect)
{
CWindow::SetWindowRect(WindowRect);
m_ClientRect = m_WindowRect.SizeRect();
m_ClientRect.Grow(-3);
UpdateScrollBars();
}
bool CTextBox::OnMouseButtonDown(CPoint Point, unsigned int Button) // virtual
{
bool bResult = CWindow::OnMouseButtonDown(Point, Button);
CPoint WindowPoint(ViewToWindow(Point));
if (!bResult && m_bVisible && (m_ClientRect.HitTest(WindowPoint) == CRect::RELPOS_INSIDE))
{
if (Button == CMouseMessage::LEFT && !m_bReadOnly)
{
bool fSkipCursorPositioning = false;
// If we haven't initialized the double click timer, do so.
if (!m_pDblClickTimer->IsRunning())
{
m_pDblClickTimer->StartTimer(500, false);
}
else
{
// Raise double click event
Application().MessageServer()->QueueMessage(new TIntMessage(CMessage::CTRL_DOUBLELCLICK, this, this, 0));
fSkipCursorPositioning = true;
}
if (Application().GetKeyFocus() != this)
{
Application().SetKeyFocus(this);
}
if (!fSkipCursorPositioning)
{
// set the cursor
std::vector<CPoint> vOffsets;
std::vector<std::vector<CRect> > vCharRects;
int iIndex = 0;
// get the dimensions of all the characters
for(const auto *str : m_vpRenderedString)
{
CPoint Offset;
std::vector<CRect> CharRects;
str->GetMetrics(nullptr, &Offset, &CharRects);
vOffsets.push_back(Offset);
vCharRects.push_back(CharRects);
++iIndex;
}
// figure out which line was clicked on
unsigned int iCurLine = (WindowPoint.YPos() - m_ClientRect.Top()) / m_iRowHeight + m_pVerticalScrollBar->GetValue();
if (iCurLine >= m_iLineCount)
{
iCurLine = m_iLineCount - 1;
}
// figure out which character was clicked on
int xDelta = abs(WindowPoint.XPos() - (vCharRects.at(iCurLine).at(0).Left() + vOffsets.at(iCurLine).XPos() + m_ClientRect.Left()));
m_SelStart = 0;
for (unsigned int i = 0; i < vCharRects.at(iCurLine).size(); ++i)
{
if (abs(WindowPoint.XPos() - (vCharRects.at(iCurLine).at(i).Right() + vOffsets.at(iCurLine).XPos()
+ m_ClientRect.Left() - m_pHorizontalScrollBar->GetValue() * 10)) < xDelta)
{
xDelta = abs(WindowPoint.XPos() - (vCharRects.at(iCurLine).at(i).Right() + vOffsets.at(iCurLine).XPos()
+ m_ClientRect.Left() - m_pHorizontalScrollBar->GetValue() * 10));
m_SelStart = i + 1;
}
}
for (unsigned int iChar = 0; iChar < iCurLine; ++iChar)
{
m_SelStart += vCharRects.at(iChar).size();
}
}
m_DragStart = m_SelStart;
m_SelLength = 0;
m_bMouseDown = true;
Draw();
bResult = true;
}
if (Button == CMouseMessage::WHEELUP)
{
m_pVerticalScrollBar->SetValue(m_pVerticalScrollBar->GetValue() - 1);
bResult = true;
}
else if (Button == CMouseMessage::WHEELDOWN)
{
m_pVerticalScrollBar->SetValue(m_pVerticalScrollBar->GetValue() + 1);
bResult = true;
}
}
return bResult;
}
bool CTextBox::HandleMessage(CMessage* pMessage) // virtual
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::CTRL_DOUBLELCLICK:
if (pMessage->Destination() == this)
{
m_SelStart = 0;
m_SelLength = stdex::safe_static_cast<int>(m_sWindowText.length());
Draw();
bHandled = true;
}
break;
case CMessage::MOUSE_BUTTONUP:
m_bMouseDown = false;
break;
case CMessage::MOUSE_MOVE:
{
CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);
if (pMouseMessage && m_bVisible && !m_bReadOnly)
{
CPoint WindowPoint(ViewToWindow(pMouseMessage->Point));
//If the cursor is within the control then check to see if we've already
// set the cursor to the I Beam, if we have, don't do anything. If we
// havent, set it to the ibeam.
//Else if it's outside the control and the I Beam cursor is set, set it
// back to a normal cursor.
CView* pView = GetView();
bool bHitFloating = pView && pView->GetFloatingWindow() && pView->GetFloatingWindow()->HitTest(pMouseMessage->Point);
if (m_ClientRect.HitTest(WindowPoint) == CRect::RELPOS_INSIDE && !bHitFloating && !m_bLastMouseMoveInside)
{
m_bLastMouseMoveInside = true;
CwgCursorResourceHandle IBeamHandle(Application(), WGRES_IBEAM_CURSOR);
Application().SetMouseCursor(&IBeamHandle);
}
else if ((m_ClientRect.HitTest(WindowPoint) != CRect::RELPOS_INSIDE || bHitFloating) && m_bLastMouseMoveInside)
{
m_bLastMouseMoveInside= false;
Application().SetMouseCursor();
}
if (m_bMouseDown)
{
// get the dimensions for all the characters
std::vector<CPoint> vOffsets;
std::vector<std::vector<CRect> > vCharRects;
int iIndex = 0;
for(const auto *str : m_vpRenderedString)
{
CPoint Offset;
std::vector<CRect> CharRects;
str->GetMetrics(nullptr, &Offset, &CharRects);
vOffsets.push_back(Offset);
vCharRects.push_back(CharRects);
++iIndex;
}
// figure out which line was clicked on
unsigned int iCurLine = 0;
if (m_ClientRect.HitTest(WindowPoint) == CRect::RELPOS_INSIDE)
{
iCurLine = (WindowPoint.YPos() - m_ClientRect.Top()) / m_iRowHeight + m_pVerticalScrollBar->GetValue();
if (iCurLine >= m_iLineCount)
{
iCurLine = m_iLineCount - 1;
}
}
else if (m_ClientRect.HitTest(WindowPoint) == CRect::RELPOS_BELOW)
{
iCurLine = m_iLineCount - 1;
}
// figure out which character was clicked on
int xDelta = abs(WindowPoint.XPos() - (vCharRects.at(iCurLine).at(0).Left() + vOffsets.at(iCurLine).XPos() + m_ClientRect.Left()));
std::string::size_type CursorPos = 0;
for (unsigned int i = 0; i < vCharRects.at(iCurLine).size(); ++i)
{
if (abs(WindowPoint.XPos() - (vCharRects.at(iCurLine).at(i).Right() + vOffsets.at(iCurLine).XPos()
+ m_ClientRect.Left() - m_pHorizontalScrollBar->GetValue() * 10)) < xDelta)
{
xDelta = abs(WindowPoint.XPos() - (vCharRects.at(iCurLine).at(i).Right() + vOffsets.at(iCurLine).XPos()
+ m_ClientRect.Left() - m_pHorizontalScrollBar->GetValue() * 10));
CursorPos = i + 1;
}
}
for (unsigned int iChar = 0; iChar < iCurLine; ++iChar)
{
CursorPos += vCharRects.at(iChar).size();
}
// set the highlighting
if (CursorPos < m_DragStart)
{
m_SelLength = stdex::safe_static_cast<int>(m_DragStart) - stdex::safe_static_cast<int>(CursorPos);
m_SelStart = CursorPos;
}
else
{
m_SelStart = m_DragStart;
m_SelLength = stdex::safe_static_cast<int>(CursorPos) - stdex::safe_static_cast<int>(m_SelStart);
}
bHandled = true;
Draw();
}
}
break;
}
case CMessage::CTRL_TIMER:
if (pMessage->Destination() == this && pMessage->Source() == m_pCursorTimer)
{
//This redraws the whole control each time we want to show/not show the cursor, that's probably a bad idea.
m_bDrawCursor = !m_bDrawCursor;
Draw();
bHandled = true;
}
break;
case CMessage::CTRL_GAININGKEYFOCUS:
if (pMessage->Destination() == this && !m_bReadOnly)
{
m_pCursorTimer->StartTimer(750, true);
m_bDrawCursor = true;
Draw();
bHandled = true;
SDL_StartTextInput();
}
break;
case CMessage::CTRL_LOSINGKEYFOCUS:
if (pMessage->Destination() == this)
{
m_pCursorTimer->StopTimer();
Draw();
bHandled = true;
SDL_StopTextInput();
}
break;
case CMessage::TEXTINPUT:
if (pMessage->Destination() == this)
{
CTextInputMessage* pTextInputMessage = dynamic_cast<CTextInputMessage*>(pMessage);
if (pTextInputMessage && !m_bReadOnly)
{
std::string sBuffer = m_sWindowText;
sBuffer.insert(m_SelStart, pTextInputMessage->Text);
m_SelStart += pTextInputMessage->Text.length();
if (m_sWindowText != sBuffer)
{
Application().MessageServer()->QueueMessage(new TStringMessage(CMessage::CTRL_VALUECHANGE, m_pParentWindow, this, sBuffer));
m_sWindowText = sBuffer;
PrepareWindowText(sBuffer);
}
m_bDrawCursor = true;
m_bScrollToCursor = true; // a key was pressed, so we need to make sure that the cursor is visible
Draw();
}
}
break;
case CMessage::KEYBOARD_KEYDOWN:
if (m_bVisible)
{
CKeyboardMessage* pKeyboardMessage = dynamic_cast<CKeyboardMessage*>(pMessage);
if (pKeyboardMessage && pMessage->Destination() == this && !m_bReadOnly)
{
std::string sBuffer = m_sWindowText;
switch(pKeyboardMessage->Key)
{
case SDLK_BACKSPACE:
if (m_SelLength != 0)
{
SelDelete(&sBuffer);
}
else
{
if (m_SelStart > 0)
{
sBuffer.erase(--m_SelStart, 1);
}
}
break;
case SDLK_DELETE:
if (m_SelStart < sBuffer.length())
{
if (m_SelLength != 0)
{
SelDelete(&sBuffer);
}
else
{
sBuffer.erase(m_SelStart, 1);
}
}
break;
case SDLK_LEFT:
if (pKeyboardMessage->Modifiers & KMOD_SHIFT) //Shift modifier
{
if (m_SelStart > 0)
{
if ((m_SelLength > 0) || ((m_SelStart - abs(m_SelLength)) > 0))
{
if (pKeyboardMessage->Modifiers & KMOD_CTRL)
{
std::string::size_type pos = sBuffer.rfind(' ', (m_SelStart + m_SelLength) - 1);
if (pos != std::string::npos)
{
m_SelLength = stdex::safe_static_cast<int>(pos) - stdex::safe_static_cast<int>(m_SelStart);
}
else
{
m_SelLength = stdex::safe_static_cast<int>(m_SelStart) * -1;
}
}
else
{
m_SelLength--;
}
}
}
}
else if (m_SelLength != 0)
{
if (m_SelLength < 0)
{
m_SelStart = m_SelStart + m_SelLength;
}
m_SelLength = 0;
}
else if (m_SelStart > 0)
{
if (pKeyboardMessage->Modifiers & KMOD_CTRL)
{
std::string::size_type pos = sBuffer.rfind(' ', m_SelStart - 1);
if (pos != std::string::npos)
{
m_SelStart = pos;
}
else
{
m_SelStart = 0;
}
}
else
{
--m_SelStart;
}
m_SelLength = 0;
}
break;
case SDLK_RIGHT:
if (m_SelStart <= sBuffer.length())
{
if (pKeyboardMessage->Modifiers & KMOD_SHIFT)
{
if (pKeyboardMessage->Modifiers & KMOD_CTRL)
{
std::string::size_type pos = sBuffer.find(' ', m_SelStart + m_SelLength);
if (pos != std::string::npos)
{
m_SelLength = stdex::safe_static_cast<int>(pos) - stdex::safe_static_cast<int>(m_SelStart) + 1;
}
else
{
m_SelLength = stdex::safe_static_cast<int>(sBuffer.length()) - stdex::safe_static_cast<int>(m_SelStart);
}
}
else if (m_SelStart + m_SelLength < sBuffer.length())
{
m_SelLength++; //Selecting, one character at a time, increase the selection length by one.
}
}
else if(m_SelLength == 0 && m_SelStart < sBuffer.length())
{
//With the ctrl modifier used, we look for the next instance of a space.
// If we find one, we set the cursor position to that location.
// If we can't find one, we set the cursor position to the end of the string.
// If we don't have the ctrl modifier, then we just incriment the cursor position by one character
if (pKeyboardMessage->Modifiers & KMOD_CTRL)
{
std::string::size_type pos = sBuffer.find(' ', m_SelStart + 1);
if (pos != std::string::npos)
{
m_SelStart = pos + 1;
}
else
{
m_SelStart = sBuffer.length();
}
}
else
{
++m_SelStart; //We don't have anything selected, so we'll just incriment the start position
}
}
else
{
if (m_SelLength > 0)
{
m_SelStart = m_SelStart + m_SelLength; //Reset cursor position to the end of the selection
}
m_SelLength = 0; //Set selection length to zero
}
}
break;
case SDLK_DOWN:
if (m_SelStart <= sBuffer.length())
{
if (pKeyboardMessage->Modifiers & KMOD_SHIFT)
{
CPoint CursorPoint(RowColFromIndex(m_SelStart + m_SelLength));
if (CursorPoint.YPos() == stdex::safe_static_cast<int>(m_iLineCount - 1))
{
m_SelLength = stdex::safe_static_cast<int>(m_sWindowText.size() - m_SelStart);
}
else
{
m_SelLength = stdex::safe_static_cast<int>(IndexFromRowCol(CursorPoint.YPos() + 1, CursorPoint.XPos()))
- stdex::safe_static_cast<int>(m_SelStart);
}
}
else if(m_SelLength == 0)
{
CPoint CursorPoint(RowColFromIndex(m_SelStart));
if (CursorPoint.YPos() == stdex::safe_static_cast<int>(m_iLineCount - 1))
{
m_SelStart = m_sWindowText.size();
}
else
{
m_SelStart = IndexFromRowCol(CursorPoint.YPos() + 1, CursorPoint.XPos());
}
}
else
{
if (m_SelLength > 0)
{
m_SelStart = m_SelStart + m_SelLength;
}
m_SelLength = 0;
}
}
break;
case SDLK_UP:
if (m_SelStart <= sBuffer.length())
{
if (pKeyboardMessage->Modifiers & KMOD_SHIFT)
{
CPoint CursorPoint(RowColFromIndex(m_SelStart + m_SelLength));
if (CursorPoint.YPos() == 0)
{
m_SelLength = -stdex::safe_static_cast<int>(m_SelStart);
}
else
{
m_SelLength = stdex::safe_static_cast<int>(IndexFromRowCol(CursorPoint.YPos() - 1, CursorPoint.XPos()))
- stdex::safe_static_cast<int>(m_SelStart);
}
}
else if(m_SelLength == 0 )
{
CPoint CursorPoint(RowColFromIndex(m_SelStart));
if (CursorPoint.YPos() == 0)
{
m_SelStart = 0;
}
else
{
m_SelStart = IndexFromRowCol(CursorPoint.YPos() - 1, CursorPoint.XPos());
}
}
else
{
if (m_SelLength < 0)
{
m_SelStart = m_SelStart + m_SelLength;
}
m_SelLength = 0;
}
}
break;
case SDLK_END:
if (pKeyboardMessage->Modifiers & KMOD_SHIFT)
{
m_SelLength = stdex::safe_static_cast<int>(sBuffer.length()) - stdex::safe_static_cast<int>(m_SelStart);
}
else
{
m_SelLength = 0;
m_SelStart = sBuffer.length();
}
break;
case SDLK_HOME:
if (pKeyboardMessage->Modifiers & KMOD_SHIFT)
{
m_SelLength = stdex::safe_static_cast<int>(m_SelStart);
m_SelStart = 0;
}
else
{
m_SelLength = 0;
m_SelStart = 0;
}
break;
case SDLK_RETURN:
SelDelete(&sBuffer);
sBuffer.insert(m_SelStart++, 1, '\n');
break;
default:
break;
}
if (m_sWindowText != sBuffer)
{
Application().MessageServer()->QueueMessage(new TStringMessage(CMessage::CTRL_VALUECHANGE, m_pParentWindow, this, sBuffer));
m_sWindowText = sBuffer;
PrepareWindowText(sBuffer);
}
m_bDrawCursor = true;
m_bScrollToCursor = true; // a key was pressed, so we need to make sure that the cursor is visible
Draw();
}
}
break;
case CMessage::CTRL_VALUECHANGE:
case CMessage::CTRL_VALUECHANGING:
{
if (pMessage->Source() == m_pVerticalScrollBar || pMessage->Source() == m_pHorizontalScrollBar)
{
Draw();
bHandled = true;
}
break;
}
default :
bHandled = CWindow::HandleMessage(pMessage);
break;
}
}
return bHandled;
}
void CTextBox::SelDelete(std::string* psString)
{
//This means we've selected something, therefore, should replace it
if (m_SelLength != 0)
{
std::string::size_type SelStartNorm = 0;
std::string::size_type SelLenNorm = abs(m_SelLength);
if (m_SelLength < 0)
{
SelStartNorm = m_SelStart + m_SelLength;
}
else
{
SelStartNorm = m_SelStart;
}
psString->erase(SelStartNorm, SelLenNorm);
//Since we're deleting the stuff here and setting the selection length to zero, we also need to set the selection start properly
m_SelStart = SelStartNorm;
m_SelLength = 0;
}
}
void CTextBox::PrepareWindowText(const std::string& sText)
{
for(const auto *str : m_vpRenderedString)
delete str;
m_vpRenderedString.clear();
m_iLineCount = 0;
std::string::size_type start = 0;
std::string::size_type loc = 0;
m_iMaxWidth = 0;
while (loc != std::string::npos)
{
loc = sText.find('\n', start);
m_vpRenderedString.push_back(new CRenderedString(
m_pFontEngine, sText.substr(start, loc - start), CRenderedString::VALIGN_TOP, CRenderedString::HALIGN_LEFT));
CPoint BoundingDimensions;
m_vpRenderedString.back()->GetMetrics(&BoundingDimensions, nullptr, nullptr);
if (BoundingDimensions.XPos() > stdex::safe_static_cast<int>(m_iMaxWidth))
{
m_iMaxWidth = BoundingDimensions.XPos();
}
start = loc + 1;
++m_iLineCount;
}
m_iRowHeight = m_vpRenderedString.at(0)->GetMaxFontHeight() + 2;
UpdateScrollBars();
}
void CTextBox::UpdateScrollBars()
{
m_ClientRect = CRect(3, 3, m_WindowRect.Width() - 5, m_WindowRect.Height() - 5);
bool bHorzVisible = m_ScrollBarVisibilityMap[CScrollBar::HORIZONTAL] == SCROLLBAR_VIS_ALWAYS ||
(m_ScrollBarVisibilityMap[CScrollBar::HORIZONTAL] == SCROLLBAR_VIS_AUTO && stdex::safe_static_cast<int>(m_iMaxWidth) > (m_ClientRect.Width() - m_pVerticalScrollBar->GetClientRect().Width()));
int iMaxHorzLimit = (stdex::safe_static_cast<int>(m_iMaxWidth) - (m_ClientRect.Width() - m_pVerticalScrollBar->GetClientRect().Width())) / 10 + 1;
if (iMaxHorzLimit < 0)
{
iMaxHorzLimit = 0;
}
m_iVisibleLines = (m_ClientRect.Height() - (bHorzVisible ? 12 : 0)) / m_iRowHeight;
unsigned int iLastLine = std::max(0, static_cast<int>(m_iLineCount) - static_cast<int>(m_iVisibleLines));
bool bVertVisible = m_ScrollBarVisibilityMap[CScrollBar::VERTICAL] == SCROLLBAR_VIS_ALWAYS ||
(m_ScrollBarVisibilityMap[CScrollBar::VERTICAL] == SCROLLBAR_VIS_AUTO && m_iLineCount > (m_ClientRect.Height() - (bHorzVisible ? m_pVerticalScrollBar->GetClientRect().Height() : 0)) / m_iRowHeight);
m_pVerticalScrollBar->SetVisible(bVertVisible);
m_pHorizontalScrollBar->SetVisible(bHorzVisible);
if (bVertVisible)
{
m_ClientRect.SetRight(m_WindowRect.Width() - 17);
}
if (bHorzVisible)
{
m_ClientRect.SetBottom(m_WindowRect.Height() - 17);
}
m_pVerticalScrollBar->SetMaxLimit(iLastLine);
if (m_pVerticalScrollBar->GetValue() > static_cast<int>(iLastLine))
{
m_pVerticalScrollBar->SetValue(iLastLine);
}
m_pVerticalScrollBar->SetWindowRect(CRect(m_ClientRect.Width() + 2, 1 - m_ClientRect.Top(), m_ClientRect.Width() + 14, m_ClientRect.Height()));
m_pHorizontalScrollBar->SetMaxLimit(iMaxHorzLimit);
if (m_pHorizontalScrollBar->GetValue() > iMaxHorzLimit)
{
m_pHorizontalScrollBar->SetValue(iMaxHorzLimit);
}
m_pHorizontalScrollBar->SetWindowRect(CRect(1 - m_ClientRect.Left(), m_ClientRect.Height() + 2, m_ClientRect.Width(), m_ClientRect.Height() + 14));
}
CPoint CTextBox::RowColFromIndex(std::string::size_type Index) const
{
int iRow = 0;
int iCol = stdex::safe_static_cast<int>(Index);
std::string::size_type loc = m_sWindowText.find('\n');
std::string::size_type start = 0;
while (loc != std::string::npos && loc < Index)
{
++iRow;
iCol -= (stdex::safe_static_cast<int>(loc - start) + 1);
start = loc + 1;
loc = m_sWindowText.find('\n', start);
}
return CPoint(iCol, iRow);
}
std::string::size_type CTextBox::IndexFromRowCol(std::string::size_type Row, std::string::size_type Col) const
{
std::string::size_type Index = 0;
for (std::string::size_type iRow = 0; iRow < Row && iRow < m_vpRenderedString.size(); ++iRow)
Index += m_vpRenderedString.at(iRow)->GetLength() + 1;
if (Col > m_vpRenderedString.at(Row)->GetLength())
Col = m_vpRenderedString.at(Row)->GetLength();
return Index + Col;
}
}
| 29,837
|
C++
|
.cpp
| 881
| 28.777526
| 200
| 0.659397
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
753,818
|
wg_resources.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_resources.cpp
|
// wg_resources.cpp
//
// wgui resources
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_resources.h"
#include "wg_error.h"
#include "wg_painter.h"
#include "wg_application.h"
#include <list>
namespace wGui
{
CwgBitmapResourceHandle::CwgBitmapResourceHandle(CApplication& application, EwgResourceId resId) :
CBitmapResourceHandle(resId)
{
if (m_BitmapMap.find(m_ResourceId) == m_BitmapMap.end())
{
const CRGBColor T = COLOR_TRANSPARENT;
const CRGBColor B = DEFAULT_CHECKBOX_COLOR;
//const CRGBColor W = COLOR_WHITE;
switch (m_ResourceId)
{
case NULL_RESOURCE_ID:
m_BitmapMap[NULL_RESOURCE_ID] = nullptr;
break;
case WGRES_UP_ARROW_BITMAP:
{
CRGBColor buf[] = {T, T, T, T, T, T, T, T,
T, T, T, T, T, T, T, T,
T, T, T, T, T, T, T, T,
T, T, T, B, B, T, T, T,
T, T, B, B, B, B, T, T,
T, B, B, T, T, B, B, T,
T, T, T, T, T, T, T, T,
T, T, T, T, T, T, T, T};
m_BitmapMap[m_ResourceId] = DrawBitmap(buf, sizeof(buf) / sizeof(CRGBColor), 8, 8);
break;
}
case WGRES_DOWN_ARROW_BITMAP:
{
CRGBColor buf[] = {T, T, T, T, T, T, T, T,
T, T, T, T, T, T, T, T,
T, B, B, T, T, B, B, T,
T, T, B, B, B, B, T, T,
T, T, T, B, B, T, T, T,
T, T, T, T, T, T, T, T,
T, T, T, T, T, T, T, T,
T, T, T, T, T, T, T, T};
m_BitmapMap[m_ResourceId] = DrawBitmap(buf, sizeof(buf) / sizeof(CRGBColor), 8, 8);
break;
}
case WGRES_LEFT_ARROW_BITMAP:
{
CRGBColor buf[] = {T, T, T, T, T, T, T, T,
T, T, T, T, T, B, T, T,
T, T, T, T, B, B, T, T,
T, T, T, B, B, T, T, T,
T, T, T, B, B, T, T, T,
T, T, T, T, B, B, T, T,
T, T, T, T, T, B, T, T,
T, T, T, T, T, T, T, T};
m_BitmapMap[m_ResourceId] = DrawBitmap(buf, sizeof(buf) / sizeof(CRGBColor), 8, 8);
break;
}
case WGRES_RIGHT_ARROW_BITMAP:
{
CRGBColor buf[] = {T, T, T, T, T, T, T, T,
T, T, B, T, T, T, T, T,
T, T, B, B, T, T, T, T,
T, T, T, B, B, T, T, T,
T, T, T, B, B, T, T, T,
T, T, B, B, T, T, T, T,
T, T, B, T, T, T, T, T,
T, T, T, T, T, T, T, T};
m_BitmapMap[m_ResourceId] = DrawBitmap(buf, sizeof(buf) / sizeof(CRGBColor), 8, 8);
break;
}
case WGRES_X_BITMAP:
{
CRGBColor buf[] = { B, B, T, T, B, B,
T, B, B, B, B, T,
T, T, B, B, T, T,
T, T, B, B, T, T,
T, B, B, B, B, T,
B, B, T, T, B, B};
m_BitmapMap[m_ResourceId] = DrawBitmap(buf, sizeof(buf) / sizeof(CRGBColor), 6, 6);
break;
}
case WGRES_RADIOBUTTON_BITMAP:
{
CRGBColor buf[] = {T, T, T, T, T, T,
T, B, B, B, B, T,
T, B, B, B, B, T,
T, B, B, B, B, T,
T, B, B, B, B, T,
T, T, T, T, T, T};
m_BitmapMap[m_ResourceId] = DrawBitmap(buf, sizeof(buf) / sizeof(CRGBColor), 6, 6);
break;
}
case WGRES_CHECK_BITMAP:
{
CRGBColor buf[] = { T, T, T, T, T, T,
T, T, T, T, T, B,
B, T, T, T, B, B,
B, B, T, B, B, T,
T, B, B, B, T, T,
T, T, B, T, T, T};
m_BitmapMap[m_ResourceId] = DrawBitmap(buf, sizeof(buf) / sizeof(CRGBColor), 6, 6);
break;
}
case WGRES_MAXIMIZE_UNMAXED_BITMAP:
{
CRGBColor buf[] = {T, B, B, B, B, B, B, T,
T, B, B, B, B, B, B, T,
T, B, T, T, T, T, B, T,
T, B, T, T, T, T, B, T,
T, B, T, T, T, T, B, T,
T, B, T, T, T, T, B, T,
T, B, B, B, B, B, B, T,
T, T, T, T, T, T, T, T};
m_BitmapMap[m_ResourceId] = DrawBitmap(buf, sizeof(buf) / sizeof(CRGBColor), 8, 8);
break;
}
case WGRES_MAXIMIZE_MAXED_BITMAP:
{
CRGBColor buf[] = {T, T, T, B, B, B, B, B,
T, T, T, B, B, B, B, B,
T, T, T, B, T, T, T, B,
B, B, B, B, B, T, T, B,
B, B, B, B, B, T, T, B,
B, T, T, T, B, B, B, B,
B, T, T, T, B, T, T, T,
B, B, B, B, B, T, T, T};
m_BitmapMap[m_ResourceId] = DrawBitmap(buf, sizeof(buf) / sizeof(CRGBColor), 8, 8);
break;
}
case WGRES_MINIMIZE_BITMAP:
{
CRGBColor buf[] = {T, T, T, T, T, T, T, T,
T, T, T, T, T, T, T, T,
T, T, T, T, T, T, T, T,
T, T, T, T, T, T, T, T,
T, T, T, T, T, T, T, T,
T, B, B, B, B, B, B, T,
T, B, B, B, B, B, B, T,
T, T, T, T, T, T, T, T};
m_BitmapMap[m_ResourceId] = DrawBitmap(buf, sizeof(buf) / sizeof(CRGBColor), 8, 8);
break;
}
case INVALID_RESOURCE_ID:
case AUTO_CREATE_RESOURCE_ID:
default:
throw(Wg_Ex_App("Invalid Resource ID.", "CwgBitmapResourceHandle::AllocateResource"));
break;
}
CResourceHandle TempHandle(m_ResourceId);
application.AddToResourcePool(TempHandle);
}
}
SDL_Surface* CwgBitmapResourceHandle::DrawBitmap(CRGBColor Data[], int iDataLength, int iWidth, int iHeight) const
{
SDL_Surface* pBitmap = SDL_CreateRGBSurface(0, iWidth, iHeight,
DEFAULT_BPP, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
CPainter Painter(pBitmap, CPainter::PAINT_REPLACE);
for (int iRow = 0; iRow < iHeight; ++iRow)
{
for (int iCol = 0; iCol < iWidth; ++iCol)
{
int iIndex = iRow * iWidth + iCol;
if (iIndex < iDataLength)
{
Painter.DrawPoint(CPoint(iCol, iRow), Data[iRow * iWidth + iCol]);
}
}
}
return pBitmap;
}
CwgStringResourceHandle::CwgStringResourceHandle(CApplication& application, EwgResourceId resId) :
CStringResourceHandle(resId)
{
if (m_StringMap.find(m_ResourceId) == m_StringMap.end())
{
switch (m_ResourceId)
{
case NULL_RESOURCE_ID:
m_StringMap[m_ResourceId] = "";
break;
case INVALID_RESOURCE_ID:
case AUTO_CREATE_RESOURCE_ID:
default:
throw(Wg_Ex_App("Invalid Resource ID.", "CwgBitmapResourceHandle::AllocateResource"));
break;
}
CResourceHandle TempHandle(m_ResourceId);
application.AddToResourcePool(TempHandle);
}
}
CwgCursorResourceHandle::CwgCursorResourceHandle(CApplication& application, EwgResourceId resId) :
CCursorResourceHandle(resId)
{
if (m_SDLCursorMap.find(m_ResourceId) == m_SDLCursorMap.end())
{
switch (m_ResourceId)
{
case NULL_RESOURCE_ID:
m_SDLCursorMap[m_ResourceId] = nullptr;
break;
case WGRES_POINTER_CURSOR:
{
char buf[] = {X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,M,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,M,M,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,M,M,M,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,M,M,M,M,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,M,M,M,M,M,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,M,M,M,M,M,M,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,M,M,M,M,M,X,X,X,X,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,M,M,X,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,M,X,O,X,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,X,O,O,X,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,O,O,O,O,X,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,X,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,X,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,X,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,X,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O};
m_SDLCursorMap[m_ResourceId] = CreateCursor(buf, sizeof(buf) / sizeof(char), 32, 32, 0, 0);
break;
}
case WGRES_IBEAM_CURSOR:
{
char buf[] = {D,D,D,O,D,D,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
D,D,D,O,D,D,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O};
m_SDLCursorMap[m_ResourceId] = CreateCursor(buf, sizeof(buf) / sizeof(char), 32, 32, 3, 8);
break;
}
case WGRES_WAIT_CURSOR:
{
char buf[] = {X,X,X,X,X,X,X,X,X,X,X,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,M,M,M,M,M,M,M,M,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,M,M,M,M,M,M,M,M,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,M,M,M,M,M,M,M,M,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,X,X,M,X,M,X,M,X,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,X,X,M,X,M,X,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,X,X,M,X,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,X,X,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,X,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,X,M,X,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,X,M,M,M,X,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,X,M,M,M,X,M,M,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,M,M,M,M,M,M,M,M,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,M,M,M,M,X,M,X,M,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,M,X,M,X,M,X,M,X,M,M,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
X,X,X,X,X,X,X,X,X,X,X,X,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O};
m_SDLCursorMap[m_ResourceId] = CreateCursor(buf, sizeof(buf) / sizeof(char), 32, 32, 0, 0);
break;
}
case WGRES_MOVE_CURSOR:
{
char buf[] = {
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,D,D,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,D,D,D,D,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,D,O,O,O,O,D,O,O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,D,O,O,O,O,D,O,O,O,O,D,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,D,D,D,D,D,D,D,D,D,D,D,D,D,D,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,D,O,O,O,O,D,O,O,O,O,D,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,D,O,O,O,O,D,O,O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,D,O,O,O,O,O,O,O,O,X,X,X,X,X,X,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,D,O,O,O,O,O,O,O,O,X,M,M,M,M,X,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,D,D,D,D,D,O,O,O,O,O,O,X,M,M,M,X,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,D,D,D,O,O,O,O,O,O,O,X,M,M,M,M,X,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,D,O,O,O,O,O,O,O,O,X,M,X,M,M,M,X,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,X,X,O,X,M,M,X,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,X,X,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O};
m_SDLCursorMap[m_ResourceId] = CreateCursor(buf, sizeof(buf) / sizeof(char), 32, 32, 9, 9);
break;
}
case WGRES_ZOOM_CURSOR:
{
char buf[] = {
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,D,D,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,D,O,O,O,D,O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,D,D,O,O,O,D,O,O,O,D,D,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,D,D,D,D,D,D,D,D,D,D,D,D,D,D,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,D,D,O,O,O,O,D,O,O,O,O,D,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,D,O,O,O,O,D,O,O,O,O,D,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,D,O,O,O,O,O,O,O,O,X,X,X,X,X,X,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,D,D,D,D,D,D,D,O,O,O,O,O,X,M,M,M,M,X,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,D,D,D,D,D,O,O,O,O,O,O,X,M,M,M,X,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,D,D,D,O,O,O,O,O,O,O,X,M,M,M,M,X,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,D,O,O,O,O,O,O,O,O,X,M,X,M,M,M,X,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,X,X,O,X,M,M,X,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,X,X,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,
O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O};
m_SDLCursorMap[m_ResourceId] = CreateCursor(buf, sizeof(buf) / sizeof(char), 32, 32, 9, 9);
break;
}
case INVALID_RESOURCE_ID:
case AUTO_CREATE_RESOURCE_ID:
default:
throw(Wg_Ex_App("Invalid Resource ID.", "CwgBitmapResourceHandle::AllocateResource"));
break;
}
CResourceHandle TempHandle(m_ResourceId);
application.AddToResourcePool(TempHandle);
}
}
SDL_Cursor* CwgCursorResourceHandle::CreateCursor(const char DataIn[], int iDataLength, int iWidth, int iHeight, int iXHotSpot, int iYHotSpot) const
{
if (iWidth % 8)
{
throw(Wg_Ex_App("Cursors must be multiples of 8 bits wide.", "CwgCursorResourceHandle::CreateCursor"));
}
int iDataSize = iWidth * iHeight / 8;
auto pData = new Uint8[iDataSize];
auto pMask = new Uint8[iDataSize];
int i = -1;
for (int iRow = 0; iRow < iHeight; ++iRow)
{
for (int iCol = 0; iCol < iWidth; ++iCol)
{
int iIndex = iCol + iRow * iWidth;
if (iIndex < iDataLength)
{
if (iCol % 8)
{
pData[i] <<= 1;
pMask[i] <<= 1;
}
else
{
++i;
pData[i] = 0;
pMask[i] = 0;
}
switch (DataIn[iIndex])
{
case X:
pData[i] |= 0x01;
pMask[i] |= 0x01;
break;
case D:
pData[i] |= 0x01;
break;
case M:
pMask[i] |= 0x01;
break;
case O:
break;
}
}
}
}
return SDL_CreateCursor(pData, pMask, iWidth, iHeight, iXHotSpot, iYHotSpot);
}
}
| 20,669
|
C++
|
.cpp
| 470
| 38.051064
| 148
| 0.506567
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,819
|
CapriceOptions.cpp
|
ColinPitrat_caprice32/src/gui/src/CapriceOptions.cpp
|
// 'Options' window for Caprice32
// Inherited from CFrame
#include <map>
#include <string>
#include "log.h"
#include "std_ex.h"
#include "CapriceOptions.h"
#include "cap32.h"
#include "keyboard.h"
#include "fileutils.h"
#include "wg_messagebox.h"
// CPC emulation properties, defined in cap32.h:
extern t_CPC CPC;
std::vector<std::string> mapFileList;
namespace wGui {
CapriceOptions::CapriceOptions(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine) :
CFrame(WindowRect, pParent, pFontEngine, "Options", false)
{
SetModal(true);
// Make this window listen to incoming CTRL_VALUECHANGE messages (used for updating scrollbar values)
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_VALUECHANGE);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_VALUECHANGING);
// remember the current CPC configuration.
m_oldCPCsettings = CPC;
// Navigation bar
m_pNavigationBar = new CNavigationBar(this, CPoint(10, 5), 6, 50, 50);
m_pNavigationBar->AddItem(SNavBarItem("General", CPC.resources_path + "/general.bmp"));
m_pNavigationBar->AddItem(SNavBarItem("ROMs", CPC.resources_path + "/rom.bmp"));
m_pNavigationBar->AddItem(SNavBarItem("Video", CPC.resources_path + "/video.bmp"));
m_pNavigationBar->AddItem(SNavBarItem("Audio", CPC.resources_path + "/audio.bmp"));
m_pNavigationBar->AddItem(SNavBarItem("Disk", CPC.resources_path + "/disk.bmp"));
m_pNavigationBar->AddItem(SNavBarItem("Input", CPC.resources_path + "/input.bmp"));
m_pNavigationBar->SelectItem(0);
m_pNavigationBar->SetIsFocusable(true);
// Groupboxes containing controls for each 'tab' (easier to make a 'tab page' visible or invisible)
m_pGroupBoxTabGeneral = new CGroupBox(CRect(CPoint(5, 60), m_ClientRect.Width() - 12, m_ClientRect.Height() - 80), this, "");
m_pGroupBoxTabExpansion = new CGroupBox(CRect(CPoint(5, 60), m_ClientRect.Width() - 12, m_ClientRect.Height() - 80), this, "ROM slots");
m_pGroupBoxTabVideo = new CGroupBox(CRect(CPoint(5, 60), m_ClientRect.Width() - 12, m_ClientRect.Height() - 80), this, "");
m_pGroupBoxTabAudio = new CGroupBox(CRect(CPoint(5, 60), m_ClientRect.Width() - 12, m_ClientRect.Height() - 80), this, "");
m_pGroupBoxTabDisk = new CGroupBox(CRect(CPoint(5, 60), m_ClientRect.Width() - 12, m_ClientRect.Height() - 80), this, "");
m_pGroupBoxTabInput = new CGroupBox(CRect(CPoint(5, 60), m_ClientRect.Width() - 12, m_ClientRect.Height() - 80), this, "");
// Store associations, see EnableTab method:
TabMap["general"] = m_pGroupBoxTabGeneral;
TabMap["expansion"] = m_pGroupBoxTabExpansion;
TabMap["video"] = m_pGroupBoxTabVideo;
TabMap["audio"] = m_pGroupBoxTabAudio;
TabMap["disk"] = m_pGroupBoxTabDisk;
TabMap["input"] = m_pGroupBoxTabInput;
// ---------------- 'General' Options ----------------
m_pLabelCPCModel = new CLabel(CPoint(10, 3), m_pGroupBoxTabGeneral, "CPC Model");
m_pDropDownCPCModel = new CDropDown(CRect(CPoint(80, 0), 80, 16), m_pGroupBoxTabGeneral, false);
m_pDropDownCPCModel->AddItem(SListItem("CPC 464"));
m_pDropDownCPCModel->AddItem(SListItem("CPC 664"));
m_pDropDownCPCModel->AddItem(SListItem("CPC 6128"));
m_pDropDownCPCModel->AddItem(SListItem("CPC 6128+"));
m_pDropDownCPCModel->SetListboxHeight(4);
// index and model match, i.e. 0 -> 464, 1 -> 664, 2 -> 6128:
m_pDropDownCPCModel->SelectItem(CPC.model);
m_pDropDownCPCModel->SetIsFocusable(true);
m_pLabelRamSize = new CLabel(CPoint(10, 28), m_pGroupBoxTabGeneral, "RAM memory");
m_pScrollBarRamSize = new CScrollBar(CRect(CPoint(90, 25), 120, 12), m_pGroupBoxTabGeneral,
CScrollBar::HORIZONTAL);
m_pScrollBarRamSize->SetMinLimit(1); // * 64. Minimum is 128k if model is 6128!
m_pScrollBarRamSize->SetMaxLimit(9); // * 64 = 576k
m_pScrollBarRamSize->SetStepSize(1); // will multiply by 64. With the current scrollbar, it would otherwise
// (stepsize of 64) be possible to select values that are no multiple
// of 64.
m_pScrollBarRamSize->SetValue(CPC.ram_size / 64);
m_pScrollBarRamSize->SetIsFocusable(true);
m_pLabelRamSizeValue = new CLabel(CPoint(217,28), m_pGroupBoxTabGeneral, stdex::itoa(CPC.ram_size) + "k ");
m_pCheckBoxLimitSpeed = new CCheckBox(CRect(CPoint(10, 49), 10, 10), m_pGroupBoxTabGeneral);
m_pCheckBoxLimitSpeed->SetIsFocusable(true);
m_pLabelLimitSpeed = new CLabel(CPoint(27, 50), m_pGroupBoxTabGeneral, "Limit emulation speed");
if (CPC.limit_speed == 1) {
m_pCheckBoxLimitSpeed->SetCheckBoxState(CCheckBox::CHECKED);
}
m_pLabelCPCSpeed = new CLabel(CPoint(10, 71), m_pGroupBoxTabGeneral, "CPC Speed");;
m_pScrollBarCPCSpeed = new CScrollBar(CRect(CPoint(78, 68), 120, 12), m_pGroupBoxTabGeneral,
CScrollBar::HORIZONTAL);
m_pScrollBarCPCSpeed->SetMinLimit(MIN_SPEED_SETTING);
m_pScrollBarCPCSpeed->SetMaxLimit(MAX_SPEED_SETTING);
m_pScrollBarCPCSpeed->SetStepSize(1);
m_pScrollBarCPCSpeed->SetValue(CPC.speed);
m_pScrollBarCPCSpeed->SetIsFocusable(true);
// Actual emulation speed = value * 25 e.g. 4 -> 100%; values range between 2 and 32
m_pLabelCPCSpeedValue = new CLabel(CPoint(205, 71), m_pGroupBoxTabGeneral, stdex::itoa(CPC.speed * 25) + "% ");
m_pCheckBoxPrinterToFile = new CCheckBox(CRect(CPoint(10, 90), 10, 10), m_pGroupBoxTabGeneral);
m_pLabelPrinterToFile = new CLabel(CPoint(27, 91), m_pGroupBoxTabGeneral, "Capture printer output to file");
if (CPC.printer == 1) {
m_pCheckBoxPrinterToFile->SetCheckBoxState(CCheckBox::CHECKED);
}
m_pCheckBoxPrinterToFile->SetIsFocusable(true);
// ---------------- Expansion ROMs ----------------
std::string romFileName;
for (unsigned int i = 0; i < 16; i ++) { // create 16 'ROM' buttons
new CLabel(CPoint((i<8)?5:135, 4 + 18*(i%8)), m_pGroupBoxTabExpansion, stdex::itoa(i));
if (!CPC.rom_file[i].empty()) { // if CPC.rom_file[i] is not empty
romFileName = CPC.rom_file[i];
} else {
romFileName = "...";
}
CButton* romButton = new CButton(CRect(CPoint((i<8)?20:150, 1 + 18*(i%8)), 100, 15), m_pGroupBoxTabExpansion, romFileName);
romButton->SetIsFocusable(true);
m_pButtonRoms.push_back(romButton); // element i corresponds with ROM slot i.
}
// ---------------- 'Video' options ----------------
m_pDropDownVideoPlugin = new CDropDown(CRect(CPoint(50,0),120,16), m_pGroupBoxTabVideo, false); // Select video plugin
unsigned int i = 0;
for(const auto& plugin : video_plugin_list)
{
if (!plugin.hidden) {
m_pDropDownVideoPlugin->AddItem(SListItem(plugin.name, reinterpret_cast<void*>(i)));
}
if (i == CPC.scr_style) {
m_pDropDownVideoPlugin->SelectItem(m_pDropDownVideoPlugin->Size()-1);
}
i++;
}
m_pDropDownVideoPlugin->SetListboxHeight(5);
m_pDropDownVideoPlugin->SetIsFocusable(true);
m_pLabelVideoPlugin = new CLabel(CPoint(10, 2), m_pGroupBoxTabVideo, "Plugin");
m_pDropDownVideoScale = new CDropDown(CRect(CPoint(220, 0),50,16), m_pGroupBoxTabVideo, false);
for(int scale = 1; scale <= 8; scale++)
{
std::string scale_str = std::to_string(scale) + "x";
m_pDropDownVideoScale->AddItem(SListItem(scale_str));
}
m_pDropDownVideoScale->SelectItem(CPC.scr_scale-1);
m_pDropDownVideoScale->SetListboxHeight(5);
m_pDropDownVideoScale->SetIsFocusable(true);
m_pLabelVideoScale = new CLabel(CPoint(180, 2), m_pGroupBoxTabVideo, "Scale");
m_pGroupBoxMonitor = new CGroupBox(CRect(CPoint(10, 30), 280, 55), m_pGroupBoxTabVideo, "Monitor");
m_pRadioButtonColour = new CRadioButton(CPoint(10, 1), 10, m_pGroupBoxMonitor); // Colour or monochrome monitor
m_pLabelColour = new CLabel(CPoint(27,2), m_pGroupBoxMonitor, "Colour");
m_pRadioButtonMonochrome = new CRadioButton(CPoint(10, 16), 10, m_pGroupBoxMonitor); // Colour or monochrome monitor;
m_pLabelMonochrome = new CLabel(CPoint(27,17), m_pGroupBoxMonitor, "Mono");
if (CPC.scr_tube == 1) {
m_pRadioButtonMonochrome->SetState(CRadioButton::CHECKED);
} else {
m_pRadioButtonColour->SetState(CRadioButton::CHECKED);
}
m_pRadioButtonColour->SetIsFocusable(true);
m_pRadioButtonMonochrome->SetIsFocusable(true);
m_pScrollBarIntensity = new CScrollBar(CRect(CPoint(130, 8), 90, 12), m_pGroupBoxMonitor, CScrollBar::HORIZONTAL);
m_pScrollBarIntensity->SetMinLimit(5);
m_pScrollBarIntensity->SetMaxLimit(15);
m_pScrollBarIntensity->SetStepSize(1);
m_pScrollBarIntensity->SetValue(CPC.scr_intensity);
m_pScrollBarIntensity->SetIsFocusable(true);
m_pLabelIntensity = new CLabel(CPoint(80, 10), m_pGroupBoxMonitor, "Intensity");
// intensity values are indeed from 5 to 15, but we display intensity/10 :
char intensityValue[5];
sprintf(intensityValue, "%2.1f ", CPC.scr_intensity / 10.0);
m_pLabelIntensityValue = new CLabel(CPoint(230, 10), m_pGroupBoxMonitor, intensityValue);
m_pCheckBoxShowFps = new CCheckBox(CRect(CPoint(10, 90), 10, 10), m_pGroupBoxTabVideo);
if (CPC.scr_fps == 1) {
m_pCheckBoxShowFps->SetCheckBoxState(CCheckBox::CHECKED);
}
m_pCheckBoxShowFps->SetIsFocusable(true);
m_pLabelShowFps = new CLabel(CPoint(27, 91), m_pGroupBoxTabVideo, "Show emulation speed");
m_pCheckBoxFullScreen = new CCheckBox(CRect(CPoint(10, 110), 10, 10), m_pGroupBoxTabVideo);
if (CPC.scr_window == 0) {
m_pCheckBoxFullScreen->SetCheckBoxState(CCheckBox::CHECKED);
}
m_pCheckBoxFullScreen->SetIsFocusable(true);
m_pLabelFullScreen = new CLabel(CPoint(27, 111), m_pGroupBoxTabVideo, "Full screen");
m_pCheckBoxAspectRatio = new CCheckBox(CRect(CPoint(10, 130), 10, 10), m_pGroupBoxTabVideo);
if (CPC.scr_preserve_aspect_ratio == 1) {
m_pCheckBoxAspectRatio->SetCheckBoxState(CCheckBox::CHECKED);
}
m_pCheckBoxAspectRatio->SetIsFocusable(true);
m_pLabelAspectRatio = new CLabel(CPoint(27, 131), m_pGroupBoxTabVideo, "Preserve aspect ratio");
// ---------------- 'Audio' Options ----------------
m_pCheckBoxEnableSound = new CCheckBox(CRect(CPoint(10,0), 10,10), m_pGroupBoxTabAudio); // Show emulation speed
if (CPC.snd_enabled == 1) {
m_pCheckBoxEnableSound->SetCheckBoxState(CCheckBox::CHECKED);
}
m_pCheckBoxEnableSound->SetIsFocusable(true);
m_pLabelEnableSound = new CLabel(CPoint(28, 1), m_pGroupBoxTabAudio, "Enable Sound Emulation");
m_pDropDownSamplingRate = new CDropDown(CRect(CPoint(100,25),100,16), m_pGroupBoxTabAudio, false); // Select audio sampling rate
m_pDropDownSamplingRate->AddItem(SListItem("11025 Hz"));
m_pDropDownSamplingRate->AddItem(SListItem("22050 Hz"));
m_pDropDownSamplingRate->AddItem(SListItem("44100 Hz"));
m_pDropDownSamplingRate->AddItem(SListItem("48000 Hz"));
m_pDropDownSamplingRate->AddItem(SListItem("96000 Hz"));
m_pDropDownSamplingRate->SetListboxHeight(4);
m_pDropDownSamplingRate->SelectItem(CPC.snd_playback_rate);
m_pDropDownSamplingRate->SetIsFocusable(true);
m_pLabelSamplingRate = new CLabel(CPoint(10, 27), m_pGroupBoxTabAudio, "Playback Rate");
m_pGroupBoxChannels = new CGroupBox(CRect(CPoint(10, 55), 130, 40), m_pGroupBoxTabAudio, "Channels");
m_pGroupBoxSampleSize = new CGroupBox(CRect(CPoint(150, 55), 130, 40), m_pGroupBoxTabAudio, "Sample Size");
m_pRadioButtonMono = new CRadioButton(CPoint(5, 2), 10, m_pGroupBoxChannels);
m_pLabelMono = new CLabel(CPoint(20,3), m_pGroupBoxChannels, "Mono");
m_pRadioButtonStereo = new CRadioButton(CPoint(55, 2), 10, m_pGroupBoxChannels); // position is within the parent! (groupbox)
m_pLabelStereo = new CLabel(CPoint(70,3), m_pGroupBoxChannels, "Stereo");
if (CPC.snd_stereo == 0) {
m_pRadioButtonMono->SetState(CRadioButton::CHECKED);
} else {
m_pRadioButtonStereo->SetState(CRadioButton::CHECKED);
}
m_pRadioButtonMono->SetIsFocusable(true);
m_pRadioButtonStereo->SetIsFocusable(true);
m_pRadioButton8bit = new CRadioButton(CPoint(5, 2), 10, m_pGroupBoxSampleSize);
m_pLabel8bit = new CLabel(CPoint(20,3), m_pGroupBoxSampleSize, "8 bit");
m_pRadioButton16bit = new CRadioButton(CPoint(55, 2), 10, m_pGroupBoxSampleSize);
m_pLabel16bit = new CLabel(CPoint(70, 3), m_pGroupBoxSampleSize, "16 bit");
if (CPC.snd_bits == 0) {
m_pRadioButton8bit->SetState(CRadioButton::CHECKED);
} else {
m_pRadioButton16bit->SetState(CRadioButton::CHECKED);
}
m_pRadioButton8bit->SetIsFocusable(true);
m_pRadioButton16bit->SetIsFocusable(true);
m_pLabelSoundVolume = new CLabel(CPoint(10, 108), m_pGroupBoxTabAudio, "Volume");
m_pScrollBarVolume = new CScrollBar(CRect(CPoint(60, 105), 120, 16), m_pGroupBoxTabAudio, CScrollBar::HORIZONTAL);
m_pScrollBarVolume->SetMinLimit(0);
m_pScrollBarVolume->SetMaxLimit(100);
m_pScrollBarVolume->SetStepSize(5);
m_pScrollBarVolume->SetValue(CPC.snd_volume);
m_pScrollBarVolume->SetIsFocusable(true);
m_pLabelSoundVolumeValue = new CLabel(CPoint(190, 108), m_pGroupBoxTabAudio, stdex::itoa(CPC.snd_volume) + "% ");
// ---------------- 'Disk' Options ----------------
m_pGroupBoxDriveA = new CGroupBox(CRect(CPoint(10, 0), 280, 45), m_pGroupBoxTabDisk, "CPC Drive A");
m_pGroupBoxDriveB = new CGroupBox(CRect(CPoint(10, 50), 280, 45), m_pGroupBoxTabDisk, "CPC Drive B");
m_pLabelDriveAFormat = new CLabel(CPoint(10,3), m_pGroupBoxDriveA, "Insert blank disks as");
m_pDropDownDriveAFormat = new CDropDown(CRect(CPoint(130,1),140,16), m_pGroupBoxDriveA, false);
m_pDropDownDriveAFormat->AddItem(SListItem("178K Data Format"));
m_pDropDownDriveAFormat->AddItem(SListItem("169K Vendor Format"));
m_pDropDownDriveAFormat->SetListboxHeight(2);
m_pDropDownDriveAFormat->SelectItem(CPC.drvA_format == 0 ? 0 : 1);
m_pDropDownDriveAFormat->SetIsFocusable(true);
m_pLabelDriveBFormat = new CLabel(CPoint(10,3), m_pGroupBoxDriveB, "Insert blank disks as");;
m_pDropDownDriveBFormat = new CDropDown(CRect(CPoint(130,1),140,16), m_pGroupBoxDriveB, false);
m_pDropDownDriveBFormat->AddItem(SListItem("178K Data Format"));
m_pDropDownDriveBFormat->AddItem(SListItem("169K Vendor Format"));
m_pDropDownDriveBFormat->SetListboxHeight(2);
m_pDropDownDriveBFormat->SelectItem(CPC.drvB_format == 0 ? 0 : 1);
m_pDropDownDriveBFormat->SetIsFocusable(true);
// ---------------- 'Input' Options ----------------
// option 'keyboard' which is the CPC language
m_pLabelCPCLanguage = new CLabel(CPoint(10,3), m_pGroupBoxTabInput, "CPC language");;
m_pDropDownCPCLanguage = new CDropDown(CRect(CPoint(130,1),140,16), m_pGroupBoxTabInput, false);
m_pDropDownCPCLanguage->AddItem(SListItem("English CPC"));
m_pDropDownCPCLanguage->AddItem(SListItem("French CPC"));
m_pDropDownCPCLanguage->AddItem(SListItem("Spanish CPC"));
m_pDropDownCPCLanguage->SetListboxHeight(3);
m_pDropDownCPCLanguage->SelectItem(CPC.keyboard);
m_pDropDownCPCLanguage->SetIsFocusable(true);
// option 'kbd_layout' which is the platform keyboard layout (i.e. the PC keyboard layout)
m_pLabelPCLanguage = new CLabel(CPoint(10,33), m_pGroupBoxTabInput, "PC Keyboard layout");;
m_pDropDownPCLanguage = new CDropDown(CRect(CPoint(130,31),140,16), m_pGroupBoxTabInput, false);
mapFileList = listDirectoryExt(CPC.resources_path, "map");
unsigned int currentMapIndex = 0;
for (unsigned int i=0; i < mapFileList.size(); i++) {
std::string mapFileName = mapFileList[i];
m_pDropDownPCLanguage->AddItem(SListItem(mapFileName));
if (mapFileName == CPC.kbd_layout) {
currentMapIndex = i;
}
}
m_pDropDownPCLanguage->SetListboxHeight(mapFileList.size());
m_pDropDownPCLanguage->SelectItem(currentMapIndex);
m_pDropDownPCLanguage->SetIsFocusable(true);
m_pCheckBoxJoystickEmulation = new CCheckBox(CRect(CPoint(10, 62), 10, 10), m_pGroupBoxTabInput);
if (CPC.joystick_emulation == 1) {
m_pCheckBoxJoystickEmulation->SetCheckBoxState(CCheckBox::CHECKED);
}
m_pLabelJoystickEmulation = new CLabel(CPoint(27, 63), m_pGroupBoxTabInput, "Joystick emulation");
m_pCheckBoxJoystickEmulation->SetIsFocusable(true);
m_pCheckBoxJoysticks = new CCheckBox(CRect(CPoint(10, 92), 10, 10), m_pGroupBoxTabInput);
if (CPC.joysticks == 1) {
m_pCheckBoxJoysticks->SetCheckBoxState(CCheckBox::CHECKED);
}
m_pLabelJoysticks = new CLabel(CPoint(27, 93), m_pGroupBoxTabInput, "Joysticks support");
m_pCheckBoxJoysticks->SetIsFocusable(true);
EnableTab("general");
m_pButtonSave = new CButton(CRect(CPoint(70, m_ClientRect.Height() - 20), 50, 15), this, "Save");
m_pButtonSave->SetIsFocusable(true);
m_pButtonCancel = new CButton(CRect(CPoint(130, m_ClientRect.Height() - 20), 50, 15), this, "Cancel");
m_pButtonCancel->SetIsFocusable(true);
m_pButtonOk = new CButton(CRect(CPoint(190, m_ClientRect.Height() - 20), 50, 15), this, "Ok");
m_pButtonOk->SetIsFocusable(true);
}
CapriceOptions::~CapriceOptions() = default;
bool CapriceOptions::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
LOG_DEBUG("CapriceOptions::HandleMessage for " << CMessage::ToString(pMessage->MessageType()))
switch(pMessage->MessageType())
{
case CMessage::CTRL_SINGLELCLICK:
{
if (pMessage->Destination() == this)
{
if (pMessage->Source() == m_pButtonCancel) {
CloseFrame();
bHandled = true;
break;
}
if (pMessage->Source() == m_pButtonSave || pMessage->Source() == m_pButtonOk) {
// save settings + close
// 'General' settings
CPC.model = m_pDropDownCPCModel->GetSelectedIndex();
CPC.ram_size = m_pScrollBarRamSize->GetValue() * 64;
CPC.limit_speed = (m_pCheckBoxLimitSpeed->GetCheckBoxState() == CCheckBox::CHECKED)?1:0;
CPC.speed = m_pScrollBarCPCSpeed->GetValue();
CPC.printer = (m_pCheckBoxPrinterToFile->GetCheckBoxState() == CCheckBox::CHECKED)?1:0;
// Selected ROM slots ( "..." is empty)
// Take the text on each 'ROM' button, if it is "...", clear the ROM, else
// set the ROM filename:
for (unsigned int i = 0; i < m_pButtonRoms.size(); i ++) {
std::string romFileName = m_pButtonRoms.at(i)->GetWindowText();
if (romFileName == "...") {
CPC.rom_file[i] = "";
} else {
CPC.rom_file[i] = romFileName;
}
}
// 'Video' settings
CPC.scr_fps = (m_pCheckBoxShowFps->GetCheckBoxState() == CCheckBox::CHECKED)?1:0;
CPC.scr_window = (m_pCheckBoxFullScreen->GetCheckBoxState() == CCheckBox::CHECKED)?0:1;
CPC.scr_preserve_aspect_ratio = (m_pCheckBoxAspectRatio->GetCheckBoxState() == CCheckBox::CHECKED)?1:0;
CPC.scr_tube = (m_pRadioButtonMonochrome->GetState() == CRadioButton::CHECKED)?1:0;
CPC.scr_intensity = m_pScrollBarIntensity->GetValue();
CPC.scr_style = reinterpret_cast<intptr_t>(m_pDropDownVideoPlugin->GetItem(m_pDropDownVideoPlugin->GetSelectedIndex()).pItemData);
CPC.scr_scale = m_pDropDownVideoScale->GetSelectedIndex()+1;
// 'Audio' settings
CPC.snd_enabled = (m_pCheckBoxEnableSound->GetCheckBoxState() == CCheckBox::CHECKED)?1:0;
// index in listbox = index in array defining sample rate (maybe rewrite this so
// it's less dependent on this?
// + todo : audio needs to be restarted if sampling rate has changed!
CPC.snd_playback_rate = m_pDropDownSamplingRate->GetSelectedIndex();
CPC.snd_volume = m_pScrollBarVolume->GetValue();
CPC.snd_stereo = m_pRadioButtonStereo->GetState()==CRadioButton::CHECKED ? 1 : 0;
CPC.snd_bits = m_pRadioButton16bit->GetState()==CRadioButton::CHECKED ? 1 : 0;
// 'Disk' settings
CPC.drvA_format = m_pDropDownDriveAFormat->GetSelectedIndex() == 0 ? 0 : 1;
CPC.drvB_format = m_pDropDownDriveBFormat->GetSelectedIndex() == 0 ? 0 : 1;
// 'Input' settings
CPC.keyboard = m_pDropDownCPCLanguage->GetSelectedIndex();
CPC.kbd_layout = mapFileList[m_pDropDownPCLanguage->GetSelectedIndex()];
CPC.joysticks = (m_pCheckBoxJoysticks->GetCheckBoxState() == CCheckBox::CHECKED)?1:0;
CPC.joystick_emulation = (m_pCheckBoxJoystickEmulation->GetCheckBoxState() == CCheckBox::CHECKED)?1:0;
// Check if any reset or re-init is required, e.g. emulator reset, sound system reset...
if (ProcessOptionChanges(CPC, pMessage->Source() == m_pButtonSave)) {
CloseFrame();
}
bHandled = true;
break;
}
}
// 'ROM' button clicked: open the ROM selection dialog:
if (pMessage->Destination() == m_pGroupBoxTabExpansion) {
for (unsigned int i = 0; i < m_pButtonRoms.size(); i ++) {
if (pMessage->Source() == m_pButtonRoms.at(i)) {
pRomSlotsDialog = new wGui::CapriceRomSlots(CRect(
CPoint(m_pSDLSurface->w /2 - 140, 30), 250, 200), this, nullptr, "", i, m_pButtonRoms.at(i));
break;
}
}
}
break;
}
case CMessage::CTRL_VALUECHANGE:
if (pMessage->Destination() == this) {
if (pMessage->Source() == m_pNavigationBar) {
switch (m_pNavigationBar->getSelectedIndex()) {
case 0 : { // 'General'
EnableTab("general");
break;
}
case 1 : { // 'Expansion' or 'ROMs'
EnableTab("expansion");
break;
}
case 2 : { // 'Video'
EnableTab("video");
break;
}
case 3 : { // 'Audio'
EnableTab("audio");
break;
}
case 4 : { // 'Disk'
EnableTab("disk");
break;
}
case 5 : { // 'Input'
EnableTab("input");
break;
}
}
}
}
#if __GNUC__ >= 7
[[gnu::fallthrough]];
#endif
case CMessage::CTRL_VALUECHANGING:
if (pMessage->Destination() == m_pGroupBoxTabGeneral) {
// Update the CPC speed %
if (pMessage->Source() == m_pScrollBarCPCSpeed) {
m_pLabelCPCSpeedValue->SetWindowText(stdex::itoa(m_pScrollBarCPCSpeed->GetValue() * 25) + "% ");
}
// Update the RAM size value:
if (pMessage->Source() == m_pScrollBarRamSize) {
// if CPC.model = 2 (CPC 6128), minimum RAM size is 128k:
int newRamSize = m_pScrollBarRamSize->GetValue();
if (m_pDropDownCPCModel->GetSelectedIndex() >= 2) { // selection in Dropdown is 'CPC 6128'
if (newRamSize < 2) {
newRamSize = 2; // *64k
m_pScrollBarRamSize->SetValue(2);
}
}
m_pLabelRamSizeValue->SetWindowText(stdex::itoa(newRamSize * 64) + "k ");
}
if (pMessage->Source() == m_pDropDownCPCModel) {
if (m_pDropDownCPCModel->GetSelectedIndex() >= 2) { // selection changes to 'CPC 6128'
if (m_pScrollBarRamSize->GetValue() < 2) {
m_pScrollBarRamSize->SetValue(2); // *64k
m_pLabelRamSizeValue->SetWindowText("128k ");
}
}
}
}
// Update the monitor intensity value
if (pMessage->Destination() == m_pGroupBoxMonitor) {
if (pMessage->Source() == m_pScrollBarIntensity) {
char intensityValue[5];
sprintf(intensityValue, "%2.1f ", m_pScrollBarIntensity->GetValue()/ 10.0);
m_pLabelIntensityValue->SetWindowText(intensityValue);
}
}
// Update the sound volume %
if (pMessage->Destination() == m_pGroupBoxTabAudio) {
if (pMessage->Source() == m_pScrollBarVolume) {
m_pLabelSoundVolumeValue->SetWindowText(stdex::itoa(m_pScrollBarVolume->GetValue()) + "% ");
}
}
break;
default :
break;
}
}
if (!bHandled) {
LOG_DEBUG("CapriceOptions::HandleMessage forwarding " << CMessage::ToString(pMessage->MessageType()) << " to CFrame")
bHandled = CFrame::HandleMessage(pMessage);
}
return bHandled;
}
// Enable a 'tab', i.e. make the corresponding CGroupBox (and its content) visible.
void CapriceOptions::EnableTab(std::string sTabName) {
std::map<std::string, CGroupBox*>::const_iterator iter;
for (iter=TabMap.begin(); iter != TabMap.end(); ++iter) {
iter->second->SetVisible(iter->first == sTabName);
}
}
// Reinitialize parts of Caprice32 depending on options that have changed.
bool CapriceOptions::ProcessOptionChanges(t_CPC& CPC, bool saveChanges) {
// if one of the following options has changed, re-init the CPC emulation :
// - CPC Model
// - amount of RAM
// - Configuration of expansion ROMs
// - new keyboard layouts
if (CPC.model != m_oldCPCsettings.model || CPC.ram_size != m_oldCPCsettings.ram_size ||
CPC.keyboard != m_oldCPCsettings.keyboard || CPC.kbd_layout != m_oldCPCsettings.kbd_layout) {
emulator_init();
}
// compare the ROM configuration & call emulator_init if required:
bool bRomsChanged = false;
for (int i = 0; i < 16; i ++) {
if (CPC.rom_file[i] != m_oldCPCsettings.rom_file[i]) {
bRomsChanged = true;
}
}
if (bRomsChanged) {
emulator_init();
}
// if scr_tube has changed (colour-> mono or mono->colour) or if the intensity value has changed,
// call video_set_palette():
if (CPC.scr_tube != m_oldCPCsettings.scr_tube || CPC.scr_intensity != m_oldCPCsettings.scr_intensity) {
video_set_palette();
}
// Update CPC emulation speed:
if (CPC.speed != m_oldCPCsettings.speed) {
update_cpc_speed();
}
// Stop/start capturing printer output:
if (CPC.printer != m_oldCPCsettings.printer) {
if (CPC.printer) {
printer_start();
} else {
printer_stop();
}
}
if (CPC.snd_enabled != m_oldCPCsettings.snd_enabled) {
if (CPC.snd_enabled) { // disabled -> enabled: reinit required in case the user has changed sound
// options (sample size etc.) in between.
audio_shutdown();
audio_init();
}
}
// Restart audio subsystem if playback rate, sample size or channels (mono/stereo) or volume has changed:
if (CPC.snd_stereo != m_oldCPCsettings.snd_stereo || CPC.snd_bits != m_oldCPCsettings.snd_bits ||
CPC.snd_volume != m_oldCPCsettings.snd_volume ||
CPC.snd_playback_rate != m_oldCPCsettings.snd_playback_rate) {
// audio restart:
if (CPC.snd_enabled) {
audio_shutdown();
audio_init();
}
}
// Restart video subsystem
if (CPC.model != m_oldCPCsettings.model || CPC.scr_window != m_oldCPCsettings.scr_window || CPC.scr_style != m_oldCPCsettings.scr_style || CPC.scr_scale != m_oldCPCsettings.scr_scale || CPC.scr_preserve_aspect_ratio != m_oldCPCsettings.scr_preserve_aspect_ratio)
{
audio_pause();
SDL_Delay(20);
video_shutdown();
if (video_init())
{
LOG_ERROR("Couldn't apply new video settings, reverting to old ones");
// we failed video init, restore previous plugin
CPC.scr_style = m_oldCPCsettings.scr_style;
CPC.scr_scale = m_oldCPCsettings.scr_scale;
video_init();
}
audio_resume();
Application().MessageServer()->QueueMessage(new CMessage(CMessage::APP_EXIT, nullptr, this));
}
// Activate/deactivate joystick emulation
if (CPC.joystick_emulation != m_oldCPCsettings.joystick_emulation)
{
CPC.InputMapper->set_joystick_emulation();
}
if (saveChanges)
{
std::string configuration_file = getConfigurationFilename(true /* forWrite */);
if (!saveConfiguration(CPC, configuration_file)) {
std::string message = "Couldn't save to " + configuration_file;
wGui::CMessageBox *pMessageBox = new wGui::CMessageBox(CRect(CPoint(m_ClientRect.Width() /2 - 125, m_ClientRect.Height() /2 - 30), 250, 60), this, nullptr, "Saving configuration failed", message, CMessageBox::BUTTON_OK);
pMessageBox->SetModal(true);
return false;
}
}
return true;
}
} // namespace wGui
| 29,783
|
C++
|
.cpp
| 548
| 45.656934
| 266
| 0.64024
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
753,820
|
CapriceMenu.cpp
|
ColinPitrat_caprice32/src/gui/src/CapriceMenu.cpp
|
// 'Menu' window for Caprice32
// Inherited from CFrame
#include <map>
#include <string>
#include "std_ex.h"
#include "CapriceMenu.h"
#include "CapriceOptions.h"
#include "CapriceLoadSave.h"
#include "CapriceMemoryTool.h"
#include "CapriceAbout.h"
#include "cap32.h"
// CPC emulation properties, defined in cap32.h:
extern t_CPC CPC;
namespace wGui {
CapriceMenu::CapriceMenu(const CRect& WindowRect, CWindow* pParent, SDL_Surface* screen, CFontEngine* pFontEngine) :
CFrame(WindowRect, pParent, pFontEngine, "Caprice32 - Menu", false), m_pScreenSurface(screen)
{
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_MESSAGEBOXRETURN);
SetModal(true);
std::map<MenuItem, std::string> buttons = {
{ MenuItem::OPTIONS, "Options" },
{ MenuItem::LOAD_SAVE, "Load / Save" },
{ MenuItem::MEMORY_TOOL, "Memory tool" },
{ MenuItem::RESET, "Reset (F5)" },
{ MenuItem::ABOUT, "About" },
{ MenuItem::RESUME, "Resume" },
{ MenuItem::QUIT, "Quit (F10)" }
};
CPoint button_space = CPoint(0, 30);
CRect button_rect(CPoint(20, 10), 100, 20);
for(auto& b : buttons) {
CButton *button = new CButton(button_rect, this, b.second);
button->SetIsFocusable(true);
m_buttons.emplace_back(b.first, button);
button_rect += button_space;
}
}
CapriceMenu::~CapriceMenu() = default;
void CapriceMenu::CloseFrame() {
// Exit gui
Application().MessageServer()->QueueMessage(new CMessage(CMessage::APP_EXIT, nullptr, this));
}
bool CapriceMenu::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
MenuItem selected(MenuItem::NONE);
if (pMessage)
{
switch (pMessage->MessageType())
{
case CMessage::CTRL_SINGLELCLICK:
if (pMessage->Destination() == this) {
for(auto& b : m_buttons) {
if (pMessage->Source() == b.GetButton()) {
bHandled = true;
selected = b.GetItem();
break;
}
}
}
break;
case CMessage::KEYBOARD_KEYDOWN:
if (m_bVisible && pMessage->Destination() == this) {
CKeyboardMessage* pKeyboardMessage = dynamic_cast<CKeyboardMessage*>(pMessage);
if (pKeyboardMessage) {
switch (pKeyboardMessage->Key) {
case SDLK_UP:
bHandled = true;
CFrame::FocusNext(EFocusDirection::BACKWARD);
break;
case SDLK_DOWN:
bHandled = true;
CFrame::FocusNext(EFocusDirection::FORWARD);
break;
case SDLK_RETURN:
bHandled = true;
for(auto &b : m_buttons) {
if(b.GetButton()->HasFocus()) {
selected = b.GetItem();
}
}
break;
case SDLK_o:
bHandled = true;
selected = MenuItem::OPTIONS;
break;
case SDLK_l:
bHandled = true;
selected = MenuItem::LOAD_SAVE;
break;
case SDLK_m:
bHandled = true;
selected = MenuItem::MEMORY_TOOL;
break;
case SDLK_F5:
bHandled = true;
selected = MenuItem::RESET;
break;
case SDLK_a:
bHandled = true;
selected = MenuItem::ABOUT;
break;
case SDLK_q:
case SDLK_F10:
bHandled = true;
selected = MenuItem::QUIT;
break;
case SDLK_r:
case SDLK_ESCAPE:
bHandled = true;
selected = MenuItem::RESUME;
break;
default:
break;
}
}
}
break;
case CMessage::CTRL_MESSAGEBOXRETURN:
if (pMessage->Destination() == this) {
wGui::CValueMessage<CMessageBox::EButton> *pValueMessage = dynamic_cast<CValueMessage<CMessageBox::EButton>*>(pMessage);
if (pValueMessage && pValueMessage->Value() == CMessageBox::BUTTON_YES)
{
cleanExit(0, /*askIfUnsaved=*/false);
}
}
break;
default:
break;
}
}
if(!bHandled) {
bHandled = CFrame::HandleMessage(pMessage);
}
switch (selected) {
case MenuItem::OPTIONS:
{
/*CapriceOptions* pOptionsBox = */new CapriceOptions(CRect(ViewToClient(CPoint(m_pScreenSurface->w /2 - 165, m_pScreenSurface->h /2 - 127)), 330, 260), this, nullptr);
break;
}
case MenuItem::LOAD_SAVE:
{
/*CapriceLoadSave* pLoadSaveBox = */new CapriceLoadSave(CRect(ViewToClient(CPoint(m_pScreenSurface->w /2 - 165, m_pScreenSurface->h /2 - 127)), 330, 260), this, nullptr);
break;
}
case MenuItem::MEMORY_TOOL:
{
/*CapriceMemoryTool* pMemoryTool = */new CapriceMemoryTool(CRect(ViewToClient(CPoint(m_pScreenSurface->w /2 - 165, m_pScreenSurface->h /2 - 140)), 330, 270), this, nullptr);
break;
}
case MenuItem::RESET:
{
emulator_reset();
// Exit gui
Application().MessageServer()->QueueMessage(new CMessage(CMessage::APP_EXIT, nullptr, this));
break;
}
case MenuItem::ABOUT:
{
int about_width(220), about_height(260);
/*CapriceAbout* pAboutBox = */new CapriceAbout(CRect(ViewToClient(CPoint((m_pScreenSurface->w - about_width)/2, (m_pScreenSurface->h - about_height)/2)), about_width, about_height), this, nullptr);
break;
}
case MenuItem::RESUME:
{
// Exit gui
Application().MessageServer()->QueueMessage(new CMessage(CMessage::APP_EXIT, nullptr, this));
break;
}
case MenuItem::QUIT:
{
// TODO(cpitrat): Find a way to deduplicate this with the version in cap32.cpp/CapriceLeavingWithoutSavingView.cpp
// The problem is that userConfirmsQuitWithoutSaving doesn't work if a GUI is already displayed.
if (driveAltered()) {
wGui::CMessageBox* m_pMessageBox = new wGui::CMessageBox(CRect(CPoint(m_ClientRect.Width() /2 - 125, m_ClientRect.Height() /2 - 40), 250, 80), this, nullptr, "Quit without saving?", "Unsaved changes. Do you really want to quit?", CMessageBox::BUTTON_YES | CMessageBox::BUTTON_NO);
m_pMessageBox->SetModal(true);
} else {
cleanExit(0, /*askIfUnsaved=*/false);
}
break;
}
case MenuItem::NONE:
break;
}
return bHandled;
}
} // namespace wGui
| 6,478
|
C++
|
.cpp
| 187
| 26.518717
| 290
| 0.595541
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
753,821
|
cap_flag.cpp
|
ColinPitrat_caprice32/src/gui/src/cap_flag.cpp
|
#include "cap_flag.h"
namespace wGui
{
CFlag::CFlag(const CRect& WindowRect, CWindow* pParent, const std::string& name, const std::string& description, CFontEngine* pFontEngine) :
CWindow(WindowRect, pParent)
{
if (pFontEngine)
{
m_pFontEngine = pFontEngine;
}
else
{
m_pFontEngine = Application().GetDefaultFontEngine();
}
m_pLabel = new CLabel(CPoint(0, 7), this, name);
m_pValue = new CEditBox(CRect(CPoint(20, 0), 20, 20), this);
m_pTooltip = new CToolTip(this, description, COLOR_BLACK);
Draw();
}
CFlag::~CFlag() // virtual
{
delete m_pLabel;
delete m_pValue;
delete m_pTooltip;
}
void CFlag::SetValue(const std::string& c)
{
m_pValue->SetWindowText(c);
}
}
| 695
|
C++
|
.cpp
| 30
| 21.166667
| 140
| 0.723404
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,822
|
std_ex.cpp
|
ColinPitrat_caprice32/src/gui/src/std_ex.cpp
|
// std_ex.cpp
//
// Extensions to the std library
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "std_ex.h"
#include <sstream>
#include <string>
namespace stdex
{
std::string itoa(const int iValue)
{
std::ostringstream sOutStream;
sOutStream << iValue;
return sOutStream.str();
}
std::string ltoa(const long lValue)
{
std::ostringstream sOutStream;
sOutStream << lValue;
return sOutStream.str();
}
std::string ftoa(const float fValue)
{
std::ostringstream sOutStream;
sOutStream << fValue;
return sOutStream.str();
}
std::string dtoa(const double dValue)
{
std::ostringstream sOutStream;
sOutStream << dValue;
return sOutStream.str();
}
int atoi(const std::string& sValue)
{
int iResult = 0;
std::stringstream sTranslation;
sTranslation << sValue;
sTranslation >> iResult;
return iResult;
}
long atol(const std::string& sValue)
{
long lResult = 0;
std::stringstream sTranslation;
sTranslation << sValue;
sTranslation >> lResult;
return lResult;
}
float atof(const std::string& sValue)
{
float fResult = 0.0;
std::stringstream sTranslation;
sTranslation << sValue;
sTranslation >> fResult;
return fResult;
}
double atod(const std::string& sValue)
{
double dResult = 0.0;
std::stringstream sTranslation;
sTranslation << sValue;
sTranslation >> dResult;
return dResult;
}
std::string TrimString(const std::string& sString)
{
std::string::size_type start = sString.find_first_not_of(" \t");
std::string::size_type end = sString.find_last_not_of(" \t");
std::string sResult;
if (start != std::string::npos)
{
sResult = sString.substr(start, end - start + 1);
}
return sResult;
}
int MaxInt(int x, int y) { return (x >= y) ? x : y; };
int MinInt(int x, int y) { return (x <= y) ? x : y; };
std::list<std::string> DetokenizeString(const std::string& sString, const std::string& sDelimiters)
{
std::string sStringCopy(sString);
std::list<std::string> Tokens;
while (! sStringCopy.empty())
{
std::string::size_type DelimiterIndex = sStringCopy.find_first_of(sDelimiters);
if (DelimiterIndex == std::string::npos)
{
Tokens.push_back(sStringCopy);
sStringCopy = "";
}
else
{
Tokens.push_back(sStringCopy.substr(0, DelimiterIndex));
}
sStringCopy = sStringCopy.substr(DelimiterIndex + 1);
}
return Tokens;
}
}
| 3,068
|
C++
|
.cpp
| 117
| 24.376068
| 99
| 0.740766
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,823
|
wg_renderedstring.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_renderedstring.cpp
|
// wg_renderedstring.cpp
//
// CRenderedString implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_renderedstring.h"
#include "wg_painter.h"
#include "wg_error.h"
#include <algorithm>
#include <string>
namespace wGui
{
CRenderedString::CRenderedString(CFontEngine* pFontEngine, std::string sString, EVAlign eVertAlign, EHAlign eHorzAlign) :
m_pFontEngine(pFontEngine),
m_sString(std::move(sString)),
m_MaskChar(' '),
m_eVertAlign(eVertAlign),
m_eHorzAlign(eHorzAlign),
m_bCachedMetricsValid(false),
m_MaxFontHeight(-1),
m_MaxFontWidth(-1)
{
if (! m_pFontEngine)
{
throw(Wg_Ex_App("Bad pFontEngine pointer! (This is usually the result of the wgui.conf file missing or misconfigured. See the Global Config section of the docs.)", "CRenderedString::CRenderedString"));
}
}
void CRenderedString::Draw(SDL_Surface* pSurface, const CRect& BoundingRect, const CPoint& OriginPoint, const CRGBColor& FontColor) const
{
CPoint OriginOffset;
std::vector<CRect> CharacterRects;
GetMetrics(nullptr, &OriginOffset, &CharacterRects);
for (unsigned int i = 0; i < m_sString.size(); ++i)
{
FT_BitmapGlyphRec* pGlyph;
if (m_MaskChar == ' ')
{
pGlyph = m_pFontEngine->RenderGlyph(m_sString[i]);
}
else
{
pGlyph = m_pFontEngine->RenderGlyph(m_MaskChar);
}
CPainter Painter(pSurface, CPainter::PAINT_NORMAL);
for (unsigned int y = 0; y < static_cast<unsigned int>(pGlyph->bitmap.rows); ++y)
{
for (unsigned int x = 0; x < static_cast<unsigned int>(pGlyph->bitmap.width); ++x)
{
unsigned char* PixelOffset = pGlyph->bitmap.buffer + y * pGlyph->bitmap.width + x;
if (*PixelOffset != 0x00)
{
CRGBColor PixelColor(FontColor.red, FontColor.green, FontColor.blue, *PixelOffset);
CPoint PixelPoint(CPoint(x + pGlyph->left, y) + OriginPoint + OriginOffset + CharacterRects.at(i).TopLeft());
if (BoundingRect.HitTest(PixelPoint) == CRect::RELPOS_INSIDE)
{
Painter.DrawPoint(PixelPoint, PixelColor);
}
}
}
}
}
}
unsigned int CRenderedString::GetMaxFontHeight()
{
if (m_MaxFontHeight < 0)
{
int maxHeight=0;
FT_Glyph_Metrics* pMetrics;
for(int i = 0; i < 256; i++)
{
pMetrics = m_pFontEngine->GetMetrics(static_cast<char>(i));
if ((pMetrics->height >> 6) > maxHeight)
{
maxHeight = (pMetrics->height >> 6);
}
}
m_MaxFontHeight = maxHeight;
}
return m_MaxFontHeight;
}
unsigned int CRenderedString::GetMaxFontWidth()
{
if (m_MaxFontWidth < 0)
{
int maxWidth = 0;
FT_Glyph_Metrics* pMetrics;
for(int i = 0; i < 256; i++)
{
pMetrics = m_pFontEngine->GetMetrics(static_cast<char>(i));
if ((pMetrics->width >> 6) > maxWidth)
{
maxWidth = (pMetrics->width >> 6);
}
}
m_MaxFontWidth = maxWidth;
}
return m_MaxFontWidth;
}
unsigned int CRenderedString::GetWidth(std::string sText)
{
int totalWidth = 0;
FT_Glyph_Metrics* pMetrics;
for(const char c : sText)
{
pMetrics = m_pFontEngine->GetMetrics(c);
totalWidth += (pMetrics->horiAdvance >> 6);
}
return totalWidth;
}
void CRenderedString::GetMetrics(CPoint* pBoundedDimensions, CPoint* pOriginOffset, std::vector<CRect>* pCharacterRects) const
{
if (! m_bCachedMetricsValid)
{
m_CachedCharacterRects.clear();
int iMinY = 0;
int iMaxY = 0;
int iLength = 0;
for (const char c : m_sString)
{
FT_Glyph_Metrics* pMetrics;
if (m_MaskChar == ' ')
{
pMetrics = m_pFontEngine->GetMetrics(c);
}
else
{
pMetrics = m_pFontEngine->GetMetrics(m_MaskChar);
}
if ((pMetrics->horiBearingY - pMetrics->height) < iMinY)
{
// judb I think this should always be 0 (when vertical-aligning, don't count the part of the character
// below the 'baseline' for example in case of g, j, p ...
iMinY = 0; //pMetrics->horiBearingY - pMetrics->height;
}
if (pMetrics->horiBearingY > iMaxY)
{
iMaxY = pMetrics->horiBearingY;
}
iLength += (pMetrics->horiAdvance);
// The top and bottom values of the rect are not actually in rect coordinates at this point, since iMaxY and iMinY are not yet know
m_CachedCharacterRects.emplace_back((iLength - pMetrics->horiAdvance) >> 6, pMetrics->horiBearingY >> 6, iLength >> 6, pMetrics->height >> 6);
}
iMinY = iMinY >> 6;
iMaxY = iMaxY >> 6;
iLength = iLength >> 6;
// now fix the top and bottom values of the rects
for (auto &rect : m_CachedCharacterRects)
{
rect.SetTop(iMaxY - rect.Top());
rect.SetBottom(rect.Top() + rect.Bottom());
}
// Tack an empty rect on the end
m_CachedCharacterRects.emplace_back(iLength, iMaxY, iLength, iMinY);
m_CachedBoundedDimensions = CPoint(iLength, iMaxY - iMinY);
switch (m_eHorzAlign)
{
case HALIGN_CENTER:
m_OriginOffset.SetX(-iLength / 2);
break;
case HALIGN_RIGHT:
m_OriginOffset.SetX(-iLength);
break;
case HALIGN_LEFT:
default:
m_OriginOffset.SetX(0);
break;
}
switch (m_eVertAlign)
{
case VALIGN_TOP:
m_OriginOffset.SetY(0);
break;
case VALIGN_BOTTOM:
m_OriginOffset.SetY(iMinY - iMaxY);
break;
case VALIGN_CENTER:
m_OriginOffset.SetY((iMinY - iMaxY) / 2);
break;
case VALIGN_NORMAL:
default:
m_OriginOffset.SetY(-iMaxY);
break;
}
m_bCachedMetricsValid = true;
}
if (pBoundedDimensions)
{
*pBoundedDimensions = m_CachedBoundedDimensions;
}
if (pOriginOffset)
{
*pOriginOffset = m_OriginOffset;
}
if (pCharacterRects)
{
*pCharacterRects = m_CachedCharacterRects;
}
}
}
| 6,254
|
C++
|
.cpp
| 216
| 25.916667
| 204
| 0.706587
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,824
|
CapriceDevToolsView.cpp
|
ColinPitrat_caprice32/src/gui/src/CapriceDevToolsView.cpp
|
// Developers' tools for Caprice32
#include "CapriceDevToolsView.h"
#include "CapriceDevTools.h"
#include <string>
using namespace wGui;
CapriceDevToolsView::CapriceDevToolsView(CApplication& application, SDL_Surface* surface, SDL_Renderer* renderer, SDL_Texture* texture, const CRect& WindowRect, DevTools* devtools) : CView(application, surface, nullptr, WindowRect), m_pRenderer(renderer), m_pTexture(texture)
{
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_MESSAGEBOXRETURN);
m_pDevToolsFrame = new CapriceDevTools(CRect(CPoint(0, 0), DEVTOOLS_WIDTH, DEVTOOLS_HEIGHT), this, nullptr, devtools);
m_pDevToolsFrame->UpdateAll();
}
void CapriceDevToolsView::LoadSymbols(const std::string& filename)
{
m_pDevToolsFrame->LoadSymbols(filename);
}
void CapriceDevToolsView::PaintToSurface(SDL_Surface& ScreenSurface, SDL_Surface& FloatingSurface, const CPoint& Offset) const
{
if (m_bVisible)
{
// Reset backgound
SDL_FillRect(&ScreenSurface, nullptr, SDL_MapRGB(ScreenSurface.format, 255, 255, 255));
// Draw all child windows recursively
for (const auto child : m_ChildWindows)
{
if (child)
{
child->PaintToSurface(ScreenSurface, FloatingSurface, Offset);
}
}
}
}
void CapriceDevToolsView::PreUpdate()
{
m_pDevToolsFrame->PreUpdate();
}
void CapriceDevToolsView::PostUpdate()
{
m_pDevToolsFrame->PostUpdate();
}
void CapriceDevToolsView::Flip() const
{
SDL_UpdateTexture(m_pTexture, nullptr, m_pScreenSurface->pixels, m_pScreenSurface->pitch);
SDL_RenderClear(m_pRenderer);
SDL_RenderCopy(m_pRenderer, m_pTexture, nullptr, nullptr);
SDL_RenderPresent(m_pRenderer);
}
void CapriceDevToolsView::Close()
{
m_pDevToolsFrame->CloseFrame();
}
| 1,750
|
C++
|
.cpp
| 50
| 32.26
| 275
| 0.77055
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
753,825
|
wg_tooltip.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_tooltip.cpp
|
// wg_tooltip.cpp
//
// CToolTip interface
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_view.h"
#include "wg_tooltip.h"
#include <string>
namespace wGui
{
CToolTip::CToolTip(CWindow* pToolWindow, std::string sText, CRGBColor& FontColor, CRGBColor& BackgroundColor, CFontEngine* pFontEngine) :
CWindow(CRect(), pToolWindow),
m_FontColor(FontColor)
{
m_sWindowText = sText;
if (pFontEngine)
{
m_pFontEngine = pFontEngine;
}
else
{
m_pFontEngine = Application().GetDefaultFontEngine();
}
m_pRenderedString.reset(new CRenderedString(
m_pFontEngine, sText, CRenderedString::VALIGN_TOP, CRenderedString::HALIGN_LEFT));
m_pTimer = new CTimer(pToolWindow->Application(), this);
//Now resize the window so that it fits the Tooltip text
CPoint Dims;
m_pRenderedString->GetMetrics(&Dims, nullptr, nullptr);
m_BoundingRect = CRect(CPoint(0, 0), Dims + CPoint(4, 4));
m_BackgroundColor = BackgroundColor;
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_MOVE);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_TIMER);
}
CToolTip::~CToolTip()
{
delete m_pTimer;
}
void CToolTip::ShowTip(const CPoint& DrawPoint)
{
SetWindowRect(m_pParentWindow->ViewToClient(m_BoundingRect + DrawPoint));
SetVisible(true);
Draw();
}
void CToolTip::HideTip()
{
SetVisible(false);
Application().MessageServer()->QueueMessage(new CMessage(CMessage::APP_PAINT, nullptr, this));
}
void CToolTip::Draw() const
{
CWindow::Draw();
if (m_pSDLSurface)
{
CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
Painter.DrawRect(m_WindowRect.SizeRect(), false);
CRect SubRect(m_WindowRect.SizeRect());
SubRect.Grow(-2);
if (m_pRenderedString)
{
m_pRenderedString->Draw(m_pSDLSurface, SubRect, SubRect.TopLeft(), m_FontColor);
}
}
}
void CToolTip::MoveWindow(const CPoint& MoveDistance)
{
CWindow::MoveWindow(MoveDistance);
m_BoundingRect = m_BoundingRect + MoveDistance;
}
void CToolTip::PaintToSurface(SDL_Surface& /*ScreenSurface*/, SDL_Surface& FloatingSurface, const CPoint& Offset) const
{
if (m_bVisible)
{
SDL_Rect SourceRect = CRect(m_WindowRect.SizeRect()).SDLRect();
SDL_Rect DestRect = CRect(m_WindowRect + Offset).SDLRect();
SDL_BlitSurface(m_pSDLSurface, &SourceRect, &FloatingSurface, &DestRect);
CPoint NewOffset = m_ClientRect.TopLeft() + m_WindowRect.TopLeft() + Offset;
for (const auto &child : m_ChildWindows)
{
child->PaintToSurface(FloatingSurface, FloatingSurface, NewOffset);
}
}
}
bool CToolTip::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::CTRL_TIMER:
{
wGui::TIntMessage* pTimerMessage = dynamic_cast<wGui::TIntMessage*>(pMessage);
if (pTimerMessage && pMessage->Destination() == this)
{
// Timer has expired, so it's time to show the tooltip
ShowTip(m_LastMousePosition + CPoint(-6, 18));
bHandled = true;
}
break;
}
case CMessage::MOUSE_MOVE:
{
// We don't want to mess with the underlying control, so don't trap any MOUSE_MOVE messages
CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);
if (pMouseMessage)
{
m_LastMousePosition = pMouseMessage->Point;
m_pTimer->StopTimer();
if (IsVisible())
{
HideTip();
}
CView* pView = GetView();
bool bHitFloating = pView && pView->GetFloatingWindow() && pView->GetFloatingWindow()->HitTest(pMouseMessage->Point) &&
pView->GetFloatingWindow() != m_pParentWindow;
if (m_pParentWindow->GetWindowRect().SizeRect().HitTest(
m_pParentWindow->ViewToWindow(m_LastMousePosition)) == CRect::RELPOS_INSIDE && !bHitFloating)
{
m_pTimer->StartTimer(1000);
}
}
break;
}
default :
bHandled = CWindow::HandleMessage(pMessage);
break;
}
}
return bHandled;
}
}
| 4,703
|
C++
|
.cpp
| 149
| 28.503356
| 137
| 0.729079
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,826
|
wg_window.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_window.cpp
|
// wg_window.cpp
//
// CWindow class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_window.h"
#include "std_ex.h"
#include "wg_painter.h"
#include "wg_application.h"
#include "wg_error.h"
#include "wg_message_server.h"
#include "wg_view.h"
#include <algorithm>
#include <string>
#include "log.h"
namespace wGui
{
CWindow::CWindow(const CRect& WindowRect, CWindow* pParent) :
CMessageClient(pParent->Application()),
m_WindowRect(WindowRect),
m_BackgroundColor(DEFAULT_BACKGROUND_COLOR),
m_ClientRect(WindowRect.SizeRect()),
m_pParentWindow(nullptr),
m_pSDLSurface(nullptr),
m_bVisible(true),
m_bHasFocus(false),
m_bIsFocusable(false)
{
SetWindowRect(WindowRect);
m_BackgroundColor = Application().GetDefaultBackgroundColor();
SetNewParent(pParent);
}
CWindow::CWindow(CApplication& application, const CRect& WindowRect) :
CMessageClient(application),
m_WindowRect(WindowRect),
m_BackgroundColor(DEFAULT_BACKGROUND_COLOR),
m_ClientRect(WindowRect.SizeRect()),
m_pParentWindow(nullptr),
m_pSDLSurface(nullptr),
m_bVisible(true),
m_bHasFocus(false),
m_bIsFocusable(false)
{
SetWindowRect(WindowRect);
m_BackgroundColor = Application().GetDefaultBackgroundColor();
}
// judb constructor like above, but without specifying a CRect ;
// In this case you need to call SetWindowRect() before using the CWindow!
CWindow::CWindow(CWindow* pParent) :
CMessageClient(pParent->Application()),
m_BackgroundColor(DEFAULT_BACKGROUND_COLOR),
m_pParentWindow(nullptr),
m_pSDLSurface(nullptr),
m_bVisible(true),
m_bHasFocus(false)
{
m_BackgroundColor = Application().GetDefaultBackgroundColor();
SetNewParent(pParent);
}
CWindow::~CWindow()
{
// Each child window is deleted, and should in their destructors call back to this object to Deregister themselves
Application().MessageServer()->DeregisterMessageClient(this);
if (m_pSDLSurface)
SDL_FreeSurface(m_pSDLSurface);
while (!m_ChildWindows.empty())
{
delete *(m_ChildWindows.begin());
}
m_ChildWindows.clear();
SetNewParent(nullptr);
}
void CWindow::SetWindowRect(const CRect& WindowRect)
{
double dHorizontalScale = m_WindowRect.Width() != 0 ? static_cast<double>(WindowRect.Width()) / m_WindowRect.Width() : 0;
double dVerticalScale = m_WindowRect.Height() != 0 ? static_cast<double>(WindowRect.Height()) / m_WindowRect.Height() : 0;
m_WindowRect = WindowRect;
if (m_pSDLSurface)
SDL_FreeSurface(m_pSDLSurface);
m_pSDLSurface = SDL_CreateRGBSurface(0, m_WindowRect.Width(), m_WindowRect.Height(),
Application().GetBitsPerPixel(), 0x000000FF, 0x0000FF00, 0x00FF0000, /*0xFF000000*/ 0);
if (!m_pSDLSurface)
{
LOG_ERROR("CWindow::SetWindowRect: Unable to create SDL Surface of size " << m_WindowRect << ": " << SDL_GetError());
}
m_ClientRect = CRect(stdex::safe_static_cast<int>(m_ClientRect.Left() * dHorizontalScale), stdex::safe_static_cast<int>(m_ClientRect.Top() * dVerticalScale),
stdex::safe_static_cast<int>(m_ClientRect.Right() * dHorizontalScale), stdex::safe_static_cast<int>(m_ClientRect.Bottom() * dVerticalScale));
Draw(); // we need to redraw here because we've got a new buffer
}
void CWindow::MoveWindow(const CPoint& MoveDistance)
{
m_WindowRect = m_WindowRect + MoveDistance;
Application().MessageServer()->QueueMessage(new CMessage(CMessage::APP_PAINT, nullptr, this));
}
CWindow* CWindow::GetAncestor(EAncestor eAncestor) const
{
CWindow* pWindow = nullptr;
switch (eAncestor)
{
case PARENT:
pWindow = m_pParentWindow;
break;
case ROOT:
pWindow = m_pParentWindow;
if (pWindow)
{
while (pWindow->m_pParentWindow)
{
pWindow = pWindow->m_pParentWindow;
}
}
else
{
pWindow = const_cast<CWindow*>(this);
}
break;
}
return pWindow;
}
CView* CWindow::GetView() const // virtual
{
return dynamic_cast<CView*>(GetAncestor(ROOT));
}
bool CWindow::IsChildOf(CWindow* pWindow) const
{
const CWindow* pCurrentWindow = this;
bool bIsChild = false;
while (!bIsChild && pCurrentWindow)
{
pCurrentWindow = pCurrentWindow->GetAncestor(PARENT);
if (pCurrentWindow == pWindow)
{
bIsChild = true;
}
}
return bIsChild;
}
void CWindow::SetVisible(bool bVisible)
{
if (m_bVisible != bVisible)
{
m_bVisible = bVisible;
for (std::list<CWindow*>::const_iterator iter = m_ChildWindows.begin(); iter != m_ChildWindows.end(); ++iter)
{
(*iter)->SetVisible(bVisible);
if (!bVisible && (*iter) == Application().GetKeyFocus())
{
Application().SetKeyFocus(m_pParentWindow);
}
}
Application().MessageServer()->QueueMessage(new CMessage(CMessage::APP_PAINT, nullptr, this));
}
}
void CWindow::SetHasFocus(bool bHasFocus)
{
if (bHasFocus) {
Application().SetKeyFocus(this);
} else {
Application().SetKeyFocus(m_pParentWindow);
}
m_bHasFocus = bHasFocus;
Draw();
}
void CWindow::SetIsFocusable(bool bIsFocusable)
{
m_bIsFocusable = bIsFocusable;
if (m_bIsFocusable) {
m_pParentWindow->AddFocusableWidget(this);
} else {
m_pParentWindow->RemoveFocusableWidget(this);
}
}
CRect CWindow::ClientToView(const CRect& Rect) const
{
CRect ScreenRect(Rect + m_ClientRect.TopLeft() + m_WindowRect.TopLeft());
if (m_pParentWindow)
{
ScreenRect = m_pParentWindow->ClientToView(ScreenRect);
}
return ScreenRect;
}
CPoint CWindow::ClientToView(const CPoint& Point) const
{
CPoint ScreenPoint(Point + m_ClientRect.TopLeft() + m_WindowRect.TopLeft());
if (m_pParentWindow)
{
ScreenPoint = m_pParentWindow->ClientToView(ScreenPoint);
}
return ScreenPoint;
}
CRect CWindow::ViewToClient(const CRect& Rect) const
{
CRect WindowRect(Rect - m_WindowRect.TopLeft() - m_ClientRect.TopLeft());
if (m_pParentWindow)
{
WindowRect = m_pParentWindow->ViewToClient(WindowRect);
}
return WindowRect;
}
CPoint CWindow::ViewToClient(const CPoint& Point) const
{
CPoint WindowPoint(Point - m_WindowRect.TopLeft() - m_ClientRect.TopLeft());
if (m_pParentWindow)
{
WindowPoint = m_pParentWindow->ViewToClient(WindowPoint);
}
return WindowPoint;
}
CRect CWindow::ViewToWindow(const CRect& Rect) const
{
CRect WindowRect(Rect - m_WindowRect.TopLeft());
if (m_pParentWindow)
{
WindowRect = m_pParentWindow->ViewToClient(WindowRect);
}
return WindowRect;
}
CPoint CWindow::ViewToWindow(const CPoint& Point) const
{
CPoint WindowPoint(Point - m_WindowRect.TopLeft());
if (m_pParentWindow)
{
WindowPoint = m_pParentWindow->ViewToClient(WindowPoint);
}
return WindowPoint;
}
void CWindow::SetWindowText(const std::string& sText)
{
m_sWindowText = sText;
Draw();
}
bool CWindow::HitTest(const CPoint& Point) const
{
if (m_WindowRect.SizeRect().HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE) {
return true;
};
return std::any_of(m_ChildWindows.begin(), m_ChildWindows.end(), [&](const auto& child) { return child->HitTest(Point); });
}
void CWindow::Draw() const
{
if (m_pSDLSurface) {
CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
Painter.DrawRect(m_WindowRect.SizeRect(), true, m_BackgroundColor, m_BackgroundColor);
Application().MessageServer()->QueueMessage(new CMessage(CMessage::APP_PAINT, nullptr, this));
}
}
void CWindow::PaintToSurface(SDL_Surface& ScreenSurface, SDL_Surface& FloatingSurface, const CPoint& Offset) const
{
if (m_bVisible)
{
SDL_Rect SourceRect = CRect(m_WindowRect.SizeRect()).SDLRect();
SDL_Rect DestRect = CRect(m_WindowRect + Offset).SDLRect();
SDL_BlitSurface(m_pSDLSurface, &SourceRect, &ScreenSurface, &DestRect);
CPoint NewOffset = m_ClientRect.TopLeft() + m_WindowRect.TopLeft() + Offset;
for (const auto &child : m_ChildWindows)
{
if (child)
{
child->PaintToSurface(ScreenSurface, FloatingSurface, NewOffset);
}
}
}
}
void CWindow::SetNewParent(CWindow* pNewParent)
{
if (m_pParentWindow)
{
m_pParentWindow->DeregisterChildWindow(this);
}
if (pNewParent)
{
pNewParent->RegisterChildWindow(this);
}
m_pParentWindow = pNewParent;
}
bool CWindow::OnMouseButtonDown(CPoint Point, unsigned int Button)
{
bool bResult = false;
if (m_bVisible && (m_WindowRect.SizeRect().HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE))
{
for (auto iter = m_ChildWindows.rbegin(); iter != m_ChildWindows.rend(); ++iter)
{
bResult = (*iter)->OnMouseButtonDown(Point, Button);
if (bResult)
{
break;
}
}
}
return bResult;
}
bool CWindow::OnMouseButtonUp(CPoint Point, unsigned int Button)
{
bool bResult = false;
if (m_bVisible && (m_WindowRect.SizeRect().HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE))
{
for (auto iter = m_ChildWindows.rbegin(); iter != m_ChildWindows.rend(); ++iter)
{
bResult = (*iter)->OnMouseButtonUp(Point, Button);
if (bResult)
{
break;
}
}
}
return bResult;
}
void CWindow::RegisterChildWindow(CWindow* pWindow)
{
if (!pWindow)
{
// anything that gets registered should be a valid CWindow
LOG_ERROR("CWindow::RegisterChildWindow: Attempting to register a non-existent child window.");
}
else
{
m_ChildWindows.push_back(pWindow);
}
}
void CWindow::DeregisterChildWindow(CWindow* pWindow)
{
m_ChildWindows.remove(pWindow);
}
bool CWindow::HandleMessage(CMessage* /*pMessage*/)
{
bool bHandled = false;
return bHandled;
}
void CWindow::AddFocusableWidget(CWindow *pWidget)
{
if (m_pParentWindow)
{
m_pParentWindow->AddFocusableWidget(pWidget);
}
}
void CWindow::RemoveFocusableWidget(CWindow *pWidget)
{
if (m_pParentWindow)
{
m_pParentWindow->RemoveFocusableWidget(pWidget);
}
}
}
| 10,272
|
C++
|
.cpp
| 360
| 26.258333
| 158
| 0.748832
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
753,827
|
CapriceVKeyboard.cpp
|
ColinPitrat_caprice32/src/gui/src/CapriceVKeyboard.cpp
|
#include "CapriceVKeyboard.h"
#include "cap32.h"
#include "keyboard.h"
#include <string>
extern t_CPC CPC;
namespace wGui {
CapriceVKeyboard::CapriceVKeyboard(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine) :
CFrame(WindowRect, pParent, pFontEngine, "Caprice32 - Virtual Keyboard", false)
{
// TODO: This became ugly with time ... Make this more generic by creating a
// class key that has a displayable string and SDL events associated
SetModal(true);
std::vector<std::string> keys{ "ABCDEFGHIJ", "KLMNOPQRST", "UVWXYZabcd", "efghijklmn", "opqrstuvwx", "yz01234567", "89&#\"'(-_)", "=,.:!|?./*", "+%<>[]{}\\`"};
// TODO: make this configurable
std::vector<std::string> keywords{ "cat\n", "run\n", "run\"", "cls\n", "mode ", "|cpm\n", "|tape\n", "|a\n", "|b\n" };
// TODO: add files that are on disk
m_focused.first = 0;
m_focused.second = 0;
m_result = new CEditBox(CRect(CPoint(10, 10), 364, 15), this);
m_result->SetReadOnly(true);
// Add one char keys
int y = 30;
for(auto& l : keys)
{
std::vector<CButton*> line;
int x = 10;
for(auto& c : l)
{
CButton *button = new CButton(CRect(CPoint(x, y), 15, 15), this, std::string(1, c));
button->SetIsFocusable(true);
line.push_back(button);
x += 20;
}
y += 20;
m_buttons.push_back(line);
}
// Add function keys
{
std::vector<CButton*> line;
int x = 10;
for(int i = 0; i < 10; i++)
{
char fn = '0' + i;
std::string label = std::string("F") + std::string(1, fn);
CButton *button = new CButton(CRect(CPoint(x, y), 15, 15), this, label);
button->SetIsFocusable(true);
line.push_back(button);
x += 20;
}
y += 18;
m_buttons.push_back(line);
}
// Add ESC, SPACE, DELETE and RETURN buttons
// TODO: TAB ? COPY ?
std::vector<CButton*> line;
CButton *esc = new CButton(CRect(CPoint(10, y), 41, 15), this, "ESC");
CButton *space = new CButton(CRect(CPoint(62, y), 41, 15), this, "SPACE");
CButton *retur = new CButton(CRect(CPoint(113, y), 41, 15), this, "RETURN");
CButton *backs = new CButton(CRect(CPoint(164, y), 41, 15), this, "DELETE");
esc->SetIsFocusable(true);
space->SetIsFocusable(true);
retur->SetIsFocusable(true);
backs->SetIsFocusable(true);
line.push_back(esc);
line.push_back(space);
line.push_back(retur);
line.push_back(backs);
m_buttons.push_back(line);
// Add keywords
int kx = 160;
int ky = 0;
int nb_lines = m_buttons.size();
int i = nb_lines;
for(auto& w : keywords)
{
if(i >= nb_lines) {
if(kx > 290) break;
i -= nb_lines;
ky = 30;
kx += 70;
}
CButton *button = new CButton(CRect(CPoint(kx, ky), 60, 15), this, w);
button->SetIsFocusable(true);
m_buttons[i++].push_back(button);
ky += 18;
}
}
CapriceVKeyboard::~CapriceVKeyboard() = default;
void CapriceVKeyboard::CloseFrame() {
// Exit gui
Application().MessageServer()->QueueMessage(new CMessage(CMessage::APP_EXIT, nullptr, this));
}
std::list<SDL_Event> CapriceVKeyboard::GetEvents() {
return CPC.InputMapper->StringToEvents(m_result->GetWindowText());
}
void CapriceVKeyboard::moveFocus(int dx, int dy) {
m_buttons[m_focused.first][m_focused.second]->SetHasFocus(false);
m_focused.first += dy;
int height = m_buttons.size();
if(m_focused.first < 0) m_focused.first += height;
if(m_focused.first >= height) m_focused.first -= height;
m_focused.second += dx;
int width = m_buttons[m_focused.first].size();
if(m_focused.second < 0) m_focused.second += width;
if(m_focused.second >= width) {
if(dx == 0) {
m_focused.second = width - 1;
} else {
m_focused.second -= width;
}
}
m_buttons[m_focused.first][m_focused.second]->SetHasFocus(true);
}
bool CapriceVKeyboard::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch (pMessage->MessageType())
{
case CMessage::APP_DESTROY_FRAME:
bHandled = true;
CloseFrame();
break;
case CMessage::CTRL_SINGLELCLICK:
if (pMessage->Destination() == this && pMessage->Source() != m_pFrameCloseButton) {
std::string pressed = static_cast<const CWindow*>(pMessage->Source())->GetWindowText();
if(pressed == "SPACE") {
pressed = " ";
}
else if(pressed == "RETURN") {
pressed = "\n";
}
else if(pressed == "ESC") {
pressed = "\a";
pressed += static_cast<char>(CPC_ESC);
}
else if(pressed == "DELETE") {
std::string result = m_result->GetWindowText();
// If the string is not empty, and last char is not backspace remove it
if(!result.empty() && result[result.size()-1] != '\b') {
result = result.substr(0, result.size()-1);
// If the char was a special char, also remove the escaping char
if(!result.empty() && result[result.size()-1] == '\a') {
result = result.substr(0, result.size()-1);
}
m_result->SetWindowText(result);
break;
}
// Otherwise put backspace in the output
pressed = "\b";
} else if(pressed.size() == 2 && pressed[0] == 'F' && pressed[1] >= '0' && pressed[1] <= '9') {
int fkey = CPC_F0 + pressed[1] - '0';
pressed = "\a";
pressed += static_cast<char>(fkey);
}
std::string result = m_result->GetWindowText() + pressed;
m_result->SetWindowText(result);
}
break;
case CMessage::KEYBOARD_KEYDOWN:
if (m_bVisible && pMessage->Destination() == this) {
CKeyboardMessage* pKeyboardMessage = dynamic_cast<CKeyboardMessage*>(pMessage);
if (pKeyboardMessage) {
switch (pKeyboardMessage->Key) {
case SDLK_UP:
moveFocus(0, -1);
bHandled = true;
break;
case SDLK_DOWN:
moveFocus(0, 1);
bHandled = true;
break;
case SDLK_LEFT:
moveFocus(-1, 0);
bHandled = true;
break;
case SDLK_RIGHT:
moveFocus(1, 0);
bHandled = true;
break;
case SDLK_ESCAPE:
bHandled = true;
CloseFrame();
break;
default:
break;
}
}
}
break;
default:
break;
}
}
if(!bHandled) {
bHandled = CFrame::HandleMessage(pMessage);
}
return bHandled;
}
}
| 7,126
|
C++
|
.cpp
| 201
| 26.432836
| 163
| 0.540075
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,828
|
wg_groupbox.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_groupbox.cpp
|
// wg_groupbox.cpp
//
// CGroupBox class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_application.h"
#include "wg_groupbox.h"
#include <string>
namespace wGui
{
CGroupBox::CGroupBox(const CRect& WindowRect, CWindow* pParent, std::string sText, CRGBColor& FontColor, CFontEngine* pFontEngine) :
CWindow(WindowRect, pParent),
m_FontColor(FontColor)
{
m_sWindowText = sText;
if (pFontEngine)
{
m_pFontEngine = pFontEngine;
}
else
{
m_pFontEngine = Application().GetDefaultFontEngine();
}
m_ClientRect.Grow(-2);
m_ClientRect.SetTop(15);
m_pRenderedString.reset(new CRenderedString(
m_pFontEngine, sText, CRenderedString::VALIGN_TOP, CRenderedString::HALIGN_LEFT));
m_BackgroundColor = Application().GetDefaultBackgroundColor();
Application().MessageServer()->RegisterMessageClient(this, CMessage::KEYBOARD_KEYDOWN);
Draw();
}
CGroupBox::~CGroupBox() = default;
void CGroupBox::Draw() const
{
CWindow::Draw();
if (m_pSDLSurface)
{
CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
CRect rect = CRect(0, 5, m_WindowRect.Width() - 2, m_WindowRect.Height() - 6);
Painter.DrawRect(rect, false, m_BackgroundColor * 0.3);
rect = rect + CPoint(1, 1);
Painter.DrawRect(rect, false, m_BackgroundColor * 1.6);
CPoint Dims, Offset;
m_pRenderedString->GetMetrics(&Dims, &Offset, nullptr);
Painter.DrawRect(CRect(CPoint(6, 0), CPoint(14, 0) + Dims),
true, m_BackgroundColor, m_BackgroundColor);
if (m_pRenderedString)
{
m_pRenderedString->Draw(m_pSDLSurface, m_WindowRect.SizeRect(), CPoint(10, 0), m_FontColor);
}
}
}
void CGroupBox::SetWindowText(const std::string& sWindowText)
{
m_pRenderedString.reset(new CRenderedString(
m_pFontEngine, sWindowText, CRenderedString::VALIGN_TOP, CRenderedString::HALIGN_LEFT));
CWindow::SetWindowText(sWindowText);
}
void CGroupBox::SetWindowRect(const CRect& WindowRect)
{
CWindow::SetWindowRect(WindowRect);
m_ClientRect = m_WindowRect.SizeRect();
m_ClientRect.Grow(-2);
m_ClientRect.SetTop(15);
}
bool CGroupBox::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::KEYBOARD_KEYDOWN:
{
CKeyboardMessage* pKeyboardMessage = dynamic_cast<CKeyboardMessage*>(pMessage);
if (pKeyboardMessage && pMessage->Destination() == this)
{
// Forward all key downs to parent
Application().MessageServer()->QueueMessage(new CKeyboardMessage(CMessage::KEYBOARD_KEYDOWN, m_pParentWindow, this,
pKeyboardMessage->ScanCode, pKeyboardMessage->Modifiers, pKeyboardMessage->Key));
}
break;
}
default :
bHandled = CWindow::HandleMessage(pMessage);
break;
}
}
return bHandled;
}
}
| 3,538
|
C++
|
.cpp
| 108
| 30.027778
| 132
| 0.74465
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,829
|
wg_rect.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_rect.cpp
|
// wg_rect.cpp
//
// CRect class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_rect.h"
#include "wg_error.h"
#include "std_ex.h"
#include <algorithm>
#include <iostream>
std::ostream& operator<<(std::ostream& os, const wGui::CRect r)
{
os << "(" << r.Left() << ", " << r.Top() << ", " << r.Right() << ", " << r.Bottom() << ")";
return os;
}
namespace wGui
{
SDL_Rect CRect::SDLRect() const
{
SDL_Rect sdlRect;
//Normalize the rect...
sdlRect.x = stdex::safe_static_cast<short int>(std::min(m_Left, m_Right));
sdlRect.y = stdex::safe_static_cast<short int>(std::min(m_Top, m_Bottom));
sdlRect.w = stdex::safe_static_cast<short int>(Width());
sdlRect.h = stdex::safe_static_cast<short int>(Height());
return sdlRect;
}
// assignment operator
CRect& CRect::operator=(const CRect& r)
{
m_Top = r.Top();
m_Left = r.Left();
m_Right = r.Right();
m_Bottom = r.Bottom();
return *this;
}
CRect& CRect::operator=(CRect&& r) noexcept
{
m_Top = r.m_Top;
m_Left = r.m_Left;
m_Right = r.m_Right;
m_Bottom = r.m_Bottom;
return *this;
}
CRect& CRect::operator+=(const CPoint& p)
{
m_Left += p.XPos();
m_Right += p.XPos();
m_Top += p.YPos();
m_Bottom += p.YPos();
return *this;
}
CRect CRect::operator+(const CPoint& p) const
{
CRect result(*this);
result += p;
return result;
}
CRect& CRect::operator-=(const CPoint& p)
{
m_Left -= p.XPos();
m_Right -= p.XPos();
m_Top -= p.YPos();
m_Bottom -= p.YPos();
return *this;
}
CRect CRect::operator-(const CPoint& p) const
{
CRect result(*this);
result -= p;
return result;
}
CRect& CRect::Grow(int iGrowAmount)
{
m_Top -= iGrowAmount;
m_Left -= iGrowAmount;
m_Right += iGrowAmount;
m_Bottom += iGrowAmount;
return *this;
}
CRect& CRect::Move(int iOffsetX, int iOffsetY)
{
m_Left += iOffsetX;
m_Top += iOffsetY;
m_Right += iOffsetX;
m_Bottom += iOffsetY;
return *this;
}
bool CRect::Overlaps(const CRect& r) const
{
bool bOverlap = false;
if (m_Right >= r.m_Left && m_Left <= r.m_Right && m_Top <= r.m_Bottom && m_Bottom >= r.m_Top)
{
bOverlap = true;
}
return bOverlap;
}
CRect& CRect::ClipTo(const CRect& r)
{
if (! Overlaps(r))
{
m_Left = 0;
m_Top = 0;
m_Right = 0;
m_Bottom = 0;
}
else
{
if (m_Left < r.m_Left)
{
m_Left = r.m_Left;
}
if (m_Top < r.m_Top)
{
m_Top = r.m_Top;
}
if (m_Right > r.m_Right)
{
m_Right = r.m_Right;
}
if (m_Bottom > r.m_Bottom)
{
m_Bottom = r.m_Bottom;
}
}
return *this;
}
// test to see if the point lies within the rect
unsigned int CRect::HitTest(const CPoint& p) const
{
unsigned int eRelPos = 0;
eRelPos |= (p.XPos() < m_Left) ? RELPOS_LEFT : 0;
eRelPos |= (p.YPos() < m_Top) ? RELPOS_ABOVE: 0;
eRelPos |= (p.XPos() >= m_Right) ? RELPOS_RIGHT : 0;
eRelPos |= (p.YPos() >= m_Bottom) ? RELPOS_BELOW: 0;
eRelPos |= (p.XPos() >= m_Left && p.XPos() < m_Right &&
p.YPos() >= m_Top && p.YPos() < m_Bottom) ? RELPOS_INSIDE : 0;
return eRelPos;
}
}
| 3,770
|
C++
|
.cpp
| 157
| 21.949045
| 94
| 0.656119
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
753,830
|
wg_messagebox.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_messagebox.cpp
|
// wg_messagebox.cpp
//
// CMessageBox class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_messagebox.h"
#include <string>
namespace wGui
{
CMessageBox::CMessageBox(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine, const std::string& sTitle, const std::string& sMessage, int iButtons) :
CFrame(WindowRect, pParent, pFontEngine, sTitle),
m_iButtons(iButtons)
{
//m_pMessageLabel = new CLabel(CRect(75, 10, GetClientRect().Right() - 75, GetClientRect().Bottom() - 40), this, sMessage);
m_pMessageLabel = new CLabel(CPoint(10, 10), this, sMessage);
// judb Position buttons relative to lower right corner:
CPoint BottomRight(GetClientRect().Right() - 20, GetClientRect().Bottom() - 30);
if (iButtons & CMessageBox::BUTTON_CANCEL)
{
CButton *button = new CButton(CRect(BottomRight - CPoint(50, 18), BottomRight), this, "Cancel");
button->SetIsFocusable(true);
m_ButtonMap.insert(std::make_pair(CMessageBox::BUTTON_CANCEL, button));
BottomRight = BottomRight - CPoint(60, 0);
}
if (iButtons & CMessageBox::BUTTON_OK)
{
CButton *button = new CButton(CRect(BottomRight - CPoint(50, 18), BottomRight), this, "Ok");
button->SetIsFocusable(true);
m_ButtonMap.insert(std::make_pair(CMessageBox::BUTTON_OK, button));
BottomRight = BottomRight - CPoint(60, 0);
}
if (iButtons & CMessageBox::BUTTON_NO)
{
CButton *button = new CButton(CRect(BottomRight - CPoint(50, 18), BottomRight), this, "No");
button->SetIsFocusable(true);
m_ButtonMap.insert(std::make_pair(CMessageBox::BUTTON_NO, button));
BottomRight = BottomRight - CPoint(60, 0);
}
if (iButtons & CMessageBox::BUTTON_YES)
{
CButton *button = new CButton(CRect(BottomRight - CPoint(50, 18), BottomRight), this, "Yes");
button->SetIsFocusable(true);
m_ButtonMap.insert(std::make_pair(CMessageBox::BUTTON_YES, button));
BottomRight = BottomRight - CPoint(60, 0);
}
}
bool CMessageBox::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::CTRL_SINGLELCLICK:
{
if (pMessage->Destination() == this)
{
for (const auto& button : m_ButtonMap)
{
if (pMessage->Source() == button.second)
{
Application().MessageServer()->QueueMessage(new CValueMessage<CMessageBox::EButton>(CMessage::CTRL_MESSAGEBOXRETURN, m_pParentWindow, nullptr, button.first));
CloseFrame();
bHandled = true;
break;
}
}
}
break;
}
default:
break;
}
if (!bHandled)
{
bHandled = CFrame::HandleMessage(pMessage);
}
}
return bHandled;
}
}
| 3,403
|
C++
|
.cpp
| 98
| 31.867347
| 165
| 0.720874
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,831
|
CapriceRomSlots.cpp
|
ColinPitrat_caprice32/src/gui/src/CapriceRomSlots.cpp
|
// Caprice32 ROM slot selection window
// Inherited from CFrame
#include <dirent.h>
#include <string>
#include "CapriceRomSlots.h"
#include "cap32.h"
#include "fileutils.h"
// CPC emulation properties, defined in cap32.h:
extern t_CPC CPC;
namespace wGui {
CapriceRomSlots::CapriceRomSlots(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine, std::string sTitle, int selectedRomSlot, CButton* pSelectedRomButton) :
CFrame(WindowRect, pParent, pFontEngine, sTitle, false)
{
SetModal(true);
romSlot = selectedRomSlot;
m_pSelectedRomButton = pSelectedRomButton; // the button that was clicked to open this dialog
SetWindowText("ROM slot " + stdex::itoa(romSlot));
m_pListBoxRoms = new CListBox(CRect(CPoint(10, 10), m_ClientRect.Width() - 25, 140), this, true);
if (romSlot == 7) {
m_pListBoxRoms->AddItem(SListItem("DEFAULT"));
}
std::vector<std::string> romFiles = getAvailableRoms();
for (unsigned int i = 0; i < romFiles.size(); i ++) {
m_pListBoxRoms->AddItem(SListItem(romFiles.at(i)));
if (romFiles.at(i) == m_pSelectedRomButton->GetWindowText()) { // It's all based on the filename of the ROM,
// maybe find a better way.
m_pListBoxRoms->SetSelection(i, true);
m_pListBoxRoms->SetFocus(i);
}
}
m_pListBoxRoms->SetIsFocusable(true);
m_pButtonInsert = new CButton(CRect(CPoint( 40, m_ClientRect.Height() - 22), 50, 15), this, "Insert");
m_pButtonInsert->SetIsFocusable(true);
m_pButtonClear = new CButton(CRect(CPoint(100, m_ClientRect.Height() - 22), 50, 15), this, "Clear");
m_pButtonClear->SetIsFocusable(true);
m_pButtonCancel = new CButton(CRect(CPoint(160, m_ClientRect.Height() - 22), 50, 15), this, "Cancel");
m_pButtonCancel->SetIsFocusable(true);
}
bool CapriceRomSlots::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::CTRL_SINGLELCLICK:
{
if (pMessage->Destination() == this)
{
if (pMessage->Source() == m_pButtonCancel) {
CloseFrame();
bHandled = true;
break;
}
if (pMessage->Source() == m_pButtonInsert) {
// Put selected ROM filename on button: (if there is a selection)
int selectedRomIndex = m_pListBoxRoms->getFirstSelectedIndex();
if (selectedRomIndex >= 0) {
m_pSelectedRomButton->SetWindowText((m_pListBoxRoms->GetItem(selectedRomIndex)).sItemText);
CloseFrame();
bHandled = true;
}
break;
}
if (pMessage->Source() == m_pButtonClear) {
// clear selected rom
m_pSelectedRomButton->SetWindowText("...");
CloseFrame();
bHandled = true;
break;
}
bHandled = CFrame::HandleMessage(pMessage);
}
break;
}
default :
bHandled = CFrame::HandleMessage(pMessage);
break;
}
}
return bHandled;
}
// Reads the existing ROM filenames (in roms subdirectory defined in cap32.cfg)
std::vector<std::string> CapriceRomSlots::getAvailableRoms() {
// CPC.rom_path contains the ROM path, e.g. ./rom:
return listDirectory(CPC.rom_path);
}
}
| 3,291
|
C++
|
.cpp
| 88
| 31.181818
| 173
| 0.65246
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
753,832
|
wg_editbox.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_editbox.cpp
|
// wg_editbox.cpp
//
// CEditBox class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_editbox.h"
#include "wg_message_server.h"
#include "wg_application.h"
#include "wg_timer.h"
#include "wg_error.h"
#include "wg_view.h"
#include "std_ex.h"
#include <string>
namespace wGui
{
CEditBox::CEditBox(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine) :
CWindow(WindowRect, pParent),
m_SelStart(0),
m_SelLength(0),
m_DragStart(0),
m_ScrollOffset(0),
m_bReadOnly(false),
m_bMouseDown(false),
m_bUseMask(false),
m_bLastMouseMoveInside(false),
m_contentType(ANY),
m_bDrawCursor(true)
{
m_BackgroundColor = COLOR_WHITE;
m_ClientRect.Grow(-4);
if (pFontEngine)
{
m_pFontEngine = pFontEngine;
}
else
{
m_pFontEngine = Application().GetDefaultFontEngine();
}
m_pDblClickTimer = new CTimer(pParent->Application());
m_pCursorTimer = new CTimer(pParent->Application(), this);
m_pRenderedString.reset(new CRenderedString(
m_pFontEngine, "", CRenderedString::VALIGN_NORMAL, CRenderedString::HALIGN_LEFT));
Application().MessageServer()->RegisterMessageClient(this, CMessage::KEYBOARD_KEYDOWN);
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_BUTTONUP);
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_MOVE);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_DOUBLELCLICK);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_TIMER);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_GAININGKEYFOCUS);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_LOSINGKEYFOCUS);
Application().MessageServer()->RegisterMessageClient(this, CMessage::TEXTINPUT);
Draw();
}
CEditBox::~CEditBox() // virtual
{
delete m_pCursorTimer;
delete m_pDblClickTimer;
}
void CEditBox::SetReadOnly(bool bReadOnly)
{
m_BackgroundColor = bReadOnly ? COLOR_LIGHTGRAY : COLOR_WHITE;
m_bReadOnly = bReadOnly;
SetIsFocusable(!bReadOnly);
Draw();
}
std::string CEditBox::GetSelText() const
{
if (m_bUseMask)
{
return "";
}
if (m_SelLength != 0)
{
std::string::size_type SelStartNorm = 0;
std::string::size_type SelLenNorm = 0;
if (m_SelLength < 0)
{
SelStartNorm = m_SelLength + m_SelStart;
SelLenNorm = abs(m_SelLength);
}
else
{
SelStartNorm = m_SelStart;
SelLenNorm = m_SelLength;
}
return m_sWindowText.substr(SelStartNorm, SelLenNorm);
}
return "";
}
void CEditBox::SetSelection(std::string::size_type iSelStart, int iSelLength)
{
if (iSelStart < m_sWindowText.length())
{
m_SelStart = iSelStart;
if (iSelStart + iSelLength <= m_sWindowText.length())
m_SelLength = iSelLength;
else
m_SelLength = stdex::safe_static_cast<int>(m_sWindowText.length() - iSelStart);
}
else
{
m_SelStart = 0;
m_SelLength = 0;
}
}
std::string::size_type CEditBox::GetIndexFromPoint(const CPoint& Point) const // virtual
{
CPoint Offset;
std::vector<CRect> CharRects;
m_pRenderedString->GetMetrics(nullptr, &Offset, &CharRects);
CRect SubRect(m_WindowRect.SizeRect());
SubRect.Grow(-3);
std::string::size_type index = 0;
CPoint BoundedPoint = Point;
if (BoundedPoint.XPos() < SubRect.Left()) {
BoundedPoint.SetX(SubRect.Left());
}
if (BoundedPoint.XPos() > SubRect.Right()) {
BoundedPoint.SetX(SubRect.Right());
}
if (!CharRects.empty())
{
int xDelta = abs(BoundedPoint.XPos() - (CharRects.front().Left() + Offset.XPos() + SubRect.Left()));
for (unsigned int i = 0; i < m_pRenderedString->GetLength(); ++i)
{
if (abs(BoundedPoint.XPos() - (CharRects.at(i).Right() + Offset.XPos() + SubRect.Left() + m_ScrollOffset)) < xDelta)
{
xDelta = abs(BoundedPoint.XPos() - (CharRects.at(i).Right() + Offset.XPos() + SubRect.Left() + m_ScrollOffset));
index = i + 1;
}
}
}
return index;
}
void CEditBox::Draw() const
{
CWindow::Draw();
if (m_pSDLSurface)
{
CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
CRect SubRect(m_WindowRect.SizeRect());
SubRect.Grow(-3);
Painter.DrawRect(m_WindowRect.SizeRect(), false, COLOR_DARKGRAY);
CPoint FontCenterPoint = m_WindowRect.SizeRect().Center();
if (m_bUseMask)
{
m_pRenderedString->SetMaskChar('*');
}
else
{
m_pRenderedString->SetMaskChar(' ');
}
CRGBColor FontColor = m_bReadOnly ? DEFAULT_DISABLED_LINE_COLOR : COLOR_BLACK;
if (Application().GetKeyFocus() == dynamic_cast<const CWindow*>(this) && !m_bReadOnly)
{
CPoint BoundedDims;
CPoint Offset;
std::vector<CRect> CharRects;
m_pRenderedString->GetMetrics(&BoundedDims, &Offset, &CharRects);
std::string::size_type SelStartNorm = 0;
std::string::size_type SelLenNorm = abs(m_SelLength);
if (m_SelLength < 0)
{
SelStartNorm = m_SelStart + m_SelLength;
}
else
{
SelStartNorm = m_SelStart;
}
// Handle scrolling
// Patch for "Scrolling while selecting to left in editbox" by Oldrich Dlouhy
if (! m_bMouseDown)
{
if (CharRects.empty() || BoundedDims.XPos() < SubRect.Width())
{
m_ScrollOffset = 0;
}
else
{
int iCursorPos = 0;
if (m_SelStart + m_SelLength >= CharRects.size())
{
iCursorPos = CharRects.back().Right() + Offset.XPos() + SubRect.Left() + m_ScrollOffset;
}
else
{
iCursorPos = CharRects.at(m_SelStart + m_SelLength).Left() + Offset.XPos() + SubRect.Left() + m_ScrollOffset;
}
if (iCursorPos < SubRect.Left())
{
m_ScrollOffset = -(iCursorPos - m_ScrollOffset - SubRect.Left() - Offset.XPos());
}
else if (iCursorPos > SubRect.Right())
{
m_ScrollOffset = -(iCursorPos - m_ScrollOffset - SubRect.Left() - Offset.XPos() - SubRect.Width() + 1);
}
if (m_ScrollOffset < 0 && (CharRects.back().Right() + Offset.XPos() + SubRect.Left() + m_ScrollOffset < SubRect.Right()))
{
m_ScrollOffset = SubRect.Right() - CharRects.back().Right() - 1;
if (m_ScrollOffset > 0)
{
m_ScrollOffset = 0;
}
}
}
}
// Selection
if (m_SelLength != 0)
{
CRect SelRect;
SelRect.SetBottom(SubRect.Bottom());
SelRect.SetTop(SubRect.Top());
SelRect.SetLeft(CharRects.at(SelStartNorm).Left() + Offset.XPos() + SubRect.Left() + m_ScrollOffset);
SelRect.SetRight(CharRects.at(SelLenNorm + SelStartNorm - 1).Right() + Offset.XPos() + SubRect.Left() + m_ScrollOffset);
SelRect.ClipTo(SubRect);
Painter.DrawRect(SelRect, true, Application().GetDefaultSelectionColor(), Application().GetDefaultSelectionColor());
}
else if (m_bDrawCursor)
{
//RenderStringWithCursor
int CursorPos = Offset.XPos() + SubRect.Left() + m_ScrollOffset;
if (m_SelStart + m_SelLength >= CharRects.size() && !CharRects.empty())
{
CursorPos += CharRects.back().Right();
}
else if (m_SelStart + m_SelLength < CharRects.size())
{
CursorPos += CharRects.at(m_SelStart + m_SelLength).Left();
}
if (CursorPos >= SubRect.Left() && CursorPos <= SubRect.Right())
{
Painter.DrawVLine(SubRect.Top(), SubRect.Bottom(), CursorPos, COLOR_BLACK);
}
}
}
if (m_pRenderedString)
{
m_pRenderedString->Draw(m_pSDLSurface, SubRect,
CPoint(SubRect.Left() + m_ScrollOffset, SubRect.Bottom() - m_pRenderedString->GetMaxFontHeight() / 4), FontColor);
}
}
}
void CEditBox::SetWindowText(const std::string& sText)
{
m_SelStart = 0;
m_SelLength = 0;
m_pRenderedString.reset(new CRenderedString(
m_pFontEngine, sText, CRenderedString::VALIGN_NORMAL, CRenderedString::HALIGN_LEFT));
CWindow::SetWindowText(sText);
}
bool CEditBox::OnMouseButtonDown(CPoint Point, unsigned int Button)
{
bool bResult = CWindow::OnMouseButtonDown(Point, Button);
CPoint WindowPoint(ViewToWindow(Point));
if (!bResult && m_bVisible && (Button == CMouseMessage::LEFT) &&
!m_bReadOnly && (m_ClientRect.HitTest(WindowPoint) == CRect::RELPOS_INSIDE))
{
bool fSkipCursorPositioning = false;
//If we haven't initialized the double click timer, do so.
if (!m_pDblClickTimer->IsRunning())
{
m_pDblClickTimer->StartTimer(500, false);
}
else
{
//Raise double click event
//This message is being dispatched, but to where?
Application().MessageServer()->QueueMessage(new TIntMessage(CMessage::CTRL_DOUBLELCLICK, this, this, 0));
m_pDblClickTimer->StopTimer();
fSkipCursorPositioning = true;
}
if (Application().GetKeyFocus() != this)
{
Application().SetKeyFocus(this);
}
if (!fSkipCursorPositioning)
{
m_SelStart = GetIndexFromPoint(WindowPoint);
m_DragStart = m_SelStart;
m_SelLength = 0;
m_bMouseDown = true;
Draw();
bResult = true;
}
}
return bResult;
}
bool CEditBox::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
CRect SubRect(m_WindowRect);
SubRect.Grow(-3);
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::CTRL_DOUBLELCLICK:
if (pMessage->Destination() == this)
{
m_SelStart = 0;
m_SelLength = stdex::safe_static_cast<int>(m_sWindowText.length());
Draw();
bHandled = true;
}
break;
case CMessage::MOUSE_BUTTONUP:
m_bMouseDown = false;
break;
case CMessage::MOUSE_MOVE:
{
CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);
if (pMouseMessage && m_bVisible && !m_bReadOnly)
{
CPoint WindowPoint(ViewToWindow(pMouseMessage->Point));
//If the cursor is within the control then check to see if we've already
// set the cursor to the I Beam, if we have, don't do anything. If we
// havent, set it to the ibeam.
//Else if it's outside the control and the I Beam cursor is set, set it
// back to a normal cursor.
CView* pView = GetView();
bool bHitFloating = pView && pView->GetFloatingWindow() && pView->GetFloatingWindow()->HitTest(pMouseMessage->Point);
if (m_ClientRect.HitTest(WindowPoint) == CRect::RELPOS_INSIDE && !bHitFloating && !m_bLastMouseMoveInside)
{
m_bLastMouseMoveInside = true;
CwgCursorResourceHandle IBeamHandle(Application(), WGRES_IBEAM_CURSOR);
Application().SetMouseCursor(&IBeamHandle);
}
else if ((m_ClientRect.HitTest(WindowPoint) != CRect::RELPOS_INSIDE || bHitFloating) && m_bLastMouseMoveInside)
{
m_bLastMouseMoveInside= false;
Application().SetMouseCursor();
}
if (m_bMouseDown)
{
std::string::size_type CursorPos = GetIndexFromPoint(WindowPoint);
if (CursorPos < m_DragStart)
{
m_SelLength = stdex::safe_static_cast<int>(m_DragStart) - stdex::safe_static_cast<int>(CursorPos);
m_SelStart = CursorPos;
}
else
{
m_SelStart = m_DragStart;
m_SelLength = stdex::safe_static_cast<int>(CursorPos) - stdex::safe_static_cast<int>(m_SelStart);
}
bHandled = true;
Draw();
}
}
break;
}
case CMessage::CTRL_TIMER:
if (pMessage->Destination() == this && pMessage->Source() == m_pCursorTimer)
{
//This redraws the whole control each time we want to show/not show the cursor, that's probably a bad idea.
if (m_SelLength == 0)
{
m_bDrawCursor = !m_bDrawCursor;
Draw();
}
bHandled = true;
}
break;
case CMessage::CTRL_GAININGKEYFOCUS:
if (pMessage->Destination() == this && !m_bReadOnly)
{
m_pCursorTimer->StartTimer(750, true);
m_bDrawCursor = true;
Draw();
bHandled = true;
SDL_StartTextInput();
}
break;
case CMessage::CTRL_LOSINGKEYFOCUS:
if (pMessage->Destination() == this)
{
m_pCursorTimer->StopTimer();
Draw();
bHandled = true;
SDL_StopTextInput();
}
break;
case CMessage::TEXTINPUT:
if (pMessage->Destination() == this)
{
CTextInputMessage* pTextInputMessage = dynamic_cast<CTextInputMessage*>(pMessage);
if (pTextInputMessage && !m_bReadOnly)
{
std::string sBuffer = m_sWindowText;
SelDelete(&sBuffer);
// TODO: Find a clean way to handle real unicode. Here we assume this is only ASCII.
for (auto val : pTextInputMessage->Text)
{
// Ignore extended ASCII chars
if ((val & 0xFF80) != 0) continue;
if(m_contentType == NUMBER && (val < '0' || val > '9')) continue;
if(m_contentType == HEXNUMBER && (val < '0' || val > '9') && (val < 'A' || val > 'F') && (val < 'a' || val > 'f')) continue;
if(m_contentType == HEXNUMBER && val >= 'a' && val <= 'z') val += 'A' - 'a';
if(m_contentType == ALPHA && (val < 'A' || val > 'Z') && (val < 'a' || val > 'z')) continue;
if(m_contentType == ALPHANUM && (val < '0' || val > '9') && (val < 'A' || val > 'Z') && (val < 'a' || val > 'z')) continue;
sBuffer.insert(m_SelStart++, 1, val);
}
if (m_sWindowText != sBuffer)
{
Application().MessageServer()->QueueMessage(new TStringMessage(CMessage::CTRL_VALUECHANGE, m_pParentWindow, this, sBuffer));
}
m_sWindowText = sBuffer;
CWindow::SetWindowText(sBuffer);
m_pRenderedString.reset(new CRenderedString(m_pFontEngine, sBuffer, CRenderedString::VALIGN_NORMAL, CRenderedString::HALIGN_LEFT));
m_bDrawCursor = true;
Draw();
}
}
break;
case CMessage::KEYBOARD_KEYDOWN:
if (m_bVisible)
{
CKeyboardMessage* pKeyboardMessage = dynamic_cast<CKeyboardMessage*>(pMessage);
if (pKeyboardMessage && pMessage->Destination() == this && !m_bReadOnly)
{
std::string sBuffer = m_sWindowText;
bHandled = true;
switch(pKeyboardMessage->Key)
{
case SDLK_BACKSPACE:
if (m_SelLength != 0)
{
SelDelete(&sBuffer);
}
else
{
if (m_SelStart > 0)
{
sBuffer.erase(--m_SelStart, 1);
}
}
break;
case SDLK_DELETE:
if (m_SelStart < sBuffer.length())
{
if (m_SelLength != 0)
{
SelDelete(&sBuffer);
}
else
{
sBuffer.erase(m_SelStart, 1);
}
}
break;
case SDLK_LEFT:
if (pKeyboardMessage->Modifiers & KMOD_SHIFT) //Shift modifier
{
if (m_SelStart > 0)
{
if ((m_SelLength > 0) || ((m_SelStart - abs(m_SelLength)) > 0))
{
if (pKeyboardMessage->Modifiers & KMOD_CTRL)
{
std::string::size_type pos = sBuffer.rfind(' ', (m_SelStart + m_SelLength) - 1);
if (pos != std::string::npos)
{
m_SelLength = stdex::safe_static_cast<int>(pos) - stdex::safe_static_cast<int>(m_SelStart);
}
else
{
m_SelLength = stdex::safe_static_cast<int>(m_SelStart) * -1;
}
}
else
{
m_SelLength--;
}
}
}
}
else if (m_SelLength != 0)
{
if (m_SelLength < 0)
{
m_SelStart = m_SelStart + m_SelLength;
}
m_SelLength = 0;
}
else if (m_SelStart > 0)
{
if (pKeyboardMessage->Modifiers & KMOD_CTRL)
{
std::string::size_type pos = sBuffer.rfind(' ', m_SelStart - 1);
if (pos != std::string::npos)
{
m_SelStart = pos;
}
else
{
m_SelStart = 0;
}
}
else
{
--m_SelStart;
}
m_SelLength = 0;
}
break;
case SDLK_RIGHT:
if (m_SelStart <= sBuffer.length())
{
if (pKeyboardMessage->Modifiers & KMOD_SHIFT)
{
if (pKeyboardMessage->Modifiers & KMOD_CTRL)
{
std::string::size_type pos = sBuffer.find(' ', m_SelStart + m_SelLength);
if (pos != std::string::npos)
{
m_SelLength = stdex::safe_static_cast<int>(pos) - stdex::safe_static_cast<int>(m_SelStart) + 1;
}
else
{
m_SelLength = stdex::safe_static_cast<int>(sBuffer.length()) - stdex::safe_static_cast<int>(m_SelStart);
}
}
else if (m_SelStart + m_SelLength < sBuffer.length())
{
m_SelLength++; //Selecting, one character at a time, increase the selection length by one.
}
}
else if(m_SelLength == 0 && m_SelStart < sBuffer.length())
{
//With the ctrl modifier used, we look for the next instance of a space.
// If we find one, we set the cursor position to that location.
// If we can't find one, we set the cursor position to the end of the string.
// If we don't have the ctrl modifier, then we just incriment the cursor position by one character
if (pKeyboardMessage->Modifiers & KMOD_CTRL)
{
std::string::size_type pos = sBuffer.find(' ', m_SelStart + 1);
if (pos != std::string::npos)
{
m_SelStart = pos + 1;
}
else
{
m_SelStart = sBuffer.length();
}
}
else
{
++m_SelStart; //We don't have anything selected, so we'll just incriment the start position
}
}
else
{
if (m_SelLength > 0)
{
m_SelStart = m_SelStart + m_SelLength; //Reset cursor position to the end of the selection
}
m_SelLength = 0; //Set selection length to zero
}
}
break;
case SDLK_END:
if (pKeyboardMessage->Modifiers & KMOD_SHIFT)
{
m_SelLength = stdex::safe_static_cast<int>(sBuffer.length()) - stdex::safe_static_cast<int>(m_SelStart);
}
else
{
m_SelLength = 0;
m_SelStart = sBuffer.length();
}
break;
case SDLK_HOME:
if (pKeyboardMessage->Modifiers & KMOD_SHIFT)
{
m_SelLength = stdex::safe_static_cast<int>(m_SelStart);
m_SelStart = 0;
}
else
{
m_SelLength = 0;
m_SelStart = 0;
}
break;
case SDLK_ESCAPE: // intentional fall through
case SDLK_TAB:
// Not for us - let parent handle it
Application().MessageServer()->QueueMessage(new CKeyboardMessage(CMessage::KEYBOARD_KEYDOWN, m_pParentWindow, this,
pKeyboardMessage->ScanCode, pKeyboardMessage->Modifiers, pKeyboardMessage->Key));
break;
default:
break;
}
if (m_sWindowText != sBuffer)
{
Application().MessageServer()->QueueMessage(new TStringMessage(CMessage::CTRL_VALUECHANGE, m_pParentWindow, this, sBuffer));
}
m_sWindowText = sBuffer;
CWindow::SetWindowText(sBuffer);
m_pRenderedString.reset(new CRenderedString(m_pFontEngine, sBuffer, CRenderedString::VALIGN_NORMAL, CRenderedString::HALIGN_LEFT));
m_bDrawCursor = true;
Draw();
}
break;
}
default :
break;
}
}
if (!bHandled) {
bHandled = CWindow::HandleMessage(pMessage);
}
return bHandled;
}
void CEditBox::SelDelete(std::string* psString)
{
//This means we've selected something, therefore, should replace it
if (m_SelLength != 0)
{
std::string::size_type SelStartNorm = 0;
std::string::size_type SelLenNorm = 0;
if (m_SelLength < 0)
{
SelStartNorm = m_SelLength + m_SelStart;
SelLenNorm = abs(m_SelLength);
}
else
{
SelStartNorm = m_SelStart;
SelLenNorm = m_SelLength;
}
psString->erase(SelStartNorm, SelLenNorm);
//Since we're deleting the stuff here and setting the selection length to zero, we also need to set the selection start properly
m_SelStart = SelStartNorm;
m_SelLength = 0;
}
}
}
| 20,360
|
C++
|
.cpp
| 653
| 25.905054
| 141
| 0.640706
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,833
|
cap_register.cpp
|
ColinPitrat_caprice32/src/gui/src/cap_register.cpp
|
#include "cap_register.h"
#include <iomanip>
#include <sstream>
#include <string>
namespace wGui
{
CRegister::CRegister(const CRect& WindowRect, CWindow* pParent, const std::string& name, CFontEngine* pFontEngine) :
CWindow(WindowRect, pParent)
{
if (pFontEngine)
{
m_pFontEngine = pFontEngine;
}
else
{
m_pFontEngine = Application().GetDefaultFontEngine();
}
m_pLabel = new CLabel(CPoint(0, 7), this, name);
m_pHexValue = new CEditBox(CRect(CPoint(20, 0), 30, 20), this);
m_pDecValue = new CEditBox(CRect(CPoint(55, 0), 40, 20), this);
m_pCharValue = new CEditBox(CRect(CPoint(100, 0), 25, 20), this);
Draw();
}
CRegister::~CRegister() // virtual
{
delete m_pLabel;
delete m_pHexValue;
delete m_pDecValue;
delete m_pCharValue;
}
void CRegister::SetValue(const unsigned int c)
{
m_Value = c;
std::ostringstream oss;
oss << std::hex << c;
m_pHexValue->SetWindowText(oss.str());
m_pDecValue->SetWindowText(std::to_string(c));
if ( c < 256 ) {
m_pCharValue->SetWindowText(std::string(1, static_cast<char>(c)));
} else {
m_pCharValue->SetWindowText(
std::string(1, static_cast<char>((c & 0xFF00) >> 8)) +
std::string(1, static_cast<char>(c & 0xFF)));
}
}
}
| 1,226
|
C++
|
.cpp
| 46
| 24.086957
| 116
| 0.688832
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
753,834
|
wg_toolbar.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_toolbar.cpp
|
// wg_toolbar.cpp
//
// CToolBar class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_toolbar.h"
#include "wg_application.h"
namespace wGui
{
CToolBar::CToolBar(const CRect& WindowRect, CWindow* pParent) :
CWindow(WindowRect, pParent)
{
m_BackgroundColor = COLOR_LIGHTGRAY;
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_SINGLELCLICK);
Draw();
}
CToolBar::~CToolBar() = default;
void CToolBar::InsertButton(CButton* pButton, long int iButtonID, unsigned int iPosition)
{
if (iPosition > m_vpButtons.size())
iPosition = stdex::safe_static_cast<unsigned int>(m_vpButtons.size());
long int iFixedButtonID = iButtonID;
if (pButton == nullptr)
{
iFixedButtonID = 0;
}
else
{
// Transfer ownership of the button to the ToolBar
pButton->SetNewParent(this);
}
m_vpButtons.insert(m_vpButtons.begin() + iPosition, std::make_pair(pButton, iFixedButtonID));
RepositionButtons();
}
void CToolBar::AppendButton(CButton* pButton, long int iButtonID)
{
InsertButton(pButton, iButtonID, stdex::safe_static_cast<unsigned int>(m_vpButtons.size()));
}
void CToolBar::RemoveButton(unsigned int iPosition)
{
CButton* pButton = m_vpButtons.at(iPosition).first;
m_vpButtons.erase(m_vpButtons.begin() + iPosition);
delete pButton;
}
void CToolBar::Clear()
{
for(const auto &button : m_vpButtons)
{
delete button.first;
}
m_vpButtons.clear();
}
int CToolBar::GetButtonPosition(long int iButtonID)
{
int iPosition = -1;
for (auto iter = m_vpButtons.begin(); iter != m_vpButtons.end(); ++iter)
{
if (iter->second == iButtonID)
{
iPosition = stdex::safe_static_cast<int>(iter - m_vpButtons.begin());
}
}
return iPosition;
}
void CToolBar::RepositionButtons()
{
int xPosition = 4;
for (auto &button : m_vpButtons)
{
CButton* pButton = button.first;
if (pButton)
{
int xStartPosition = xPosition;
xPosition = xPosition + 2 + pButton->GetWindowRect().Width();
pButton->SetWindowRect(CRect(xStartPosition, 2, xPosition - 3, pButton->GetWindowRect().Height() + 1));
// Hide any buttons that extend beyond the end of the toolbar
pButton->SetVisible(xPosition <= m_WindowRect.Width());
}
else
{
// Spacer
xPosition += 6;
}
}
}
void CToolBar::SetWindowRect(const CRect& WindowRect)
{
CWindow::SetWindowRect(WindowRect);
m_ClientRect = m_WindowRect.SizeRect();
RepositionButtons();
}
bool CToolBar::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::CTRL_SINGLELCLICK:
{
if (pMessage->Destination() == this)
{
long int iButtonID = 0;
for (const auto &button : m_vpButtons)
{
if (button.first == pMessage->Source())
{
iButtonID = button.second;
}
}
Application().MessageServer()->QueueMessage(new TIntMessage(CMessage::CTRL_SINGLELCLICK, m_pParentWindow, this, iButtonID));
bHandled = true;
}
break;
}
default :
bHandled = CWindow::HandleMessage(pMessage);
break;
}
}
return bHandled;
}
}
| 3,844
|
C++
|
.cpp
| 140
| 25
| 128
| 0.732318
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,835
|
wg_message.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_message.cpp
|
// wg_message.cpp
//
// CMessage class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_message.h"
#include "std_ex.h"
#include "log.h"
#include <string>
namespace wGui
{
CMessage::CMessage(const EMessageType MessageType, const CMessageClient* pDestination, const CMessageClient* pSource) :
m_MessageType(MessageType),
m_pDestination(pDestination),
m_pSource(pSource)
{
}
std::string CMessage::ToString(EMessageType message_type) {
switch (message_type) {
case UNKNOWN: return "UNKNOWN";
case APP_DESTROY_FRAME: return "APP_DESTROY_FRAME";
case APP_EXIT: return "APP_EXIT";
case APP_PAINT: return "APP_PAINT";
case CTRL_DOUBLELCLICK: return "CTRL_DOUBLELCLICK";
case CTRL_DOUBLEMCLICK: return "CTRL_DOUBLEMCLICK";
case CTRL_DOUBLERCLICK: return "CTRL_DOUBLERCLICK";
case CTRL_GAININGKEYFOCUS: return "CTRL_GAININGKEYFOCUS";
case CTRL_GAININGMOUSEFOCUS: return "CTRL_GAININGMOUSEFOCUS";
case CTRL_LOSINGKEYFOCUS: return "CTRL_LOSINGKEYFOCUS";
case CTRL_LOSINGMOUSEFOCUS: return "CTRL_LOSINGMOUSEFOCUS";
case CTRL_MESSAGEBOXRETURN: return "CTRL_MESSAGEBOXRETURN";
case CTRL_RESIZE: return "CTRL_RESIZE";
case CTRL_SINGLELCLICK: return "CTRL_SINGLELCLICK";
case CTRL_SINGLEMCLICK: return "CTRL_SINGLEMCLICK";
case CTRL_SINGLERCLICK: return "CTRL_SINGLERCLICK";
case CTRL_TIMER: return "CTRL_TIMER";
case CTRL_VALUECHANGE: return "CTRL_VALUECHANGE";
case CTRL_VALUECHANGING: return "CTRL_VALUECHANGING";
case KEYBOARD_KEYDOWN: return "KEYBOARD_KEYDOWN";
case KEYBOARD_KEYUP: return "KEYBOARD_KEYUP";
case TEXTINPUT: return "TEXTINPUT";
case MOUSE_BUTTONDOWN: return "MOUSE_BUTTONDOWN";
case MOUSE_BUTTONUP: return "MOUSE_BUTTONUP";
case MOUSE_MOVE: return "MOUSE_MOVE";
case SDL: return "SDL";
case USER: return "USER";
}
return " ** Unimplemented **";
}
CSDLMessage::CSDLMessage(const EMessageType MessageType, const CMessageClient* pDestination, const CMessageClient* pSource, SDL_Event SDLEvent) : // NOLINT(modernize-pass-by-value): if we pass by value and move SDLEvent, clang produce another warning (misc-move-const-arg) about moving a trivially-copyable type
CMessage(MessageType, pDestination, pSource),
SDLEvent(SDLEvent)
{
}
CKeyboardMessage::CKeyboardMessage(const EMessageType MessageType, const CMessageClient* pDestination, const CMessageClient* pSource,
unsigned char ScanCode, SDL_Keymod Modifiers, SDL_Keycode Key) :
CMessage(MessageType, pDestination, pSource),
ScanCode(ScanCode),
Modifiers(Modifiers),
Key(Key)
{
}
CTextInputMessage::CTextInputMessage(const EMessageType MessageType, const CMessageClient* pDestination, const CMessageClient* pSource,
std::string Text) :
CMessage(MessageType, pDestination, pSource),
Text(std::move(Text))
{
}
CMouseMessage::CMouseMessage(const EMessageType MessageType, const CMessageClient* pDestination, const CMessageClient* pSource,
CPoint Point, CPoint Relative, unsigned int Button) :
CMessage(MessageType, pDestination, pSource),
Point(Point),
Relative(Relative),
Button(Button)
{
}
unsigned int CMouseMessage::TranslateSDLButton(Uint8 SDLButton)
{
unsigned int Button = 0;
switch (SDLButton)
{
case SDL_BUTTON_LEFT:
Button = LEFT;
break;
case SDL_BUTTON_RIGHT:
Button = RIGHT;
break;
case SDL_BUTTON_MIDDLE:
Button = MIDDLE;
break;
default:
LOG_ERROR("Untranslated SDL Button # " + stdex::itoa(SDLButton));
break;
}
return Button;
}
unsigned int CMouseMessage::TranslateSDLButtonState(Uint8 SDLButtonState)
{
unsigned int Button = 0;
if (SDLButtonState & SDL_BUTTON(1))
{
Button |= LEFT;
}
if (SDLButtonState & SDL_BUTTON(2))
{
Button |= RIGHT;
}
if (SDLButtonState & SDL_BUTTON(3))
{
Button |= MIDDLE;
}
if (SDLButtonState & SDL_BUTTON(4))
{
Button |= WHEELUP;
}
if (SDLButtonState & SDL_BUTTON(5))
{
Button |= WHEELDOWN;
}
return Button;
}
}
| 4,708
|
C++
|
.cpp
| 139
| 31.309353
| 311
| 0.764486
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,836
|
wg_painter.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_painter.cpp
|
// wg_painter.cpp
//
// CPainter class
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_painter.h"
#include "wg_error.h"
#include "std_ex.h"
#include <algorithm>
#include <math.h>
namespace wGui
{
CPainter::CPainter(SDL_Surface* pSurface, EPaintMode ePaintMode) :
m_pSurface(pSurface),
m_pWindow(nullptr),
m_PaintMode(ePaintMode)
{
if (!m_pSurface)
{
throw Wg_Ex_App("Invalid pointer to surface.", "CPainter::CPainter");
}
}
CPainter::CPainter(CWindow* pWindow, EPaintMode ePaintMode) :
m_pSurface(nullptr),
m_pWindow(pWindow),
m_PaintMode(ePaintMode)
{
if (!m_pWindow)
{
throw Wg_Ex_App("Invalid pointer to window.", "CPainter::CPainter");
}
m_pSurface = pWindow->GetSDLSurface();
if (!m_pSurface)
{
throw Wg_Ex_App("Invalid pointer to surface.", "CPainter::CPainter");
}
}
void CPainter::DrawHLine(int xStart, int xEnd, int y, const CRGBColor& LineColor)
{
if (m_pWindow)
{
CPoint Offset = m_pWindow->GetClientRect().TopLeft();
xStart += Offset.XPos();
xEnd += Offset.XPos();
y += Offset.YPos();
}
SDL_Rect Rect;
Rect.x = stdex::safe_static_cast<short int>(std::min(xStart, xEnd));
Rect.y = stdex::safe_static_cast<short int>(y);
Rect.w = stdex::safe_static_cast<short int>(std::max(xEnd - xStart + 1, xStart - xEnd + 1));
Rect.h = 1;
SDL_FillRect(m_pSurface, &Rect, LineColor.SDLColor(m_pSurface->format));
}
void CPainter::DrawVLine(int yStart, int yEnd, int x, const CRGBColor& LineColor)
{
if (m_pWindow)
{
CPoint Offset = m_pWindow->GetClientRect().TopLeft();
yStart += Offset.YPos();
yEnd += Offset.YPos();
x += Offset.XPos();
}
SDL_Rect Rect;
Rect.x = stdex::safe_static_cast<short int>(x);
Rect.y = stdex::safe_static_cast<short int>(std::min(yStart, yEnd));
Rect.w = 1;
Rect.h = stdex::safe_static_cast<short int>(std::max(yEnd - yStart + 1, yStart - yEnd + 1));
SDL_FillRect(m_pSurface, &Rect, LineColor.SDLColor(m_pSurface->format));
}
void CPainter::DrawRect(const CRect& Rect, bool bFilled, const CRGBColor& BorderColor, const CRGBColor& FillColor)
{
CRect RealRect(Rect);
if (m_pWindow)
{
RealRect = Rect + m_pWindow->GetClientRect().TopLeft();
RealRect.ClipTo(m_pWindow->GetClientRect());
}
if (!bFilled || (BorderColor != FillColor))
{
DrawHLine(RealRect.Left(), RealRect.Right(), RealRect.Top(), BorderColor);
DrawHLine(RealRect.Left(), RealRect.Right(), RealRect.Bottom(), BorderColor);
DrawVLine(RealRect.Top(), RealRect.Bottom(), RealRect.Left(), BorderColor);
DrawVLine(RealRect.Top(), RealRect.Bottom(), RealRect.Right(), BorderColor);
RealRect.Grow(-1); //In case we have to fill the rect, then it's ready to go.
}
if (bFilled)
{
if (m_PaintMode == PAINT_REPLACE)
{
SDL_Rect FillRect = RealRect.SDLRect();
SDL_FillRect(m_pSurface, &FillRect, FillColor.SDLColor(m_pSurface->format));
}
else
{
for (int iY = RealRect.Top(); iY <= RealRect.Bottom(); ++iY)
{
for (int iX = RealRect.Left(); iX <= RealRect.Right(); ++iX)
{
DrawPoint(CPoint(iX, iY), FillColor);
}
}
}
}
}
// judb draw a 'raised button' border based on the given color
void CPainter::Draw3DRaisedRect(const CRect& Rect, const CRGBColor& Color)
{
CRect RealRect(Rect);
if (m_pWindow) {
RealRect = Rect + m_pWindow->GetClientRect().TopLeft();
RealRect.ClipTo(m_pWindow->GetClientRect());
}
DrawHLine(RealRect.Left(), RealRect.Right(), RealRect.Top(), Color * 1.6);
DrawVLine(RealRect.Top(), RealRect.Bottom(), RealRect.Left(), Color * 1.6);
DrawVLine(RealRect.Top(), RealRect.Bottom(), RealRect.Right(), Color * 0.3);
DrawHLine(RealRect.Left(), RealRect.Right(), RealRect.Bottom(), Color * 0.3);
}
// judb draw a 'lowered button' border based on the given color
void CPainter::Draw3DLoweredRect(const CRect& Rect, const CRGBColor& Color)
{
CRect RealRect(Rect);
if (m_pWindow) {
RealRect = Rect + m_pWindow->GetClientRect().TopLeft();
RealRect.ClipTo(m_pWindow->GetClientRect());
}
DrawHLine(RealRect.Left(), RealRect.Right(), RealRect.Top(), Color * 0.3);
DrawHLine(RealRect.Left(), RealRect.Right(), RealRect.Bottom(), Color * 1.6);
DrawVLine(RealRect.Top(), RealRect.Bottom(), RealRect.Left(), Color * 0.3);
DrawVLine(RealRect.Top(), RealRect.Bottom(), RealRect.Right(), Color * 1.6);
}
void CPainter::DrawLine(const CPoint& Point1, const CPoint& Point2, const CRGBColor& LineColor)
{
if (Point1.XPos() == Point2.XPos())
{
DrawVLine(Point1.YPos(), Point2.YPos(), Point1.XPos(), LineColor);
}
else
{
double iSlope = double(Point2.YPos() - Point1.YPos()) / (Point2.XPos() - Point1.XPos());
if (iSlope <= 1 && iSlope >= -1)
{
CPoint StartPoint = (Point1.XPos() < Point2.XPos()) ? Point1 : Point2;
CPoint EndPoint = (Point1.XPos() < Point2.XPos()) ? Point2 : Point1;
for (int x = StartPoint.XPos(); x <= EndPoint.XPos(); ++x)
{
DrawPoint(CPoint(x, stdex::safe_static_cast<int>(StartPoint.YPos() + (x - StartPoint.XPos()) * iSlope)), LineColor);
}
}
else
{
CPoint StartPoint = (Point1.YPos() < Point2.YPos()) ? Point1 : Point2;
CPoint EndPoint = (Point1.YPos() < Point2.YPos()) ? Point2 : Point1;
for (int y = StartPoint.YPos(); y <= EndPoint.YPos(); ++y)
{
DrawPoint(CPoint(stdex::safe_static_cast<int>(StartPoint.XPos() + (y - StartPoint.YPos()) / iSlope), y), LineColor);
}
}
}
}
// judb draw box (filled)
void CPainter::DrawBox(CPoint UpperLeftPoint, int width, int height, const CRGBColor& LineColor)
{
if (m_pWindow)
{
CPoint Offset = m_pWindow->GetClientRect().TopLeft();
UpperLeftPoint = UpperLeftPoint + Offset;
}
SDL_Rect Rect = CRect(UpperLeftPoint, width, height).SDLRect();
SDL_FillRect(m_pSurface, &Rect, LineColor.SDLColor(m_pSurface->format));
}
void CPainter::DrawPoint(const CPoint& Point, const CRGBColor& PointColor)
{
CPoint RealPoint = (m_pWindow != nullptr) ? Point + m_pWindow->GetClientRect().TopLeft() : Point;
if (CRect(0, 0, m_pSurface->w, m_pSurface->h).HitTest(RealPoint) == CRect::RELPOS_INSIDE)
{
LockSurface();
Uint8* PixelOffset = static_cast<Uint8*>(m_pSurface->pixels) +
m_pSurface->format->BytesPerPixel * RealPoint.XPos() + m_pSurface->pitch * RealPoint.YPos();
switch (m_pSurface->format->BytesPerPixel)
{
case 1: // 8 bpp
*reinterpret_cast<Uint8*>(PixelOffset) = static_cast<Uint8>(MixColor(ReadPoint(Point), PointColor).SDLColor(m_pSurface->format));
break;
case 2: // 16 bpp
*reinterpret_cast<Uint16*>(PixelOffset) = static_cast<Uint16>(MixColor(ReadPoint(Point), PointColor).SDLColor(m_pSurface->format));
break;
case 3: // 24 bpp
{
Uint32 PixelColor = MixColor(ReadPoint(Point), PointColor).SDLColor(m_pSurface->format);
Uint8* pPixelSource = reinterpret_cast<Uint8*>(&PixelColor);
Uint8* pPixelDest = reinterpret_cast<Uint8*>(PixelOffset);
*pPixelDest = *pPixelSource;
*(++pPixelDest) = *(++pPixelSource);
*(++pPixelDest) = *(++pPixelSource);
break;
}
case 4: // 32 bpp
*reinterpret_cast<Uint32*>(PixelOffset) = static_cast<Uint32>(MixColor(ReadPoint(Point), PointColor).SDLColor(m_pSurface->format));
break;
default:
throw(Wg_Ex_SDL("Unrecognized BytesPerPixel.", "CPainter::DrawPoint"));
break;
}
UnlockSurface();
}
}
CRGBColor CPainter::ReadPoint(const CPoint& Point)
{
CPoint RealPoint = (m_pWindow != nullptr) ? Point + m_pWindow->GetClientRect().TopLeft() : Point;
Uint32 PixelColor = 0;
if (CRect(0, 0, m_pSurface->w, m_pSurface->h).HitTest(RealPoint) == CRect::RELPOS_INSIDE)
{
Uint8* PixelOffset = static_cast<Uint8*>(m_pSurface->pixels) +
m_pSurface->format->BytesPerPixel * RealPoint.XPos() + m_pSurface->pitch * RealPoint.YPos();
switch (m_pSurface->format->BytesPerPixel)
{
case 1: // 8 bpp
PixelColor = *reinterpret_cast<Uint8*>(PixelOffset);
break;
case 2: // 16 bpp
PixelColor = *reinterpret_cast<Uint16*>(PixelOffset);
break;
case 3: // 24 bpp
{
Uint8* pPixelDest = reinterpret_cast<Uint8*>(&PixelColor);
Uint8* pPixelSource = reinterpret_cast<Uint8*>(PixelOffset);
*pPixelDest = *pPixelSource;
*(++pPixelDest) = *(++pPixelSource);
*(++pPixelDest) = *(++pPixelSource);
break;
}
case 4: // 32 bpp
PixelColor = *reinterpret_cast<Uint32*>(PixelOffset);
break;
default:
throw(Wg_Ex_SDL("Unrecognized BytesPerPixel.", "CPainter::DrawPoint"));
break;
}
}
return CRGBColor(&PixelColor, m_pSurface->format);
}
void CPainter::LockSurface()
{
if (SDL_MUSTLOCK(m_pSurface))
{
if (SDL_LockSurface(m_pSurface) < 0)
{
SDL_Delay(10);
if (SDL_LockSurface(m_pSurface) < 0)
{
throw(Wg_Ex_SDL("Unable to lock surface.", "CPainter::LockSurface"));
}
}
}
}
void CPainter::UnlockSurface()
{
if (SDL_MUSTLOCK(m_pSurface))
{
SDL_UnlockSurface(m_pSurface);
}
}
CRGBColor CPainter::MixColor(const CRGBColor& ColorBase, const CRGBColor& ColorAdd)
{
CRGBColor MixedColor(COLOR_TRANSPARENT);
switch (m_PaintMode)
{
case PAINT_IGNORE:
MixedColor = ColorBase;
break;
case PAINT_REPLACE:
MixedColor = ColorAdd;
break;
case PAINT_NORMAL:
MixedColor = ColorBase.MixNormal(ColorAdd);
break;
case PAINT_AND:
MixedColor = ColorBase & ColorAdd;
break;
case PAINT_OR:
MixedColor = ColorBase | ColorAdd;
break;
case PAINT_XOR:
MixedColor = ColorBase ^ ColorAdd;
break;
case PAINT_ADDITIVE:
MixedColor = ColorBase + ColorAdd;
break;
}
return MixedColor;
}
void CPainter::ReplaceColor(const CRGBColor& NewColor, const CRGBColor& OldColor)
{
for (int y = 0; y < m_pSurface->h; ++y)
{
for (int x = 0; x < m_pSurface->w; ++x)
{
CPoint point(x, y);
if(ReadPoint(point) == OldColor)
{
DrawPoint(point, NewColor);
}
}
}
}
void CPainter::TransparentColor(const CRGBColor& TransparentColor)
{
SDL_SetColorKey(m_pSurface, SDL_TRUE, TransparentColor.SDLColor(m_pSurface->format));
}
}
| 10,550
|
C++
|
.cpp
| 327
| 29.733945
| 134
| 0.704445
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,837
|
wg_button.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_button.cpp
|
// wg_button.cpp
//
// CButton class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_button.h"
#include "wg_application.h"
#include "wg_view.h"
#include "wg_message_server.h"
#include "std_ex.h"
#include <algorithm>
#include <string>
namespace wGui
{
CButton::CButton(const CRect& WindowRect, CWindow* pParent, std::string sText, CFontEngine* pFontEngine) :
CWindow(WindowRect, pParent),
m_eButtonState(UP),
m_MouseButton(0)
{
m_sWindowText = sText;
if (pFontEngine)
{
m_pFontEngine = pFontEngine;
}
else
{
m_pFontEngine = Application().GetDefaultFontEngine();
}
m_pRenderedString.reset(new CRenderedString(
m_pFontEngine, sText, CRenderedString::VALIGN_CENTER, CRenderedString::HALIGN_CENTER));
// m_BackgroundColor = Application().GetDefaultForegroundColor();
m_BackgroundColor = DEFAULT_BUTTON_COLOR;
Application().MessageServer()->RegisterMessageClient(this, CMessage::KEYBOARD_KEYDOWN);
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_BUTTONUP);
Draw();
}
CButton::~CButton()
{
if(m_pParentWindow)
{
m_pParentWindow->RemoveFocusableWidget(this);
}
}
void CButton::SetButtonState(EState eState)
{
if (m_eButtonState != eState)
{
m_eButtonState = eState;
Draw();
}
}
void CButton::Draw() const
{
CWindow::Draw();
if (m_pSDLSurface)
{
CPoint FontCenterPoint = m_WindowRect.SizeRect().Center();
CRect SubRect(m_WindowRect.SizeRect());
CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
CRGBColor FontColor = DEFAULT_TEXT_COLOR;
switch (m_eButtonState)
{
case UP:
Painter.Draw3DRaisedRect(SubRect, DEFAULT_BUTTON_COLOR);
break;
case DOWN:
Painter.Draw3DLoweredRect(SubRect, DEFAULT_BUTTON_COLOR);
FontCenterPoint = FontCenterPoint + CPoint(1, 1);
break;
case DISABLED:
FontColor = DEFAULT_DISABLED_LINE_COLOR;
break;
default:
break;
}
SubRect.Grow(-2);
if (m_bHasFocus)
{
Painter.DrawRect(SubRect, false, COLOR_GRAY);
}
if (m_pRenderedString)
{
m_pRenderedString->Draw(m_pSDLSurface, SubRect, FontCenterPoint, FontColor);
}
}
}
void CButton::SetWindowText(const std::string& sWindowText)
{
m_pRenderedString.reset(new CRenderedString(
m_pFontEngine, sWindowText, CRenderedString::VALIGN_CENTER, CRenderedString::HALIGN_CENTER));
CWindow::SetWindowText(sWindowText);
}
bool CButton::OnMouseButtonDown(CPoint Point, unsigned int Button)
{
bool bResult = CWindow::OnMouseButtonDown(Point, Button);
if (!bResult && m_bVisible && (m_eButtonState == UP) && (m_ClientRect.HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE))
{
SetButtonState(DOWN);
m_MouseButton = Button;
bResult = true;
}
return bResult;
}
bool CButton::OnMouseButtonUp(CPoint Point, unsigned int Button)
{
bool bResult = CWindow::OnMouseButtonUp(Point, Button);
if (!bResult && m_bVisible && (m_eButtonState == DOWN) &&
(m_MouseButton == Button) && (m_ClientRect.HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE))
{
SetButtonState(UP);
CMessage::EMessageType MessageType = CMessage::UNKNOWN;
switch (m_MouseButton)
{
case CMouseMessage::LEFT:
MessageType = CMessage::CTRL_SINGLELCLICK;
break;
case CMouseMessage::RIGHT:
MessageType = CMessage::CTRL_SINGLERCLICK;
break;
case CMouseMessage::MIDDLE:
MessageType = CMessage::CTRL_SINGLEMCLICK;
break;
}
Application().MessageServer()->QueueMessage(new TIntMessage(MessageType, m_pParentWindow, this, 0));
bResult = true;
}
return bResult;
}
bool CButton::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::KEYBOARD_KEYDOWN:
{
CKeyboardMessage* pKeyboardMessage = dynamic_cast<CKeyboardMessage*>(pMessage);
if (pKeyboardMessage && pMessage->Destination() == this)
{
// Forward all key downs to parent
Application().MessageServer()->QueueMessage(new CKeyboardMessage(CMessage::KEYBOARD_KEYDOWN, m_pParentWindow, this,
pKeyboardMessage->ScanCode, pKeyboardMessage->Modifiers, pKeyboardMessage->Key));
}
break;
}
case CMessage::MOUSE_BUTTONUP:
{
CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);
if (pMouseMessage && m_eButtonState == DOWN)
{
SetButtonState(UP);
bHandled = true;
}
break;
}
default :
bHandled = CWindow::HandleMessage(pMessage);
break;
}
}
return bHandled;
}
CPictureButton::CPictureButton(const CRect& WindowRect, CWindow* pParent, std::string sPictureFile) :
CButton(WindowRect, pParent, sPictureFile)
{
m_phBitmap.reset(new CBitmapFileResourceHandle(sPictureFile));
Draw();
}
CPictureButton::CPictureButton(const CRect& WindowRect, CWindow* pParent, const CBitmapResourceHandle& hBitmap) :
CButton(WindowRect, pParent, "<bitmap>")
{
m_phBitmap.reset(new CBitmapResourceHandle(hBitmap));
Draw();
}
CPictureButton::~CPictureButton() = default;
void CPictureButton::SetPicture(std::string sPictureFile)
{
SetPicture(CBitmapFileResourceHandle(sPictureFile));
}
void CPictureButton::SetPicture(const CBitmapResourceHandle& hBitmap)
{
m_phBitmap.reset(new CBitmapResourceHandle(hBitmap));
Draw();
}
void CPictureButton::Draw() const
{
CWindow::Draw();
if (m_pSDLSurface)
{
CRect SubRect(m_WindowRect.SizeRect());
CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
switch (m_eButtonState)
{
case UP:
Painter.Draw3DRaisedRect(SubRect, DEFAULT_BUTTON_COLOR);
break;
case DOWN:
Painter.Draw3DLoweredRect(SubRect, DEFAULT_BUTTON_COLOR);
SubRect = SubRect + CPoint(1, 1);
break;
case DISABLED:
break;
default:
break;
}
SubRect.Grow(-2);
if (m_bHasFocus)
{
Painter.DrawRect(SubRect, false, COLOR_GRAY);
}
SubRect.Grow(-1);
SDL_Rect SourceRect;
SourceRect.x = stdex::safe_static_cast<short int>((m_phBitmap->Bitmap()->w - SubRect.Width()) / 2 < 0 ? 0 : (m_phBitmap->Bitmap()->w - SubRect.Width()) / 2);
SourceRect.y = stdex::safe_static_cast<short int>((m_phBitmap->Bitmap()->h - SubRect.Height()) / 2 < 0 ? 0 : (m_phBitmap->Bitmap()->w - SubRect.Height()) / 2);
SourceRect.w = stdex::safe_static_cast<short int>(std::min(SubRect.Width(), m_phBitmap->Bitmap()->w));
SourceRect.h = stdex::safe_static_cast<short int>(std::min(SubRect.Height(), m_phBitmap->Bitmap()->h));
SDL_Rect DestRect;
DestRect.x = stdex::safe_static_cast<short int>((SubRect.Width() - m_phBitmap->Bitmap()->w) / 2 < 0 ? SubRect.Left() : SubRect.Left() + (SubRect.Width() - m_phBitmap->Bitmap()->w) / 2);
DestRect.y = stdex::safe_static_cast<short int>((SubRect.Height() - m_phBitmap->Bitmap()->h) / 2 < 0 ? SubRect.Top() : SubRect.Top() + (SubRect.Height() - m_phBitmap->Bitmap()->h) / 2);
DestRect.w = stdex::safe_static_cast<short int>(std::min(SubRect.Width(), m_phBitmap->Bitmap()->w));
DestRect.h = stdex::safe_static_cast<short int>(std::min(SubRect.Height(), m_phBitmap->Bitmap()->h));
SDL_BlitSurface(m_phBitmap->Bitmap(), &SourceRect, m_pSDLSurface, &DestRect);
}
}
}
| 7,820
|
C++
|
.cpp
| 243
| 29.411523
| 187
| 0.733077
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,838
|
wg_frame.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_frame.cpp
|
// wg_frame.cpp
//
// CFrame class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_frame.h"
#include "wg_application.h"
#include "log.h"
#include <algorithm>
#include <iostream>
#include <string>
namespace wGui
{
CFrame::CFrame(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine, const std::string& sTitle, bool bResizable) :
CWindow(WindowRect, pParent),
m_TitleBarColor(DEFAULT_TITLEBAR_COLOR),
m_TitleBarTextColor(DEFAULT_TITLEBAR_TEXT_COLOR),
m_iTitleBarHeight(12),
m_bResizable(bResizable),
m_bModal(false),
m_pMenu(nullptr),
m_bDragMode(false)
{
if (pFontEngine) {
m_pFontEngine = pFontEngine;
} else {
m_pFontEngine = Application().GetDefaultFontEngine();
}
m_sWindowText = sTitle;
m_pFrameCloseButton = new CPictureButton(CRect(0, 0, 8, 8),
this, CwgBitmapResourceHandle(Application(), WGRES_X_BITMAP));
m_pRenderedString.reset(new CRenderedString(m_pFontEngine, m_sWindowText, CRenderedString::VALIGN_CENTER));
SetWindowRect(WindowRect); // must be done after the buttons are created, and after the CRenderedString is created
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_BUTTONUP);
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_MOVE);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_SINGLELCLICK);
Application().MessageServer()->RegisterMessageClient(this, CMessage::KEYBOARD_KEYDOWN);
}
CFrame::~CFrame() // virtual
{
if (m_bModal)
{
SetModal(false);
}
}
void CFrame::CloseFrame()
{
Application().MessageServer()->QueueMessage(new CMessage(CMessage::APP_DESTROY_FRAME, nullptr, this));
}
void CFrame::SetModal(bool bModal)
{
m_bModal = bModal;
if (m_bModal) {
Application().SetMouseFocus(this);
Application().SetKeyFocus(this);
} else if (m_pParentWindow) {
Application().SetMouseFocus(m_pParentWindow);
Application().SetKeyFocus(m_pParentWindow);
}
}
void CFrame::Draw() const
{
CWindow::Draw();
if (m_pSDLSurface)
{
CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
CRect SubRect(m_WindowRect.SizeRect());
Painter.Draw3DRaisedRect(SubRect, DEFAULT_BACKGROUND_COLOR);
SubRect.Grow(-2);
if (m_iTitleBarHeight > 0) {
Painter.DrawRect(m_TitleBarRect, true, m_TitleBarColor, m_TitleBarColor);
Painter.Draw3DLoweredRect(m_TitleBarRect, m_TitleBarColor);
CRect TextClipRect(m_TitleBarRect);
TextClipRect.SetRight(TextClipRect.Right() - 16);
TextClipRect.Grow(-1);
if (m_pRenderedString)
{
m_pRenderedString->Draw(m_pSDLSurface, TextClipRect, m_TitleBarRect.TopLeft() + CPoint(6, m_iTitleBarHeight / 2 - 1), m_TitleBarTextColor);
}
}
}
}
void CFrame::PaintToSurface(SDL_Surface& ScreenSurface, SDL_Surface& FloatingSurface, const CPoint& Offset) const
{
if (m_bVisible)
{
SDL_Rect SourceRect = CRect(m_WindowRect.SizeRect()).SDLRect();
if (!m_bDragMode)
{
SDL_Rect DestRect = CRect(m_WindowRect + Offset).SDLRect();
SDL_BlitSurface(m_pSDLSurface, &SourceRect, &ScreenSurface, &DestRect);
CPoint NewOffset = m_ClientRect.TopLeft() + m_WindowRect.TopLeft() + Offset;
for (const auto& child : m_ChildWindows)
{
if (child)
{
child->PaintToSurface(ScreenSurface, FloatingSurface, NewOffset);
}
}
}
else
{
SDL_Rect DestGhostRect = CRect(m_FrameGhostRect + Offset).SDLRect();
// SDL_BlitSurface(m_pSDLSurface, &SourceRect, &ScreenSurface, &DestGhostRect);
// Original line:
SDL_BlitSurface(m_pSDLSurface, &SourceRect, &FloatingSurface, &DestGhostRect);
for (const auto& child : m_ChildWindows)
{
if (child)
{
// (*iter)->PaintToSurface(ScreenSurface, FloatingSurface, m_ClientRect.TopLeft() + m_FrameGhostRect.TopLeft() + Offset);
// Original line:
child->PaintToSurface(FloatingSurface, FloatingSurface, m_ClientRect.TopLeft() + m_FrameGhostRect.TopLeft() + Offset);
}
}
// this is a quick trick to convert the surface to being transparent
// judb there seems to be a problem while dragging the window ; have to find out (has to do with the
// fact that the WindowRect and ClientRect are not at (0,0), there may be a problem with FloatingSurface
// Original lines (together with the lines a bit higher I commented out)
CPainter Painter(&FloatingSurface, CPainter::PAINT_AND);
Painter.DrawRect(m_FrameGhostRect + Offset, true, CRGBColor(0xFF, 0xFF, 0xFF, 0x40), CRGBColor(0xFF, 0xFF, 0xFF, 0xC0));
}
}
}
void CFrame::SetTitleBarHeight(int iTitleBarHeight)
{
m_iTitleBarHeight = iTitleBarHeight;
if (m_iTitleBarHeight > 0) {
delete m_pFrameCloseButton;
m_pFrameCloseButton = new CPictureButton(CRect(0, 0, 8, 8),
this, CwgBitmapResourceHandle(Application(), WGRES_X_BITMAP));
} else {
delete m_pFrameCloseButton;
m_pFrameCloseButton = nullptr;
}
SetWindowRect(m_WindowRect);
}
void CFrame::AttachMenu(CMenu* pMenu)
{
delete m_pMenu;
m_pMenu = pMenu;
if (m_pMenu)
{
int iMenuHeight = m_pMenu->GetWindowRect().Height();
m_pMenu->SetWindowRect(CRect(0, -iMenuHeight, m_WindowRect.Width() - 1, -1));
m_ClientRect.SetTop(iMenuHeight + 1);
m_ClientRect.ClipTo(m_WindowRect.SizeRect());
}
else
{
m_ClientRect = m_WindowRect.SizeRect();
}
}
void CFrame::SetWindowRect(const CRect& WindowRect) // virtual
{
m_TitleBarRect = CRect(3, 2, WindowRect.Width() - 4, m_iTitleBarHeight);
if (m_pFrameCloseButton)
m_pFrameCloseButton->SetWindowRect(CRect(CPoint(WindowRect.Width() - 15, (-m_iTitleBarHeight / 2) - 5), 9, 9));
m_ClientRect = CRect(2, m_iTitleBarHeight + 2, WindowRect.Width() - 1, WindowRect.Height() - 1);
// SetWindowRect() must be called last since it calls Draw(), and needs the titlebar rect and such to be set first
CWindow::SetWindowRect(WindowRect);
}
void CFrame::SetWindowText(const std::string& sWindowText) // virtual
{
m_pRenderedString.reset(new CRenderedString(m_pFontEngine, sWindowText, CRenderedString::VALIGN_CENTER));
CWindow::SetWindowText(sWindowText);
}
bool CFrame::OnMouseButtonDown(CPoint Point, unsigned int Button) // virtual
{
bool bResult = CWindow::OnMouseButtonDown(Point, Button);
if (!bResult && m_bVisible && (m_WindowRect.SizeRect().HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE))
{
if (m_TitleBarRect.HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE)
{
m_bDragMode = true;
m_DragPointerStart = Point;
m_FrameGhostRect = m_WindowRect;
Application().MessageServer()->QueueMessage(new CMessage(CMessage::APP_PAINT, nullptr, this));
}
SetNewParent(m_pParentWindow); // This moves the window to the top
bResult = true;
}
return bResult;
}
bool CFrame::HandleMessage(CMessage* pMessage) // virtual
{
bool bHandled = false;
if (pMessage)
{
LOG_DEBUG("CFrame::HandleMessage for " << CMessage::ToString(pMessage->MessageType()));
switch(pMessage->MessageType())
{
case CMessage::MOUSE_MOVE: // intentional fall through
case CMessage::MOUSE_BUTTONUP:
{
CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);
if (pMouseMessage && m_bDragMode)
{
CRect MovedRect = m_WindowRect + (pMouseMessage->Point - m_DragPointerStart);
CRect Bounds = m_pParentWindow->GetClientRect().SizeRect();
// if (MovedRect.Right() > Bounds.Right())
// {
// MovedRect.Move(Bounds.Right() - MovedRect.Right(), 0);
// }
// if (MovedRect.Left() < Bounds.Left())
// {
// MovedRect.Move(Bounds.Left() - MovedRect.Left(), 0);
// }
// if (MovedRect.Bottom() > Bounds.Bottom())
// {
// MovedRect.Move(0, Bounds.Bottom() - MovedRect.Bottom());
// }
// if (MovedRect.Top() < Bounds.Top())
// {
// MovedRect.Move(0, Bounds.Top() - MovedRect.Top());
// }
if (pMessage->MessageType() == CMessage::MOUSE_BUTTONUP)
{
m_WindowRect = MovedRect;
m_bDragMode = false;
bHandled = true;
}
else
{
m_FrameGhostRect = MovedRect;
}
Application().MessageServer()->QueueMessage(new CMessage(CMessage::APP_PAINT, nullptr, this));
}
break;
}
case CMessage::CTRL_SINGLELCLICK:
{
if (pMessage->Destination() == this)
{
if (pMessage->Source() == m_pFrameCloseButton)
{
CloseFrame();
bHandled = true;
}
}
break;
}
case CMessage::KEYBOARD_KEYDOWN:
{
if (m_bVisible && pMessage->Destination() == this) {
CKeyboardMessage* pKeyboardMessage = dynamic_cast<CKeyboardMessage*>(pMessage);
if (pKeyboardMessage) {
switch (pKeyboardMessage->Key) {
case SDLK_ESCAPE:
CloseFrame();
bHandled = true;
break;
case SDLK_TAB:
bHandled = true;
if(pKeyboardMessage->Modifiers & KMOD_SHIFT) {
CFrame::FocusNext(EFocusDirection::BACKWARD);
} else {
CFrame::FocusNext(EFocusDirection::FORWARD);
}
break;
case SDLK_SPACE:
case SDLK_RETURN:
{
CWindow *target = GetFocused();
if (target) {
bHandled = true;
Application().MessageServer()->QueueMessage(new TIntMessage(
CMessage::CTRL_SINGLELCLICK, target->GetAncestor(PARENT), target,
0));
}
break;
}
default:
break;
}
}
}
break;
}
default :
LOG_DEBUG("CFrame::HandleMessage forwarding " << CMessage::ToString(pMessage->MessageType()) << " to CWindow");
bHandled = CWindow::HandleMessage(pMessage);
break;
}
}
return bHandled;
}
void CFrame::AddFocusableWidget(CWindow *pWidget)
{
if (pWidget && pWidget->IsFocusable()) {
// TODO: we can end-up with a non-visible widget being focused. This is not a big issue but still not super cool
//if (find_if(m_FocusableWidgets.begin(), m_FocusableWidgets.end(), [](CWindow *w) -> bool { return w->IsVisible(); }) == m_FocusableWidgets.end()) {
if (m_FocusableWidgets.empty()) {
pWidget->SetHasFocus(true);
}
m_FocusableWidgets.push_back(pWidget);
}
}
void CFrame::RemoveFocusableWidget(CWindow *pWidget)
{
if (pWidget && pWidget->HasFocus()) {
FocusNext(EFocusDirection::FORWARD);
}
// The widget can still have the focus if it's the only focusable one
if (pWidget && pWidget == GetFocused()) {
pWidget->SetHasFocus(false);
}
m_FocusableWidgets.remove(pWidget);
}
CWindow *CFrame::GetFocused() {
auto focused = std::find_if(m_FocusableWidgets.begin(), m_FocusableWidgets.end(), [](CWindow *w) { return w->HasFocus(); });
if(focused == m_FocusableWidgets.end()) {
return nullptr;
}
return *focused;
}
void CFrame::FocusNext(EFocusDirection direction, bool loop)
{
CWindow *to_unfocus = nullptr;
auto loop_body = [&to_unfocus](CWindow* w) {
if(to_unfocus != nullptr) {
if(w->IsVisible()) {
to_unfocus->SetHasFocus(false);
w->SetHasFocus(true);
to_unfocus = nullptr;
}
} else if(w->HasFocus()) {
to_unfocus = w;
}
};
do {
if(direction == EFocusDirection::BACKWARD)
std::for_each(m_FocusableWidgets.rbegin(), m_FocusableWidgets.rend(), loop_body);
else
std::for_each(m_FocusableWidgets.begin(), m_FocusableWidgets.end(), loop_body);
} while(loop &&
(loop = !loop // Ensure we loop only once even if there's just one focusable widget
|| to_unfocus)); // If to_unfocus is not null, it means the focused widget is the last one eligible and we need to loop
}
}
| 12,912
|
C++
|
.cpp
| 357
| 30.593838
| 153
| 0.663123
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
753,839
|
wg_timer.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_timer.cpp
|
// wg_timer.cpp
//
// CTimer class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_timer.h"
#include "wg_application.h"
namespace wGui
{
Uint32 TimerCallback(Uint32 Interval, void* param)
{
return static_cast<CTimer*>(param)->TimerHit(Interval);
}
CTimer::CTimer(CApplication& application, CMessageClient* pOwner) :
CMessageClient(application),
m_TimerID(0),
m_bAutoRestart(false),
m_iCounter(0),
m_pOwner(pOwner)
{ }
CTimer::~CTimer()
{
StopTimer();
}
void CTimer::StartTimer(unsigned long int Interval, bool bAutoRestart)
{
m_bAutoRestart = bAutoRestart;
if (m_TimerID != 0)
{
StopTimer();
}
m_TimerID = SDL_AddTimer(Interval, &TimerCallback, this);
}
void CTimer::StopTimer()
{
if (m_TimerID)
{
SDL_RemoveTimer(m_TimerID);
m_TimerID = 0;
}
}
Uint32 CTimer::TimerHit(Uint32 Interval)
{
m_iCounter++;
Application().MessageServer()->QueueMessage(new TIntMessage(CMessage::CTRL_TIMER, m_pOwner, this, m_iCounter));
if (!m_bAutoRestart)
{
StopTimer();
}
return Interval;
}
bool CTimer::HandleMessage(CMessage* /*pMessage*/)
{
bool bHandled = false;
return bHandled;
}
}
| 1,910
|
C++
|
.cpp
| 74
| 24.094595
| 112
| 0.75427
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,840
|
wg_scrollbar.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_scrollbar.cpp
|
// wg_scrollbar.cpp
//
// CScrollBar class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_application.h"
#include "wg_scrollbar.h"
#include "wg_message_server.h"
#include "wg_error.h"
#include "wg_resources.h"
#include "std_ex.h"
namespace wGui
{
CScrollBar::CScrollBar(const CRect& WindowRect, CWindow* pParent, EScrollBarType ScrollBarType) :
CRangeControl<int>(WindowRect, pParent, 0, 100, 1, 0),
m_ScrollBarType(ScrollBarType),
m_iJumpAmount(5),
m_bDragging(false)
{
m_BackgroundColor = Application().GetDefaultForegroundColor();
switch (m_ScrollBarType)
{
case VERTICAL:
// m_ClientRect is the area that doesn't contain the buttons.
// The height of the button is the width of the bar (they are square).
m_ClientRect = CRect(0, m_WindowRect.Width(), m_WindowRect.Width() - 1, m_WindowRect.Height() - m_WindowRect.Width() - 1);
m_pBtnUpLeft = new CPictureButton(CRect(0, -m_ClientRect.Width(), m_ClientRect.Width() - 1, -1),
this, CwgBitmapResourceHandle(Application(), WGRES_UP_ARROW_BITMAP));
m_pBtnDownRight = new CPictureButton(
CRect(0, m_ClientRect.Height() + 1, m_ClientRect.Width() - 1, m_ClientRect.Height() + m_ClientRect.Width()),
this, CwgBitmapResourceHandle(Application(), WGRES_DOWN_ARROW_BITMAP));
break;
case HORIZONTAL:
// m_ClientRect is the area that doesn't contain the buttons.
// The width of the button is the height of the bar (they are square).
m_ClientRect = CRect(m_WindowRect.Height(), 0, m_WindowRect.Width() - m_WindowRect.Height() - 1, m_WindowRect.Height() - 1);
m_pBtnUpLeft = new CPictureButton(CRect(-m_ClientRect.Height(), 0, -1, m_ClientRect.Height() - 1),
this, CwgBitmapResourceHandle(Application(), WGRES_LEFT_ARROW_BITMAP));
m_pBtnDownRight = new CPictureButton(
CRect(m_ClientRect.Width() + 1, 0, m_ClientRect.Width() + m_ClientRect.Height(), m_ClientRect.Height() - 1),
this, CwgBitmapResourceHandle(Application(), WGRES_RIGHT_ARROW_BITMAP));
break;
default:
throw(Wg_Ex_App("Unrecognized ScrollBar Type.", "CScrollBar::CScrollBar"));
break;
}
m_ThumbRect = m_ClientRect;
RepositionThumb();
Application().MessageServer()->RegisterMessageClient(this, CMessage::KEYBOARD_KEYDOWN);
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_BUTTONUP);
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_MOVE);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_SINGLELCLICK);
Draw();
}
CScrollBar::~CScrollBar() = default;
void CScrollBar::SetValue(int iValue, bool bRedraw, bool bNotify)
{
CRangeControl<int>::SetValue(iValue, false, bNotify);
RepositionThumb();
if (bRedraw)
{
Draw();
}
}
void CScrollBar::SetMinLimit(int minLimit)
{
CRangeControl<int>::SetMinLimit(minLimit);
RepositionThumb();
Draw();
}
void CScrollBar::SetMaxLimit(int maxLimit)
{
CRangeControl<int>::SetMaxLimit(maxLimit);
RepositionThumb();
Draw();
}
void CScrollBar::Draw() const
{
CWindow::Draw();
if (m_pSDLSurface)
{
CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
Painter.DrawRect(m_WindowRect.SizeRect(), false, m_BackgroundColor * 0.7);
if (m_MinLimit != m_MaxLimit)
{
CRect SubRect(m_ThumbRect);
Painter.DrawRect(SubRect, true, DEFAULT_BUTTON_COLOR, DEFAULT_BUTTON_COLOR);
Painter.Draw3DRaisedRect(SubRect, DEFAULT_BUTTON_COLOR);
}
}
}
void CScrollBar::SetWindowRect(const CRect& WindowRect)
{
CWindow::SetWindowRect(WindowRect);
// Resposition the thumb rect and the button controls
switch (m_ScrollBarType)
{
case VERTICAL:
{
m_ClientRect = CRect(0, m_WindowRect.Width(), m_WindowRect.Width() - 1, m_WindowRect.Height() - m_WindowRect.Width() - 1);
m_pBtnUpLeft->SetWindowRect(CRect(0, -m_ClientRect.Width(), m_ClientRect.Width() - 1, -1));
m_pBtnDownRight->SetWindowRect(CRect(0, m_ClientRect.Height() + 1, m_ClientRect.Width() - 1, m_ClientRect.Height() + m_ClientRect.Width()));
break;
}
case HORIZONTAL:
{
m_ClientRect = CRect(m_WindowRect.Height(), 0, m_WindowRect.Width() - m_WindowRect.Height() - 1, m_WindowRect.Height() - 1);
m_pBtnUpLeft->SetWindowRect(CRect(-m_ClientRect.Height(), 0, -1, m_ClientRect.Height() - 1));
m_pBtnDownRight->SetWindowRect(CRect(m_ClientRect.Width() + 1, 0, m_ClientRect.Width() + m_ClientRect.Height(), m_ClientRect.Height() - 1));
break;
}
default:
throw(Wg_Ex_App("Unrecognized ScrollBar Type.", "CScrollBar::SetWindowRect"));
break;
}
SetValue(m_Value);
}
void CScrollBar::MoveWindow(const CPoint& MoveDistance)
{
CWindow::MoveWindow(MoveDistance);
m_ThumbRect = m_ThumbRect + MoveDistance;
}
bool CScrollBar::HandleMouseScroll(unsigned int Button)
{
if (Button == CMouseMessage::WHEELUP)
{
Decrement();
return true;
}
if (Button == CMouseMessage::WHEELDOWN)
{
Increment();
return true;
}
return false;
}
bool CScrollBar::OnMouseButtonDown(CPoint Point, unsigned int Button)
{
bool bResult = CWindow::OnMouseButtonDown(Point, Button);
if (!bResult && m_bVisible && m_ClientRect.HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE)
{
if (HandleMouseScroll(Button)) {
return true;
}
if (Button == CMouseMessage::LEFT)
{
switch (m_ThumbRect.HitTest(ViewToWindow(Point)))
{
case CRect::RELPOS_INSIDE:
m_bDragging = true;
break;
case CRect::RELPOS_ABOVE:
case CRect::RELPOS_LEFT:
SetValue(m_Value - m_iJumpAmount );
break;
case CRect::RELPOS_BELOW:
case CRect::RELPOS_RIGHT:
SetValue(m_Value + m_iJumpAmount );
break;
}
bResult = true;
}
}
return bResult;
}
void CScrollBar::SetIsFocusable(bool bFocusable)
{
m_pBtnUpLeft->SetIsFocusable(bFocusable);
m_pBtnDownRight->SetIsFocusable(bFocusable);
}
bool CScrollBar::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::KEYBOARD_KEYDOWN:
{
CKeyboardMessage* pKeyboardMessage = dynamic_cast<CKeyboardMessage*>(pMessage);
if (pKeyboardMessage && pMessage->Destination() == this)
{
// Forward all key downs to parent
Application().MessageServer()->QueueMessage(new CKeyboardMessage(CMessage::KEYBOARD_KEYDOWN, m_pParentWindow, this,
pKeyboardMessage->ScanCode, pKeyboardMessage->Modifiers, pKeyboardMessage->Key));
}
break;
}
case CMessage::MOUSE_BUTTONUP:
{
CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);
if (pMouseMessage && m_bDragging && pMouseMessage->Button == CMouseMessage::LEFT)
{
m_bDragging = false;
Application().MessageServer()->QueueMessage(new TIntMessage(CMessage::CTRL_VALUECHANGE, m_pParentWindow, this, m_Value));
bHandled = true;
}
break;
}
case CMessage::MOUSE_MOVE:
if (m_bDragging)
{
CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);
if (pMouseMessage)
{
int iOldPosition = m_Value;
switch (m_ScrollBarType)
{
case VERTICAL:
m_Value = ConstrainValue((ViewToWindow(pMouseMessage->Point).YPos() - m_ClientRect.Top() - m_ThumbRect.Height() / 2) *
(m_MaxLimit - m_MinLimit) / (m_ClientRect.Height() - m_ThumbRect.Height()) + m_MinLimit);
break;
case HORIZONTAL:
m_Value = ConstrainValue((ViewToWindow(pMouseMessage->Point).XPos() - m_ClientRect.Left() - m_ThumbRect.Width() / 2) *
(m_MaxLimit - m_MinLimit) / (m_ClientRect.Width() - m_ThumbRect.Width()) + m_MinLimit);
break;
default:
throw(Wg_Ex_App("Unrecognized ScrollBar Type.", "CScrollBar::HandleMessage"));
break;
}
if (iOldPosition != m_Value)
{
Application().MessageServer()->QueueMessage(new TIntMessage(CMessage::CTRL_VALUECHANGING, m_pParentWindow, this, m_Value));
RepositionThumb();
Draw();
}
}
}
break;
case CMessage::CTRL_SINGLELCLICK:
{
if (pMessage->Destination() == this)
{
if (pMessage->Source() == m_pBtnUpLeft)
{
Decrement();
bHandled = true;
}
else if (pMessage->Source() == m_pBtnDownRight)
{
Increment();
bHandled = true;
}
}
break;
}
default :
bHandled = CWindow::HandleMessage(pMessage);
break;
}
}
return bHandled;
}
void CScrollBar::RepositionThumb()
{
int range = m_MaxLimit - m_MinLimit;
int value = m_Value - m_MinLimit;
int position = 0;
switch (m_ScrollBarType)
{
case VERTICAL:
{
int iThumbHeight = m_ClientRect.Height() / (range + 1);
if (iThumbHeight < 10)
{
iThumbHeight = 10;
}
if (range != 0) {
position = (m_ClientRect.Height() - iThumbHeight) * value / range;
}
m_ThumbRect.SetTop(m_ClientRect.Top() + position);
m_ThumbRect.SetBottom(m_ThumbRect.Top() + iThumbHeight);
break;
}
case HORIZONTAL:
{
int iThumbWidth = m_ClientRect.Width() / (range + 1);
if (iThumbWidth < 10)
{
iThumbWidth = 10;
}
if (range != 0) {
position = (m_ClientRect.Width() - iThumbWidth) * value / range;
}
m_ThumbRect.SetLeft(m_ClientRect.Left() + position);
m_ThumbRect.SetRight(m_ThumbRect.Left() + iThumbWidth);
break;
}
default:
throw(Wg_Ex_App("Unrecognized ScrollBar Type.", "CScrollBar::RepositionThumb"));
break;
}
}
}
| 10,159
|
C++
|
.cpp
| 311
| 28.913183
| 142
| 0.700601
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,841
|
wg_resource_handle.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_resource_handle.cpp
|
// wg_resource_handle.cpp
//
// Resource Handle implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_resource_handle.h"
#include "wg_error.h"
#include "wg_application.h"
#include <map>
#include <string>
#include "log.h"
namespace wGui
{
std::map<TResourceId, unsigned int> CResourceHandle::m_RefCountMap;
std::map<TResourceId, SDL_Surface*> CBitmapResourceHandle::m_BitmapMap;
std::map<TResourceId, std::string> CStringResourceHandle::m_StringMap;
std::map<TResourceId, SDL_Cursor*> CCursorResourceHandle::m_SDLCursorMap;
TResourceId CResourceHandle::m_NextUnusedResourceId = 10000;
CResourceHandle::CResourceHandle(TResourceId resId) :
m_ResourceId(resId)
{
if (m_ResourceId == AUTO_CREATE_RESOURCE_ID)
{
while (m_RefCountMap.find(m_NextUnusedResourceId) != m_RefCountMap.end())
{
++m_NextUnusedResourceId;
}
m_ResourceId = m_NextUnusedResourceId;
++m_NextUnusedResourceId;
}
if (m_RefCountMap.find(m_ResourceId) == m_RefCountMap.end() || m_RefCountMap[m_ResourceId] == 0)
{
m_RefCountMap[m_ResourceId] = 0;
}
++m_RefCountMap[m_ResourceId];
}
CResourceHandle::CResourceHandle(const CResourceHandle& resHandle)
{
m_ResourceId = resHandle.m_ResourceId;
++m_RefCountMap[m_ResourceId];
}
CResourceHandle::~CResourceHandle()
{
if (GetRefCount() > 0)
{
--m_RefCountMap[m_ResourceId];
}
else
{
LOG_ERROR("CResourceHandle::~CResourceHandle : Trying to decrement refcount of zero!");
}
}
CBitmapResourceHandle::~CBitmapResourceHandle()
{
if (GetRefCount() == 1 && m_BitmapMap.find(m_ResourceId) != m_BitmapMap.end())
{
SDL_FreeSurface(m_BitmapMap[m_ResourceId]);
m_BitmapMap.erase(m_ResourceId);
}
}
SDL_Surface* CBitmapResourceHandle::Bitmap() const
{
return (m_BitmapMap.find(m_ResourceId) != m_BitmapMap.end()) ? m_BitmapMap[m_ResourceId] : nullptr;
}
CBitmapFileResourceHandle::CBitmapFileResourceHandle(std::string sFilename) :
CBitmapResourceHandle(AUTO_CREATE_RESOURCE_ID),
m_sFilename(std::move(sFilename))
{
if (m_BitmapMap.find(m_ResourceId) == m_BitmapMap.end())
{
SDL_Surface* pSurface = SDL_LoadBMP(m_sFilename.c_str());
if (!pSurface)
{
throw(Wg_Ex_App("Unable to load bitmap: " + m_sFilename, "CBitmapFileResourceHandle::CBitmapFileResourceHandle"));
}
m_BitmapMap[m_ResourceId] = pSurface;
}
}
CStringResourceHandle::~CStringResourceHandle()
{
if (GetRefCount() == 1 && m_StringMap.find(m_ResourceId) != m_StringMap.end())
{
m_StringMap.erase(m_ResourceId);
}
}
std::string CStringResourceHandle::String() const
{
return (m_StringMap.find(m_ResourceId) != m_StringMap.end()) ? m_StringMap[m_ResourceId] : "";
}
CCursorResourceHandle::~CCursorResourceHandle()
{
if (GetRefCount() == 1 && m_SDLCursorMap.find(m_ResourceId) != m_SDLCursorMap.end())
{
SDL_FreeCursor(m_SDLCursorMap[m_ResourceId]);
m_SDLCursorMap.erase(m_ResourceId);
}
}
SDL_Cursor* CCursorResourceHandle::Cursor() const
{
return (m_SDLCursorMap.find(m_ResourceId) != m_SDLCursorMap.end()) ? m_SDLCursorMap[m_ResourceId] : nullptr;
}
}
| 3,793
|
C++
|
.cpp
| 119
| 30.016807
| 117
| 0.75692
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,842
|
wg_listbox.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_listbox.cpp
|
// wg_listbox.cpp
//
// CListBox class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_listbox.h"
#include "wg_application.h"
#include "wg_message_server.h"
#include "wg_error.h"
#include "std_ex.h"
namespace wGui
{
CListBox::CListBox(const CRect& WindowRect, CWindow* pParent, bool bSingleSelection, unsigned int iItemHeight, CFontEngine* pFontEngine) :
CWindow(WindowRect, pParent),
m_iItemHeight(iItemHeight),
m_iFocusedItem(0),
m_bSingleSelection(bSingleSelection),
m_pDropDown(nullptr)
{
if (pFontEngine)
{
m_pFontEngine = pFontEngine;
}
else
{
m_pFontEngine = Application().GetDefaultFontEngine();
}
CRect ScrollbarRect(m_WindowRect.SizeRect());
ScrollbarRect.Grow(-1);
m_pVScrollbar = new CScrollBar(
CRect(ScrollbarRect.Right() - 12, ScrollbarRect.Top(), ScrollbarRect.Right() + 1, ScrollbarRect.Bottom()) - CPoint(2, 2) /* client adjustment */,
this, CScrollBar::VERTICAL),
m_pVScrollbar->SetMaxLimit(0);
m_ClientRect = CRect(2, 2, m_WindowRect.Width() - 16, m_WindowRect.Height() - 2);
m_BackgroundColor = COLOR_WHITE;
Application().MessageServer()->RegisterMessageClient(this, CMessage::KEYBOARD_KEYDOWN);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_VALUECHANGE);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_VALUECHANGING);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_GAININGKEYFOCUS);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_LOSINGKEYFOCUS);
Draw();
}
CListBox::~CListBox() = default;
void CListBox::SetItemHeight(unsigned int iItemHeight)
{
m_iItemHeight = iItemHeight;
Draw();
}
unsigned int CListBox::AddItem(SListItem ListItem)
{
m_Items.push_back(ListItem);
m_SelectedItems.push_back(false);
m_RenderedStrings.emplace_back(m_pFontEngine, ListItem.sItemText, CRenderedString::VALIGN_TOP, CRenderedString::HALIGN_LEFT);
UpdateMaxLimit();
Draw();
return m_Items.size();
}
unsigned int CListBox::AddItems(std::vector<SListItem> ListItems)
{
m_Items.insert(m_Items.end(), ListItems.begin(), ListItems.end());
m_SelectedItems.resize(m_SelectedItems.size() + ListItems.size());
for (const auto& item : ListItems) {
m_RenderedStrings.emplace_back(m_pFontEngine, item.sItemText, CRenderedString::VALIGN_TOP, CRenderedString::HALIGN_LEFT);
}
UpdateMaxLimit();
Draw();
return m_Items.size();
}
void CListBox::RemoveItem(unsigned int iItemIndex)
{
if (iItemIndex < m_SelectedItems.size())
{
m_Items.erase(m_Items.begin() + iItemIndex);
m_SelectedItems.erase(m_SelectedItems.begin() + iItemIndex);
UpdateMaxLimit();
Draw();
}
}
void CListBox::ClearItems()
{
m_Items.clear();
m_SelectedItems.clear();
m_RenderedStrings.clear();
m_pVScrollbar->SetMaxLimit(0);
m_pVScrollbar->SetValue(0, false, false);
Draw();
}
int CListBox::getFirstSelectedIndex() {
for (unsigned int i = 0; i < m_Items.size(); i ++) {
if (IsSelected(i)) {
return i;
}
}
return -1;
}
void CListBox::SetPosition(int iItemIndex, EPosition ePosition)
{
switch (ePosition) {
case UP:
m_pVScrollbar->SetValue(iItemIndex, /*bRedraw=*/false, /*bNotify=*/false);
break;
case CENTER:
{
int boxsize = m_ClientRect.Height() / m_iItemHeight;
m_pVScrollbar->SetValue(iItemIndex-boxsize/2, /*bRedraw=*/false, /*bNotify=*/false);
break;
}
break;
case DOWN:
{
int boxsize = m_ClientRect.Height() / m_iItemHeight;
m_pVScrollbar->SetValue(iItemIndex-boxsize+1, /*bRedraw=*/false, /*bNotify=*/false);
break;
}
default:
throw Wg_Ex_App("Unrecognized ListBox position.", "CListBox::SetPosition");
}
}
void CListBox::SetSelection(unsigned int iItemIndex, bool bSelected, bool bNotify)
{
if (iItemIndex < m_SelectedItems.size())
{
if (m_bSingleSelection)
{
SetAllSelections(false);
}
m_SelectedItems.at(iItemIndex) = bSelected;
CWindow* pDestination = m_pParentWindow;
if (m_pDropDown)
{
pDestination = m_pDropDown;
}
if (bNotify)
{
Application().MessageServer()->QueueMessage(new TIntMessage(CMessage::CTRL_VALUECHANGE, pDestination, this, m_iFocusedItem));
}
Draw();
}
}
void CListBox::SetAllSelections(bool bSelected)
{
for (unsigned int i = 0; i < m_Items.size(); ++i)
{
m_SelectedItems.at(i) = bSelected;
}
}
void CListBox::SetFocus(unsigned int iItemIndex) {
m_iFocusedItem = iItemIndex;
}
void CListBox::SetDropDown(CWindow* pDropDown)
{
m_pDropDown = pDropDown;
if (pDropDown == nullptr) {
SetIsFocusable(true);
} else {
SetIsFocusable(false);
}
}
void CListBox::Draw() const
{
CWindow::Draw();
if (m_pSDLSurface)
{
CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
Painter.DrawRect(m_WindowRect.SizeRect(), false, COLOR_DARKGRAY);
int iStartIndex = m_pVScrollbar->GetValue();
for (unsigned int i = iStartIndex; i < m_Items.size(); ++i)
{
CRect ItemRect(m_ClientRect.Left(), m_ClientRect.Top() + (i - iStartIndex) * m_iItemHeight,
m_ClientRect.Right(), m_ClientRect.Top() + (i - iStartIndex + 1) * m_iItemHeight - 1);
if (ItemRect.Overlaps(m_ClientRect))
{
ItemRect.ClipTo(m_ClientRect);
ItemRect.SetBottom(ItemRect.Bottom() - 1);
if (m_SelectedItems.at(i))
{
Painter.DrawRect(ItemRect, true, Application().GetDefaultSelectionColor(), Application().GetDefaultSelectionColor());
}
if (i == m_iFocusedItem && Application().GetKeyFocus() == this)
{
ItemRect.Grow(1);
Painter.DrawRect(ItemRect, false, COLOR_DARKGRAY);
ItemRect.Grow(-1);
}
ItemRect.Grow(-1);
m_RenderedStrings.at(i).Draw(m_pSDLSurface, ItemRect, ItemRect.TopLeft() + CPoint(0, 1), m_Items[i].ItemColor);
}
else
{
break;
}
}
}
m_pVScrollbar->Draw();
}
void CListBox::SetWindowRect(const CRect& WindowRect)
{
CWindow::SetWindowRect(WindowRect);
m_ClientRect = CRect(2, 2, m_WindowRect.Width() - 16, m_WindowRect.Height() - 2);
CRect ScrollbarRect(m_WindowRect.SizeRect());
ScrollbarRect.Grow(-1);
UpdateMaxLimit();
m_pVScrollbar->SetWindowRect(
CRect(ScrollbarRect.Right() - 12, ScrollbarRect.Top(), ScrollbarRect.Right() + 1, ScrollbarRect.Bottom()) - CPoint(2, 2) /* client adjustment */);
}
void CListBox::PaintToSurface(SDL_Surface& ScreenSurface, SDL_Surface& FloatingSurface, const CPoint& Offset) const
{
if (m_pDropDown)
{
if (m_bVisible)
{
SDL_Rect SourceRect = CRect(m_WindowRect.SizeRect()).SDLRect();
SDL_Rect DestRect = CRect(m_WindowRect + Offset).SDLRect();
SDL_BlitSurface(m_pSDLSurface, &SourceRect, &FloatingSurface, &DestRect);
CPoint NewOffset = m_ClientRect.TopLeft() + m_WindowRect.TopLeft() + Offset;
for (const auto& child : m_ChildWindows)
{
child->PaintToSurface(FloatingSurface, FloatingSurface, NewOffset);
}
}
}
else
{
CWindow::PaintToSurface(ScreenSurface, FloatingSurface, Offset);
}
}
bool CListBox::OnMouseButtonDown(CPoint Point, unsigned int Button)
{
CPoint WindowPoint(ViewToWindow(Point));
if (CWindow::OnMouseButtonDown(Point, Button)) {
return true;
}
if (!m_bVisible) {
return false;
}
if (m_WindowRect.SizeRect().HitTest(WindowPoint) != CRect::RELPOS_INSIDE) {
return false;
}
if (m_pVScrollbar->HandleMouseScroll(Button)) {
return true;
}
if (Button == CMouseMessage::LEFT && Application().GetKeyFocus() != this)
{
Application().SetKeyFocus(this);
}
if (Button == CMouseMessage::LEFT && !m_Items.empty()) {
// Prep the new selection
// judb m_iFocusedItem should be <= the number of items in the listbox (0-based, so m_Items.size() -1)
m_iFocusedItem = std::min((WindowPoint.YPos() + m_ClientRect.Top()) / m_iItemHeight + m_pVScrollbar->GetValue(), stdex::safe_static_cast<unsigned int>(m_Items.size()) - 1);
return true;
}
return false;
}
bool CListBox::OnMouseButtonUp(CPoint Point, unsigned int Button)
{
bool bResult = CWindow::OnMouseButtonUp(Point, Button);
CPoint WindowPoint(ViewToWindow(Point));
if (!bResult && m_bVisible && (Button == CMouseMessage::LEFT) && (m_ClientRect.HitTest(WindowPoint) == CRect::RELPOS_INSIDE))
{
// judb m_iFocusedItem should be <= the number of items in the listbox (0-based, so m_Items.size() - 1)
if (m_iFocusedItem == std::min(((WindowPoint.YPos() - m_ClientRect.Top()) / m_iItemHeight + m_pVScrollbar->GetValue()), stdex::safe_static_cast<unsigned int>(m_Items.size()) - 1))
{
SetSelection(m_iFocusedItem, !IsSelected(m_iFocusedItem));
}
bResult = true;
}
return bResult;
}
bool CListBox::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::CTRL_GAININGKEYFOCUS: // intentional fall through
case CMessage::CTRL_LOSINGKEYFOCUS:
Draw();
break;
case CMessage::KEYBOARD_KEYDOWN:
{
CKeyboardMessage* pKeyMsg = dynamic_cast<CKeyboardMessage*>(pMessage);
if (pKeyMsg && pMessage->Destination() == this)
{
switch (pKeyMsg->Key)
{
case SDLK_DOWN:
{
if (m_iFocusedItem + 1 < Size())
{
m_iFocusedItem++;
int diff = m_iFocusedItem - m_pVScrollbar->GetValue();
if (m_iItemHeight * (m_pVScrollbar->GetValue() + diff + 1) > static_cast<unsigned int>(m_ClientRect.Height()))
{
m_pVScrollbar->SetValue(m_pVScrollbar->GetValue() + 1);
}
Draw();
bHandled = true;
}
break;
}
case SDLK_UP:
{
if ( m_iFocusedItem > 0 )
{
m_iFocusedItem--;
if (m_iFocusedItem < static_cast<unsigned int>(m_pVScrollbar->GetValue()))
{
m_pVScrollbar->SetValue(m_pVScrollbar->GetValue() - 1);
}
Draw();
bHandled = true;
}
break;
}
case SDLK_PAGEDOWN:
{
unsigned int nSize = Size() - 1;
unsigned int nItemsPerPage = m_ClientRect.Height() / m_iItemHeight;
if (m_iFocusedItem + nItemsPerPage < nSize)
{
m_iFocusedItem += nItemsPerPage;
}
else
{
m_iFocusedItem = nSize;
}
m_pVScrollbar->SetValue(m_iFocusedItem);
Draw();
bHandled=true;
break;
}
case SDLK_PAGEUP:
{
int nItemsPerPage = m_ClientRect.Height() / m_iItemHeight;
if (m_iFocusedItem - nItemsPerPage > 0)
{
m_iFocusedItem -= nItemsPerPage;
}
else
{
m_iFocusedItem = 0;
}
m_pVScrollbar->SetValue(m_iFocusedItem);
Draw();
bHandled=true;
break;
}
case SDLK_RETURN: // intentional fall through
case SDLK_SPACE:
{
if (! m_Items.empty())
{
SetSelection(m_iFocusedItem, !IsSelected(m_iFocusedItem));
Draw();
}
bHandled = true;
break;
}
default:
{
// Not for us - let parent handle it
Application().MessageServer()->QueueMessage(new CKeyboardMessage(CMessage::KEYBOARD_KEYDOWN, m_pParentWindow, this,
pKeyMsg->ScanCode, pKeyMsg->Modifiers, pKeyMsg->Key));
bHandled=false;
break;
}
}
}
break;
}
case CMessage::CTRL_VALUECHANGE:
case CMessage::CTRL_VALUECHANGING:
{
if (pMessage->Source() == m_pVScrollbar)
{
Draw();
bHandled = true;
}
break;
}
default :
bHandled = CWindow::HandleMessage(pMessage);
break;
}
}
return bHandled;
}
void CListBox::UpdateMaxLimit()
{
int iMax = m_Items.empty() ? 0 : m_Items.size() - 1;
m_pVScrollbar->SetMaxLimit(stdex::MaxInt(iMax - (m_ClientRect.Height() / m_iItemHeight) + 1, 0));
}
}
| 12,442
|
C++
|
.cpp
| 411
| 26.291971
| 181
| 0.686687
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,843
|
wg_point.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_point.cpp
|
// wg_point.cpp
//
// CPoint class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_point.h"
namespace wGui
{
// CPoint class
// add the points
CPoint CPoint::operator+(const CPoint& p) const
{
CPoint result;
result.SetX(m_XPos + p.XPos());
result.SetY(m_YPos + p.YPos());
return result;
}
// subtract the points
CPoint CPoint::operator-(const CPoint& p) const
{
CPoint result;
result.SetX(m_XPos - p.XPos());
result.SetY(m_YPos - p.YPos());
return result;
}
// assignment operator
CPoint& CPoint::operator=(const CPoint& p)
{
m_XPos = p.XPos();
m_YPos = p.YPos();
return *this;
}
}
| 1,397
|
C++
|
.cpp
| 50
| 26.42
| 74
| 0.741742
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,844
|
CapriceAbout.cpp
|
ColinPitrat_caprice32/src/gui/src/CapriceAbout.cpp
|
// 'About' box for Caprice32
// Inherited from CMessageBox
#include "CapriceAbout.h"
#include "cap32.h"
#include <string>
#include "log.h"
#include "wg_error.h"
// CPC emulation properties, defined in cap32.h:
extern t_CPC CPC;
namespace wGui {
static const std::string shortcuts = R"(F1 - Menu / Pause
F2 - Fullscreen
F3 - Save screenshot
F4 - Tape play
F5 - Reset
F6 - Multiface II Stop
F7 - Joystick emulation
F8 - Display FPS
F9 - Limit speed
F10 - Quit
Shift + F1 - Virtual keyboard
Shift + F2 - Developers' tools
Shift + F3 - Save machine snapshot youhou
Shift + F4 - Load last snapshot
Shift + F7 - Activate phazer)";
CapriceAbout::CapriceAbout(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine) :
CMessageBox(WindowRect, pParent, pFontEngine, "About Caprice32", "", CMessageBox::BUTTON_OK)
{
SetModal(true);
// Override here: specify position of label ourselves:
#ifdef HASH
std::string commit_hash = std::string(HASH);
#else
std::string commit_hash;
#endif
m_pMessageLabel = new CLabel(CPoint(5, 70), this, VERSION_STRING + (commit_hash.empty()?"":"-"+commit_hash.substr(0, 16)));
m_pTextBox = new CTextBox(CRect(10, 90, 210, 200), this);
m_pTextBox->SetWindowText(shortcuts);
m_pTextBox->SetReadOnly(true);
try {
m_pPicture = new CPicture(CRect(CPoint(18, 5), 162, 62), this, CPC.resources_path + "/cap32logo.bmp", true);
} catch (Wg_Ex_App &e) {
// we don't want to stop the program if we can't load the picture, so just print the error and keep going
LOG_ERROR("CapriceAbout::CapriceAbout: Couldn't load cap32logo.bmp: " << e.std_what());
}
}
}
| 1,611
|
C++
|
.cpp
| 47
| 32.510638
| 124
| 0.730893
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,845
|
wg_checkbox.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_checkbox.cpp
|
// wg_checkbox.cpp
//
// CCheckBox class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_checkbox.h"
#include "wg_application.h"
#include "log.h"
namespace wGui
{
CCheckBox::CCheckBox(const CRect& WindowRect, CWindow* pParent) :
CWindow(WindowRect, pParent),
m_eCheckBoxState(UNCHECKED),
m_bReadOnly(false),
m_MouseButton(0),
m_hBitmapCheck(CwgBitmapResourceHandle(Application(), WGRES_CHECK_BITMAP))
{
m_BackgroundColor = DEFAULT_CHECKBOX_BACK_COLOR;
Application().MessageServer()->RegisterMessageClient(this, CMessage::KEYBOARD_KEYDOWN);
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_BUTTONUP);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_SINGLELCLICK);
Draw();
}
CCheckBox::~CCheckBox() = default;
void CCheckBox::SetReadOnly(bool bReadOnly)
{
m_BackgroundColor = bReadOnly ? COLOR_LIGHTGRAY : COLOR_WHITE;
m_bReadOnly = bReadOnly;
SetIsFocusable(!bReadOnly);
Draw();
}
void CCheckBox::SetCheckBoxState(EState eState)
{
if (m_eCheckBoxState != eState)
{
m_eCheckBoxState = eState;
Draw();
}
}
void CCheckBox::ToggleCheckBoxState()
{
if (m_bReadOnly) {
LOG_VERBOSE("CCheckBox::ToggleCheckBoxState ignored, control is read-only");
return;
}
switch (m_eCheckBoxState)
{
case UNCHECKED:
SetCheckBoxState(CHECKED);
Application().MessageServer()->QueueMessage(new TIntMessage(CMessage::CTRL_VALUECHANGE, m_pParentWindow, this, 1));
break;
case CHECKED:
SetCheckBoxState(UNCHECKED);
Application().MessageServer()->QueueMessage(new TIntMessage(CMessage::CTRL_VALUECHANGE, m_pParentWindow, this, 0));
break;
default:
break;
}
}
void CCheckBox::Draw() const
{
CWindow::Draw();
if (m_pSDLSurface)
{
CRect SubRect(m_WindowRect.SizeRect());
CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
Painter.DrawRect(m_WindowRect.SizeRect(), false, COLOR_WHITE);
if (m_eCheckBoxState != DISABLED)
{
Painter.DrawRect(SubRect, false, COLOR_LIGHTGRAY);
Painter.DrawHLine(SubRect.Left(), SubRect.Right(), SubRect.Top(), COLOR_BLACK);
Painter.DrawVLine(SubRect.Top(), SubRect.Bottom(), SubRect.Left(), COLOR_BLACK);
SubRect.Grow(-1);
if (m_bHasFocus)
{
Painter.DrawRect(SubRect, false, COLOR_GRAY);
}
SubRect.Grow(-1);
if (m_eCheckBoxState == CHECKED)
{
//Painter.DrawLine(SubRect.TopLeft(), SubRect.BottomRight(), DEFAULT_LINE_COLOR);
//Painter.DrawLine(SubRect.BottomLeft(), SubRect.TopRight(), DEFAULT_LINE_COLOR);
SDL_Rect SourceRect = m_WindowRect.SizeRect().SDLRect();
SDL_Rect DestRect = SubRect.SDLRect();
SDL_BlitSurface(m_hBitmapCheck.Bitmap(), &SourceRect, m_pSDLSurface, &DestRect);
}
}
}
}
bool CCheckBox::OnMouseButtonDown(CPoint Point, unsigned int Button)
{
bool bResult = CWindow::OnMouseButtonDown(Point, Button);
if (!bResult && m_bVisible && !m_bReadOnly && (m_eCheckBoxState != DISABLED) &&
(m_ClientRect.HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE))
{
m_MouseButton = Button;
bResult = true;
}
return bResult;
}
bool CCheckBox::OnMouseButtonUp(CPoint Point, unsigned int Button)
{
bool bResult = CWindow::OnMouseButtonUp(Point, Button);
LOG_DEBUG("CCheckBox::OnMouseButtonUp called");
if (!bResult && m_bVisible && !m_bReadOnly && (m_eCheckBoxState != DISABLED) &&
(m_MouseButton == Button) &&
(m_ClientRect.HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE))
{
LOG_DEBUG("CCheckBox::OnMouseButtonUp taken into account");
CMessage::EMessageType MessageType = CMessage::UNKNOWN;
switch (m_MouseButton)
{
case CMouseMessage::LEFT:
MessageType = CMessage::CTRL_SINGLELCLICK;
break;
case CMouseMessage::RIGHT:
MessageType = CMessage::CTRL_SINGLERCLICK;
break;
case CMouseMessage::MIDDLE:
MessageType = CMessage::CTRL_SINGLEMCLICK;
break;
}
Application().MessageServer()->QueueMessage(new TIntMessage(MessageType, this, this, 0));
bResult = true;
}
return bResult;
}
bool CCheckBox::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
LOG_DEBUG("CCheckBox::HandleMessage for " << CMessage::ToString(pMessage->MessageType()));
switch(pMessage->MessageType())
{
case CMessage::KEYBOARD_KEYDOWN:
{
CKeyboardMessage* pKeyboardMessage = dynamic_cast<CKeyboardMessage*>(pMessage);
if (pKeyboardMessage && pMessage->Destination() == this)
{
switch (pKeyboardMessage->Key)
{
case SDLK_RETURN: // intentional fall through
case SDLK_SPACE:
ToggleCheckBoxState();
break;
default:
// Forward all key downs to parent
Application().MessageServer()->QueueMessage(new CKeyboardMessage(CMessage::KEYBOARD_KEYDOWN, m_pParentWindow, this,
pKeyboardMessage->ScanCode, pKeyboardMessage->Modifiers, pKeyboardMessage->Key));
break;
}
}
break;
}
case CMessage::MOUSE_BUTTONUP:
{
CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);
if (pMouseMessage && (m_ClientRect.HitTest(ViewToWindow(pMouseMessage->Point)) != CRect::RELPOS_INSIDE)
&& (m_MouseButton == pMouseMessage->Button))
{
m_MouseButton = 0;
bHandled = true;
}
break;
}
case CMessage::CTRL_SINGLELCLICK:
if (pMessage->Destination() == this)
{
LOG_DEBUG("CCheckBox::HandleMessage received " << CMessage::ToString(pMessage->MessageType()) << " -> Toggling state");
ToggleCheckBoxState();
bHandled = true;
}
break;
default :
LOG_DEBUG("CCheckBox::HandleMessage forwarding " << CMessage::ToString(pMessage->MessageType()) << " to CWindow");
bHandled = CWindow::HandleMessage(pMessage);
break;
}
}
return bHandled;
}
}
| 6,975
|
C++
|
.cpp
| 200
| 29.27
| 131
| 0.678879
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
753,846
|
wg_message_server.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_message_server.cpp
|
// wg_message_server.cpp
//
// CMessageServer class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_message_server.h"
#include "wg_application.h"
#include "std_ex.h"
#include "wg_message_client.h"
#include "wg_error.h"
#include <sstream>
#include <algorithm>
#include <functional>
#include "log.h"
namespace wGui
{
CMessageServer::CMessageServer() : m_bIgnoreAllNewMessages(true)
{
m_pSemaphore = SDL_CreateSemaphore(0);
}
CMessageServer::~CMessageServer() = default;
void CMessageServer::RegisterMessageClient(CMessageClient* pClient, CMessage::EMessageType eMessageType, unsigned char Priority)
{
if (!pClient)
{
LOG_ERROR("CMessageServer::RegisterMessageClient : Attempting to register a non-existent message client.");
}
else
{
m_MessageClients[eMessageType].insert(std::make_pair(Priority, s_MessageClientActive(pClient, false)));
}
}
void CMessageServer::DeregisterMessageClient(CMessageClient* pClient, CMessage::EMessageType eMessageType)
{
t_MessageClientPriorityMap& PriorityMap = m_MessageClients[eMessageType];
auto iter = PriorityMap.begin();
while (iter != PriorityMap.end())
{
if (iter->second.pClient == pClient)
{
PriorityMap.erase(iter);
iter = PriorityMap.begin();
}
else
{
++iter;
}
}
}
void CMessageServer::DeregisterMessageClient(CMessageClient* pClient)
{
for (auto& client : m_MessageClients)
{
auto iter = client.second.begin();
while (iter != client.second.end())
{
if (iter->second.pClient == pClient)
{
client.second.erase(iter);
iter = client.second.begin();
}
else
{
++iter;
}
}
}
}
void CMessageServer::DeliverMessage()
{
if (!m_MessageQueue.empty())
{
CMessage* pMessage = m_MessageQueue.front();
t_MessageClientPriorityMap& PriorityMap = m_MessageClients[pMessage->MessageType()];
// we have to make sure that each client only gets the message once,
// even if the handling of one of these messages changes the message map
for (auto& priority : PriorityMap)
{
priority.second.bWaitingForMessage = true;
}
bool bFinished = false;
while (! bFinished)
{
auto iter = PriorityMap.begin();
for (; iter != PriorityMap.end(); ++iter)
{
if (iter->second.bWaitingForMessage)
{
iter->second.bWaitingForMessage = false;
bFinished = iter->second.pClient->HandleMessage(pMessage);
break;
}
}
if (iter == PriorityMap.end())
{
bFinished = true;
}
}
m_MessageQueue.pop_front();
delete pMessage;
}
}
//! A functor for finding duplicate APP_PAINT messages
struct Duplicate_APP_PAINT
{
public:
//! The functor constructor
//! \param pClient The destination of the message that is being checked
Duplicate_APP_PAINT(const CMessageClient* pClient) : m_pClient(pClient) { }
//! Checks to see if the message is a duplicate of an existing APP_PAINT message
//! \param pMessage A pointer to the message that is being checked against
//! \return true of the message is a duplicate
bool operator() (CMessage* pMessage) const
{
bool bResult = (pMessage->MessageType() == CMessage::APP_PAINT) && (pMessage->Destination() == m_pClient);
return bResult;
}
private:
//! The destination of the message that is being checked
const CMessageClient* m_pClient;
};
void CMessageServer::QueueMessage(CMessage* pMessage)
{
if (!m_bIgnoreAllNewMessages)
{
// check for and remove any redundant APP_PAINT messages in the queue
if (pMessage->MessageType() == CMessage::APP_PAINT)
{
m_MessageQueue.erase(std::remove_if(m_MessageQueue.begin(), m_MessageQueue.end(), Duplicate_APP_PAINT(pMessage->Destination())), m_MessageQueue.end());
}
m_MessageQueue.push_back(pMessage);
}
}
void CMessageServer::PurgeQueuedMessages()
{
m_MessageQueue.clear();
}
}
| 4,551
|
C++
|
.cpp
| 155
| 26.909677
| 154
| 0.74136
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
753,847
|
wg_label.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_label.cpp
|
// wg_label.cpp
//
// CLabel class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_label.h"
#include <string>
namespace wGui
{
CLabel::CLabel(const CRect& WindowRect, CWindow* pParent, std::string sText, CRGBColor& FontColor, CFontEngine* pFontEngine) :
CWindow(WindowRect, pParent),
m_FontColor(FontColor)
{
m_sWindowText = sText;
if (pFontEngine)
{
m_pFontEngine = pFontEngine;
}
else
{
m_pFontEngine = Application().GetDefaultFontEngine();
}
m_pRenderedString.reset(new CRenderedString(
m_pFontEngine, sText, CRenderedString::VALIGN_CENTER, CRenderedString::HALIGN_LEFT));
m_BackgroundColor = Application().GetDefaultBackgroundColor();
Draw();
}
CLabel::CLabel(const CPoint& point, CWindow* pParent, std::string sText, CRGBColor& FontColor, CFontEngine* pFontEngine) :
CWindow(pParent),
m_FontColor(FontColor)
{
m_sWindowText = sText;
if (pFontEngine)
{
m_pFontEngine = pFontEngine;
}
else
{
m_pFontEngine = Application().GetDefaultFontEngine();
}
m_pRenderedString.reset(new CRenderedString(m_pFontEngine, sText, CRenderedString::VALIGN_TOP, CRenderedString::HALIGN_LEFT));
m_BackgroundColor = Application().GetDefaultBackgroundColor();
// set width and height of the label's rectangle:
CWindow::SetWindowRect(CRect(point, m_pRenderedString->GetWidth(sText) + 1, m_pRenderedString->GetMaxFontHeight() + 1));
Draw();
}
CLabel::~CLabel() = default;
void CLabel::Draw() const
{
CWindow::Draw();
if (m_pSDLSurface && m_pRenderedString.get())
{
// judb together with VALIGN_CENTER, the originpoint should be
// the height of the rectangle/2 (so also vertically centered)
//m_pRenderedString->Draw(m_pSDLSurface, m_WindowRect.SizeRect(), CPoint(0, m_WindowRect.Height()/2), m_FontColor);
m_pRenderedString->Draw(m_pSDLSurface, m_WindowRect.SizeRect(), CPoint(0, 0), m_FontColor);
}
}
void CLabel::SetWindowText(const std::string& sWindowText)
{
m_pRenderedString.reset(new CRenderedString(
m_pFontEngine, sWindowText, CRenderedString::VALIGN_TOP, CRenderedString::HALIGN_LEFT));
CWindow::SetWindowText(sWindowText);
}
}
| 2,888
|
C++
|
.cpp
| 82
| 33.231707
| 127
| 0.764621
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
753,848
|
wg_application.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_application.cpp
|
// wg_application.cpp
//
// CApplication interface
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_application.h"
#include "wg_error.h"
#include "wg_view.h"
#include "video.h"
#include <iostream>
#include <fstream>
#include <string>
#include "cap32.h"
#include "log.h"
// CPC emulation properties, defined in cap32.h:
extern t_CPC CPC;
// Video plugin, defined in video.h:
extern video_plugin* vid_plugin;
namespace wGui
{
bool CApplication::HandleSDLEvent(SDL_Event event)
{
auto windowId = SDL_GetWindowID(m_pSDLWindow);
bool forMe = m_Focused;
switch (event.type) {
case SDL_KEYDOWN:
case SDL_KEYUP:
if (event.key.windowID == windowId) forMe = true;
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
if (event.button.windowID == windowId) forMe = true;
break;
case SDL_TEXTEDITING:
if (event.edit.windowID == windowId) forMe = true;
break;
case SDL_MOUSEMOTION:
if (event.motion.windowID == windowId) forMe = true;
break;
case SDL_TEXTINPUT:
if (event.text.windowID == windowId) forMe = true;
break;
case SDL_MOUSEWHEEL:
if (event.wheel.windowID == windowId) forMe = true;
break;
case SDL_WINDOWEVENT:
if (event.window.windowID == windowId) forMe = true;
if (forMe && event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) {
m_Focused = true;
return true;
}
if (forMe && event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) {
m_Focused = false;
return true;
}
if (forMe && event.window.event == SDL_WINDOWEVENT_CLOSE) {
MessageServer()->QueueMessage(new CMessage(CMessage::APP_EXIT, nullptr, this));
return true;
}
break;
}
if (!forMe) return false;
// this will turn an SDL event into a wGui message
switch (event.type)
{
case SDL_WINDOWEVENT:
MessageServer()->QueueMessage(new CMessage(CMessage::APP_PAINT, nullptr, this));
if (event.window.event == SDL_WINDOWEVENT_RESIZED ||
event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
MessageServer()->QueueMessage(new TPointMessage(
CMessage::CTRL_RESIZE, nullptr, this, CPoint(event.window.data1, event.window.data2)));
}
break;
case SDL_TEXTINPUT:
MessageServer()->QueueMessage(new CTextInputMessage(
CMessage::TEXTINPUT, GetKeyFocus(), this,
std::string(event.text.text)));
break;
case SDL_KEYDOWN:
MessageServer()->QueueMessage(new CKeyboardMessage(
CMessage::KEYBOARD_KEYDOWN, GetKeyFocus(), this,
event.key.keysym.scancode, static_cast<SDL_Keymod>(event.key.keysym.mod),
event.key.keysym.sym));
break;
case SDL_KEYUP:
MessageServer()->QueueMessage(new CKeyboardMessage(
CMessage::KEYBOARD_KEYUP, GetKeyFocus(), this,
event.key.keysym.scancode, static_cast<SDL_Keymod>(event.key.keysym.mod),
event.key.keysym.sym));
break;
case SDL_MOUSEBUTTONDOWN:
{
int x(event.button.x), y(event.button.y);
if (m_bInMainView) {
x = (event.button.x-vid_plugin->x_offset)*vid_plugin->x_scale;
y = (event.button.y-vid_plugin->y_offset)*vid_plugin->y_scale;
} else {
x = event.button.x/m_iScale;
y = event.button.y/m_iScale;
}
MessageServer()->QueueMessage(new CMouseMessage(
CMessage::MOUSE_BUTTONDOWN, GetMouseFocus(), this, CPoint(x, y), CPoint(),
CMouseMessage::TranslateSDLButton(event.button.button)));
break;
}
case SDL_MOUSEBUTTONUP:
{
int x(event.button.x), y(event.button.y);
if (m_bInMainView) {
x = (event.button.x-vid_plugin->x_offset)*vid_plugin->x_scale;
y = (event.button.y-vid_plugin->y_offset)*vid_plugin->y_scale;
} else {
x = event.button.x/m_iScale;
y = event.button.y/m_iScale;
}
MessageServer()->QueueMessage(new CMouseMessage(
CMessage::MOUSE_BUTTONUP, GetMouseFocus(), this, CPoint(x, y), CPoint(),
CMouseMessage::TranslateSDLButton(event.button.button)));
break;
}
case SDL_MOUSEWHEEL:
{
unsigned int wheeldirection = CMouseMessage::NONE;
if (event.wheel.x > 0 || event.wheel.y > 0) {
wheeldirection = CMouseMessage::WHEELUP;
} else {
wheeldirection = CMouseMessage::WHEELDOWN;
}
int x, y;
SDL_GetMouseState(&x, &y);
if (m_bInMainView) {
x = (x-vid_plugin->x_offset)*vid_plugin->x_scale;
y = (y-vid_plugin->y_offset)*vid_plugin->y_scale;
} else {
x = event.button.x/m_iScale;
y = event.button.y/m_iScale;
}
MessageServer()->QueueMessage(new CMouseMessage(
CMessage::MOUSE_BUTTONDOWN, GetMouseFocus(), this, CPoint(x, y), CPoint(),
wheeldirection));
break;
}
case SDL_MOUSEMOTION:
{
int x(event.motion.x), y(event.motion.y);
if (m_bInMainView) {
x = (event.motion.x-vid_plugin->x_offset)*vid_plugin->x_scale;
y = (event.motion.y-vid_plugin->y_offset)*vid_plugin->y_scale;
} else {
x = event.button.x/m_iScale;
y = event.button.y/m_iScale;
}
MessageServer()->QueueMessage(new CMouseMessage(
CMessage::MOUSE_MOVE, GetMouseFocus(), this, CPoint(x, y), CPoint(),
CMouseMessage::TranslateSDLButtonState(event.motion.state)));
break;
}
case SDL_JOYAXISMOTION:
{
SDL_Keycode key(SDLK_UNKNOWN);
switch(event.jaxis.axis) {
case 0:
case 2:
// TODO: validate with a joystick with non-binary axis
// should we add some timing or consider only state changes ?
if(event.jaxis.value < -JOYSTICK_AXIS_THRESHOLD) {
key = SDLK_LEFT;
} else if(event.jaxis.value > JOYSTICK_AXIS_THRESHOLD) {
key = SDLK_RIGHT;
}
break;
case 1:
case 3:
if(event.jaxis.value < -JOYSTICK_AXIS_THRESHOLD) {
key = SDLK_UP;
} else if(event.jaxis.value > JOYSTICK_AXIS_THRESHOLD) {
key = SDLK_DOWN;
}
break;
}
if (key != SDLK_UNKNOWN) {
MessageServer()->QueueMessage(new CKeyboardMessage(
CMessage::KEYBOARD_KEYDOWN, GetKeyFocus(), this,
0, KMOD_NONE, key));
MessageServer()->QueueMessage(new CKeyboardMessage(
CMessage::KEYBOARD_KEYUP, GetKeyFocus(), this,
0, KMOD_NONE, key));
}
break;
}
case SDL_JOYBUTTONUP:
case SDL_JOYBUTTONDOWN:
{
CMessage::EMessageType type = CMessage::KEYBOARD_KEYDOWN;
if (event.type == SDL_JOYBUTTONUP) {
type = CMessage::KEYBOARD_KEYUP;
}
SDL_Keycode key(SDLK_UNKNOWN);
SDL_Keymod mod = KMOD_NONE;
bool ignore_event = false;
// TODO: arbitrary binding: validate with various joystick models
switch (event.jbutton.button) {
case 0:
key = SDLK_RETURN;
break;
case 1:
case 4:
key = SDLK_TAB;
break;
case 2:
case 5:
key = SDLK_TAB;
mod = KMOD_RSHIFT;
break;
case 3:
key = SDLK_ESCAPE;
break;
default:
ignore_event = true;
break;
}
if (!ignore_event) {
MessageServer()->QueueMessage(new CKeyboardMessage(
type, GetKeyFocus(), this,
0, mod, key));
}
break;
}
case SDL_QUIT:
// MessageServer()->QueueMessage(new CMessage(CMessage::APP_EXIT, nullptr, this));
exit(0);
break;
default:
MessageServer()->QueueMessage(new CSDLMessage(CMessage::SDL, nullptr, this, event));
break;
}
return true;
}
CApplication::CApplication(SDL_Window* pWindow, std::string sFontFileName) :
CMessageClient(*this),
m_pSDLWindow(pWindow),
m_pMainView(nullptr),
m_sFontFileName(std::move(sFontFileName)),
m_iExitCode(EXIT_FAILURE),
m_bRunning(false),
m_bInited(false),
m_pKeyFocusWindow(nullptr),
m_pMouseFocusWindow(nullptr),
m_pDefaultFontEngine(nullptr),
m_DefaultBackgroundColor(DEFAULT_BACKGROUND_COLOR),
m_DefaultForegroundColor(DEFAULT_FOREGROUND_COLOR),
m_DefaultSelectionColor(DEFAULT_BACKGROUND_COLOR),
m_pCurrentCursorResourceHandle(nullptr),
m_pSystemDefaultCursor(nullptr)
{
m_pMessageServer = std::make_unique<CMessageServer>();
// judb
//if(SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE ) == -1)
//{
// throw(Wg_Ex_SDL(std::string("Could not initialize SDL: ") + SDL_GetError(), "CApplication::CApplication"));
//}
//Setting the keyboard repeat rate using the SDL Default rates
//if(SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL) == -1)
//{
// throw(Wg_Ex_SDL("Error setting SDL keyboard repeat rate.", "CApplication::Capplication"));
//}
m_pSystemDefaultCursor = SDL_GetCursor();
atexit(SDL_Quit);
}
CApplication::~CApplication()
{
m_pMessageServer = nullptr;
for(auto& fontEngine : m_FontEngines)
{
delete fontEngine.second;
fontEngine.second = nullptr;
}
}
void CApplication::RegisterView(CView* pView)
{
if (m_pMainView != nullptr)
{
throw(Wg_Ex_App("This application already has a view registered.", "CApplication::RegisterView"));
}
m_pMainView = pView;
}
void CApplication::SetKeyFocus(CWindow* pWindow)
{
if (pWindow && m_pKeyFocusWindow != pWindow)
{
if (pWindow->IsVisible())
{
// notify the window that's losing focus to repaint itself
if (m_pKeyFocusWindow)
{
MessageServer()->QueueMessage(new CMessage(CMessage::CTRL_LOSINGKEYFOCUS, m_pKeyFocusWindow, this));
}
m_pKeyFocusWindow = pWindow;
MessageServer()->QueueMessage(new CMessage(CMessage::CTRL_GAININGKEYFOCUS, m_pKeyFocusWindow, this));
}
else
{
SetKeyFocus(pWindow->GetAncestor(CWindow::PARENT));
}
}
}
void CApplication::SetMouseFocus(CWindow* pWindow)
{
if (m_pMouseFocusWindow != pWindow)
{
// notify the window that's losing focus to repaint itself
if (m_pMouseFocusWindow)
{
MessageServer()->QueueMessage(new CMessage(CMessage::CTRL_LOSINGMOUSEFOCUS, m_pMouseFocusWindow, this));
}
m_pMouseFocusWindow = pWindow;
MessageServer()->QueueMessage(new CMessage(CMessage::CTRL_GAININGMOUSEFOCUS, m_pMouseFocusWindow, this));
}
}
void CApplication::Init()
{
MessageServer()->RegisterMessageClient(this, CMessage::APP_EXIT, CMessageServer::PRIORITY_LAST);
// judb removed references to wgui.conf; for caprice32 we may integrate these settings in cap32.cfg:
m_pDefaultFontEngine = GetFontEngine(CPC.resources_path + "/vera_sans.ttf", 10); // default size was 10
m_DefaultBackgroundColor = DEFAULT_BACKGROUND_COLOR;
m_DefaultForegroundColor = DEFAULT_FOREGROUND_COLOR;
m_DefaultSelectionColor = DEFAULT_SELECTION_COLOR;
m_bInited = true;
}
bool CApplication::ProcessEvent(SDL_Event& event)
{
if (!m_bInited)
{
throw(Wg_Ex_App("Application Init() was not called!", "CApplication::Step"));
}
m_bRunning = true;
MessageServer()->IgnoreAllNewMessages(false);
MessageServer()->QueueMessage(new CMessage(CMessage::APP_PAINT, nullptr, this));
auto result = HandleSDLEvent(event);
MessageServer()->DeliverMessage();
return result;
}
void CApplication::Update()
{
if (!m_bInited)
{
throw(Wg_Ex_App("Application Init() was not called!", "CApplication::Step"));
}
m_bRunning = true;
MessageServer()->IgnoreAllNewMessages(false);
MessageServer()->QueueMessage(new CMessage(CMessage::APP_PAINT, nullptr, this));
MessageServer()->DeliverMessage();
}
void CApplication::Exec()
{
try
{
if (!m_bInited)
{
throw(Wg_Ex_App("Application Init() was not called!", "CApplication::Exec"));
}
m_bRunning = true;
SDL_Event event;
MessageServer()->IgnoreAllNewMessages(false);
MessageServer()->QueueMessage(new CMessage(CMessage::APP_PAINT, nullptr, this));
while (m_bRunning)
{
do {
while (SDL_PollEvent(&event)) {
HandleSDLEvent(event);
}
SDL_Delay(5);
} while (!MessageServer()->MessageAvailable());
MessageServer()->DeliverMessage();
}
}
catch (Wg_Ex_Base& e)
{
LOG_ERROR("Exception (wGui) : " << e.std_what() << " - SDL Last Error: " << SDL_GetError());
}
catch (std::exception& e)
{
LOG_ERROR("Exception (std) : " << std::string(e.what()) << " - SDL Last Error: " << SDL_GetError());
}
catch (...)
{
LOG_ERROR("Exception (non std) - SDL Last Error: " << SDL_GetError());
}
}
void CApplication::ApplicationExit(int iExitCode)
{
// push an event into the SDL queue so the SDLEventLoopThread can exit
// the actual contents of the event are not a concern as it serves just to trigger the SDL_WaitEvent
SDL_Event user_event;
user_event.type=SDL_USEREVENT;
user_event.user.code=0;
user_event.user.data1=nullptr;
user_event.user.data2=nullptr;
int iResult = SDL_PushEvent(&user_event);
if (iResult == -1) {
LOG_ERROR("CApplication::ApplicationExit - Unable to push SDL user_event: " << SDL_GetError());
}
m_iExitCode = iExitCode;
m_bRunning = false;
if (m_pMainView) m_pMainView->Close();
}
CFontEngine* CApplication::GetFontEngine(std::string sFontFileName, unsigned char iFontSize)
{
// First search to see if the requested font engine already exists
auto iterFontEngine = m_FontEngines.find(std::make_pair(sFontFileName, iFontSize));
CFontEngine* pFontEngine = nullptr;
if (iterFontEngine == m_FontEngines.end())
{
// Requested font engine doesn't exist, so create one and add it to the map
try
{
std::ifstream FileTest(sFontFileName.c_str());
bool bFileExists = FileTest.is_open();
FileTest.close();
if (bFileExists)
{
pFontEngine = new CFontEngine(sFontFileName, iFontSize);
}
else
{
throw(Wg_Ex_App("File not found: " + sFontFileName, "CApplication::GetFontEngine"));
}
if (pFontEngine)
{
m_FontEngines.insert(std::make_pair(std::make_pair(sFontFileName, iFontSize), pFontEngine));
}
}
catch (Wg_Ex_FreeType& e)
{
LOG_ERROR("CApplication::GetFontEngine - Exception thrown while creating Font Engine : " + e.std_what());
}
}
else
{
pFontEngine = iterFontEngine->second;
}
return pFontEngine;
}
bool CApplication::AddToResourcePool(CResourceHandle& ResourceHandle)
{
m_ResourceHandlePool.push_back(ResourceHandle);
return true;
}
void CApplication::SetMouseCursor(CCursorResourceHandle* pCursorResourceHandle)
{
// The auto pointer is used to make sure that the cursor handle is valid until we're done using the cursor
if (pCursorResourceHandle && pCursorResourceHandle != m_pCurrentCursorResourceHandle.get())
{
m_pCurrentCursorResourceHandle.reset(new CCursorResourceHandle(*pCursorResourceHandle));
SDL_SetCursor(m_pCurrentCursorResourceHandle->Cursor());
}
else
{
if( m_pCurrentCursorResourceHandle )
{
m_pCurrentCursorResourceHandle.reset(nullptr);
SDL_SetCursor(m_pSystemDefaultCursor);
}
}
}
bool CApplication::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch (pMessage->MessageType())
{
case CMessage::APP_EXIT :
ApplicationExit();
bHandled = true;
break;
default:
break;
}
}
return bHandled;
}
}
| 16,035
|
C++
|
.cpp
| 500
| 27.27
| 111
| 0.67844
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
753,849
|
wg_progress.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_progress.cpp
|
// wg_progress.cpp
//
// CProgress class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_progress.h"
#include "std_ex.h"
namespace wGui
{
CProgress::CProgress(const CRect& WindowRect, CWindow* pParent, CRGBColor BarColor) :
CRangeControl<int>(WindowRect, pParent, 0, 100, 1, 0),
m_BarColor(BarColor)
{
m_BackgroundColor = DEFAULT_FOREGROUND_COLOR;
Draw();
}
CProgress::~CProgress() = default;
void CProgress::Draw() const
{
CWindow::Draw();
if (m_pSDLSurface)
{
CRect SubRect(m_WindowRect.SizeRect());
SubRect.Grow(-1);
CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
Painter.DrawRect(m_WindowRect.SizeRect(), false, COLOR_BLACK);
Painter.DrawRect(SubRect, false, COLOR_LIGHTGRAY);
Painter.DrawHLine(SubRect.Left(), SubRect.Right(), SubRect.Top(), COLOR_DARKGRAY);
Painter.DrawVLine(SubRect.Top(), SubRect.Bottom(), SubRect.Left(), COLOR_DARKGRAY);
SubRect.Grow(-2);
if (m_Value > m_MinLimit)
{
if (m_Value < m_MaxLimit)
{
SubRect.SetRight(stdex::safe_static_cast<int>(SubRect.Left() +
SubRect.Width() * (stdex::safe_static_cast<double>(m_Value - m_MinLimit) / (m_MaxLimit - m_MinLimit))));
}
Painter.DrawRect(SubRect, true, m_BarColor, m_BarColor);
}
}
}
}
| 2,020
|
C++
|
.cpp
| 59
| 32.169492
| 109
| 0.73884
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,850
|
wg_view.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_view.cpp
|
// wg_view.cpp
//
// CView class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_view.h"
#include "wg_error.h"
#include "wg_painter.h"
#include "wg_message_server.h"
#include "wg_application.h"
#include "wg_frame.h"
#include "std_ex.h"
#include "video.h"
#include "log.h"
#include <algorithm>
#include <string>
extern video_plugin* vid_plugin;
namespace wGui
{
CView::CView(CApplication& application, SDL_Surface* surface, SDL_Surface* backSurface, const CRect& WindowRect) :
CWindow(application, CRect(0, 0, surface->w, surface->h)),
m_pMenu(nullptr),
m_pFloatingWindow(nullptr),
m_pScreenSurface(nullptr)
{
Application().RegisterView(this);
Application().MessageServer()->RegisterMessageClient(this, CMessage::APP_PAINT);
Application().MessageServer()->RegisterMessageClient(this, CMessage::APP_DESTROY_FRAME, CMessageServer::PRIORITY_FIRST);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_RESIZE);
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_BUTTONDOWN, CMessageServer::PRIORITY_FIRST);
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_BUTTONUP, CMessageServer::PRIORITY_FIRST);
// judb this works, but better rewrite this to make things clearer !
CWindow::SetWindowRect(WindowRect);
// judb ClientRect is relative to WindowRect (it is the client area within a Window(Rect) ) so
// its coordinates are relative to WindowRect ->
// here we use a rectangle with the same dimensions as WindowRect, but (0,0) as its upper left point.
// so it covers the entire WindowRect.
m_ClientRect = WindowRect.SizeRect();
m_pScreenSurface = surface;
m_pBackSurface = backSurface;
// judb should not happen:-)
if (m_pScreenSurface == nullptr)
throw( Wg_Ex_SDL(std::string("Surface not created? : ") + SDL_GetError(), "CView::CView"));
Draw();
}
CView::~CView()
{
delete m_pMenu;
}
void CView::AttachMenu(CMenu* pMenu)
{
delete m_pMenu;
m_pMenu = pMenu;
if (m_pMenu)
{
m_pMenu->SetNewParent(this);
int iMenuHeight = m_pMenu->GetWindowRect().Height();
m_pMenu->SetWindowRect(CRect(0, -iMenuHeight, m_WindowRect.Width() - 1, -1));
m_ClientRect.SetTop(iMenuHeight + 1);
m_ClientRect.ClipTo(m_WindowRect.SizeRect());
}
else
{
m_ClientRect = m_WindowRect.SizeRect();
}
}
void CView::SetWindowText(const std::string& sText)
{
CWindow::SetWindowText(sText);
SDL_SetWindowTitle(m_pWindow, m_sWindowText.c_str());
}
void CView::Flip() const
{
vid_plugin->flip(vid_plugin);
}
bool CView::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::APP_PAINT :
if (pMessage->Destination() == this || pMessage->Destination() == nullptr)
{
SDL_Surface* pFloatingSurface = SDL_CreateRGBSurface(0, m_pScreenSurface->w, m_pScreenSurface->h, Application().GetBitsPerPixel(), 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
PaintToSurface(*m_pScreenSurface, *pFloatingSurface, CPoint(0, 0));
// judb use entire application SDL surface (otherwise strange clipping effects occur
// when moving frames, also clipping of listboxes.)
// SDL_Rect SourceRect = CRect(m_WindowRect.SizeRect()).SDLRect();
SDL_Rect SourceRect = CRect(0, 0, m_pScreenSurface->w, m_pScreenSurface->h).SDLRect();
// SDL_Rect DestRect = CRect(m_WindowRect.SizeRect()).SDLRect();
SDL_Rect DestRect = CRect(0, 0, m_pScreenSurface->w, m_pScreenSurface->h).SDLRect();
SDL_BlitSurface(pFloatingSurface, &SourceRect, m_pScreenSurface, &DestRect);
SDL_FreeSurface(pFloatingSurface);
//SDL_UpdateRect(m_pScreenSurface, 0, 0, 0, 0);
Flip();
bHandled = true;
}
break;
case CMessage::APP_DESTROY_FRAME:
if (pMessage->Destination() == this || pMessage->Destination() == nullptr)
{
CFrame* pFrame = dynamic_cast<CFrame*>(const_cast<CMessageClient*>(pMessage->Source()));
if (pFrame)
{
pFrame->SetModal(false);
pFrame->SetNewParent(nullptr);
Application().MessageServer()->QueueMessage(new CMessage(CMessage::APP_PAINT, nullptr, this));
delete pFrame;
}
bHandled = true;
}
break;
case CMessage::CTRL_RESIZE:
{
TPointMessage* pResizeMessage = dynamic_cast<TPointMessage*>(pMessage);
if (pResizeMessage && pResizeMessage->Source() == &Application())
{
LOG_ERROR("CView::HandleMessage called received a CTRL_RESIZE message - not migrated to SDL2");
/*
CWindow::SetWindowRect(CRect(m_WindowRect.TopLeft(), m_WindowRect.TopLeft() + pResizeMessage->Value()));
m_ClientRect = CRect(m_ClientRect.Left(), m_ClientRect.Top(), m_WindowRect.Width(), m_WindowRect.Height());
m_ClientRect.ClipTo(m_WindowRect.SizeRect());
m_pScreenSurface = SDL_SetVideoMode(m_WindowRect.Width(), m_WindowRect.Height(), DEFAULT_BPP, iFlags);
if (m_pScreenSurface == nullptr)
throw( Wg_Ex_SDL(std::string("Could not set video mode : ") + SDL_GetError(), "CView::HandleMessage") );
*/
bHandled = true;
}
break;
}
case CMessage::MOUSE_BUTTONDOWN:
{
CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);
if (pMouseMessage && m_WindowRect.HitTest(pMouseMessage->Point) == CRect::RELPOS_INSIDE)
{
if (!m_pFloatingWindow || !m_pFloatingWindow->OnMouseButtonDown(pMouseMessage->Point, pMouseMessage->Button))
{
if (pMouseMessage->Destination() == nullptr)
{
OnMouseButtonDown(pMouseMessage->Point, pMouseMessage->Button);
}
else if (dynamic_cast<const CWindow*>(pMouseMessage->Destination()))
{
const_cast<CWindow*>(static_cast<const CWindow*>(pMouseMessage->Destination()))->
OnMouseButtonDown(pMouseMessage->Point, pMouseMessage->Button);
}
}
}
break;
}
case CMessage::MOUSE_BUTTONUP:
{
CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);
if (pMouseMessage && m_WindowRect.HitTest(pMouseMessage->Point) == CRect::RELPOS_INSIDE)
{
if (!m_pFloatingWindow || !m_pFloatingWindow->OnMouseButtonUp(pMouseMessage->Point, pMouseMessage->Button))
{
if (pMouseMessage->Destination() == nullptr)
{
OnMouseButtonUp(pMouseMessage->Point, pMouseMessage->Button);
}
else if (dynamic_cast<const CWindow*>(pMouseMessage->Destination()))
{
const_cast<CWindow*>(static_cast<const CWindow*>(pMouseMessage->Destination()))->
OnMouseButtonUp(pMouseMessage->Point, pMouseMessage->Button);
}
}
}
break;
}
default :
bHandled = CWindow::HandleMessage(pMessage);
break;
}
}
return bHandled;
}
}
| 7,404
|
C++
|
.cpp
| 197
| 34.228426
| 183
| 0.722044
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,851
|
CapriceGuiView.cpp
|
ColinPitrat_caprice32/src/gui/src/CapriceGuiView.cpp
|
#include "CapriceGuiView.h"
#include "CapriceMenu.h"
using namespace wGui;
CapriceGuiView::CapriceGuiView(CApplication& application, SDL_Surface* surface, SDL_Surface* backSurface, const CRect& WindowRect) : CView(application, surface, backSurface, WindowRect)
{
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_MESSAGEBOXRETURN);
m_menuFrame = new CapriceMenu(CRect(CPoint(m_pScreenSurface->w / 2 - 70, m_pScreenSurface->h / 2 - 110), 140, 240), this, m_pScreenSurface, nullptr);
}
// judb Show the Caprice32 emulation display, and our CCaGuiView (CView) on top of it.
// The only CView object in Caprice32 is the first window you see when you activate the gui.
void CapriceGuiView::PaintToSurface(SDL_Surface& ScreenSurface, SDL_Surface& FloatingSurface, const CPoint& Offset) const
{
if (m_bVisible)
{
// Reset backgound
SDL_BlitSurface(m_pBackSurface, nullptr, &ScreenSurface, nullptr);
// Draw all child windows recursively
for (const auto child : m_ChildWindows)
{
if (child)
{
child->PaintToSurface(ScreenSurface, FloatingSurface, Offset);
}
}
}
}
| 1,144
|
C++
|
.cpp
| 26
| 40.538462
| 185
| 0.748654
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,852
|
wg_navigationbar.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_navigationbar.cpp
|
// wg_navigationbar.cpp
//
// CNavigationBar class implementation
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_application.h"
#include "wg_error.h"
#include "wg_message_server.h"
#include "wg_navigationbar.h"
#include "std_ex.h"
namespace wGui
{
CNavigationBar::CNavigationBar(CWindow* pParent, const CPoint& UpperLeft, unsigned int iMaxItems,
unsigned int iItemWidth, unsigned int iItemHeight, CFontEngine* pFontEngine) :
CWindow(CRect(UpperLeft, iMaxItems * iItemWidth + 4, iItemHeight), pParent),
m_iItemHeight(iItemHeight),
m_iItemWidth(iItemWidth),
m_iSelectedItem(0),
m_iFocusedItem(0)
{
if (pFontEngine) {
m_pFontEngine = pFontEngine;
} else {
m_pFontEngine = Application().GetDefaultFontEngine();
}
// Make space for a 3D border and a focus rectangle around each item.
// To make it all match (and avoid that the last item gets clipped at the right side),
// we added + 4 to the width (in the CWindow constructor above)
m_ClientRect = CRect(2, 2, m_WindowRect.Width() - 2, m_WindowRect.Height() - 2);
m_BackgroundColor = COLOR_WHITE;
Application().MessageServer()->RegisterMessageClient(this, CMessage::KEYBOARD_KEYDOWN);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_VALUECHANGE);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_VALUECHANGING);
Draw();
}
CNavigationBar::~CNavigationBar() {
// Delete the bitmaps
for (const auto& bitmap : m_Bitmaps) {
delete bitmap;
}
}
void CNavigationBar::SetItemHeight(unsigned int iItemHeight) {
m_iItemHeight = iItemHeight;
Draw();
}
void CNavigationBar::SetItemWidth(unsigned int iItemWidth) {
m_iItemWidth = iItemWidth;
Draw();
}
unsigned int CNavigationBar::AddItem(SNavBarItem NavBarItem) {
m_Items.push_back(NavBarItem);
m_RenderedStrings.emplace_back(m_pFontEngine, NavBarItem.sItemText, CRenderedString::VALIGN_BOTTOM, CRenderedString::HALIGN_CENTER);
if (!NavBarItem.sPictureFilename.empty()) {
m_Bitmaps.push_back(new CBitmapFileResourceHandle(NavBarItem.sPictureFilename));
// Set transparency color to COLOR_WHITE:
SDL_SetColorKey(m_Bitmaps.at(m_Bitmaps.size() - 1)->Bitmap(), SDL_TRUE, COLOR_WHITE.SDLColor(m_pSDLSurface->format));
} else {
m_Bitmaps.push_back(nullptr);
}
Draw();
return m_Items.size();
}
void CNavigationBar::RemoveItem(unsigned int iItemIndex) {
if (iItemIndex < m_Items.size()) {
m_Items.erase(m_Items.begin() + iItemIndex);
m_RenderedStrings.erase(m_RenderedStrings.begin() + iItemIndex);
delete m_Bitmaps.at(iItemIndex); // allocated pointer -> delete
m_Bitmaps.erase(m_Bitmaps.begin() + iItemIndex);
Draw();
}
}
void CNavigationBar::ClearItems()
{
m_Items.clear();
Draw();
}
unsigned int CNavigationBar::getSelectedIndex() const {
return m_iSelectedItem;
}
void CNavigationBar::SelectItem(unsigned int iItemIndex) {
if (iItemIndex < m_Items.size()) {
m_iSelectedItem = iItemIndex;
m_iFocusedItem = iItemIndex;
CWindow* pDestination = m_pParentWindow;
// could be optimized : keep 'previous' selection and only send the message if new m_iFocusedItem != previous focused item.
Application().MessageServer()->QueueMessage(new TIntMessage(CMessage::CTRL_VALUECHANGE, pDestination, this, m_iFocusedItem));
Draw();
}
}
unsigned int CNavigationBar::getFocusedIndex() const {
return m_iFocusedItem;
}
void CNavigationBar::FocusItem(unsigned int iItemIndex) {
if (iItemIndex < m_Items.size()) {
m_iFocusedItem = iItemIndex;
Draw();
}
}
void CNavigationBar::Draw() const {
CWindow::Draw();
if (m_pSDLSurface)
{
CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
Painter.Draw3DLoweredRect(m_WindowRect.SizeRect(), DEFAULT_BACKGROUND_COLOR);
SDL_Rect PictureSourceRect = CRect(CPoint(0, 0), 30, 30).SDLRect();
for (unsigned int i = 0; i < m_Items.size(); ++i)
{
CRect ItemRect(CPoint(m_ClientRect.Left() + i*m_iItemWidth, m_ClientRect.Top()),
m_iItemWidth , m_iItemHeight);
if (ItemRect.Overlaps(m_ClientRect))
{
ItemRect.ClipTo(m_ClientRect);
ItemRect.SetBottom(ItemRect.Bottom() - 1);
ItemRect.SetRight(ItemRect.Right() - 1);
if (i == m_iSelectedItem)
{
Painter.DrawRect(ItemRect, true, Application().GetDefaultSelectionColor(), Application().GetDefaultSelectionColor());
}
if (i == m_iFocusedItem && HasFocus())
{
ItemRect.Grow(1);
Painter.DrawRect(ItemRect, false, Application().GetDefaultSelectionColor() * 0.7);
ItemRect.Grow(-1);
}
ItemRect.Grow(-1);
// '- CPoint(0,1)' is to move the reference point one pixel up (otherwise the lowest pixels of p,g,q,y
// etc. are not fully visible.
m_RenderedStrings.at(i).Draw(m_pSDLSurface, ItemRect, ItemRect.BottomLeft() - CPoint(0, 1) + CPoint(ItemRect.Width()/2, 0), m_Items[i].ItemColor);
// Draw the picture (if available):
if (m_Bitmaps.at(i) != nullptr) {
SDL_Rect DestRect = ItemRect.Move(9, 1).SDLRect();
SDL_BlitSurface(m_Bitmaps.at(i)->Bitmap(), &PictureSourceRect, m_pSDLSurface, &DestRect);
}
}
}
}
}
void CNavigationBar::SetWindowRect(const CRect& WindowRect) {
CWindow::SetWindowRect(WindowRect);
m_ClientRect = CRect(2, 2, m_WindowRect.Width() - 2, m_WindowRect.Height() - 2);
}
void CNavigationBar::PaintToSurface(SDL_Surface& ScreenSurface, SDL_Surface& FloatingSurface, const CPoint& Offset) const {
CWindow::PaintToSurface(ScreenSurface, FloatingSurface, Offset);
}
bool CNavigationBar::OnMouseButtonDown(CPoint Point, unsigned int Button)
{
CPoint WindowPoint(ViewToClient(Point));
bool bResult = CWindow::OnMouseButtonDown(Point, Button);
if (!bResult && m_bVisible && (Button == CMouseMessage::LEFT))
{
if (!m_Items.empty() && m_ClientRect.HitTest(WindowPoint) == CRect::RELPOS_INSIDE) {
// Prep the new selection
// judb m_iFocusedItem should be <= the number of items in the bar (0-based, so m_Items.size() - 1)
m_iFocusedItem = stdex::MinInt((WindowPoint.XPos() / m_iItemWidth), m_Items.size() - 1);
SelectItem(m_iFocusedItem);
bResult = true;
}
}
return bResult;
}
// this routine doesn't do a lot for the moment :-)
// Functionality may be added later.
bool CNavigationBar::HandleMessage(CMessage* pMessage) {
bool bHandled = false;
if (pMessage) {
switch(pMessage->MessageType()) {
case CMessage::KEYBOARD_KEYDOWN:
{
CKeyboardMessage* pKeyMsg = dynamic_cast<CKeyboardMessage*>(pMessage);
if (pKeyMsg && pMessage->Destination() == this)
{
switch (pKeyMsg->Key)
{
case SDLK_LEFT:
FocusItem(getFocusedIndex() - 1);
break;
case SDLK_RIGHT:
FocusItem(getFocusedIndex() + 1);
break;
case SDLK_SPACE: // intentional fall through
case SDLK_RETURN:
SelectItem(getFocusedIndex());
break;
default:
// Let the parent handle it
Application().MessageServer()->QueueMessage(new CKeyboardMessage(CMessage::KEYBOARD_KEYDOWN, m_pParentWindow, this,
pKeyMsg->ScanCode, pKeyMsg->Modifiers, pKeyMsg->Key));
break;
bHandled = false;
break;
}
}
break;
}
case CMessage::CTRL_VALUECHANGE:
case CMessage::CTRL_VALUECHANGING:
{
break;
}
default :
bHandled = CWindow::HandleMessage(pMessage);
break;
}
}
return bHandled;
}
}
| 8,256
|
C++
|
.cpp
| 220
| 33.145455
| 150
| 0.704287
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,853
|
wg_radiobutton.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_radiobutton.cpp
|
// wg_radiobutton.cpp
//
// CRadioButton class implementation
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_radiobutton.h"
#include "wg_application.h"
namespace wGui
{
// judb p is the upper-left corner of the radiobutton; size is the width=height
CRadioButton::CRadioButton(const CPoint& p, int size, CWindow* pParent) :
CWindow(CRect(p, size, size), pParent),
m_eRadioButtonState(UNCHECKED),
m_MouseButton(0),
m_hBitmapRadioButton(CwgBitmapResourceHandle(Application(), WGRES_RADIOBUTTON_BITMAP))
{
m_BackgroundColor = DEFAULT_CHECKBOX_BACK_COLOR;
Application().MessageServer()->RegisterMessageClient(this, CMessage::KEYBOARD_KEYDOWN);
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_BUTTONUP);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_SINGLELCLICK);
Draw();
}
CRadioButton::~CRadioButton() = default;
void CRadioButton::SetState(EState eState)
{
if (m_eRadioButtonState != eState)
{
m_eRadioButtonState = eState;
Draw();
}
}
void CRadioButton::Select()
{
if (m_eRadioButtonState == UNCHECKED)
{
SetState(CHECKED);
// Uncheck all other 'children' of this parent that are radiobuttons:
std::list<CWindow*> myChildWindows = m_pParentWindow->GetChildWindows();
for (const auto &child : myChildWindows)
{
// Compare the types to find out if a child is a CRadioButton.
if (typeid(*child) == typeid(*this) && child != this)
{
// 'other' radiobutton found -> UNCHECK
dynamic_cast<CRadioButton*>(child)->SetState(UNCHECKED);
}
}
Application().MessageServer()->QueueMessage(new TIntMessage(CMessage::CTRL_VALUECHANGE, m_pParentWindow, this, 1));
}
}
void CRadioButton::Draw() const
{
CWindow::Draw();
if (m_pSDLSurface)
{
CRect SubRect(m_WindowRect.SizeRect());
CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
if (m_eRadioButtonState != DISABLED)
{
Painter.DrawRect(SubRect, false, COLOR_LIGHTGRAY);
Painter.DrawHLine(SubRect.Left(), SubRect.Right(), SubRect.Top(), COLOR_BLACK);
Painter.DrawVLine(SubRect.Top(), SubRect.Bottom(), SubRect.Left(), COLOR_BLACK);
SubRect.Grow(-1);
if (m_bHasFocus)
{
Painter.DrawRect(SubRect, false, COLOR_GRAY);
}
if (m_eRadioButtonState == CHECKED)
{
SubRect.Grow(-2);
Painter.DrawRect(SubRect, true, COLOR_BLACK, COLOR_BLACK);
/*
SDL_Rect SourceRect = m_WindowRect.SizeRect().SDLRect();
SDL_Rect DestRect = SubRect.SDLRect();
SDL_BlitSurface(m_hBitmapRadioButton.Bitmap(), &SourceRect, m_pSDLSurface, &DestRect);
*/
}
} else {
Painter.DrawRect(SubRect, false, COLOR_LIGHTGRAY);
}
}
}
bool CRadioButton::OnMouseButtonDown(CPoint Point, unsigned int Button)
{
bool bResult = CWindow::OnMouseButtonDown(Point, Button);
if (!bResult && m_bVisible && (m_eRadioButtonState != DISABLED) &&
(m_ClientRect.HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE))
{
m_MouseButton = Button;
bResult = true;
}
return bResult;
}
bool CRadioButton::OnMouseButtonUp(CPoint Point, unsigned int Button)
{
bool bResult = CWindow::OnMouseButtonUp(Point, Button);
if (!bResult && m_bVisible && (m_eRadioButtonState != DISABLED) && (m_MouseButton == Button) &&
(m_ClientRect.HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE))
{
CMessage::EMessageType MessageType = CMessage::UNKNOWN;
switch (m_MouseButton)
{
case CMouseMessage::LEFT:
MessageType = CMessage::CTRL_SINGLELCLICK;
break;
case CMouseMessage::RIGHT:
MessageType = CMessage::CTRL_SINGLERCLICK;
break;
case CMouseMessage::MIDDLE:
MessageType = CMessage::CTRL_SINGLEMCLICK;
break;
}
Application().MessageServer()->QueueMessage(new TIntMessage(MessageType, this, this, 0));
bResult = true;
}
return bResult;
}
bool CRadioButton::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::KEYBOARD_KEYDOWN:
{
CKeyboardMessage* pKeyboardMessage = dynamic_cast<CKeyboardMessage*>(pMessage);
if (pKeyboardMessage && pMessage->Destination() == this)
{
switch (pKeyboardMessage->Key)
{
case SDLK_RETURN: // intentional fall through
case SDLK_SPACE:
Select();
break;
default:
// Forward all key downs to parent
Application().MessageServer()->QueueMessage(new CKeyboardMessage(CMessage::KEYBOARD_KEYDOWN, m_pParentWindow, this,
pKeyboardMessage->ScanCode, pKeyboardMessage->Modifiers, pKeyboardMessage->Key));
break;
}
}
break;
}
case CMessage::MOUSE_BUTTONUP:
{
CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);
if (pMouseMessage && (m_ClientRect.HitTest(ViewToWindow(pMouseMessage->Point)) != CRect::RELPOS_INSIDE)
&& (m_MouseButton == pMouseMessage->Button))
{
m_MouseButton = 0;
bHandled = true;
}
break;
}
case CMessage::CTRL_SINGLELCLICK:
if (pMessage->Destination() == this)
{
Select();
bHandled = true;
}
break;
default :
bHandled = CWindow::HandleMessage(pMessage);
break;
}
}
return bHandled;
}
}
| 6,007
|
C++
|
.cpp
| 183
| 28.666667
| 127
| 0.705223
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,855
|
wg_dropdown.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_dropdown.cpp
|
// wg_dropdown.cpp
//
// CDropDown class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "std_ex.h"
#include "wg_dropdown.h"
#include "wg_application.h"
#include "wg_resources.h"
#include "wg_view.h"
#include <string>
namespace wGui
{
CDropDown::CDropDown(const CRect& WindowRect, CWindow* pParent, bool bAllowEdit, unsigned int iItemHeight, CFontEngine* pFontEngine) :
CWindow(WindowRect, pParent),
m_bAllowEdit(bAllowEdit),
m_iItemCount(5)
{
m_pCViewAncestor = GetView();
m_pEditBox = new CEditBox(CRect(0, 0, m_WindowRect.Width() - m_WindowRect.Height(), m_WindowRect.Height()), this, pFontEngine);
if (!m_bAllowEdit)
{
m_pEditBox->SetReadOnly(true);
// Override the normal read-only BG color
m_pEditBox->SetBackgroundColor(COLOR_WHITE);
}
m_pListBox = new CListBox(CRect(0, m_WindowRect.Height(), m_WindowRect.Width(), m_WindowRect.Height() + iItemHeight * m_iItemCount + 2),
this, true, iItemHeight, pFontEngine);
m_pListBox->SetVisible(false);
m_pListBox->SetDropDown(this);
m_pDropButton = new CPictureButton(
CRect(m_WindowRect.Width() - m_WindowRect.Height() + 1, 0, m_WindowRect.Width(), m_WindowRect.Height()),
this, CwgBitmapResourceHandle(Application(), WGRES_DOWN_ARROW_BITMAP));
Application().MessageServer()->RegisterMessageClient(this, CMessage::KEYBOARD_KEYDOWN);
Application().MessageServer()->RegisterMessageClient(this, CMessage::MOUSE_BUTTONDOWN);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_SINGLELCLICK);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_VALUECHANGE);
Draw();
}
CDropDown::~CDropDown()
{
if(m_pCViewAncestor)
{
// Reset floating window (see HideListBox() and ShowListBox()), otherwise the FloatingWindow
// would point to 'nothing' -> memory errors. This could occur when you open the dropdown list
// and immediately close the window with the keyboard.
m_pCViewAncestor->SetFloatingWindow(nullptr);
}
}
void CDropDown::SetListboxHeight(int iItemCount)
{
m_iItemCount = iItemCount;
m_pListBox->SetWindowRect(
CRect(0, m_WindowRect.Height(), m_WindowRect.Width(), m_WindowRect.Height() + m_pListBox->GetItemHeight() * m_iItemCount + 2));
}
void CDropDown::SetWindowRect(const CRect& WindowRect)
{
CWindow::SetWindowRect(WindowRect);
m_pListBox->SetWindowRect(CRect(0, m_WindowRect.Height(), m_WindowRect.Width(), m_WindowRect.Height() + m_pListBox->GetItemHeight() * m_iItemCount + 2));
m_pDropButton->SetWindowRect(CRect(m_WindowRect.Width() - m_WindowRect.Height() + 1, 0, m_WindowRect.Width(), m_WindowRect.Height()));
m_pEditBox->SetWindowRect(CRect(0, 0, m_WindowRect.Width() - m_WindowRect.Height(), m_WindowRect.Height()));
}
void CDropDown::SetWindowText(const std::string& sWindowText)
{
m_pEditBox->SetWindowText(sWindowText);
}
std::string CDropDown::GetWindowText() const
{
return m_pEditBox->GetWindowText();
}
void CDropDown::MoveWindow(const CPoint& MoveDistance)
{
CWindow::MoveWindow(MoveDistance);
m_pListBox->MoveWindow(MoveDistance);
}
void CDropDown::SetVisible(bool bVisible) {
CWindow::SetVisible(bVisible);
HideListBox();
}
void CDropDown::SetIsFocusable(bool bFocusable) {
m_pDropButton->SetIsFocusable(bFocusable);
}
bool CDropDown::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
CRect SubRect(m_WindowRect);
SubRect.Grow(-3);
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::KEYBOARD_KEYDOWN:
{
CKeyboardMessage* pKeyboardMessage = dynamic_cast<CKeyboardMessage*>(pMessage);
if (pKeyboardMessage && pMessage->Destination() == this)
{
switch (pKeyboardMessage->Key)
{
case SDLK_UP:
SelectItem(GetSelectedIndex() - 1);
ShowListBox();
break;
case SDLK_DOWN:
SelectItem(GetSelectedIndex() + 1);
ShowListBox();
break;
case SDLK_RETURN:
case SDLK_SPACE:
HideListBox();
break;
case SDLK_TAB:
HideListBox();
#if __GNUC__ >= 7
[[gnu::fallthrough]]; // the parent frame will change focused widget
#endif
default:
// Forward all key downs to parent
Application().MessageServer()->QueueMessage(
new CKeyboardMessage(CMessage::KEYBOARD_KEYDOWN, m_pParentWindow, this,
pKeyboardMessage->ScanCode, pKeyboardMessage->Modifiers,
pKeyboardMessage->Key));
break;
}
}
break;
}
case CMessage::MOUSE_BUTTONDOWN:
{
CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);
if (pMouseMessage->Button == CMouseMessage::LEFT)
{
if (m_pListBox->IsVisible() &&
m_pDropButton->GetWindowRect().SizeRect().HitTest(m_pDropButton->ViewToWindow(pMouseMessage->Point)) != CRect::RELPOS_INSIDE &&
m_pListBox->GetWindowRect().SizeRect().HitTest(m_pListBox->ViewToWindow(pMouseMessage->Point)) != CRect::RELPOS_INSIDE)
{
HideListBox();
}
}
break;
}
case CMessage::CTRL_SINGLELCLICK:
{
if (pMessage->Destination() == this)
{
if (pMessage->Source() == m_pDropButton)
{
if (m_pListBox->IsVisible())
{
HideListBox();
}
else
{
ShowListBox();
}
bHandled = true;
}
}
break;
}
case CMessage::CTRL_VALUECHANGE:
{
TIntMessage* pIntMessage = dynamic_cast<TIntMessage*>(pMessage);
if (pIntMessage && pMessage->Destination() == this)
{
if (pIntMessage->Source() == m_pListBox)
{
const SListItem& ListItem = m_pListBox->GetItem(pIntMessage->Value());
SetWindowText(ListItem.sItemText);
HideListBox();
Application().MessageServer()->QueueMessage(new TIntMessage(CMessage::CTRL_VALUECHANGE, m_pParentWindow, this, 0));
bHandled = true;
}
}
TStringMessage* pStringMessage = dynamic_cast<TStringMessage*>(pMessage);
if (pStringMessage && pMessage->Destination() == this)
{
if (pStringMessage->Source() == m_pEditBox)
{
m_pListBox->SetAllSelections(false);
HideListBox();
Application().MessageServer()->QueueMessage(new TIntMessage(CMessage::CTRL_VALUECHANGE, m_pParentWindow, this, 0));
bHandled = true;
}
}
break;
}
default :
bHandled = CWindow::HandleMessage(pMessage);
break;
}
}
return bHandled;
}
int CDropDown::GetSelectedIndex() {
for (unsigned int i = 0; i < m_pListBox->Size(); i ++) {
if (IsSelected(i)) {
return i;
}
}
return -1;
}
void CDropDown::SelectItem(unsigned int iItemIndex) {
if (iItemIndex >= m_pListBox->Size()) {
return;
}
m_pListBox->SetSelection(iItemIndex, true, false);
SetWindowText(m_pListBox->GetItem(iItemIndex).sItemText);
Application().MessageServer()->QueueMessage(new TIntMessage(CMessage::CTRL_VALUECHANGE, this, this, 0));
Draw();
}
void CDropDown::ShowListBox()
{
if (!m_pListBox->IsVisible())
{
if (m_pCViewAncestor)
{
m_pCViewAncestor->SetFloatingWindow(m_pListBox);
}
m_pListBox->SetVisible(true);
}
}
void CDropDown::HideListBox()
{
if (m_pListBox->IsVisible())
{
m_pListBox->SetVisible(false);
if (m_pCViewAncestor && m_pCViewAncestor->GetFloatingWindow() == m_pListBox)
{
m_pCViewAncestor->SetFloatingWindow(nullptr);
}
}
}
}
| 8,905
|
C++
|
.cpp
| 250
| 28.448
| 155
| 0.639147
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
753,856
|
wg_fontengine.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_fontengine.cpp
|
// wg_fontengine.cpp
//
// CFontEngine implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_fontengine.h"
#include "wg_error.h"
#include "wg_application.h"
#include <string>
namespace wGui {
// Static members
FT_Library CFontEngine::m_FTLibrary;
bool CFontEngine::m_bFTLibraryLoaded = false;
CFontEngine::CFontEngine(const std::string& sFontFileName, unsigned char FontSize)
{
if (!m_bFTLibraryLoaded)
{
if (FT_Init_FreeType(&m_FTLibrary))
{
throw(Wg_Ex_FreeType("Unable to initialize FreeType library.", "CFontEngine::CFontEngine"));
}
m_bFTLibraryLoaded = true;
}
if (FT_New_Face(m_FTLibrary, sFontFileName.c_str(), 0, &m_FontFace))
{
throw(Wg_Ex_FreeType("Unable to create font face.", "CFontEngine::CFontEngine"));
}
if (FT_Set_Char_Size(m_FontFace, 0, FontSize * 64, 0, 0))
{
throw(Wg_Ex_FreeType("Unable to set character size.", "CFontEngine::CFontEngine"));
}
}
CFontEngine::~CFontEngine()
{
FT_Done_Face(m_FontFace);
}
FT_BitmapGlyphRec* CFontEngine::RenderGlyph(char Char)
{
auto glyphIter = m_CachedGlyphMap.find(Char);
if (glyphIter == m_CachedGlyphMap.end())
{
if (FT_Load_Char(m_FontFace, Char, FT_LOAD_DEFAULT))
{
throw(Wg_Ex_FreeType("Unable to render glyph.", "CFontEngine::RenderGlyph"));
}
FT_Glyph glyph;
if (FT_Get_Glyph(m_FontFace->glyph, &glyph))
{
throw(Wg_Ex_FreeType("Unable to copy glyph.", "CFontEngine::RenderGlyph"));
}
if (FT_Glyph_To_Bitmap(&glyph, ft_render_mode_normal, nullptr, 1))
{
throw(Wg_Ex_FreeType("Unable to render glyph.", "CFontEngine::RenderGlyph"));
}
glyphIter = m_CachedGlyphMap.insert(std::make_pair(Char, *reinterpret_cast<FT_BitmapGlyph>(glyph))).first;
}
return &(glyphIter->second);
}
FT_Glyph_Metrics* CFontEngine::GetMetrics(char Char)
{
auto glyphIter = m_CachedMetricsMap.find(Char);
if (glyphIter == m_CachedMetricsMap.end())
{
if (FT_Load_Char(m_FontFace, Char, FT_LOAD_DEFAULT))
{
throw(Wg_Ex_FreeType("Unable to render glyph.", "CFontEngine::RenderGlyph"));
}
glyphIter = m_CachedMetricsMap.insert(std::make_pair(Char, m_FontFace->glyph->metrics)).first;
}
return &(glyphIter->second);
}
}
| 2,925
|
C++
|
.cpp
| 89
| 30.853933
| 108
| 0.736805
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,857
|
CapriceVKeyboardView.cpp
|
ColinPitrat_caprice32/src/gui/src/CapriceVKeyboardView.cpp
|
#include "CapriceVKeyboardView.h"
CapriceVKeyboardView::CapriceVKeyboardView(CApplication& application, SDL_Surface* surface, SDL_Surface* backSurface, const CRect& WindowRect) : CView(application, surface, backSurface, WindowRect)
{
m_kbdFrame = new CapriceVKeyboard(CRect(CPoint(0, 0), 384, 270), this, nullptr);
}
std::list<SDL_Event> CapriceVKeyboardView::GetEvents()
{
return m_kbdFrame->GetEvents();
}
void CapriceVKeyboardView::PaintToSurface(SDL_Surface& ScreenSurface, SDL_Surface& FloatingSurface, const CPoint& Offset) const
{
if (m_bVisible)
{
// Reset backgound
SDL_BlitSurface(m_pBackSurface, nullptr, &ScreenSurface, nullptr);
// Draw all child windows recursively
for (const auto child : m_ChildWindows)
{
if (child)
{
child->PaintToSurface(ScreenSurface, FloatingSurface, Offset);
}
}
}
}
| 870
|
C++
|
.cpp
| 25
| 31.24
| 197
| 0.744352
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,858
|
CapriceMemoryTool.cpp
|
ColinPitrat_caprice32/src/gui/src/CapriceMemoryTool.cpp
|
// 'Memory tool' window for Caprice32
#include "CapriceMemoryTool.h"
#include "cap32.h"
#include "z80.h"
#include "log.h"
#include <iomanip>
#include <sstream>
#include <string>
extern byte *pbRAM;
extern t_CPC CPC;
namespace wGui {
CapriceMemoryTool::CapriceMemoryTool(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine) :
CFrame(WindowRect, pParent, pFontEngine, "Memory Tool", false)
{
SetModal(true);
m_pMonoFontEngine = Application().GetFontEngine(CPC.resources_path + "/vera_mono.ttf", 8);
// Make this window listen to incoming CTRL_VALUECHANGING messages for dropdown list update
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_VALUECHANGE);
Application().MessageServer()->RegisterMessageClient(this, CMessage::CTRL_VALUECHANGING);
m_pPokeAdressLabel = new CLabel( CPoint(10, 18), this, "Address: ");
m_pPokeAdress = new CEditBox(CRect(CPoint(55, 13), 30, 20), this);
m_pPokeAdress->SetIsFocusable(true);
m_pPokeValueLabel = new CLabel( CPoint(95, 18), this, "Value: ");
m_pPokeValue = new CEditBox(CRect(CPoint(130, 13), 30, 20), this);
m_pPokeValue->SetIsFocusable(true);
m_pButtonPoke = new CButton( CRect(CPoint(175, 13), 30, 20), this, "Poke");
m_pButtonPoke->SetIsFocusable(true);
m_pAdressLabel = new CLabel( CPoint(10, 50), this, "Address: ");
m_pAdressValue = new CEditBox(CRect(CPoint(55, 45), 30, 20), this);
m_pAdressValue->SetIsFocusable(true);
m_pButtonDisplay = new CButton( CRect(CPoint(95, 45), 45, 20), this, "Display");
m_pButtonDisplay->SetIsFocusable(true);
m_pBytesPerLineLbl = new CLabel( CPoint(240, 35), this, "Bytes per line:");
m_pBytesPerLine = new CDropDown( CRect(CPoint(240, 45), 50, 20), this, false);
m_pBytesPerLine->AddItem(SListItem("1"));
m_pBytesPerLine->AddItem(SListItem("4"));
m_pBytesPerLine->AddItem(SListItem("8"));
m_pBytesPerLine->AddItem(SListItem("16"));
m_pBytesPerLine->AddItem(SListItem("32"));
m_pBytesPerLine->AddItem(SListItem("64"));
m_pBytesPerLine->SetListboxHeight(4);
m_bytesPerLine = 16;
m_pBytesPerLine->SelectItem(3);
m_pBytesPerLine->SetIsFocusable(true);
m_pFilterLabel = new CLabel( CPoint(15, 80), this, "Byte: ");
m_pFilterValue = new CEditBox(CRect(CPoint(55, 75), 30, 20), this);
m_pFilterValue->SetIsFocusable(true);
m_pButtonFilter = new CButton( CRect(CPoint(95, 75), 45, 20), this, "Filter");
m_pButtonFilter->SetIsFocusable(true);
m_pButtonCopy = new CButton( CRect(CPoint(220, 75), 95, 20), this, "Dump to stdout");
m_pButtonCopy->SetIsFocusable(true);
m_pTextMemContent = new CTextBox(CRect(CPoint(15, 105), 300, 102), this, m_pMonoFontEngine);
m_pButtonClose = new CButton( CRect(CPoint(15, 220), 300, 20), this, "Close");
m_pButtonClose->SetIsFocusable(true);
m_pPokeAdress->SetContentType(CEditBox::HEXNUMBER);
m_pPokeValue->SetContentType(CEditBox::HEXNUMBER);
m_pAdressValue->SetContentType(CEditBox::HEXNUMBER);
m_pFilterValue->SetContentType(CEditBox::HEXNUMBER);
m_pTextMemContent->SetReadOnly(true);
m_filterValue = -1;
m_displayValue = -1;
UpdateTextMemory();
}
CapriceMemoryTool::~CapriceMemoryTool() = default;
bool CapriceMemoryTool::HandleMessage(CMessage* pMessage)
{
bool bHandled = false;
if (pMessage)
{
switch(pMessage->MessageType())
{
case CMessage::CTRL_SINGLELCLICK:
{
if (pMessage->Destination() == this)
{
if (pMessage->Source() == m_pButtonPoke) {
std::string adress = m_pPokeAdress->GetWindowText();
std::string value = m_pPokeValue->GetWindowText();
unsigned int pokeAdress = strtol(adress.c_str(), nullptr, 16);
int pokeValue = strtol(value.c_str(), nullptr, 16);
if(!adress.empty() && !value.empty() && pokeAdress < 65536 && pokeValue >= -128 && pokeValue <= 255) {
std::cout << "Poking " << pokeAdress << " with " << pokeValue << std::endl;
pbRAM[pokeAdress] = pokeValue;
UpdateTextMemory();
} else {
std::cout << "Cannot poke " << adress << "(" << pokeAdress << ") with " << value << "(" << pokeValue << ")" << std::endl;
}
bHandled = true;
break;
}
if (pMessage->Source() == m_pButtonDisplay) {
std::string display = m_pAdressValue->GetWindowText();
if(display.empty()) {
m_displayValue = -1;
} else {
m_displayValue = strtol(display.c_str(), nullptr, 16);
}
m_filterValue = -1;
std::cout << "Displaying address " << m_displayValue << " in memory." << std::endl;
UpdateTextMemory();
bHandled = true;
break;
}
if (pMessage->Source() == m_pButtonFilter) {
m_displayValue = -1;
std::string filter = m_pFilterValue->GetWindowText();
if(filter.empty()) {
m_filterValue = -1;
} else {
m_filterValue = strtol(filter.c_str(), nullptr, 16);
}
std::cout << "Filtering value " << m_filterValue << " in memory." << std::endl;
UpdateTextMemory();
bHandled = true;
break;
}
if (pMessage->Source() == m_pButtonCopy) {
std::cout << m_pTextMemContent->GetWindowText() << std::endl;
if(SDL_SetClipboardText(m_pTextMemContent->GetWindowText().c_str()) < 0) {
LOG_ERROR("Error while copying data to clipboard: " << SDL_GetError());
}
bHandled = true;
break;
}
if (pMessage->Source() == m_pButtonClose) {
CloseFrame();
bHandled = true;
break;
}
}
}
break;
case CMessage::CTRL_VALUECHANGE:
if (pMessage->Destination() == m_pBytesPerLine) {
switch (m_pBytesPerLine->GetSelectedIndex()) {
case 0:
m_bytesPerLine = 1;
break;
case 1:
m_bytesPerLine = 4;
break;
case 2:
m_bytesPerLine = 8;
break;
case 3:
m_bytesPerLine = 16;
break;
case 4:
m_bytesPerLine = 32;
break;
case 5:
m_bytesPerLine = 64;
break;
}
UpdateTextMemory();
}
break;
default :
break;
}
}
if (!bHandled) {
bHandled = CFrame::HandleMessage(pMessage);
}
return bHandled;
}
void CapriceMemoryTool::UpdateTextMemory() {
std::ostringstream memText;
for(unsigned int i = 0; i < 65536/m_bytesPerLine; i++) {
std::ostringstream memLine;
memLine << std::uppercase << std::setfill('0') << std::setw(4) << std::hex << i*m_bytesPerLine << " : ";
bool displayLine = false;
bool filterAdress = (m_displayValue >= 0 && m_displayValue <= 65535);
bool filterValue = (m_filterValue >= 0 && m_filterValue <= 255);
for(unsigned int j = 0; j < m_bytesPerLine; j++) {
memLine << std::setw(2) << static_cast<unsigned int>(pbRAM[i*m_bytesPerLine+j]) << " ";
if(!filterAdress && !filterValue) {
displayLine = true;
}
if(filterValue && static_cast<int>(pbRAM[i*m_bytesPerLine+j]) == m_filterValue) {
displayLine = true;
}
if(filterAdress && (i*m_bytesPerLine+j == static_cast<unsigned int>(m_displayValue))) {
displayLine = true;
}
}
if(displayLine) {
memText << memLine.str() << "\n";
}
}
m_pTextMemContent->SetWindowText(memText.str().substr(0, memText.str().size()-1));
}
} // namespace wGui
| 8,128
|
C++
|
.cpp
| 193
| 33.450777
| 137
| 0.578522
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
753,859
|
wg_picture.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_picture.cpp
|
// wg_picture.cpp
//
// CPicture class implementation
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_picture.h"
#include <string>
namespace wGui
{
CPicture::CPicture(const CRect& WindowRect, CWindow* pParent, const std::string& sPictureFile,
bool bDrawBorder, const CRGBColor& BorderColor) :
CWindow(WindowRect, pParent),
m_bDrawBorder(bDrawBorder),
m_BorderColor(BorderColor),
m_hBitmap(CBitmapFileResourceHandle(sPictureFile))
{
if (m_bDrawBorder)
{
m_ClientRect.Grow(-1);
}
Draw();
}
CPicture::CPicture(const CRect& WindowRect, CWindow* pParent, const CBitmapResourceHandle& hBitmap,
bool bDrawBorder, const CRGBColor& BorderColor) :
CWindow(WindowRect, pParent),
m_bDrawBorder(bDrawBorder),
m_BorderColor(BorderColor),
m_hBitmap(hBitmap)
{
if (m_bDrawBorder)
{
m_ClientRect.Grow(-1);
}
Draw();
}
CPicture::~CPicture() = default;
void CPicture::Draw() const
{
CWindow::Draw();
if (m_pSDLSurface)
{
SDL_Rect SourceRect = m_ClientRect.SizeRect().SDLRect();
SDL_Rect DestRect = m_ClientRect.SDLRect();
SDL_BlitSurface(m_hBitmap.Bitmap(), &SourceRect, m_pSDLSurface, &DestRect);
CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
if (m_bDrawBorder) {
Painter.DrawRect(m_WindowRect.SizeRect(), false, m_BorderColor);
}
}
}
void CPicture::SetWindowRect(const CRect& WindowRect)
{
CWindow::SetWindowRect(WindowRect);
m_ClientRect = m_WindowRect.SizeRect();
m_ClientRect.Grow(-1);
}
}
| 2,225
|
C++
|
.cpp
| 74
| 28.216216
| 99
| 0.762887
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,860
|
wg_color.cpp
|
ColinPitrat_caprice32/src/gui/src/wg_color.cpp
|
// wg_color.cpp
//
// CRGBColor class
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "wg_color.h"
#include "std_ex.h"
#include <string>
namespace wGui
{
CRGBColor::CRGBColor(const Uint32* pColorValue, const SDL_PixelFormat* pFormat)
{
red = stdex::safe_static_cast<unsigned char>((pFormat->Rmask & *pColorValue) >> pFormat->Rshift);
green = stdex::safe_static_cast<unsigned char>((pFormat->Gmask & *pColorValue) >> pFormat->Gshift);
blue = stdex::safe_static_cast<unsigned char>((pFormat->Bmask & *pColorValue) >> pFormat->Bshift);
alpha = stdex::safe_static_cast<unsigned char>((pFormat->Amask & *pColorValue) >> pFormat->Ashift);
}
CRGBColor& CRGBColor::operator=(const CRGBColor& c) = default;
CRGBColor::CRGBColor(std::string s)
{
bool bInitted=false;
std::string::size_type pos;
std::string::size_type posOld;
if (s == "WHITE")
{
red = 0xFF;
green = 0xFF;
blue = 0xFF;
bInitted = true;
}
if (s == "LIGHTGRAY")
{
red = 0xC0;
green = 0xC0;
blue = 0xC0;
bInitted = true;
}
// etc...
//0,0,0 - 255,255,255
//|-5-| |---11----|
//It's possible that we have a string with arbitrary values
if (!bInitted && s.length() > 4 && s.length() < 12)
{
pos = s.find(',', 0);
if (pos != std::string::npos)
{
std::string sub = s.substr(0, pos);
red = stdex::safe_static_cast<unsigned char>((stdex::atoi(sub)));
posOld = pos + 1;
pos = s.find(',', posOld);
if (pos != std::string::npos)
{
sub = s.substr(posOld, pos - posOld);
green = stdex::safe_static_cast<unsigned char>((stdex::atoi(sub)));
posOld = pos + 1;
sub = s.substr(posOld, s.length() - posOld);
if (sub.length() > 0)
{
blue = stdex::safe_static_cast<unsigned char>((stdex::atoi(sub)));
bInitted = true;
}
}
}
//If we have yet to find a good value, we'll just use white... maybe this should throw an error...
if (!bInitted)
{
red = 0xFF;
green = 0xFF;
blue = 0xFF;
}
}
}
CRGBColor CRGBColor::operator+(const CRGBColor& c) const
{
double c1_ratio = stdex::safe_static_cast<double>(alpha) / 0xFF;
double c2_ratio = stdex::safe_static_cast<double>(c.alpha) / 0xFF;
double new_red = red * c1_ratio + c.red * c2_ratio;
if (new_red > 255)
{
new_red = 255;
}
double new_green = green * c1_ratio + c.green * c2_ratio;
if (new_green > 255)
{
new_green = 255;
}
double new_blue = blue * c1_ratio + c.blue * c2_ratio;
if (new_blue > 255)
{
new_blue = 255;
}
double new_alpha = alpha + c.alpha;
if (new_alpha > 255)
{
new_alpha = 255;
}
return CRGBColor(stdex::safe_static_cast<unsigned char>(new_red), stdex::safe_static_cast<unsigned char>(new_green),
stdex::safe_static_cast<unsigned char>(new_blue), stdex::safe_static_cast<unsigned char>(new_alpha));
}
CRGBColor CRGBColor::operator*(float f) const
{
double new_red = floor(red * f);
if (new_red > 255)
{
new_red = 255;
}
double new_green = floor(green * f);
if (new_green > 255)
{
new_green = 255;
}
double new_blue = floor(blue * f);
if (new_blue > 255)
{
new_blue = 255;
}
return CRGBColor(stdex::safe_static_cast<unsigned char>(new_red), stdex::safe_static_cast<unsigned char>(new_green),
stdex::safe_static_cast<unsigned char>(new_blue));
}
CRGBColor CRGBColor::operator|(const CRGBColor& c) const
{
return CRGBColor(red | c.red, green | c.green, blue | c.blue, alpha | c.alpha);
}
CRGBColor CRGBColor::operator&(const CRGBColor& c) const
{
return CRGBColor(red & c.red, green & c.green, blue & c.blue, alpha & c.alpha);
}
CRGBColor CRGBColor::operator^(const CRGBColor& c) const
{
return CRGBColor(red ^ c.red, green ^ c.green, blue ^ c.blue, alpha ^ c.alpha);
}
CRGBColor CRGBColor::MixNormal(const CRGBColor& c) const
{
double fg_ratio = stdex::safe_static_cast<double>(c.alpha) / 0xFF;
double bg_ratio = stdex::safe_static_cast<double>(1.0 - fg_ratio);
char new_red = stdex::safe_static_cast<unsigned char>(floor(red * bg_ratio + c.red * fg_ratio));
char new_green = stdex::safe_static_cast<unsigned char>(floor(green * bg_ratio + c.green * fg_ratio));
char new_blue = stdex::safe_static_cast<unsigned char>(floor(blue * bg_ratio + c.blue * fg_ratio));
return CRGBColor(new_red, new_green, new_blue, alpha);
}
// standard
CRGBColor DEFAULT_BACKGROUND_COLOR = CRGBColor(0xC0, 0xC0, 0xCA);
CRGBColor DEFAULT_FOREGROUND_COLOR = CRGBColor(0x90, 0x90, 0x90);
CRGBColor DEFAULT_LINE_COLOR = CRGBColor(0xC0, 0xC0, 0xC0);
CRGBColor DEFAULT_DISABLED_LINE_COLOR = CRGBColor(0x80, 0x80, 0x80);
CRGBColor COLOR_TRANSPARENT = CRGBColor(0x00, 0x00, 0x00, 0x00);
CRGBColor COLOR_WHITE = CRGBColor(0xFF, 0xFF, 0xFF);
CRGBColor COLOR_LIGHTGRAY = CRGBColor(0xC0, 0xC0, 0xC0);
CRGBColor COLOR_GRAY = CRGBColor(0x80, 0x80, 0x80);
CRGBColor COLOR_DARKGRAY = CRGBColor(0x40, 0x40, 0x40);
CRGBColor COLOR_BLACK = CRGBColor(0x00, 0x00, 0x00);
CRGBColor COLOR_BLUE = CRGBColor(0x00, 0x00, 0xFF);
CRGBColor COLOR_DARKBLUE = CRGBColor(0x00, 0x00, 0x80);
CRGBColor COLOR_BLUE_1 = CRGBColor(0x40, 0x48, 0x73);
CRGBColor COLOR_RED = CRGBColor(0xFF, 0x00, 0x00);
CRGBColor COLOR_GREEN = CRGBColor(0x00, 0xFF, 0x00);
CRGBColor COLOR_DARKGREEN = CRGBColor(0x00, 0x80, 0x00);
CRGBColor COLOR_YELLOW = CRGBColor(0xFF, 0xFF, 0x00);
CRGBColor COLOR_CYAN = CRGBColor(0x00, 0xFF, 0xFF);
CRGBColor COLOR_MAGENTA = CRGBColor(0xFF, 0x00, 0xFF);
CRGBColor COLOR_DARKMAGENTA = CRGBColor(0x80, 0x00, 0x80);
// judb
CRGBColor DEFAULT_TITLEBAR_COLOR = CRGBColor(0xA6, 0xAD, 0xD0); // caption bar for CFrames
CRGBColor DEFAULT_TITLEBAR_TEXT_COLOR = CRGBColor(0x30, 0x38, 0x63); // text in titlebar
CRGBColor DEFAULT_BUTTON_COLOR = CRGBColor(0xC0, 0xC0, 0xCA); // (picture) buttons, scrollbar and dropdown buttons.
CRGBColor DEFAULT_TEXT_COLOR = CRGBColor(0x00, 0x00, 0x00); // text in labels, buttons...
CRGBColor ALTERNATE_TEXT_COLOR = CRGBColor(0x30, 0x38, 0x63); // a 2nd color for example text on groupboxes...
CRGBColor DEFAULT_CHECKBOX_COLOR = CRGBColor(0x40, 0x48, 0x73); // checkbox and radiobutton color
CRGBColor DEFAULT_CHECKBOX_BACK_COLOR = CRGBColor(0xFF, 0xFF, 0xFF); // checkbox and radiobutton background color
CRGBColor DEFAULT_SELECTION_COLOR = CRGBColor(0xA6, 0xAD, 0xD0);
}
| 6,933
|
C++
|
.cpp
| 188
| 34.739362
| 117
| 0.711965
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
753,861
|
disk.h
|
ColinPitrat_caprice32/src/disk.h
|
#ifndef DISK_H
#define DISK_H
#include <string>
// FDC constants
#define DSK_BPTMAX 8192
#define DSK_TRACKMAX 102 // max amount that fits in a DSK header
#define DSK_SIDEMAX 2
#define DSK_SECTORMAX 29 // max amount that fits in a track header
#define FDC_TO_CPU 0
#define CPU_TO_FDC 1
#define CMD_PHASE 0
#define EXEC_PHASE 1
#define RESULT_PHASE 2
#define SKIP_flag 1 // skip sectors with DDAM/DAM
#define SEEKDRVA_flag 2 // seek operation has finished for drive A
#define SEEKDRVB_flag 4 // seek operation has finished for drive B
#define RNDDE_flag 8 // simulate random DE sectors
#define OVERRUN_flag 16 // data transfer timed out
#define SCAN_flag 32 // one of the three scan commands is active
#define SCANFAILED_flag 64 // memory and sector data does not match
#define STATUSDRVA_flag 128 // status change of drive A
#define STATUSDRVB_flag 256 // status change of drive B
// This is only for debug purposes
std::string chrn_to_string(unsigned char* chrn);
typedef struct {
char id[34];
char unused1[14];
unsigned char tracks;
unsigned char sides;
unsigned char unused2[2];
unsigned char track_size[DSK_TRACKMAX*DSK_SIDEMAX];
} t_DSK_header;
typedef struct {
char id[12];
char unused1[4];
unsigned char track;
unsigned char side;
unsigned char unused2[2];
unsigned char bps;
unsigned char sectors;
unsigned char gap3;
unsigned char filler;
unsigned char sector[DSK_SECTORMAX][8];
} t_track_header;
class t_sector {
public:
unsigned char CHRN[4]; // the CHRN for this sector
unsigned char flags[4]; // ST1 and ST2 - reflects any possible error conditions
void setData(unsigned char* data) {
data_ = data;
}
unsigned char* getDataForWrite() {
return data_;
}
unsigned char* getDataForRead() {
weak_read_version_ = (weak_read_version_ + 1) % weak_versions_;
return &data_[weak_read_version_*size_];
}
void setSizes(unsigned int size, unsigned int total_size);
unsigned int getTotalSize() const {
return total_size_;
}
private:
unsigned int size_; // sector size in bytes
unsigned char *data_; // pointer to sector data
unsigned int total_size_; // total data size in bytes
unsigned int weak_versions_; // number of versions of this sector (should be 1 except for weak/random sectors)
unsigned int weak_read_version_; // version of the sector to return when reading
};
typedef struct {
unsigned int sectors; // sector count for this track
unsigned int size; // track size in bytes
unsigned char *data; // pointer to track data
t_sector sector[DSK_SECTORMAX]; // array of sector information structures
} t_track;
struct t_drive {
unsigned int tracks; // total number of tracks
unsigned int current_track; // location of drive head
unsigned int sides; // total number of sides
unsigned int current_side; // side being accessed
unsigned int current_sector; // sector being accessed
bool altered; // has the image been modified?
unsigned int write_protected; // is the image write protected?
unsigned int random_DEs; // sectors with Data Errors return random data?
unsigned int flipped; // reverse the side to access?
long ipf_id; // IPF ID if the track is loaded with a IPF image
void (*track_hook)(struct t_drive *); // hook called each disk rotation
void (*eject_hook)(struct t_drive *); // hook called on disk eject
t_track track[DSK_TRACKMAX][DSK_SIDEMAX]; // array of track information structures
};
struct t_disk_format {
std::string label; // label to display in options dialog
unsigned int tracks{0}; // number of tracks
unsigned int sides{0}; // number of sides
unsigned int sectors{0}; // sectors per track
unsigned int sector_size{0}; // sector size as N value
unsigned int gap3_length{0}; // GAP#3 size
unsigned char filler_byte{0}; // default byte to use
unsigned char sector_ids[2][16]{0}; // sector IDs - indices: side, sector
};
#endif
| 4,066
|
C++
|
.h
| 101
| 37.09901
| 113
| 0.711353
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,862
|
z80_macros.h
|
ColinPitrat_caprice32/src/z80_macros.h
|
/* Caprice32 - Amstrad CPC Emulator
(c) Copyright 1997-2004 Ulrich Doewich
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* TODO: single letter macros are reserved for compiler internal use and
* should be renamed/refactored in future.
* See: https://github.com/ColinPitrat/caprice32/issues/150
*/
#ifndef Z80_MACROS_H
#define Z80_MACROS_H
#define _A z80.AF.b.h
#define _F z80.AF.b.l
#define _AF z80.AF.w.l
#define _AFdword z80.AF.d
#define _B z80.BC.b.h
#define _C z80.BC.b.l
#define _BC z80.BC.w.l
#define _BCdword z80.BC.d
#define _D z80.DE.b.h
#define _E z80.DE.b.l
#define _DE z80.DE.w.l
#define _DEdword z80.DE.d
#define _H z80.HL.b.h
#define _L z80.HL.b.l
#define _HL z80.HL.w.l
#define _HLdword z80.HL.d
#define _PC z80.PC.w.l
#define _PCdword z80.PC.d
#define _SP z80.SP.w.l
#define _IXh z80.IX.b.h
#define _IXl z80.IX.b.l
#define _IX z80.IX.w.l
#define _IXdword z80.IX.d
#define _IYh z80.IY.b.h
#define _IYl z80.IY.b.l
#define _IY z80.IY.w.l
#define _IYdword z80.IY.d
#define _I z80.I
#define _R z80.R
#define _Rb7 z80.Rb7
#define _IFF1 z80.IFF1
#define _IFF2 z80.IFF2
#define _IM z80.IM
#define _HALT z80.HALT
#define _A z80.AF.b.h
#define _F z80.AF.b.l
#define _AF z80.AF.w.l
#define _AFdword z80.AF.d
#define _B z80.BC.b.h
#define _C z80.BC.b.l
#define _BC z80.BC.w.l
#define _BCdword z80.BC.d
#define _D z80.DE.b.h
#define _E z80.DE.b.l
#define _DE z80.DE.w.l
#define _DEdword z80.DE.d
#define _H z80.HL.b.h
#define _L z80.HL.b.l
#define _HL z80.HL.w.l
#define _HLdword z80.HL.d
#define _PC z80.PC.w.l
#define _PCdword z80.PC.d
#define _SP z80.SP.w.l
#define _IXh z80.IX.b.h
#define _IXl z80.IX.b.l
#define _IX z80.IX.w.l
#define _IXdword z80.IX.d
#define _IYh z80.IY.b.h
#define _IYl z80.IY.b.l
#define _IY z80.IY.w.l
#define _IYdword z80.IY.d
#define _I z80.I
#define _R z80.R
#define _Rb7 z80.Rb7
#define _IFF1 z80.IFF1
#define _IFF2 z80.IFF2
#define _IM z80.IM
#define _HALT z80.HALT
#endif
| 2,914
|
C++
|
.h
| 90
| 30.8
| 72
| 0.646515
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,863
|
cap32.h
|
ColinPitrat_caprice32/src/cap32.h
|
/* Caprice32 - Amstrad CPC Emulator
(c) Copyright 1997-2005 Ulrich Doewich
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef CAP32_H
#define CAP32_H
#include <array>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <string>
#include <vector>
#include "types.h"
#include "phazer.h"
class InputMapper;
//#define DEBUG
//#define DEBUG_CRTC
//#define DEBUG_FDC
//#define DEBUG_GA
//#define DEBUG_NO_VIDEO
//#define DEBUG_TAPE
//#define DEBUG_Z80
#define VERSION_STRING "v4.6.0"
#ifndef _MAX_PATH
#ifdef _POSIX_PATH_MAX
#define _MAX_PATH _POSIX_PATH_MAX
#else
#define _MAX_PATH 256
#endif
#endif
#define CPC_BASE_FREQUENCY_MHZ 4.0
#define FRAME_PERIOD_MS 20.0
#define CYCLE_COUNT_INIT (CPC_BASE_FREQUENCY_MHZ*FRAME_PERIOD_MS*1000)
#define CPC_SCR_WIDTH 1024 // max width
#define CPC_SCR_HEIGHT 312 // max height
#define CPC_VISIBLE_SCR_WIDTH 384 // visible width: 4+40+4 * 8
#define CPC_VISIBLE_SCR_HEIGHT 270
// Emulation speed range
#define MIN_SPEED_SETTING 1
#define MAX_SPEED_SETTING 32
#define DEF_SPEED_SETTING 4
#define ICN_DISK_WIDTH 14
#define ICN_DISK_HEIGHT 16
#define ICN_TAPE_WIDTH 18
#define ICN_TAPE_HEIGHT 13
#define VOC_THRESHOLD 128
// CRTC flags
#define VS_flag 1
#define HS_flag 2
#define HDT_flag 4
#define VDT_flag 8
#define HT_flag 16
#define VT_flag 32
#define MR_flag 64
#define VTadj_flag 128
#define VSf_flag 256
// Multiface 2 flags
#define MF2_ACTIVE 1
#define MF2_RUNNING 2
#define MF2_INVISIBLE 4
// TODO: Tune threshold based on different joysticks or make it configurable ?
#define JOYSTICK_AXIS_THRESHOLD 16384
#define DEFAULT_VIDEO_PLUGIN 0
#ifdef _WIN32
// As opposed to ms_struct, needs to be explicit on Windows
#define ATTR_PACKED __attribute__((packed, gcc_struct))
#else
#define ATTR_PACKED __attribute__((packed))
#endif
typedef struct {
char id[8];
char unused1[8];
unsigned char version;
unsigned char AF[2];
unsigned char BC[2];
unsigned char DE[2];
unsigned char HL[2];
unsigned char R;
unsigned char I;
unsigned char IFF0;
unsigned char IFF1;
unsigned char IX[2];
unsigned char IY[2];
unsigned char SP[2];
unsigned char PC[2];
unsigned char IM;
unsigned char AFx[2];
unsigned char BCx[2];
unsigned char DEx[2];
unsigned char HLx[2];
unsigned char ga_pen;
unsigned char ga_ink_values[17];
unsigned char ga_ROM_config;
unsigned char ga_RAM_config;
unsigned char crtc_reg_select;
unsigned char crtc_registers[18];
unsigned char upper_ROM;
unsigned char ppi_A;
unsigned char ppi_B;
unsigned char ppi_C;
unsigned char ppi_control;
unsigned char psg_reg_select;
unsigned char psg_registers[16];
unsigned char ram_size[2];
// version 2 info follows
unsigned char cpc_model;
unsigned char last_interrupt;
unsigned char scr_modes[6];
// version 3 info follows
unsigned char drvA_DOSfilename[13];
unsigned char drvB_DOSfilename[13];
unsigned char cart_DOSfilename[13];
unsigned char fdc_motor;
unsigned char drvA_current_track;
unsigned char drvB_current_track;
unsigned char drvC_current_track;
unsigned char drvD_current_track;
unsigned char printer_data;
unsigned char psg_env_step;
unsigned char psg_env_direction;
unsigned char crtc_type;
unsigned char crtc_addr[2];
unsigned char crtc_scanline[2];
unsigned char crtc_char_count[2];
unsigned char crtc_line_count;
unsigned char crtc_raster_count;
unsigned char crtc_vt_adjust_count;
unsigned char crtc_hsw_count;
unsigned char crtc_vsw_count;
unsigned char crtc_flags[2];
unsigned char ga_int_delay;
unsigned char ga_sl_count;
unsigned char z80_int_pending;
unsigned char unused2[75];
} t_SNA_header;
typedef struct {
unsigned int model;
unsigned int jumpers;
unsigned int ram_size;
unsigned int speed;
unsigned int limit_speed;
bool paused;
unsigned int auto_pause;
unsigned int boot_time;
unsigned int keyboard_line;
unsigned int tape_motor;
unsigned int tape_play_button;
unsigned int printer;
unsigned int printer_port;
unsigned int mf2;
unsigned int keyboard;
unsigned int joystick_emulation;
unsigned int joysticks;
unsigned int joystick_menu_button;
unsigned int joystick_vkeyboard_button;
PhazerType phazer_emulation;
bool phazer_pressed;
unsigned int phazer_x;
unsigned int phazer_y;
int cycle_count;
std::string resources_path;
unsigned int scr_style;
unsigned int scr_scale;
unsigned int scr_oglfilter;
unsigned int scr_oglscanlines;
unsigned int scr_led;
unsigned int scr_fps;
unsigned int scr_tube;
unsigned int scr_intensity;
unsigned int scr_remanency;
unsigned int scr_window;
unsigned int scr_bpp; // bits per pixel of the SDL back_surface
unsigned int scr_preserve_aspect_ratio;
dword dwYScale; // Y scale (i.e. number of lines in SDL back_surface per CPC line)
unsigned int scr_bps; // bytes per line in the SDL back_surface
unsigned int scr_line_offs; // bytes per CPC line in the SDL back_surface (2*scr_bps if doubling Y)
unsigned int scr_green_mode;
unsigned int scr_green_blue_percent;
unsigned char *scr_base; // begining of current line in the SDL back_surface
unsigned char *scr_pos; // current position in the SDL back_surface
void (*scr_render)();
void (*scr_prerendernorm)();
void (*scr_prerenderbord)();
void (*scr_prerendersync)();
bool scr_is_ogl;
bool scr_gui_is_currently_on;
int devtools_scale;
unsigned int snd_enabled;
unsigned int snd_playback_rate;
unsigned int snd_bits;
unsigned int snd_stereo;
unsigned int snd_volume;
unsigned int snd_pp_device;
unsigned int snd_buffersize;
unsigned char *snd_bufferptr;
union {
struct {
unsigned int low;
unsigned int high;
};
int64_t both;
} snd_cycle_count_init;
std::string kbd_layout;
unsigned int max_tracksize;
std::string snap_path; // Path where machine state snapshots will be loaded/saved by default.
std::string snap_file; // Path to the actual file (zip or not)
std::string cart_path;
std::string cart_file;
std::string dsk_path;
std::string drvA_file;
unsigned int drvA_format;
std::string drvB_file;
unsigned int drvB_format;
std::string tape_path;
std::string tape_file;
std::string printer_file;
std::string sdump_dir;
std::string rom_path;
std::string rom_file[16];
std::string rom_mf2;
std::string current_snap_path; // Last used snapshot path in the file dialog.
std::string current_cart_path; // Last used cartridge path in the file dialog.
std::string current_dsk_path; // Last used disk path in the file dialog.
std::string current_tape_path; // Last used tape path in the file dialog.
class InputMapper *InputMapper;
} t_CPC;
typedef struct {
unsigned int requested_addr;
unsigned int next_addr;
unsigned int addr;
unsigned int next_address;
unsigned int scr_base;
unsigned int char_count;
unsigned int line_count;
unsigned int raster_count;
unsigned int hsw;
unsigned int hsw_count;
unsigned int vsw;
unsigned int vsw_count;
unsigned int flag_hadhsync;
unsigned int flag_inmonhsync;
unsigned int flag_invsync;
unsigned int flag_invta;
unsigned int flag_newscan;
unsigned int flag_reschar;
unsigned int flag_resframe;
unsigned int flag_resnext;
unsigned int flag_resscan;
unsigned int flag_resvsync;
unsigned int flag_startvta;
unsigned int last_hend;
unsigned int reg5;
unsigned int r7match;
unsigned int r9match;
unsigned int hstart;
unsigned int hend;
void (*CharInstMR)();
void (*CharInstSL)();
unsigned char reg_select;
unsigned char registers[18];
// 6128+ split screen support
unsigned int split_addr;
unsigned char split_sl;
unsigned int sl_count;
unsigned char interrupt_sl;
} t_CRTC;
typedef struct {
int timeout;
int motor;
int led;
int flags;
int phase;
int byte_count;
int buffer_count;
int cmd_length;
int res_length;
int cmd_direction;
void (*cmd_handler)();
unsigned char *buffer_ptr;
unsigned char *buffer_endptr;
unsigned char command[12];
unsigned char result[8];
} t_FDC;
typedef struct {
unsigned int hs_count;
unsigned char ROM_config;
unsigned char lower_ROM_bank;
bool registerPageOn;
unsigned char RAM_bank;
unsigned char RAM_config;
unsigned char upper_ROM;
unsigned int requested_scr_mode;
unsigned int scr_mode;
unsigned char pen;
unsigned char ink_values[17];
unsigned int palette[34];
unsigned char sl_count;
unsigned char int_delay;
} t_GateArray;
typedef struct {
unsigned char control;
unsigned char portA;
unsigned char portB;
unsigned char portC;
} t_PPI;
typedef struct {
union {
struct {
unsigned int low;
unsigned int high;
};
int64_t both;
} cycle_count;
unsigned int buffer_full;
unsigned char control;
unsigned char reg_select;
union {
unsigned char Index[16];
struct {
unsigned char TonALo, TonAHi;
unsigned char TonBLo, TonBHi;
unsigned char TonCLo, TonCHi;
unsigned char Noise;
unsigned char Mixer;
unsigned char AmplitudeA, AmplitudeB, AmplitudeC;
unsigned char EnvelopeLo, EnvelopeHi;
unsigned char EnvType;
unsigned char PortA;
unsigned char PortB;
};
struct {
unsigned short TonA;
unsigned short TonB;
unsigned short TonC;
unsigned char _noise, _mixer, _ampa, _ampb, _ampc;
unsigned short Envelope;
unsigned char _envtype, _porta, portb;
} ATTR_PACKED;
} RegisterAY;
int AmplitudeEnv;
bool FirstPeriod;
void (*Synthesizer)();
} t_PSG;
typedef struct {
int scrln;
int scanline;
unsigned int flag_drawing;
unsigned int frame_completed;
} t_VDU;
using t_MemBankConfig = std::array<std::array<byte*, 4>, 8>;
// cap32.cpp
void ga_init_banking(t_MemBankConfig& membank_config, unsigned char RAM_bank);
bool driveAltered();
void emulator_reset();
int emulator_init();
int video_set_palette();
void init_joystick_emulation();
void update_cpc_speed();
int printer_start();
void printer_stop();
int audio_init ();
void audio_shutdown ();
void audio_pause ();
void audio_resume ();
void mouse_init ();
int video_init ();
void video_shutdown ();
void cleanExit(int returnCode, bool askIfUnsaved = true);
// Return the path to the best (i.e: most specific) configuration file.
// Priority order is:
// - cap32.cfg in the same directory as cap32 binary
// - $XDG_CONFIG_HOME/cap32.cfg
// - $HOME/.config/cap32.cfg
// - $HOME/.cap32.cfg
// - /etc/cap32.cfg
std::string getConfigurationFilename(bool forWrite = false);
void loadConfiguration (t_CPC &CPC, const std::string& configFilename);
bool saveConfiguration (t_CPC &CPC, const std::string& configFilename);
void ShowCursor(bool show);
int cap32_main(int argc, char **argv);
// fdc.c
void fdc_write_data(unsigned char val);
unsigned char fdc_read_status();
unsigned char fdc_read_data();
// psg.c
void SetAYRegister(int Num, unsigned char Value);
void Calculate_Level_Tables();
void ResetAYChipEmulation();
void InitAYCounterVars();
void InitAY();
double *video_get_green_palette(int mode);
double *video_get_rgb_color(int color);
#endif
| 12,268
|
C++
|
.h
| 407
| 26.619165
| 103
| 0.721601
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,864
|
keyboard.h
|
ColinPitrat_caprice32/src/keyboard.h
|
#ifndef _KEYBOARD_H_
#define _KEYBOARD_H_
#include "types.h"
#include "SDL.h"
#include <map>
#include <list>
#include <string>
#include "cap32.h"
#define MOD_CPC_SHIFT (0x01 << 8)
#define MOD_CPC_CTRL (0x02 << 8)
#define MOD_EMU_KEY (0x10 << 8)
#define BITSHIFT_MOD 32
#define BITMASK_NOMOD ((static_cast<PCKey>(1)<<BITSHIFT_MOD) - 1)
#define MOD_PC_SHIFT (static_cast<PCKey>(KMOD_SHIFT) << BITSHIFT_MOD)
#define MOD_PC_CTRL (static_cast<PCKey>(KMOD_CTRL) << BITSHIFT_MOD)
#define MOD_PC_MODE (static_cast<PCKey>(KMOD_MODE) << BITSHIFT_MOD)
// MOD_PC_ALT shouldn't be used: SDLK_LALT is mapped as a non-modifier key to CPC_COPY.
#define MOD_PC_ALT (static_cast<PCKey>(KMOD_LALT) << BITSHIFT_MOD)
#define MOD_PC_NUM (static_cast<PCKey>(KMOD_NUM) << BITSHIFT_MOD)
#define MOD_PC_CAPS (static_cast<PCKey>(KMOD_CAPS) << BITSHIFT_MOD)
typedef enum {
CAP32_EXIT = MOD_EMU_KEY,
CAP32_FPS,
CAP32_FULLSCRN,
CAP32_GUI,
CAP32_VKBD,
CAP32_JOY,
CAP32_PHAZER,
CAP32_MF2STOP,
CAP32_RESET,
CAP32_SCRNSHOT,
CAP32_SPEED,
CAP32_TAPEPLAY,
CAP32_DEBUG,
CAP32_SNAPSHOT,
CAP32_LD_SNAP,
CAP32_WAITBREAK,
CAP32_DELAY,
CAP32_PASTE,
CAP32_DEVTOOLS
} CAP32_KEYS;
typedef enum {
CPC_0,
CPC_1,
CPC_2,
CPC_3,
CPC_4,
CPC_5,
CPC_6,
CPC_7,
CPC_8,
CPC_9,
CPC_A,
CPC_B,
CPC_C,
CPC_D,
CPC_E,
CPC_F,
CPC_G,
CPC_H,
CPC_I,
CPC_J,
CPC_K,
CPC_L,
CPC_M,
CPC_N,
CPC_O,
CPC_P,
CPC_Q,
CPC_R,
CPC_S,
CPC_T,
CPC_U,
CPC_V,
CPC_W,
CPC_X,
CPC_Y,
CPC_Z,
CPC_a,
CPC_b,
CPC_c,
CPC_d,
CPC_e,
CPC_f,
CPC_g,
CPC_h,
CPC_i,
CPC_j,
CPC_k,
CPC_l,
CPC_m,
CPC_n,
CPC_o,
CPC_p,
CPC_q,
CPC_r,
CPC_s,
CPC_t,
CPC_u,
CPC_v,
CPC_w,
CPC_x,
CPC_y,
CPC_z,
CPC_CTRL_a,
CPC_CTRL_b,
CPC_CTRL_c,
CPC_CTRL_d,
CPC_CTRL_e,
CPC_CTRL_f,
CPC_CTRL_g,
CPC_CTRL_h,
CPC_CTRL_i,
CPC_CTRL_j,
CPC_CTRL_k,
CPC_CTRL_l,
CPC_CTRL_m,
CPC_CTRL_n,
CPC_CTRL_o,
CPC_CTRL_p,
CPC_CTRL_q,
CPC_CTRL_r,
CPC_CTRL_s,
CPC_CTRL_t,
CPC_CTRL_u,
CPC_CTRL_v,
CPC_CTRL_w,
CPC_CTRL_x,
CPC_CTRL_y,
CPC_CTRL_z,
CPC_CTRL_0,
CPC_CTRL_1,
CPC_CTRL_2,
CPC_CTRL_3,
CPC_CTRL_4,
CPC_CTRL_5,
CPC_CTRL_6,
CPC_CTRL_7,
CPC_CTRL_8,
CPC_CTRL_9,
CPC_CTRL_UP,
CPC_CTRL_DOWN,
CPC_CTRL_LEFT,
CPC_CTRL_RIGHT,
CPC_AMPERSAND,
CPC_ASTERISK,
CPC_AT,
CPC_BACKQUOTE,
CPC_BACKSLASH,
CPC_CAPSLOCK,
CPC_CLR,
CPC_COLON,
CPC_COMMA,
CPC_CONTROL,
CPC_COPY,
CPC_CPY_DOWN,
CPC_CPY_LEFT,
CPC_CPY_RIGHT,
CPC_CPY_UP,
CPC_CUR_DOWN,
CPC_CUR_LEFT,
CPC_CUR_RIGHT,
CPC_CUR_UP,
CPC_CUR_ENDBL,
CPC_CUR_HOMELN,
CPC_CUR_ENDLN,
CPC_CUR_HOMEBL,
CPC_DBLQUOTE,
CPC_DEL,
CPC_DOLLAR,
CPC_ENTER,
CPC_EQUAL,
CPC_ESC,
CPC_EXCLAMATN,
CPC_F0,
CPC_F1,
CPC_F2,
CPC_F3,
CPC_F4,
CPC_F5,
CPC_F6,
CPC_F7,
CPC_F8,
CPC_F9,
CPC_CTRL_F0,
CPC_CTRL_F1,
CPC_CTRL_F2,
CPC_CTRL_F3,
CPC_CTRL_F4,
CPC_CTRL_F5,
CPC_CTRL_F6,
CPC_CTRL_F7,
CPC_CTRL_F8,
CPC_CTRL_F9,
CPC_SHIFT_F0,
CPC_SHIFT_F1,
CPC_SHIFT_F2,
CPC_SHIFT_F3,
CPC_SHIFT_F4,
CPC_SHIFT_F5,
CPC_SHIFT_F6,
CPC_SHIFT_F7,
CPC_SHIFT_F8,
CPC_SHIFT_F9,
CPC_FPERIOD,
CPC_GREATER,
CPC_HASH,
CPC_LBRACKET,
CPC_LCBRACE,
CPC_LEFTPAREN,
CPC_LESS,
CPC_LSHIFT,
CPC_MINUS,
CPC_PERCENT,
CPC_PERIOD,
CPC_PIPE,
CPC_PLUS,
CPC_POUND,
CPC_POWER,
CPC_QUESTION,
CPC_QUOTE,
CPC_RBRACKET,
CPC_RCBRACE,
CPC_RETURN,
CPC_RIGHTPAREN,
CPC_RSHIFT,
CPC_SEMICOLON,
CPC_SLASH,
CPC_SPACE,
CPC_TAB,
CPC_UNDERSCORE,
CPC_J0_UP,
CPC_J0_DOWN,
CPC_J0_LEFT,
CPC_J0_RIGHT,
CPC_J0_FIRE1,
CPC_J0_FIRE2,
CPC_J1_UP,
CPC_J1_DOWN,
CPC_J1_LEFT,
CPC_J1_RIGHT,
CPC_J1_FIRE1,
CPC_J1_FIRE2,
CPC_ES_NTILDE,
CPC_ES_nTILDE,
CPC_ES_PESETA,
CPC_FR_eACUTE,
CPC_FR_eGRAVE,
CPC_FR_cCEDIL,
CPC_FR_aGRAVE,
CPC_FR_uGRAVE
} CPC_KEYS;
#define CPC_KEY_NUM 209 // Number of different keys on a CPC keyboard
#define CPC_KEYBOARD_NUM 3 // Number of different keyboards supported.
// PCKey represents a key combination pressed on the host keyboard.
// This is a modifier (high dword) and a pressed key (low dword).
using PCKey = qword;
// CapriceKey represents a host-agnostic representation of a keyboard event.
// This can be either a CPC key combination (CPC_KEYS) or an emulator command (CAP32_KEYS).
using CapriceKey = unsigned int;
// CPCScancode is a hardware scancode.
// cf. https://www.cpcwiki.eu/index.php/Programming:Keyboard_scanning#Hardware_scancode_table
using CPCScancode = dword;
void applyKeypress(CPCScancode cpc_key, byte keyboard_matrix[], bool pressed);
class LineParsingResult {
public:
bool valid = true;
bool contains_mapping = false;
CapriceKey cpc_key = 0;
PCKey sdl_key = 0;
std::string cpc_key_name;
std::string sdl_key_name;
};
// CPCScancode is a hardware scancode.
// cf. https://www.cpcwiki.eu/index.php/Programming:Keyboard_scanning#Hardware_scancode_table
using CPCScancode = dword;
class InputMapper {
private:
static const CPCScancode cpc_kbd[CPC_KEYBOARD_NUM][CPC_KEY_NUM];
static const std::map<const std::string, const CapriceKey> CPCkeysFromStrings;
static const std::map<const std::string, const PCKey> SDLkeysFromStrings;
static const std::map<const char, const CPC_KEYS> CPCkeysFromChars;
std::map<char, std::pair<SDL_Keycode, SDL_Keymod>> SDLkeysFromChars;
static std::map<CapriceKey, PCKey> SDLkeysymFromCPCkeys_us;
std::map<PCKey, CapriceKey> CPCkeysFromSDLkeysym;
std::map<CapriceKey, PCKey> SDLkeysymFromCPCkeys;
t_CPC *CPC;
LineParsingResult process_cfg_line(char *line);
public:
InputMapper(t_CPC *CPC);
bool load_layout(const std::string& filename);
void init();
CPCScancode CPCscancodeFromCPCkey(CPC_KEYS cpc_key);
CPCScancode CPCscancodeFromKeysym(SDL_Keysym keysym);
CapriceKey CPCkeyFromKeysym(SDL_Keysym keysym);
std::string CPCkeyToString(const CapriceKey cpc_key);
CPCScancode CPCscancodeFromJoystickButton(SDL_JoyButtonEvent jbutton);
void CPCscancodeFromJoystickAxis(SDL_JoyAxisEvent jaxis, CPCScancode *cpc_key, bool &release);
std::list<SDL_Event> StringToEvents(std::string toTranslate);
void set_joystick_emulation();
};
#endif
| 6,539
|
C++
|
.h
| 302
| 17.956954
| 98
| 0.669667
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,865
|
video.h
|
ColinPitrat_caprice32/src/video.h
|
/* Caprice32 - Amstrad CPC Emulator
(c) Copyright 1997-2004 Ulrich Doewich
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef VIDEO_H
#define VIDEO_H
#include "SDL.h"
#include <vector>
typedef struct video_plugin
{
/* the user-displayed name of this plugin */
const char* name;
/* whether the plugin should be hidden from UI (i.e. is deprecated) */
bool hidden;
/* initializes the video plugin ; returns the surface that you must draw into, nullptr in the (unlikely ;) event of a failure */
SDL_Surface* (*init)(video_plugin* t, int scale, bool fs);
void (*set_palette)(SDL_Color* c);
/* "flips" the video surface. Note that this might not always do a real flip */
void (*flip)(video_plugin* t);
/* closes the plugin */
void (*close)();
/* this plugin wants : 0 half sized pixels (320x200 screen)/1 full sized pixels (640x200 screen)*/
Uint8 half_pixels;
/* mouse offset/scaling info */
int x_offset, y_offset;
float x_scale, y_scale;
/* width & height of the surface to display */
int width, height;
}
video_plugin;
extern std::vector<video_plugin> video_plugin_list;
/* Only exposed for testing purposes. Do not use. */
void compute_rects_for_tests(SDL_Rect* src, SDL_Rect* dst, Uint8 half_pixels);
int renderer_bpp(SDL_Renderer *sdl_renderer);
#endif
| 1,957
|
C++
|
.h
| 45
| 40.6
| 130
| 0.73723
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,866
|
symfile.h
|
ColinPitrat_caprice32/src/symfile.h
|
#ifndef _SYMFILE_H
#define _SYMFILE_H
#include <map>
#include <string>
#include <vector>
#include "types.h"
class Symfile
{
public:
Symfile() = default;
explicit Symfile(const std::string& filename);
bool SaveTo(const std::string& filename);
void addBreakpoint(word addr);
void addEntrypoint(word addr);
void addSymbol(word addr, const std::string& symbol);
std::map<word, std::string> Symbols() { return symbols; };
std::vector<word> Breakpoints() { return breakpoints; };
std::vector<word> Entrypoints() { return entrypoints; };
private:
std::vector<word> breakpoints;
std::vector<word> entrypoints;
std::map<word, std::string> symbols;
};
#endif
| 708
|
C++
|
.h
| 24
| 26.041667
| 62
| 0.703102
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,867
|
z80daa.h
|
ColinPitrat_caprice32/src/z80daa.h
|
/* Caprice32 - Amstrad CPC Emulator
(c) Copyright 1997-2004 Ulrich Doewich
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define CF 0x01
#define NF 0x02
#define PF 0x04
#define VF PF
#define XF 0x08
#define HF 0x10
#define YF 0x20
#define ZF 0x40
#define SF 0x80
static word DAATable[0x800] = {
(0x00<<8) +ZF +VF ,
(0x01<<8) ,
(0x02<<8) ,
(0x03<<8) +VF ,
(0x04<<8) ,
(0x05<<8) +VF ,
(0x06<<8) +VF ,
(0x07<<8) ,
(0x08<<8) +XF ,
(0x09<<8) +XF+VF ,
(0x10<<8) +HF ,
(0x11<<8) +HF +VF ,
(0x12<<8) +HF +VF ,
(0x13<<8) +HF ,
(0x14<<8) +HF +VF ,
(0x15<<8) +HF ,
(0x10<<8) ,
(0x11<<8) +VF ,
(0x12<<8) +VF ,
(0x13<<8) ,
(0x14<<8) +VF ,
(0x15<<8) ,
(0x16<<8) ,
(0x17<<8) +VF ,
(0x18<<8) +XF+VF ,
(0x19<<8) +XF ,
(0x20<<8) +YF+HF ,
(0x21<<8) +YF+HF +VF ,
(0x22<<8) +YF+HF +VF ,
(0x23<<8) +YF+HF ,
(0x24<<8) +YF+HF +VF ,
(0x25<<8) +YF+HF ,
(0x20<<8) +YF ,
(0x21<<8) +YF +VF ,
(0x22<<8) +YF +VF ,
(0x23<<8) +YF ,
(0x24<<8) +YF +VF ,
(0x25<<8) +YF ,
(0x26<<8) +YF ,
(0x27<<8) +YF +VF ,
(0x28<<8) +YF +XF+VF ,
(0x29<<8) +YF +XF ,
(0x30<<8) +YF+HF +VF ,
(0x31<<8) +YF+HF ,
(0x32<<8) +YF+HF ,
(0x33<<8) +YF+HF +VF ,
(0x34<<8) +YF+HF ,
(0x35<<8) +YF+HF +VF ,
(0x30<<8) +YF +VF ,
(0x31<<8) +YF ,
(0x32<<8) +YF ,
(0x33<<8) +YF +VF ,
(0x34<<8) +YF ,
(0x35<<8) +YF +VF ,
(0x36<<8) +YF +VF ,
(0x37<<8) +YF ,
(0x38<<8) +YF +XF ,
(0x39<<8) +YF +XF+VF ,
(0x40<<8) +HF ,
(0x41<<8) +HF +VF ,
(0x42<<8) +HF +VF ,
(0x43<<8) +HF ,
(0x44<<8) +HF +VF ,
(0x45<<8) +HF ,
(0x40<<8) ,
(0x41<<8) +VF ,
(0x42<<8) +VF ,
(0x43<<8) ,
(0x44<<8) +VF ,
(0x45<<8) ,
(0x46<<8) ,
(0x47<<8) +VF ,
(0x48<<8) +XF+VF ,
(0x49<<8) +XF ,
(0x50<<8) +HF +VF ,
(0x51<<8) +HF ,
(0x52<<8) +HF ,
(0x53<<8) +HF +VF ,
(0x54<<8) +HF ,
(0x55<<8) +HF +VF ,
(0x50<<8) +VF ,
(0x51<<8) ,
(0x52<<8) ,
(0x53<<8) +VF ,
(0x54<<8) ,
(0x55<<8) +VF ,
(0x56<<8) +VF ,
(0x57<<8) ,
(0x58<<8) +XF ,
(0x59<<8) +XF+VF ,
(0x60<<8) +YF+HF +VF ,
(0x61<<8) +YF+HF ,
(0x62<<8) +YF+HF ,
(0x63<<8) +YF+HF +VF ,
(0x64<<8) +YF+HF ,
(0x65<<8) +YF+HF +VF ,
(0x60<<8) +YF +VF ,
(0x61<<8) +YF ,
(0x62<<8) +YF ,
(0x63<<8) +YF +VF ,
(0x64<<8) +YF ,
(0x65<<8) +YF +VF ,
(0x66<<8) +YF +VF ,
(0x67<<8) +YF ,
(0x68<<8) +YF +XF ,
(0x69<<8) +YF +XF+VF ,
(0x70<<8) +YF+HF ,
(0x71<<8) +YF+HF +VF ,
(0x72<<8) +YF+HF +VF ,
(0x73<<8) +YF+HF ,
(0x74<<8) +YF+HF +VF ,
(0x75<<8) +YF+HF ,
(0x70<<8) +YF ,
(0x71<<8) +YF +VF ,
(0x72<<8) +YF +VF ,
(0x73<<8) +YF ,
(0x74<<8) +YF +VF ,
(0x75<<8) +YF ,
(0x76<<8) +YF ,
(0x77<<8) +YF +VF ,
(0x78<<8) +YF +XF+VF ,
(0x79<<8) +YF +XF ,
(0x80<<8)+SF +HF ,
(0x81<<8)+SF +HF +VF ,
(0x82<<8)+SF +HF +VF ,
(0x83<<8)+SF +HF ,
(0x84<<8)+SF +HF +VF ,
(0x85<<8)+SF +HF ,
(0x80<<8)+SF ,
(0x81<<8)+SF +VF ,
(0x82<<8)+SF +VF ,
(0x83<<8)+SF ,
(0x84<<8)+SF +VF ,
(0x85<<8)+SF ,
(0x86<<8)+SF ,
(0x87<<8)+SF +VF ,
(0x88<<8)+SF +XF+VF ,
(0x89<<8)+SF +XF ,
(0x90<<8)+SF +HF +VF ,
(0x91<<8)+SF +HF ,
(0x92<<8)+SF +HF ,
(0x93<<8)+SF +HF +VF ,
(0x94<<8)+SF +HF ,
(0x95<<8)+SF +HF +VF ,
(0x90<<8)+SF +VF ,
(0x91<<8)+SF ,
(0x92<<8)+SF ,
(0x93<<8)+SF +VF ,
(0x94<<8)+SF ,
(0x95<<8)+SF +VF ,
(0x96<<8)+SF +VF ,
(0x97<<8)+SF ,
(0x98<<8)+SF +XF ,
(0x99<<8)+SF +XF+VF ,
(0x00<<8) +ZF +HF +VF +CF,
(0x01<<8) +HF +CF,
(0x02<<8) +HF +CF,
(0x03<<8) +HF +VF +CF,
(0x04<<8) +HF +CF,
(0x05<<8) +HF +VF +CF,
(0x00<<8) +ZF +VF +CF,
(0x01<<8) +CF,
(0x02<<8) +CF,
(0x03<<8) +VF +CF,
(0x04<<8) +CF,
(0x05<<8) +VF +CF,
(0x06<<8) +VF +CF,
(0x07<<8) +CF,
(0x08<<8) +XF +CF,
(0x09<<8) +XF+VF +CF,
(0x10<<8) +HF +CF,
(0x11<<8) +HF +VF +CF,
(0x12<<8) +HF +VF +CF,
(0x13<<8) +HF +CF,
(0x14<<8) +HF +VF +CF,
(0x15<<8) +HF +CF,
(0x10<<8) +CF,
(0x11<<8) +VF +CF,
(0x12<<8) +VF +CF,
(0x13<<8) +CF,
(0x14<<8) +VF +CF,
(0x15<<8) +CF,
(0x16<<8) +CF,
(0x17<<8) +VF +CF,
(0x18<<8) +XF+VF +CF,
(0x19<<8) +XF +CF,
(0x20<<8) +YF+HF +CF,
(0x21<<8) +YF+HF +VF +CF,
(0x22<<8) +YF+HF +VF +CF,
(0x23<<8) +YF+HF +CF,
(0x24<<8) +YF+HF +VF +CF,
(0x25<<8) +YF+HF +CF,
(0x20<<8) +YF +CF,
(0x21<<8) +YF +VF +CF,
(0x22<<8) +YF +VF +CF,
(0x23<<8) +YF +CF,
(0x24<<8) +YF +VF +CF,
(0x25<<8) +YF +CF,
(0x26<<8) +YF +CF,
(0x27<<8) +YF +VF +CF,
(0x28<<8) +YF +XF+VF +CF,
(0x29<<8) +YF +XF +CF,
(0x30<<8) +YF+HF +VF +CF,
(0x31<<8) +YF+HF +CF,
(0x32<<8) +YF+HF +CF,
(0x33<<8) +YF+HF +VF +CF,
(0x34<<8) +YF+HF +CF,
(0x35<<8) +YF+HF +VF +CF,
(0x30<<8) +YF +VF +CF,
(0x31<<8) +YF +CF,
(0x32<<8) +YF +CF,
(0x33<<8) +YF +VF +CF,
(0x34<<8) +YF +CF,
(0x35<<8) +YF +VF +CF,
(0x36<<8) +YF +VF +CF,
(0x37<<8) +YF +CF,
(0x38<<8) +YF +XF +CF,
(0x39<<8) +YF +XF+VF +CF,
(0x40<<8) +HF +CF,
(0x41<<8) +HF +VF +CF,
(0x42<<8) +HF +VF +CF,
(0x43<<8) +HF +CF,
(0x44<<8) +HF +VF +CF,
(0x45<<8) +HF +CF,
(0x40<<8) +CF,
(0x41<<8) +VF +CF,
(0x42<<8) +VF +CF,
(0x43<<8) +CF,
(0x44<<8) +VF +CF,
(0x45<<8) +CF,
(0x46<<8) +CF,
(0x47<<8) +VF +CF,
(0x48<<8) +XF+VF +CF,
(0x49<<8) +XF +CF,
(0x50<<8) +HF +VF +CF,
(0x51<<8) +HF +CF,
(0x52<<8) +HF +CF,
(0x53<<8) +HF +VF +CF,
(0x54<<8) +HF +CF,
(0x55<<8) +HF +VF +CF,
(0x50<<8) +VF +CF,
(0x51<<8) +CF,
(0x52<<8) +CF,
(0x53<<8) +VF +CF,
(0x54<<8) +CF,
(0x55<<8) +VF +CF,
(0x56<<8) +VF +CF,
(0x57<<8) +CF,
(0x58<<8) +XF +CF,
(0x59<<8) +XF+VF +CF,
(0x60<<8) +YF+HF +VF +CF,
(0x61<<8) +YF+HF +CF,
(0x62<<8) +YF+HF +CF,
(0x63<<8) +YF+HF +VF +CF,
(0x64<<8) +YF+HF +CF,
(0x65<<8) +YF+HF +VF +CF,
(0x60<<8) +YF +VF +CF,
(0x61<<8) +YF +CF,
(0x62<<8) +YF +CF,
(0x63<<8) +YF +VF +CF,
(0x64<<8) +YF +CF,
(0x65<<8) +YF +VF +CF,
(0x66<<8) +YF +VF +CF,
(0x67<<8) +YF +CF,
(0x68<<8) +YF +XF +CF,
(0x69<<8) +YF +XF+VF +CF,
(0x70<<8) +YF+HF +CF,
(0x71<<8) +YF+HF +VF +CF,
(0x72<<8) +YF+HF +VF +CF,
(0x73<<8) +YF+HF +CF,
(0x74<<8) +YF+HF +VF +CF,
(0x75<<8) +YF+HF +CF,
(0x70<<8) +YF +CF,
(0x71<<8) +YF +VF +CF,
(0x72<<8) +YF +VF +CF,
(0x73<<8) +YF +CF,
(0x74<<8) +YF +VF +CF,
(0x75<<8) +YF +CF,
(0x76<<8) +YF +CF,
(0x77<<8) +YF +VF +CF,
(0x78<<8) +YF +XF+VF +CF,
(0x79<<8) +YF +XF +CF,
(0x80<<8)+SF +HF +CF,
(0x81<<8)+SF +HF +VF +CF,
(0x82<<8)+SF +HF +VF +CF,
(0x83<<8)+SF +HF +CF,
(0x84<<8)+SF +HF +VF +CF,
(0x85<<8)+SF +HF +CF,
(0x80<<8)+SF +CF,
(0x81<<8)+SF +VF +CF,
(0x82<<8)+SF +VF +CF,
(0x83<<8)+SF +CF,
(0x84<<8)+SF +VF +CF,
(0x85<<8)+SF +CF,
(0x86<<8)+SF +CF,
(0x87<<8)+SF +VF +CF,
(0x88<<8)+SF +XF+VF +CF,
(0x89<<8)+SF +XF +CF,
(0x90<<8)+SF +HF +VF +CF,
(0x91<<8)+SF +HF +CF,
(0x92<<8)+SF +HF +CF,
(0x93<<8)+SF +HF +VF +CF,
(0x94<<8)+SF +HF +CF,
(0x95<<8)+SF +HF +VF +CF,
(0x90<<8)+SF +VF +CF,
(0x91<<8)+SF +CF,
(0x92<<8)+SF +CF,
(0x93<<8)+SF +VF +CF,
(0x94<<8)+SF +CF,
(0x95<<8)+SF +VF +CF,
(0x96<<8)+SF +VF +CF,
(0x97<<8)+SF +CF,
(0x98<<8)+SF +XF +CF,
(0x99<<8)+SF +XF+VF +CF,
(0xA0<<8)+SF +YF+HF +VF +CF,
(0xA1<<8)+SF +YF+HF +CF,
(0xA2<<8)+SF +YF+HF +CF,
(0xA3<<8)+SF +YF+HF +VF +CF,
(0xA4<<8)+SF +YF+HF +CF,
(0xA5<<8)+SF +YF+HF +VF +CF,
(0xA0<<8)+SF +YF +VF +CF,
(0xA1<<8)+SF +YF +CF,
(0xA2<<8)+SF +YF +CF,
(0xA3<<8)+SF +YF +VF +CF,
(0xA4<<8)+SF +YF +CF,
(0xA5<<8)+SF +YF +VF +CF,
(0xA6<<8)+SF +YF +VF +CF,
(0xA7<<8)+SF +YF +CF,
(0xA8<<8)+SF +YF +XF +CF,
(0xA9<<8)+SF +YF +XF+VF +CF,
(0xB0<<8)+SF +YF+HF +CF,
(0xB1<<8)+SF +YF+HF +VF +CF,
(0xB2<<8)+SF +YF+HF +VF +CF,
(0xB3<<8)+SF +YF+HF +CF,
(0xB4<<8)+SF +YF+HF +VF +CF,
(0xB5<<8)+SF +YF+HF +CF,
(0xB0<<8)+SF +YF +CF,
(0xB1<<8)+SF +YF +VF +CF,
(0xB2<<8)+SF +YF +VF +CF,
(0xB3<<8)+SF +YF +CF,
(0xB4<<8)+SF +YF +VF +CF,
(0xB5<<8)+SF +YF +CF,
(0xB6<<8)+SF +YF +CF,
(0xB7<<8)+SF +YF +VF +CF,
(0xB8<<8)+SF +YF +XF+VF +CF,
(0xB9<<8)+SF +YF +XF +CF,
(0xC0<<8)+SF +HF +VF +CF,
(0xC1<<8)+SF +HF +CF,
(0xC2<<8)+SF +HF +CF,
(0xC3<<8)+SF +HF +VF +CF,
(0xC4<<8)+SF +HF +CF,
(0xC5<<8)+SF +HF +VF +CF,
(0xC0<<8)+SF +VF +CF,
(0xC1<<8)+SF +CF,
(0xC2<<8)+SF +CF,
(0xC3<<8)+SF +VF +CF,
(0xC4<<8)+SF +CF,
(0xC5<<8)+SF +VF +CF,
(0xC6<<8)+SF +VF +CF,
(0xC7<<8)+SF +CF,
(0xC8<<8)+SF +XF +CF,
(0xC9<<8)+SF +XF+VF +CF,
(0xD0<<8)+SF +HF +CF,
(0xD1<<8)+SF +HF +VF +CF,
(0xD2<<8)+SF +HF +VF +CF,
(0xD3<<8)+SF +HF +CF,
(0xD4<<8)+SF +HF +VF +CF,
(0xD5<<8)+SF +HF +CF,
(0xD0<<8)+SF +CF,
(0xD1<<8)+SF +VF +CF,
(0xD2<<8)+SF +VF +CF,
(0xD3<<8)+SF +CF,
(0xD4<<8)+SF +VF +CF,
(0xD5<<8)+SF +CF,
(0xD6<<8)+SF +CF,
(0xD7<<8)+SF +VF +CF,
(0xD8<<8)+SF +XF+VF +CF,
(0xD9<<8)+SF +XF +CF,
(0xE0<<8)+SF +YF+HF +CF,
(0xE1<<8)+SF +YF+HF +VF +CF,
(0xE2<<8)+SF +YF+HF +VF +CF,
(0xE3<<8)+SF +YF+HF +CF,
(0xE4<<8)+SF +YF+HF +VF +CF,
(0xE5<<8)+SF +YF+HF +CF,
(0xE0<<8)+SF +YF +CF,
(0xE1<<8)+SF +YF +VF +CF,
(0xE2<<8)+SF +YF +VF +CF,
(0xE3<<8)+SF +YF +CF,
(0xE4<<8)+SF +YF +VF +CF,
(0xE5<<8)+SF +YF +CF,
(0xE6<<8)+SF +YF +CF,
(0xE7<<8)+SF +YF +VF +CF,
(0xE8<<8)+SF +YF +XF+VF +CF,
(0xE9<<8)+SF +YF +XF +CF,
(0xF0<<8)+SF +YF+HF +VF +CF,
(0xF1<<8)+SF +YF+HF +CF,
(0xF2<<8)+SF +YF+HF +CF,
(0xF3<<8)+SF +YF+HF +VF +CF,
(0xF4<<8)+SF +YF+HF +CF,
(0xF5<<8)+SF +YF+HF +VF +CF,
(0xF0<<8)+SF +YF +VF +CF,
(0xF1<<8)+SF +YF +CF,
(0xF2<<8)+SF +YF +CF,
(0xF3<<8)+SF +YF +VF +CF,
(0xF4<<8)+SF +YF +CF,
(0xF5<<8)+SF +YF +VF +CF,
(0xF6<<8)+SF +YF +VF +CF,
(0xF7<<8)+SF +YF +CF,
(0xF8<<8)+SF +YF +XF +CF,
(0xF9<<8)+SF +YF +XF+VF +CF,
(0x00<<8) +ZF +HF +VF +CF,
(0x01<<8) +HF +CF,
(0x02<<8) +HF +CF,
(0x03<<8) +HF +VF +CF,
(0x04<<8) +HF +CF,
(0x05<<8) +HF +VF +CF,
(0x00<<8) +ZF +VF +CF,
(0x01<<8) +CF,
(0x02<<8) +CF,
(0x03<<8) +VF +CF,
(0x04<<8) +CF,
(0x05<<8) +VF +CF,
(0x06<<8) +VF +CF,
(0x07<<8) +CF,
(0x08<<8) +XF +CF,
(0x09<<8) +XF+VF +CF,
(0x10<<8) +HF +CF,
(0x11<<8) +HF +VF +CF,
(0x12<<8) +HF +VF +CF,
(0x13<<8) +HF +CF,
(0x14<<8) +HF +VF +CF,
(0x15<<8) +HF +CF,
(0x10<<8) +CF,
(0x11<<8) +VF +CF,
(0x12<<8) +VF +CF,
(0x13<<8) +CF,
(0x14<<8) +VF +CF,
(0x15<<8) +CF,
(0x16<<8) +CF,
(0x17<<8) +VF +CF,
(0x18<<8) +XF+VF +CF,
(0x19<<8) +XF +CF,
(0x20<<8) +YF+HF +CF,
(0x21<<8) +YF+HF +VF +CF,
(0x22<<8) +YF+HF +VF +CF,
(0x23<<8) +YF+HF +CF,
(0x24<<8) +YF+HF +VF +CF,
(0x25<<8) +YF+HF +CF,
(0x20<<8) +YF +CF,
(0x21<<8) +YF +VF +CF,
(0x22<<8) +YF +VF +CF,
(0x23<<8) +YF +CF,
(0x24<<8) +YF +VF +CF,
(0x25<<8) +YF +CF,
(0x26<<8) +YF +CF,
(0x27<<8) +YF +VF +CF,
(0x28<<8) +YF +XF+VF +CF,
(0x29<<8) +YF +XF +CF,
(0x30<<8) +YF+HF +VF +CF,
(0x31<<8) +YF+HF +CF,
(0x32<<8) +YF+HF +CF,
(0x33<<8) +YF+HF +VF +CF,
(0x34<<8) +YF+HF +CF,
(0x35<<8) +YF+HF +VF +CF,
(0x30<<8) +YF +VF +CF,
(0x31<<8) +YF +CF,
(0x32<<8) +YF +CF,
(0x33<<8) +YF +VF +CF,
(0x34<<8) +YF +CF,
(0x35<<8) +YF +VF +CF,
(0x36<<8) +YF +VF +CF,
(0x37<<8) +YF +CF,
(0x38<<8) +YF +XF +CF,
(0x39<<8) +YF +XF+VF +CF,
(0x40<<8) +HF +CF,
(0x41<<8) +HF +VF +CF,
(0x42<<8) +HF +VF +CF,
(0x43<<8) +HF +CF,
(0x44<<8) +HF +VF +CF,
(0x45<<8) +HF +CF,
(0x40<<8) +CF,
(0x41<<8) +VF +CF,
(0x42<<8) +VF +CF,
(0x43<<8) +CF,
(0x44<<8) +VF +CF,
(0x45<<8) +CF,
(0x46<<8) +CF,
(0x47<<8) +VF +CF,
(0x48<<8) +XF+VF +CF,
(0x49<<8) +XF +CF,
(0x50<<8) +HF +VF +CF,
(0x51<<8) +HF +CF,
(0x52<<8) +HF +CF,
(0x53<<8) +HF +VF +CF,
(0x54<<8) +HF +CF,
(0x55<<8) +HF +VF +CF,
(0x50<<8) +VF +CF,
(0x51<<8) +CF,
(0x52<<8) +CF,
(0x53<<8) +VF +CF,
(0x54<<8) +CF,
(0x55<<8) +VF +CF,
(0x56<<8) +VF +CF,
(0x57<<8) +CF,
(0x58<<8) +XF +CF,
(0x59<<8) +XF+VF +CF,
(0x60<<8) +YF+HF +VF +CF,
(0x61<<8) +YF+HF +CF,
(0x62<<8) +YF+HF +CF,
(0x63<<8) +YF+HF +VF +CF,
(0x64<<8) +YF+HF +CF,
(0x65<<8) +YF+HF +VF +CF,
(0x06<<8) +VF ,
(0x07<<8) ,
(0x08<<8) +XF ,
(0x09<<8) +XF+VF ,
(0x0A<<8) +XF+VF ,
(0x0B<<8) +XF ,
(0x0C<<8) +XF+VF ,
(0x0D<<8) +XF ,
(0x0E<<8) +XF ,
(0x0F<<8) +XF+VF ,
(0x10<<8) +HF ,
(0x11<<8) +HF +VF ,
(0x12<<8) +HF +VF ,
(0x13<<8) +HF ,
(0x14<<8) +HF +VF ,
(0x15<<8) +HF ,
(0x16<<8) ,
(0x17<<8) +VF ,
(0x18<<8) +XF+VF ,
(0x19<<8) +XF ,
(0x1A<<8) +XF ,
(0x1B<<8) +XF+VF ,
(0x1C<<8) +XF ,
(0x1D<<8) +XF+VF ,
(0x1E<<8) +XF+VF ,
(0x1F<<8) +XF ,
(0x20<<8) +YF+HF ,
(0x21<<8) +YF+HF +VF ,
(0x22<<8) +YF+HF +VF ,
(0x23<<8) +YF+HF ,
(0x24<<8) +YF+HF +VF ,
(0x25<<8) +YF+HF ,
(0x26<<8) +YF ,
(0x27<<8) +YF +VF ,
(0x28<<8) +YF +XF+VF ,
(0x29<<8) +YF +XF ,
(0x2A<<8) +YF +XF ,
(0x2B<<8) +YF +XF+VF ,
(0x2C<<8) +YF +XF ,
(0x2D<<8) +YF +XF+VF ,
(0x2E<<8) +YF +XF+VF ,
(0x2F<<8) +YF +XF ,
(0x30<<8) +YF+HF +VF ,
(0x31<<8) +YF+HF ,
(0x32<<8) +YF+HF ,
(0x33<<8) +YF+HF +VF ,
(0x34<<8) +YF+HF ,
(0x35<<8) +YF+HF +VF ,
(0x36<<8) +YF +VF ,
(0x37<<8) +YF ,
(0x38<<8) +YF +XF ,
(0x39<<8) +YF +XF+VF ,
(0x3A<<8) +YF +XF+VF ,
(0x3B<<8) +YF +XF ,
(0x3C<<8) +YF +XF+VF ,
(0x3D<<8) +YF +XF ,
(0x3E<<8) +YF +XF ,
(0x3F<<8) +YF +XF+VF ,
(0x40<<8) +HF ,
(0x41<<8) +HF +VF ,
(0x42<<8) +HF +VF ,
(0x43<<8) +HF ,
(0x44<<8) +HF +VF ,
(0x45<<8) +HF ,
(0x46<<8) ,
(0x47<<8) +VF ,
(0x48<<8) +XF+VF ,
(0x49<<8) +XF ,
(0x4A<<8) +XF ,
(0x4B<<8) +XF+VF ,
(0x4C<<8) +XF ,
(0x4D<<8) +XF+VF ,
(0x4E<<8) +XF+VF ,
(0x4F<<8) +XF ,
(0x50<<8) +HF +VF ,
(0x51<<8) +HF ,
(0x52<<8) +HF ,
(0x53<<8) +HF +VF ,
(0x54<<8) +HF ,
(0x55<<8) +HF +VF ,
(0x56<<8) +VF ,
(0x57<<8) ,
(0x58<<8) +XF ,
(0x59<<8) +XF+VF ,
(0x5A<<8) +XF+VF ,
(0x5B<<8) +XF ,
(0x5C<<8) +XF+VF ,
(0x5D<<8) +XF ,
(0x5E<<8) +XF ,
(0x5F<<8) +XF+VF ,
(0x60<<8) +YF+HF +VF ,
(0x61<<8) +YF+HF ,
(0x62<<8) +YF+HF ,
(0x63<<8) +YF+HF +VF ,
(0x64<<8) +YF+HF ,
(0x65<<8) +YF+HF +VF ,
(0x66<<8) +YF +VF ,
(0x67<<8) +YF ,
(0x68<<8) +YF +XF ,
(0x69<<8) +YF +XF+VF ,
(0x6A<<8) +YF +XF+VF ,
(0x6B<<8) +YF +XF ,
(0x6C<<8) +YF +XF+VF ,
(0x6D<<8) +YF +XF ,
(0x6E<<8) +YF +XF ,
(0x6F<<8) +YF +XF+VF ,
(0x70<<8) +YF+HF ,
(0x71<<8) +YF+HF +VF ,
(0x72<<8) +YF+HF +VF ,
(0x73<<8) +YF+HF ,
(0x74<<8) +YF+HF +VF ,
(0x75<<8) +YF+HF ,
(0x76<<8) +YF ,
(0x77<<8) +YF +VF ,
(0x78<<8) +YF +XF+VF ,
(0x79<<8) +YF +XF ,
(0x7A<<8) +YF +XF ,
(0x7B<<8) +YF +XF+VF ,
(0x7C<<8) +YF +XF ,
(0x7D<<8) +YF +XF+VF ,
(0x7E<<8) +YF +XF+VF ,
(0x7F<<8) +YF +XF ,
(0x80<<8)+SF +HF ,
(0x81<<8)+SF +HF +VF ,
(0x82<<8)+SF +HF +VF ,
(0x83<<8)+SF +HF ,
(0x84<<8)+SF +HF +VF ,
(0x85<<8)+SF +HF ,
(0x86<<8)+SF ,
(0x87<<8)+SF +VF ,
(0x88<<8)+SF +XF+VF ,
(0x89<<8)+SF +XF ,
(0x8A<<8)+SF +XF ,
(0x8B<<8)+SF +XF+VF ,
(0x8C<<8)+SF +XF ,
(0x8D<<8)+SF +XF+VF ,
(0x8E<<8)+SF +XF+VF ,
(0x8F<<8)+SF +XF ,
(0x90<<8)+SF +HF +VF ,
(0x91<<8)+SF +HF ,
(0x92<<8)+SF +HF ,
(0x93<<8)+SF +HF +VF ,
(0x94<<8)+SF +HF ,
(0x95<<8)+SF +HF +VF ,
(0x96<<8)+SF +VF ,
(0x97<<8)+SF ,
(0x98<<8)+SF +XF ,
(0x99<<8)+SF +XF+VF ,
(0x9A<<8)+SF +XF+VF ,
(0x9B<<8)+SF +XF ,
(0x9C<<8)+SF +XF+VF ,
(0x9D<<8)+SF +XF ,
(0x9E<<8)+SF +XF ,
(0x9F<<8)+SF +XF+VF ,
(0x00<<8) +ZF +HF +VF +CF,
(0x01<<8) +HF +CF,
(0x02<<8) +HF +CF,
(0x03<<8) +HF +VF +CF,
(0x04<<8) +HF +CF,
(0x05<<8) +HF +VF +CF,
(0x06<<8) +VF +CF,
(0x07<<8) +CF,
(0x08<<8) +XF +CF,
(0x09<<8) +XF+VF +CF,
(0x0A<<8) +XF+VF +CF,
(0x0B<<8) +XF +CF,
(0x0C<<8) +XF+VF +CF,
(0x0D<<8) +XF +CF,
(0x0E<<8) +XF +CF,
(0x0F<<8) +XF+VF +CF,
(0x10<<8) +HF +CF,
(0x11<<8) +HF +VF +CF,
(0x12<<8) +HF +VF +CF,
(0x13<<8) +HF +CF,
(0x14<<8) +HF +VF +CF,
(0x15<<8) +HF +CF,
(0x16<<8) +CF,
(0x17<<8) +VF +CF,
(0x18<<8) +XF+VF +CF,
(0x19<<8) +XF +CF,
(0x1A<<8) +XF +CF,
(0x1B<<8) +XF+VF +CF,
(0x1C<<8) +XF +CF,
(0x1D<<8) +XF+VF +CF,
(0x1E<<8) +XF+VF +CF,
(0x1F<<8) +XF +CF,
(0x20<<8) +YF+HF +CF,
(0x21<<8) +YF+HF +VF +CF,
(0x22<<8) +YF+HF +VF +CF,
(0x23<<8) +YF+HF +CF,
(0x24<<8) +YF+HF +VF +CF,
(0x25<<8) +YF+HF +CF,
(0x26<<8) +YF +CF,
(0x27<<8) +YF +VF +CF,
(0x28<<8) +YF +XF+VF +CF,
(0x29<<8) +YF +XF +CF,
(0x2A<<8) +YF +XF +CF,
(0x2B<<8) +YF +XF+VF +CF,
(0x2C<<8) +YF +XF +CF,
(0x2D<<8) +YF +XF+VF +CF,
(0x2E<<8) +YF +XF+VF +CF,
(0x2F<<8) +YF +XF +CF,
(0x30<<8) +YF+HF +VF +CF,
(0x31<<8) +YF+HF +CF,
(0x32<<8) +YF+HF +CF,
(0x33<<8) +YF+HF +VF +CF,
(0x34<<8) +YF+HF +CF,
(0x35<<8) +YF+HF +VF +CF,
(0x36<<8) +YF +VF +CF,
(0x37<<8) +YF +CF,
(0x38<<8) +YF +XF +CF,
(0x39<<8) +YF +XF+VF +CF,
(0x3A<<8) +YF +XF+VF +CF,
(0x3B<<8) +YF +XF +CF,
(0x3C<<8) +YF +XF+VF +CF,
(0x3D<<8) +YF +XF +CF,
(0x3E<<8) +YF +XF +CF,
(0x3F<<8) +YF +XF+VF +CF,
(0x40<<8) +HF +CF,
(0x41<<8) +HF +VF +CF,
(0x42<<8) +HF +VF +CF,
(0x43<<8) +HF +CF,
(0x44<<8) +HF +VF +CF,
(0x45<<8) +HF +CF,
(0x46<<8) +CF,
(0x47<<8) +VF +CF,
(0x48<<8) +XF+VF +CF,
(0x49<<8) +XF +CF,
(0x4A<<8) +XF +CF,
(0x4B<<8) +XF+VF +CF,
(0x4C<<8) +XF +CF,
(0x4D<<8) +XF+VF +CF,
(0x4E<<8) +XF+VF +CF,
(0x4F<<8) +XF +CF,
(0x50<<8) +HF +VF +CF,
(0x51<<8) +HF +CF,
(0x52<<8) +HF +CF,
(0x53<<8) +HF +VF +CF,
(0x54<<8) +HF +CF,
(0x55<<8) +HF +VF +CF,
(0x56<<8) +VF +CF,
(0x57<<8) +CF,
(0x58<<8) +XF +CF,
(0x59<<8) +XF+VF +CF,
(0x5A<<8) +XF+VF +CF,
(0x5B<<8) +XF +CF,
(0x5C<<8) +XF+VF +CF,
(0x5D<<8) +XF +CF,
(0x5E<<8) +XF +CF,
(0x5F<<8) +XF+VF +CF,
(0x60<<8) +YF+HF +VF +CF,
(0x61<<8) +YF+HF +CF,
(0x62<<8) +YF+HF +CF,
(0x63<<8) +YF+HF +VF +CF,
(0x64<<8) +YF+HF +CF,
(0x65<<8) +YF+HF +VF +CF,
(0x66<<8) +YF +VF +CF,
(0x67<<8) +YF +CF,
(0x68<<8) +YF +XF +CF,
(0x69<<8) +YF +XF+VF +CF,
(0x6A<<8) +YF +XF+VF +CF,
(0x6B<<8) +YF +XF +CF,
(0x6C<<8) +YF +XF+VF +CF,
(0x6D<<8) +YF +XF +CF,
(0x6E<<8) +YF +XF +CF,
(0x6F<<8) +YF +XF+VF +CF,
(0x70<<8) +YF+HF +CF,
(0x71<<8) +YF+HF +VF +CF,
(0x72<<8) +YF+HF +VF +CF,
(0x73<<8) +YF+HF +CF,
(0x74<<8) +YF+HF +VF +CF,
(0x75<<8) +YF+HF +CF,
(0x76<<8) +YF +CF,
(0x77<<8) +YF +VF +CF,
(0x78<<8) +YF +XF+VF +CF,
(0x79<<8) +YF +XF +CF,
(0x7A<<8) +YF +XF +CF,
(0x7B<<8) +YF +XF+VF +CF,
(0x7C<<8) +YF +XF +CF,
(0x7D<<8) +YF +XF+VF +CF,
(0x7E<<8) +YF +XF+VF +CF,
(0x7F<<8) +YF +XF +CF,
(0x80<<8)+SF +HF +CF,
(0x81<<8)+SF +HF +VF +CF,
(0x82<<8)+SF +HF +VF +CF,
(0x83<<8)+SF +HF +CF,
(0x84<<8)+SF +HF +VF +CF,
(0x85<<8)+SF +HF +CF,
(0x86<<8)+SF +CF,
(0x87<<8)+SF +VF +CF,
(0x88<<8)+SF +XF+VF +CF,
(0x89<<8)+SF +XF +CF,
(0x8A<<8)+SF +XF +CF,
(0x8B<<8)+SF +XF+VF +CF,
(0x8C<<8)+SF +XF +CF,
(0x8D<<8)+SF +XF+VF +CF,
(0x8E<<8)+SF +XF+VF +CF,
(0x8F<<8)+SF +XF +CF,
(0x90<<8)+SF +HF +VF +CF,
(0x91<<8)+SF +HF +CF,
(0x92<<8)+SF +HF +CF,
(0x93<<8)+SF +HF +VF +CF,
(0x94<<8)+SF +HF +CF,
(0x95<<8)+SF +HF +VF +CF,
(0x96<<8)+SF +VF +CF,
(0x97<<8)+SF +CF,
(0x98<<8)+SF +XF +CF,
(0x99<<8)+SF +XF+VF +CF,
(0x9A<<8)+SF +XF+VF +CF,
(0x9B<<8)+SF +XF +CF,
(0x9C<<8)+SF +XF+VF +CF,
(0x9D<<8)+SF +XF +CF,
(0x9E<<8)+SF +XF +CF,
(0x9F<<8)+SF +XF+VF +CF,
(0xA0<<8)+SF +YF+HF +VF +CF,
(0xA1<<8)+SF +YF+HF +CF,
(0xA2<<8)+SF +YF+HF +CF,
(0xA3<<8)+SF +YF+HF +VF +CF,
(0xA4<<8)+SF +YF+HF +CF,
(0xA5<<8)+SF +YF+HF +VF +CF,
(0xA6<<8)+SF +YF +VF +CF,
(0xA7<<8)+SF +YF +CF,
(0xA8<<8)+SF +YF +XF +CF,
(0xA9<<8)+SF +YF +XF+VF +CF,
(0xAA<<8)+SF +YF +XF+VF +CF,
(0xAB<<8)+SF +YF +XF +CF,
(0xAC<<8)+SF +YF +XF+VF +CF,
(0xAD<<8)+SF +YF +XF +CF,
(0xAE<<8)+SF +YF +XF +CF,
(0xAF<<8)+SF +YF +XF+VF +CF,
(0xB0<<8)+SF +YF+HF +CF,
(0xB1<<8)+SF +YF+HF +VF +CF,
(0xB2<<8)+SF +YF+HF +VF +CF,
(0xB3<<8)+SF +YF+HF +CF,
(0xB4<<8)+SF +YF+HF +VF +CF,
(0xB5<<8)+SF +YF+HF +CF,
(0xB6<<8)+SF +YF +CF,
(0xB7<<8)+SF +YF +VF +CF,
(0xB8<<8)+SF +YF +XF+VF +CF,
(0xB9<<8)+SF +YF +XF +CF,
(0xBA<<8)+SF +YF +XF +CF,
(0xBB<<8)+SF +YF +XF+VF +CF,
(0xBC<<8)+SF +YF +XF +CF,
(0xBD<<8)+SF +YF +XF+VF +CF,
(0xBE<<8)+SF +YF +XF+VF +CF,
(0xBF<<8)+SF +YF +XF +CF,
(0xC0<<8)+SF +HF +VF +CF,
(0xC1<<8)+SF +HF +CF,
(0xC2<<8)+SF +HF +CF,
(0xC3<<8)+SF +HF +VF +CF,
(0xC4<<8)+SF +HF +CF,
(0xC5<<8)+SF +HF +VF +CF,
(0xC6<<8)+SF +VF +CF,
(0xC7<<8)+SF +CF,
(0xC8<<8)+SF +XF +CF,
(0xC9<<8)+SF +XF+VF +CF,
(0xCA<<8)+SF +XF+VF +CF,
(0xCB<<8)+SF +XF +CF,
(0xCC<<8)+SF +XF+VF +CF,
(0xCD<<8)+SF +XF +CF,
(0xCE<<8)+SF +XF +CF,
(0xCF<<8)+SF +XF+VF +CF,
(0xD0<<8)+SF +HF +CF,
(0xD1<<8)+SF +HF +VF +CF,
(0xD2<<8)+SF +HF +VF +CF,
(0xD3<<8)+SF +HF +CF,
(0xD4<<8)+SF +HF +VF +CF,
(0xD5<<8)+SF +HF +CF,
(0xD6<<8)+SF +CF,
(0xD7<<8)+SF +VF +CF,
(0xD8<<8)+SF +XF+VF +CF,
(0xD9<<8)+SF +XF +CF,
(0xDA<<8)+SF +XF +CF,
(0xDB<<8)+SF +XF+VF +CF,
(0xDC<<8)+SF +XF +CF,
(0xDD<<8)+SF +XF+VF +CF,
(0xDE<<8)+SF +XF+VF +CF,
(0xDF<<8)+SF +XF +CF,
(0xE0<<8)+SF +YF+HF +CF,
(0xE1<<8)+SF +YF+HF +VF +CF,
(0xE2<<8)+SF +YF+HF +VF +CF,
(0xE3<<8)+SF +YF+HF +CF,
(0xE4<<8)+SF +YF+HF +VF +CF,
(0xE5<<8)+SF +YF+HF +CF,
(0xE6<<8)+SF +YF +CF,
(0xE7<<8)+SF +YF +VF +CF,
(0xE8<<8)+SF +YF +XF+VF +CF,
(0xE9<<8)+SF +YF +XF +CF,
(0xEA<<8)+SF +YF +XF +CF,
(0xEB<<8)+SF +YF +XF+VF +CF,
(0xEC<<8)+SF +YF +XF +CF,
(0xED<<8)+SF +YF +XF+VF +CF,
(0xEE<<8)+SF +YF +XF+VF +CF,
(0xEF<<8)+SF +YF +XF +CF,
(0xF0<<8)+SF +YF+HF +VF +CF,
(0xF1<<8)+SF +YF+HF +CF,
(0xF2<<8)+SF +YF+HF +CF,
(0xF3<<8)+SF +YF+HF +VF +CF,
(0xF4<<8)+SF +YF+HF +CF,
(0xF5<<8)+SF +YF+HF +VF +CF,
(0xF6<<8)+SF +YF +VF +CF,
(0xF7<<8)+SF +YF +CF,
(0xF8<<8)+SF +YF +XF +CF,
(0xF9<<8)+SF +YF +XF+VF +CF,
(0xFA<<8)+SF +YF +XF+VF +CF,
(0xFB<<8)+SF +YF +XF +CF,
(0xFC<<8)+SF +YF +XF+VF +CF,
(0xFD<<8)+SF +YF +XF +CF,
(0xFE<<8)+SF +YF +XF +CF,
(0xFF<<8)+SF +YF +XF+VF +CF,
(0x00<<8) +ZF +HF +VF +CF,
(0x01<<8) +HF +CF,
(0x02<<8) +HF +CF,
(0x03<<8) +HF +VF +CF,
(0x04<<8) +HF +CF,
(0x05<<8) +HF +VF +CF,
(0x06<<8) +VF +CF,
(0x07<<8) +CF,
(0x08<<8) +XF +CF,
(0x09<<8) +XF+VF +CF,
(0x0A<<8) +XF+VF +CF,
(0x0B<<8) +XF +CF,
(0x0C<<8) +XF+VF +CF,
(0x0D<<8) +XF +CF,
(0x0E<<8) +XF +CF,
(0x0F<<8) +XF+VF +CF,
(0x10<<8) +HF +CF,
(0x11<<8) +HF +VF +CF,
(0x12<<8) +HF +VF +CF,
(0x13<<8) +HF +CF,
(0x14<<8) +HF +VF +CF,
(0x15<<8) +HF +CF,
(0x16<<8) +CF,
(0x17<<8) +VF +CF,
(0x18<<8) +XF+VF +CF,
(0x19<<8) +XF +CF,
(0x1A<<8) +XF +CF,
(0x1B<<8) +XF+VF +CF,
(0x1C<<8) +XF +CF,
(0x1D<<8) +XF+VF +CF,
(0x1E<<8) +XF+VF +CF,
(0x1F<<8) +XF +CF,
(0x20<<8) +YF+HF +CF,
(0x21<<8) +YF+HF +VF +CF,
(0x22<<8) +YF+HF +VF +CF,
(0x23<<8) +YF+HF +CF,
(0x24<<8) +YF+HF +VF +CF,
(0x25<<8) +YF+HF +CF,
(0x26<<8) +YF +CF,
(0x27<<8) +YF +VF +CF,
(0x28<<8) +YF +XF+VF +CF,
(0x29<<8) +YF +XF +CF,
(0x2A<<8) +YF +XF +CF,
(0x2B<<8) +YF +XF+VF +CF,
(0x2C<<8) +YF +XF +CF,
(0x2D<<8) +YF +XF+VF +CF,
(0x2E<<8) +YF +XF+VF +CF,
(0x2F<<8) +YF +XF +CF,
(0x30<<8) +YF+HF +VF +CF,
(0x31<<8) +YF+HF +CF,
(0x32<<8) +YF+HF +CF,
(0x33<<8) +YF+HF +VF +CF,
(0x34<<8) +YF+HF +CF,
(0x35<<8) +YF+HF +VF +CF,
(0x36<<8) +YF +VF +CF,
(0x37<<8) +YF +CF,
(0x38<<8) +YF +XF +CF,
(0x39<<8) +YF +XF+VF +CF,
(0x3A<<8) +YF +XF+VF +CF,
(0x3B<<8) +YF +XF +CF,
(0x3C<<8) +YF +XF+VF +CF,
(0x3D<<8) +YF +XF +CF,
(0x3E<<8) +YF +XF +CF,
(0x3F<<8) +YF +XF+VF +CF,
(0x40<<8) +HF +CF,
(0x41<<8) +HF +VF +CF,
(0x42<<8) +HF +VF +CF,
(0x43<<8) +HF +CF,
(0x44<<8) +HF +VF +CF,
(0x45<<8) +HF +CF,
(0x46<<8) +CF,
(0x47<<8) +VF +CF,
(0x48<<8) +XF+VF +CF,
(0x49<<8) +XF +CF,
(0x4A<<8) +XF +CF,
(0x4B<<8) +XF+VF +CF,
(0x4C<<8) +XF +CF,
(0x4D<<8) +XF+VF +CF,
(0x4E<<8) +XF+VF +CF,
(0x4F<<8) +XF +CF,
(0x50<<8) +HF +VF +CF,
(0x51<<8) +HF +CF,
(0x52<<8) +HF +CF,
(0x53<<8) +HF +VF +CF,
(0x54<<8) +HF +CF,
(0x55<<8) +HF +VF +CF,
(0x56<<8) +VF +CF,
(0x57<<8) +CF,
(0x58<<8) +XF +CF,
(0x59<<8) +XF+VF +CF,
(0x5A<<8) +XF+VF +CF,
(0x5B<<8) +XF +CF,
(0x5C<<8) +XF+VF +CF,
(0x5D<<8) +XF +CF,
(0x5E<<8) +XF +CF,
(0x5F<<8) +XF+VF +CF,
(0x60<<8) +YF+HF +VF +CF,
(0x61<<8) +YF+HF +CF,
(0x62<<8) +YF+HF +CF,
(0x63<<8) +YF+HF +VF +CF,
(0x64<<8) +YF+HF +CF,
(0x65<<8) +YF+HF +VF +CF,
(0x00<<8) +ZF +VF+NF ,
(0x01<<8) +NF ,
(0x02<<8) +NF ,
(0x03<<8) +VF+NF ,
(0x04<<8) +NF ,
(0x05<<8) +VF+NF ,
(0x06<<8) +VF+NF ,
(0x07<<8) +NF ,
(0x08<<8) +XF +NF ,
(0x09<<8) +XF+VF+NF ,
(0x04<<8) +NF ,
(0x05<<8) +VF+NF ,
(0x06<<8) +VF+NF ,
(0x07<<8) +NF ,
(0x08<<8) +XF +NF ,
(0x09<<8) +XF+VF+NF ,
(0x10<<8) +NF ,
(0x11<<8) +VF+NF ,
(0x12<<8) +VF+NF ,
(0x13<<8) +NF ,
(0x14<<8) +VF+NF ,
(0x15<<8) +NF ,
(0x16<<8) +NF ,
(0x17<<8) +VF+NF ,
(0x18<<8) +XF+VF+NF ,
(0x19<<8) +XF +NF ,
(0x14<<8) +VF+NF ,
(0x15<<8) +NF ,
(0x16<<8) +NF ,
(0x17<<8) +VF+NF ,
(0x18<<8) +XF+VF+NF ,
(0x19<<8) +XF +NF ,
(0x20<<8) +YF +NF ,
(0x21<<8) +YF +VF+NF ,
(0x22<<8) +YF +VF+NF ,
(0x23<<8) +YF +NF ,
(0x24<<8) +YF +VF+NF ,
(0x25<<8) +YF +NF ,
(0x26<<8) +YF +NF ,
(0x27<<8) +YF +VF+NF ,
(0x28<<8) +YF +XF+VF+NF ,
(0x29<<8) +YF +XF +NF ,
(0x24<<8) +YF +VF+NF ,
(0x25<<8) +YF +NF ,
(0x26<<8) +YF +NF ,
(0x27<<8) +YF +VF+NF ,
(0x28<<8) +YF +XF+VF+NF ,
(0x29<<8) +YF +XF +NF ,
(0x30<<8) +YF +VF+NF ,
(0x31<<8) +YF +NF ,
(0x32<<8) +YF +NF ,
(0x33<<8) +YF +VF+NF ,
(0x34<<8) +YF +NF ,
(0x35<<8) +YF +VF+NF ,
(0x36<<8) +YF +VF+NF ,
(0x37<<8) +YF +NF ,
(0x38<<8) +YF +XF +NF ,
(0x39<<8) +YF +XF+VF+NF ,
(0x34<<8) +YF +NF ,
(0x35<<8) +YF +VF+NF ,
(0x36<<8) +YF +VF+NF ,
(0x37<<8) +YF +NF ,
(0x38<<8) +YF +XF +NF ,
(0x39<<8) +YF +XF+VF+NF ,
(0x40<<8) +NF ,
(0x41<<8) +VF+NF ,
(0x42<<8) +VF+NF ,
(0x43<<8) +NF ,
(0x44<<8) +VF+NF ,
(0x45<<8) +NF ,
(0x46<<8) +NF ,
(0x47<<8) +VF+NF ,
(0x48<<8) +XF+VF+NF ,
(0x49<<8) +XF +NF ,
(0x44<<8) +VF+NF ,
(0x45<<8) +NF ,
(0x46<<8) +NF ,
(0x47<<8) +VF+NF ,
(0x48<<8) +XF+VF+NF ,
(0x49<<8) +XF +NF ,
(0x50<<8) +VF+NF ,
(0x51<<8) +NF ,
(0x52<<8) +NF ,
(0x53<<8) +VF+NF ,
(0x54<<8) +NF ,
(0x55<<8) +VF+NF ,
(0x56<<8) +VF+NF ,
(0x57<<8) +NF ,
(0x58<<8) +XF +NF ,
(0x59<<8) +XF+VF+NF ,
(0x54<<8) +NF ,
(0x55<<8) +VF+NF ,
(0x56<<8) +VF+NF ,
(0x57<<8) +NF ,
(0x58<<8) +XF +NF ,
(0x59<<8) +XF+VF+NF ,
(0x60<<8) +YF +VF+NF ,
(0x61<<8) +YF +NF ,
(0x62<<8) +YF +NF ,
(0x63<<8) +YF +VF+NF ,
(0x64<<8) +YF +NF ,
(0x65<<8) +YF +VF+NF ,
(0x66<<8) +YF +VF+NF ,
(0x67<<8) +YF +NF ,
(0x68<<8) +YF +XF +NF ,
(0x69<<8) +YF +XF+VF+NF ,
(0x64<<8) +YF +NF ,
(0x65<<8) +YF +VF+NF ,
(0x66<<8) +YF +VF+NF ,
(0x67<<8) +YF +NF ,
(0x68<<8) +YF +XF +NF ,
(0x69<<8) +YF +XF+VF+NF ,
(0x70<<8) +YF +NF ,
(0x71<<8) +YF +VF+NF ,
(0x72<<8) +YF +VF+NF ,
(0x73<<8) +YF +NF ,
(0x74<<8) +YF +VF+NF ,
(0x75<<8) +YF +NF ,
(0x76<<8) +YF +NF ,
(0x77<<8) +YF +VF+NF ,
(0x78<<8) +YF +XF+VF+NF ,
(0x79<<8) +YF +XF +NF ,
(0x74<<8) +YF +VF+NF ,
(0x75<<8) +YF +NF ,
(0x76<<8) +YF +NF ,
(0x77<<8) +YF +VF+NF ,
(0x78<<8) +YF +XF+VF+NF ,
(0x79<<8) +YF +XF +NF ,
(0x80<<8)+SF +NF ,
(0x81<<8)+SF +VF+NF ,
(0x82<<8)+SF +VF+NF ,
(0x83<<8)+SF +NF ,
(0x84<<8)+SF +VF+NF ,
(0x85<<8)+SF +NF ,
(0x86<<8)+SF +NF ,
(0x87<<8)+SF +VF+NF ,
(0x88<<8)+SF +XF+VF+NF ,
(0x89<<8)+SF +XF +NF ,
(0x84<<8)+SF +VF+NF ,
(0x85<<8)+SF +NF ,
(0x86<<8)+SF +NF ,
(0x87<<8)+SF +VF+NF ,
(0x88<<8)+SF +XF+VF+NF ,
(0x89<<8)+SF +XF +NF ,
(0x90<<8)+SF +VF+NF ,
(0x91<<8)+SF +NF ,
(0x92<<8)+SF +NF ,
(0x93<<8)+SF +VF+NF ,
(0x94<<8)+SF +NF ,
(0x95<<8)+SF +VF+NF ,
(0x96<<8)+SF +VF+NF ,
(0x97<<8)+SF +NF ,
(0x98<<8)+SF +XF +NF ,
(0x99<<8)+SF +XF+VF+NF ,
(0x34<<8) +YF +NF+CF,
(0x35<<8) +YF +VF+NF+CF,
(0x36<<8) +YF +VF+NF+CF,
(0x37<<8) +YF +NF+CF,
(0x38<<8) +YF +XF +NF+CF,
(0x39<<8) +YF +XF+VF+NF+CF,
(0x40<<8) +NF+CF,
(0x41<<8) +VF+NF+CF,
(0x42<<8) +VF+NF+CF,
(0x43<<8) +NF+CF,
(0x44<<8) +VF+NF+CF,
(0x45<<8) +NF+CF,
(0x46<<8) +NF+CF,
(0x47<<8) +VF+NF+CF,
(0x48<<8) +XF+VF+NF+CF,
(0x49<<8) +XF +NF+CF,
(0x44<<8) +VF+NF+CF,
(0x45<<8) +NF+CF,
(0x46<<8) +NF+CF,
(0x47<<8) +VF+NF+CF,
(0x48<<8) +XF+VF+NF+CF,
(0x49<<8) +XF +NF+CF,
(0x50<<8) +VF+NF+CF,
(0x51<<8) +NF+CF,
(0x52<<8) +NF+CF,
(0x53<<8) +VF+NF+CF,
(0x54<<8) +NF+CF,
(0x55<<8) +VF+NF+CF,
(0x56<<8) +VF+NF+CF,
(0x57<<8) +NF+CF,
(0x58<<8) +XF +NF+CF,
(0x59<<8) +XF+VF+NF+CF,
(0x54<<8) +NF+CF,
(0x55<<8) +VF+NF+CF,
(0x56<<8) +VF+NF+CF,
(0x57<<8) +NF+CF,
(0x58<<8) +XF +NF+CF,
(0x59<<8) +XF+VF+NF+CF,
(0x60<<8) +YF +VF+NF+CF,
(0x61<<8) +YF +NF+CF,
(0x62<<8) +YF +NF+CF,
(0x63<<8) +YF +VF+NF+CF,
(0x64<<8) +YF +NF+CF,
(0x65<<8) +YF +VF+NF+CF,
(0x66<<8) +YF +VF+NF+CF,
(0x67<<8) +YF +NF+CF,
(0x68<<8) +YF +XF +NF+CF,
(0x69<<8) +YF +XF+VF+NF+CF,
(0x64<<8) +YF +NF+CF,
(0x65<<8) +YF +VF+NF+CF,
(0x66<<8) +YF +VF+NF+CF,
(0x67<<8) +YF +NF+CF,
(0x68<<8) +YF +XF +NF+CF,
(0x69<<8) +YF +XF+VF+NF+CF,
(0x70<<8) +YF +NF+CF,
(0x71<<8) +YF +VF+NF+CF,
(0x72<<8) +YF +VF+NF+CF,
(0x73<<8) +YF +NF+CF,
(0x74<<8) +YF +VF+NF+CF,
(0x75<<8) +YF +NF+CF,
(0x76<<8) +YF +NF+CF,
(0x77<<8) +YF +VF+NF+CF,
(0x78<<8) +YF +XF+VF+NF+CF,
(0x79<<8) +YF +XF +NF+CF,
(0x74<<8) +YF +VF+NF+CF,
(0x75<<8) +YF +NF+CF,
(0x76<<8) +YF +NF+CF,
(0x77<<8) +YF +VF+NF+CF,
(0x78<<8) +YF +XF+VF+NF+CF,
(0x79<<8) +YF +XF +NF+CF,
(0x80<<8)+SF +NF+CF,
(0x81<<8)+SF +VF+NF+CF,
(0x82<<8)+SF +VF+NF+CF,
(0x83<<8)+SF +NF+CF,
(0x84<<8)+SF +VF+NF+CF,
(0x85<<8)+SF +NF+CF,
(0x86<<8)+SF +NF+CF,
(0x87<<8)+SF +VF+NF+CF,
(0x88<<8)+SF +XF+VF+NF+CF,
(0x89<<8)+SF +XF +NF+CF,
(0x84<<8)+SF +VF+NF+CF,
(0x85<<8)+SF +NF+CF,
(0x86<<8)+SF +NF+CF,
(0x87<<8)+SF +VF+NF+CF,
(0x88<<8)+SF +XF+VF+NF+CF,
(0x89<<8)+SF +XF +NF+CF,
(0x90<<8)+SF +VF+NF+CF,
(0x91<<8)+SF +NF+CF,
(0x92<<8)+SF +NF+CF,
(0x93<<8)+SF +VF+NF+CF,
(0x94<<8)+SF +NF+CF,
(0x95<<8)+SF +VF+NF+CF,
(0x96<<8)+SF +VF+NF+CF,
(0x97<<8)+SF +NF+CF,
(0x98<<8)+SF +XF +NF+CF,
(0x99<<8)+SF +XF+VF+NF+CF,
(0x94<<8)+SF +NF+CF,
(0x95<<8)+SF +VF+NF+CF,
(0x96<<8)+SF +VF+NF+CF,
(0x97<<8)+SF +NF+CF,
(0x98<<8)+SF +XF +NF+CF,
(0x99<<8)+SF +XF+VF+NF+CF,
(0xA0<<8)+SF +YF +VF+NF+CF,
(0xA1<<8)+SF +YF +NF+CF,
(0xA2<<8)+SF +YF +NF+CF,
(0xA3<<8)+SF +YF +VF+NF+CF,
(0xA4<<8)+SF +YF +NF+CF,
(0xA5<<8)+SF +YF +VF+NF+CF,
(0xA6<<8)+SF +YF +VF+NF+CF,
(0xA7<<8)+SF +YF +NF+CF,
(0xA8<<8)+SF +YF +XF +NF+CF,
(0xA9<<8)+SF +YF +XF+VF+NF+CF,
(0xA4<<8)+SF +YF +NF+CF,
(0xA5<<8)+SF +YF +VF+NF+CF,
(0xA6<<8)+SF +YF +VF+NF+CF,
(0xA7<<8)+SF +YF +NF+CF,
(0xA8<<8)+SF +YF +XF +NF+CF,
(0xA9<<8)+SF +YF +XF+VF+NF+CF,
(0xB0<<8)+SF +YF +NF+CF,
(0xB1<<8)+SF +YF +VF+NF+CF,
(0xB2<<8)+SF +YF +VF+NF+CF,
(0xB3<<8)+SF +YF +NF+CF,
(0xB4<<8)+SF +YF +VF+NF+CF,
(0xB5<<8)+SF +YF +NF+CF,
(0xB6<<8)+SF +YF +NF+CF,
(0xB7<<8)+SF +YF +VF+NF+CF,
(0xB8<<8)+SF +YF +XF+VF+NF+CF,
(0xB9<<8)+SF +YF +XF +NF+CF,
(0xB4<<8)+SF +YF +VF+NF+CF,
(0xB5<<8)+SF +YF +NF+CF,
(0xB6<<8)+SF +YF +NF+CF,
(0xB7<<8)+SF +YF +VF+NF+CF,
(0xB8<<8)+SF +YF +XF+VF+NF+CF,
(0xB9<<8)+SF +YF +XF +NF+CF,
(0xC0<<8)+SF +VF+NF+CF,
(0xC1<<8)+SF +NF+CF,
(0xC2<<8)+SF +NF+CF,
(0xC3<<8)+SF +VF+NF+CF,
(0xC4<<8)+SF +NF+CF,
(0xC5<<8)+SF +VF+NF+CF,
(0xC6<<8)+SF +VF+NF+CF,
(0xC7<<8)+SF +NF+CF,
(0xC8<<8)+SF +XF +NF+CF,
(0xC9<<8)+SF +XF+VF+NF+CF,
(0xC4<<8)+SF +NF+CF,
(0xC5<<8)+SF +VF+NF+CF,
(0xC6<<8)+SF +VF+NF+CF,
(0xC7<<8)+SF +NF+CF,
(0xC8<<8)+SF +XF +NF+CF,
(0xC9<<8)+SF +XF+VF+NF+CF,
(0xD0<<8)+SF +NF+CF,
(0xD1<<8)+SF +VF+NF+CF,
(0xD2<<8)+SF +VF+NF+CF,
(0xD3<<8)+SF +NF+CF,
(0xD4<<8)+SF +VF+NF+CF,
(0xD5<<8)+SF +NF+CF,
(0xD6<<8)+SF +NF+CF,
(0xD7<<8)+SF +VF+NF+CF,
(0xD8<<8)+SF +XF+VF+NF+CF,
(0xD9<<8)+SF +XF +NF+CF,
(0xD4<<8)+SF +VF+NF+CF,
(0xD5<<8)+SF +NF+CF,
(0xD6<<8)+SF +NF+CF,
(0xD7<<8)+SF +VF+NF+CF,
(0xD8<<8)+SF +XF+VF+NF+CF,
(0xD9<<8)+SF +XF +NF+CF,
(0xE0<<8)+SF +YF +NF+CF,
(0xE1<<8)+SF +YF +VF+NF+CF,
(0xE2<<8)+SF +YF +VF+NF+CF,
(0xE3<<8)+SF +YF +NF+CF,
(0xE4<<8)+SF +YF +VF+NF+CF,
(0xE5<<8)+SF +YF +NF+CF,
(0xE6<<8)+SF +YF +NF+CF,
(0xE7<<8)+SF +YF +VF+NF+CF,
(0xE8<<8)+SF +YF +XF+VF+NF+CF,
(0xE9<<8)+SF +YF +XF +NF+CF,
(0xE4<<8)+SF +YF +VF+NF+CF,
(0xE5<<8)+SF +YF +NF+CF,
(0xE6<<8)+SF +YF +NF+CF,
(0xE7<<8)+SF +YF +VF+NF+CF,
(0xE8<<8)+SF +YF +XF+VF+NF+CF,
(0xE9<<8)+SF +YF +XF +NF+CF,
(0xF0<<8)+SF +YF +VF+NF+CF,
(0xF1<<8)+SF +YF +NF+CF,
(0xF2<<8)+SF +YF +NF+CF,
(0xF3<<8)+SF +YF +VF+NF+CF,
(0xF4<<8)+SF +YF +NF+CF,
(0xF5<<8)+SF +YF +VF+NF+CF,
(0xF6<<8)+SF +YF +VF+NF+CF,
(0xF7<<8)+SF +YF +NF+CF,
(0xF8<<8)+SF +YF +XF +NF+CF,
(0xF9<<8)+SF +YF +XF+VF+NF+CF,
(0xF4<<8)+SF +YF +NF+CF,
(0xF5<<8)+SF +YF +VF+NF+CF,
(0xF6<<8)+SF +YF +VF+NF+CF,
(0xF7<<8)+SF +YF +NF+CF,
(0xF8<<8)+SF +YF +XF +NF+CF,
(0xF9<<8)+SF +YF +XF+VF+NF+CF,
(0x00<<8) +ZF +VF+NF+CF,
(0x01<<8) +NF+CF,
(0x02<<8) +NF+CF,
(0x03<<8) +VF+NF+CF,
(0x04<<8) +NF+CF,
(0x05<<8) +VF+NF+CF,
(0x06<<8) +VF+NF+CF,
(0x07<<8) +NF+CF,
(0x08<<8) +XF +NF+CF,
(0x09<<8) +XF+VF+NF+CF,
(0x04<<8) +NF+CF,
(0x05<<8) +VF+NF+CF,
(0x06<<8) +VF+NF+CF,
(0x07<<8) +NF+CF,
(0x08<<8) +XF +NF+CF,
(0x09<<8) +XF+VF+NF+CF,
(0x10<<8) +NF+CF,
(0x11<<8) +VF+NF+CF,
(0x12<<8) +VF+NF+CF,
(0x13<<8) +NF+CF,
(0x14<<8) +VF+NF+CF,
(0x15<<8) +NF+CF,
(0x16<<8) +NF+CF,
(0x17<<8) +VF+NF+CF,
(0x18<<8) +XF+VF+NF+CF,
(0x19<<8) +XF +NF+CF,
(0x14<<8) +VF+NF+CF,
(0x15<<8) +NF+CF,
(0x16<<8) +NF+CF,
(0x17<<8) +VF+NF+CF,
(0x18<<8) +XF+VF+NF+CF,
(0x19<<8) +XF +NF+CF,
(0x20<<8) +YF +NF+CF,
(0x21<<8) +YF +VF+NF+CF,
(0x22<<8) +YF +VF+NF+CF,
(0x23<<8) +YF +NF+CF,
(0x24<<8) +YF +VF+NF+CF,
(0x25<<8) +YF +NF+CF,
(0x26<<8) +YF +NF+CF,
(0x27<<8) +YF +VF+NF+CF,
(0x28<<8) +YF +XF+VF+NF+CF,
(0x29<<8) +YF +XF +NF+CF,
(0x24<<8) +YF +VF+NF+CF,
(0x25<<8) +YF +NF+CF,
(0x26<<8) +YF +NF+CF,
(0x27<<8) +YF +VF+NF+CF,
(0x28<<8) +YF +XF+VF+NF+CF,
(0x29<<8) +YF +XF +NF+CF,
(0x30<<8) +YF +VF+NF+CF,
(0x31<<8) +YF +NF+CF,
(0x32<<8) +YF +NF+CF,
(0x33<<8) +YF +VF+NF+CF,
(0x34<<8) +YF +NF+CF,
(0x35<<8) +YF +VF+NF+CF,
(0x36<<8) +YF +VF+NF+CF,
(0x37<<8) +YF +NF+CF,
(0x38<<8) +YF +XF +NF+CF,
(0x39<<8) +YF +XF+VF+NF+CF,
(0x34<<8) +YF +NF+CF,
(0x35<<8) +YF +VF+NF+CF,
(0x36<<8) +YF +VF+NF+CF,
(0x37<<8) +YF +NF+CF,
(0x38<<8) +YF +XF +NF+CF,
(0x39<<8) +YF +XF+VF+NF+CF,
(0x40<<8) +NF+CF,
(0x41<<8) +VF+NF+CF,
(0x42<<8) +VF+NF+CF,
(0x43<<8) +NF+CF,
(0x44<<8) +VF+NF+CF,
(0x45<<8) +NF+CF,
(0x46<<8) +NF+CF,
(0x47<<8) +VF+NF+CF,
(0x48<<8) +XF+VF+NF+CF,
(0x49<<8) +XF +NF+CF,
(0x44<<8) +VF+NF+CF,
(0x45<<8) +NF+CF,
(0x46<<8) +NF+CF,
(0x47<<8) +VF+NF+CF,
(0x48<<8) +XF+VF+NF+CF,
(0x49<<8) +XF +NF+CF,
(0x50<<8) +VF+NF+CF,
(0x51<<8) +NF+CF,
(0x52<<8) +NF+CF,
(0x53<<8) +VF+NF+CF,
(0x54<<8) +NF+CF,
(0x55<<8) +VF+NF+CF,
(0x56<<8) +VF+NF+CF,
(0x57<<8) +NF+CF,
(0x58<<8) +XF +NF+CF,
(0x59<<8) +XF+VF+NF+CF,
(0x54<<8) +NF+CF,
(0x55<<8) +VF+NF+CF,
(0x56<<8) +VF+NF+CF,
(0x57<<8) +NF+CF,
(0x58<<8) +XF +NF+CF,
(0x59<<8) +XF+VF+NF+CF,
(0x60<<8) +YF +VF+NF+CF,
(0x61<<8) +YF +NF+CF,
(0x62<<8) +YF +NF+CF,
(0x63<<8) +YF +VF+NF+CF,
(0x64<<8) +YF +NF+CF,
(0x65<<8) +YF +VF+NF+CF,
(0x66<<8) +YF +VF+NF+CF,
(0x67<<8) +YF +NF+CF,
(0x68<<8) +YF +XF +NF+CF,
(0x69<<8) +YF +XF+VF+NF+CF,
(0x64<<8) +YF +NF+CF,
(0x65<<8) +YF +VF+NF+CF,
(0x66<<8) +YF +VF+NF+CF,
(0x67<<8) +YF +NF+CF,
(0x68<<8) +YF +XF +NF+CF,
(0x69<<8) +YF +XF+VF+NF+CF,
(0x70<<8) +YF +NF+CF,
(0x71<<8) +YF +VF+NF+CF,
(0x72<<8) +YF +VF+NF+CF,
(0x73<<8) +YF +NF+CF,
(0x74<<8) +YF +VF+NF+CF,
(0x75<<8) +YF +NF+CF,
(0x76<<8) +YF +NF+CF,
(0x77<<8) +YF +VF+NF+CF,
(0x78<<8) +YF +XF+VF+NF+CF,
(0x79<<8) +YF +XF +NF+CF,
(0x74<<8) +YF +VF+NF+CF,
(0x75<<8) +YF +NF+CF,
(0x76<<8) +YF +NF+CF,
(0x77<<8) +YF +VF+NF+CF,
(0x78<<8) +YF +XF+VF+NF+CF,
(0x79<<8) +YF +XF +NF+CF,
(0x80<<8)+SF +NF+CF,
(0x81<<8)+SF +VF+NF+CF,
(0x82<<8)+SF +VF+NF+CF,
(0x83<<8)+SF +NF+CF,
(0x84<<8)+SF +VF+NF+CF,
(0x85<<8)+SF +NF+CF,
(0x86<<8)+SF +NF+CF,
(0x87<<8)+SF +VF+NF+CF,
(0x88<<8)+SF +XF+VF+NF+CF,
(0x89<<8)+SF +XF +NF+CF,
(0x84<<8)+SF +VF+NF+CF,
(0x85<<8)+SF +NF+CF,
(0x86<<8)+SF +NF+CF,
(0x87<<8)+SF +VF+NF+CF,
(0x88<<8)+SF +XF+VF+NF+CF,
(0x89<<8)+SF +XF +NF+CF,
(0x90<<8)+SF +VF+NF+CF,
(0x91<<8)+SF +NF+CF,
(0x92<<8)+SF +NF+CF,
(0x93<<8)+SF +VF+NF+CF,
(0x94<<8)+SF +NF+CF,
(0x95<<8)+SF +VF+NF+CF,
(0x96<<8)+SF +VF+NF+CF,
(0x97<<8)+SF +NF+CF,
(0x98<<8)+SF +XF +NF+CF,
(0x99<<8)+SF +XF+VF+NF+CF,
(0x94<<8)+SF +NF+CF,
(0x95<<8)+SF +VF+NF+CF,
(0x96<<8)+SF +VF+NF+CF,
(0x97<<8)+SF +NF+CF,
(0x98<<8)+SF +XF +NF+CF,
(0x99<<8)+SF +XF+VF+NF+CF,
(0xFA<<8)+SF +YF+HF+XF+VF+NF ,
(0xFB<<8)+SF +YF+HF+XF +NF ,
(0xFC<<8)+SF +YF+HF+XF+VF+NF ,
(0xFD<<8)+SF +YF+HF+XF +NF ,
(0xFE<<8)+SF +YF+HF+XF +NF ,
(0xFF<<8)+SF +YF+HF+XF+VF+NF ,
(0x00<<8) +ZF +VF+NF ,
(0x01<<8) +NF ,
(0x02<<8) +NF ,
(0x03<<8) +VF+NF ,
(0x04<<8) +NF ,
(0x05<<8) +VF+NF ,
(0x06<<8) +VF+NF ,
(0x07<<8) +NF ,
(0x08<<8) +XF +NF ,
(0x09<<8) +XF+VF+NF ,
(0x0A<<8) +HF+XF+VF+NF ,
(0x0B<<8) +HF+XF +NF ,
(0x0C<<8) +HF+XF+VF+NF ,
(0x0D<<8) +HF+XF +NF ,
(0x0E<<8) +HF+XF +NF ,
(0x0F<<8) +HF+XF+VF+NF ,
(0x10<<8) +NF ,
(0x11<<8) +VF+NF ,
(0x12<<8) +VF+NF ,
(0x13<<8) +NF ,
(0x14<<8) +VF+NF ,
(0x15<<8) +NF ,
(0x16<<8) +NF ,
(0x17<<8) +VF+NF ,
(0x18<<8) +XF+VF+NF ,
(0x19<<8) +XF +NF ,
(0x1A<<8) +HF+XF +NF ,
(0x1B<<8) +HF+XF+VF+NF ,
(0x1C<<8) +HF+XF +NF ,
(0x1D<<8) +HF+XF+VF+NF ,
(0x1E<<8) +HF+XF+VF+NF ,
(0x1F<<8) +HF+XF +NF ,
(0x20<<8) +YF +NF ,
(0x21<<8) +YF +VF+NF ,
(0x22<<8) +YF +VF+NF ,
(0x23<<8) +YF +NF ,
(0x24<<8) +YF +VF+NF ,
(0x25<<8) +YF +NF ,
(0x26<<8) +YF +NF ,
(0x27<<8) +YF +VF+NF ,
(0x28<<8) +YF +XF+VF+NF ,
(0x29<<8) +YF +XF +NF ,
(0x2A<<8) +YF+HF+XF +NF ,
(0x2B<<8) +YF+HF+XF+VF+NF ,
(0x2C<<8) +YF+HF+XF +NF ,
(0x2D<<8) +YF+HF+XF+VF+NF ,
(0x2E<<8) +YF+HF+XF+VF+NF ,
(0x2F<<8) +YF+HF+XF +NF ,
(0x30<<8) +YF +VF+NF ,
(0x31<<8) +YF +NF ,
(0x32<<8) +YF +NF ,
(0x33<<8) +YF +VF+NF ,
(0x34<<8) +YF +NF ,
(0x35<<8) +YF +VF+NF ,
(0x36<<8) +YF +VF+NF ,
(0x37<<8) +YF +NF ,
(0x38<<8) +YF +XF +NF ,
(0x39<<8) +YF +XF+VF+NF ,
(0x3A<<8) +YF+HF+XF+VF+NF ,
(0x3B<<8) +YF+HF+XF +NF ,
(0x3C<<8) +YF+HF+XF+VF+NF ,
(0x3D<<8) +YF+HF+XF +NF ,
(0x3E<<8) +YF+HF+XF +NF ,
(0x3F<<8) +YF+HF+XF+VF+NF ,
(0x40<<8) +NF ,
(0x41<<8) +VF+NF ,
(0x42<<8) +VF+NF ,
(0x43<<8) +NF ,
(0x44<<8) +VF+NF ,
(0x45<<8) +NF ,
(0x46<<8) +NF ,
(0x47<<8) +VF+NF ,
(0x48<<8) +XF+VF+NF ,
(0x49<<8) +XF +NF ,
(0x4A<<8) +HF+XF +NF ,
(0x4B<<8) +HF+XF+VF+NF ,
(0x4C<<8) +HF+XF +NF ,
(0x4D<<8) +HF+XF+VF+NF ,
(0x4E<<8) +HF+XF+VF+NF ,
(0x4F<<8) +HF+XF +NF ,
(0x50<<8) +VF+NF ,
(0x51<<8) +NF ,
(0x52<<8) +NF ,
(0x53<<8) +VF+NF ,
(0x54<<8) +NF ,
(0x55<<8) +VF+NF ,
(0x56<<8) +VF+NF ,
(0x57<<8) +NF ,
(0x58<<8) +XF +NF ,
(0x59<<8) +XF+VF+NF ,
(0x5A<<8) +HF+XF+VF+NF ,
(0x5B<<8) +HF+XF +NF ,
(0x5C<<8) +HF+XF+VF+NF ,
(0x5D<<8) +HF+XF +NF ,
(0x5E<<8) +HF+XF +NF ,
(0x5F<<8) +HF+XF+VF+NF ,
(0x60<<8) +YF +VF+NF ,
(0x61<<8) +YF +NF ,
(0x62<<8) +YF +NF ,
(0x63<<8) +YF +VF+NF ,
(0x64<<8) +YF +NF ,
(0x65<<8) +YF +VF+NF ,
(0x66<<8) +YF +VF+NF ,
(0x67<<8) +YF +NF ,
(0x68<<8) +YF +XF +NF ,
(0x69<<8) +YF +XF+VF+NF ,
(0x6A<<8) +YF+HF+XF+VF+NF ,
(0x6B<<8) +YF+HF+XF +NF ,
(0x6C<<8) +YF+HF+XF+VF+NF ,
(0x6D<<8) +YF+HF+XF +NF ,
(0x6E<<8) +YF+HF+XF +NF ,
(0x6F<<8) +YF+HF+XF+VF+NF ,
(0x70<<8) +YF +NF ,
(0x71<<8) +YF +VF+NF ,
(0x72<<8) +YF +VF+NF ,
(0x73<<8) +YF +NF ,
(0x74<<8) +YF +VF+NF ,
(0x75<<8) +YF +NF ,
(0x76<<8) +YF +NF ,
(0x77<<8) +YF +VF+NF ,
(0x78<<8) +YF +XF+VF+NF ,
(0x79<<8) +YF +XF +NF ,
(0x7A<<8) +YF+HF+XF +NF ,
(0x7B<<8) +YF+HF+XF+VF+NF ,
(0x7C<<8) +YF+HF+XF +NF ,
(0x7D<<8) +YF+HF+XF+VF+NF ,
(0x7E<<8) +YF+HF+XF+VF+NF ,
(0x7F<<8) +YF+HF+XF +NF ,
(0x80<<8)+SF +NF ,
(0x81<<8)+SF +VF+NF ,
(0x82<<8)+SF +VF+NF ,
(0x83<<8)+SF +NF ,
(0x84<<8)+SF +VF+NF ,
(0x85<<8)+SF +NF ,
(0x86<<8)+SF +NF ,
(0x87<<8)+SF +VF+NF ,
(0x88<<8)+SF +XF+VF+NF ,
(0x89<<8)+SF +XF +NF ,
(0x8A<<8)+SF +HF+XF +NF ,
(0x8B<<8)+SF +HF+XF+VF+NF ,
(0x8C<<8)+SF +HF+XF +NF ,
(0x8D<<8)+SF +HF+XF+VF+NF ,
(0x8E<<8)+SF +HF+XF+VF+NF ,
(0x8F<<8)+SF +HF+XF +NF ,
(0x90<<8)+SF +VF+NF ,
(0x91<<8)+SF +NF ,
(0x92<<8)+SF +NF ,
(0x93<<8)+SF +VF+NF ,
(0x34<<8) +YF +NF+CF,
(0x35<<8) +YF +VF+NF+CF,
(0x36<<8) +YF +VF+NF+CF,
(0x37<<8) +YF +NF+CF,
(0x38<<8) +YF +XF +NF+CF,
(0x39<<8) +YF +XF+VF+NF+CF,
(0x3A<<8) +YF+HF+XF+VF+NF+CF,
(0x3B<<8) +YF+HF+XF +NF+CF,
(0x3C<<8) +YF+HF+XF+VF+NF+CF,
(0x3D<<8) +YF+HF+XF +NF+CF,
(0x3E<<8) +YF+HF+XF +NF+CF,
(0x3F<<8) +YF+HF+XF+VF+NF+CF,
(0x40<<8) +NF+CF,
(0x41<<8) +VF+NF+CF,
(0x42<<8) +VF+NF+CF,
(0x43<<8) +NF+CF,
(0x44<<8) +VF+NF+CF,
(0x45<<8) +NF+CF,
(0x46<<8) +NF+CF,
(0x47<<8) +VF+NF+CF,
(0x48<<8) +XF+VF+NF+CF,
(0x49<<8) +XF +NF+CF,
(0x4A<<8) +HF+XF +NF+CF,
(0x4B<<8) +HF+XF+VF+NF+CF,
(0x4C<<8) +HF+XF +NF+CF,
(0x4D<<8) +HF+XF+VF+NF+CF,
(0x4E<<8) +HF+XF+VF+NF+CF,
(0x4F<<8) +HF+XF +NF+CF,
(0x50<<8) +VF+NF+CF,
(0x51<<8) +NF+CF,
(0x52<<8) +NF+CF,
(0x53<<8) +VF+NF+CF,
(0x54<<8) +NF+CF,
(0x55<<8) +VF+NF+CF,
(0x56<<8) +VF+NF+CF,
(0x57<<8) +NF+CF,
(0x58<<8) +XF +NF+CF,
(0x59<<8) +XF+VF+NF+CF,
(0x5A<<8) +HF+XF+VF+NF+CF,
(0x5B<<8) +HF+XF +NF+CF,
(0x5C<<8) +HF+XF+VF+NF+CF,
(0x5D<<8) +HF+XF +NF+CF,
(0x5E<<8) +HF+XF +NF+CF,
(0x5F<<8) +HF+XF+VF+NF+CF,
(0x60<<8) +YF +VF+NF+CF,
(0x61<<8) +YF +NF+CF,
(0x62<<8) +YF +NF+CF,
(0x63<<8) +YF +VF+NF+CF,
(0x64<<8) +YF +NF+CF,
(0x65<<8) +YF +VF+NF+CF,
(0x66<<8) +YF +VF+NF+CF,
(0x67<<8) +YF +NF+CF,
(0x68<<8) +YF +XF +NF+CF,
(0x69<<8) +YF +XF+VF+NF+CF,
(0x6A<<8) +YF+HF+XF+VF+NF+CF,
(0x6B<<8) +YF+HF+XF +NF+CF,
(0x6C<<8) +YF+HF+XF+VF+NF+CF,
(0x6D<<8) +YF+HF+XF +NF+CF,
(0x6E<<8) +YF+HF+XF +NF+CF,
(0x6F<<8) +YF+HF+XF+VF+NF+CF,
(0x70<<8) +YF +NF+CF,
(0x71<<8) +YF +VF+NF+CF,
(0x72<<8) +YF +VF+NF+CF,
(0x73<<8) +YF +NF+CF,
(0x74<<8) +YF +VF+NF+CF,
(0x75<<8) +YF +NF+CF,
(0x76<<8) +YF +NF+CF,
(0x77<<8) +YF +VF+NF+CF,
(0x78<<8) +YF +XF+VF+NF+CF,
(0x79<<8) +YF +XF +NF+CF,
(0x7A<<8) +YF+HF+XF +NF+CF,
(0x7B<<8) +YF+HF+XF+VF+NF+CF,
(0x7C<<8) +YF+HF+XF +NF+CF,
(0x7D<<8) +YF+HF+XF+VF+NF+CF,
(0x7E<<8) +YF+HF+XF+VF+NF+CF,
(0x7F<<8) +YF+HF+XF +NF+CF,
(0x80<<8)+SF +NF+CF,
(0x81<<8)+SF +VF+NF+CF,
(0x82<<8)+SF +VF+NF+CF,
(0x83<<8)+SF +NF+CF,
(0x84<<8)+SF +VF+NF+CF,
(0x85<<8)+SF +NF+CF,
(0x86<<8)+SF +NF+CF,
(0x87<<8)+SF +VF+NF+CF,
(0x88<<8)+SF +XF+VF+NF+CF,
(0x89<<8)+SF +XF +NF+CF,
(0x8A<<8)+SF +HF+XF +NF+CF,
(0x8B<<8)+SF +HF+XF+VF+NF+CF,
(0x8C<<8)+SF +HF+XF +NF+CF,
(0x8D<<8)+SF +HF+XF+VF+NF+CF,
(0x8E<<8)+SF +HF+XF+VF+NF+CF,
(0x8F<<8)+SF +HF+XF +NF+CF,
(0x90<<8)+SF +VF+NF+CF,
(0x91<<8)+SF +NF+CF,
(0x92<<8)+SF +NF+CF,
(0x93<<8)+SF +VF+NF+CF,
(0x94<<8)+SF +NF+CF,
(0x95<<8)+SF +VF+NF+CF,
(0x96<<8)+SF +VF+NF+CF,
(0x97<<8)+SF +NF+CF,
(0x98<<8)+SF +XF +NF+CF,
(0x99<<8)+SF +XF+VF+NF+CF,
(0x9A<<8)+SF +HF+XF+VF+NF+CF,
(0x9B<<8)+SF +HF+XF +NF+CF,
(0x9C<<8)+SF +HF+XF+VF+NF+CF,
(0x9D<<8)+SF +HF+XF +NF+CF,
(0x9E<<8)+SF +HF+XF +NF+CF,
(0x9F<<8)+SF +HF+XF+VF+NF+CF,
(0xA0<<8)+SF +YF +VF+NF+CF,
(0xA1<<8)+SF +YF +NF+CF,
(0xA2<<8)+SF +YF +NF+CF,
(0xA3<<8)+SF +YF +VF+NF+CF,
(0xA4<<8)+SF +YF +NF+CF,
(0xA5<<8)+SF +YF +VF+NF+CF,
(0xA6<<8)+SF +YF +VF+NF+CF,
(0xA7<<8)+SF +YF +NF+CF,
(0xA8<<8)+SF +YF +XF +NF+CF,
(0xA9<<8)+SF +YF +XF+VF+NF+CF,
(0xAA<<8)+SF +YF+HF+XF+VF+NF+CF,
(0xAB<<8)+SF +YF+HF+XF +NF+CF,
(0xAC<<8)+SF +YF+HF+XF+VF+NF+CF,
(0xAD<<8)+SF +YF+HF+XF +NF+CF,
(0xAE<<8)+SF +YF+HF+XF +NF+CF,
(0xAF<<8)+SF +YF+HF+XF+VF+NF+CF,
(0xB0<<8)+SF +YF +NF+CF,
(0xB1<<8)+SF +YF +VF+NF+CF,
(0xB2<<8)+SF +YF +VF+NF+CF,
(0xB3<<8)+SF +YF +NF+CF,
(0xB4<<8)+SF +YF +VF+NF+CF,
(0xB5<<8)+SF +YF +NF+CF,
(0xB6<<8)+SF +YF +NF+CF,
(0xB7<<8)+SF +YF +VF+NF+CF,
(0xB8<<8)+SF +YF +XF+VF+NF+CF,
(0xB9<<8)+SF +YF +XF +NF+CF,
(0xBA<<8)+SF +YF+HF+XF +NF+CF,
(0xBB<<8)+SF +YF+HF+XF+VF+NF+CF,
(0xBC<<8)+SF +YF+HF+XF +NF+CF,
(0xBD<<8)+SF +YF+HF+XF+VF+NF+CF,
(0xBE<<8)+SF +YF+HF+XF+VF+NF+CF,
(0xBF<<8)+SF +YF+HF+XF +NF+CF,
(0xC0<<8)+SF +VF+NF+CF,
(0xC1<<8)+SF +NF+CF,
(0xC2<<8)+SF +NF+CF,
(0xC3<<8)+SF +VF+NF+CF,
(0xC4<<8)+SF +NF+CF,
(0xC5<<8)+SF +VF+NF+CF,
(0xC6<<8)+SF +VF+NF+CF,
(0xC7<<8)+SF +NF+CF,
(0xC8<<8)+SF +XF +NF+CF,
(0xC9<<8)+SF +XF+VF+NF+CF,
(0xCA<<8)+SF +HF+XF+VF+NF+CF,
(0xCB<<8)+SF +HF+XF +NF+CF,
(0xCC<<8)+SF +HF+XF+VF+NF+CF,
(0xCD<<8)+SF +HF+XF +NF+CF,
(0xCE<<8)+SF +HF+XF +NF+CF,
(0xCF<<8)+SF +HF+XF+VF+NF+CF,
(0xD0<<8)+SF +NF+CF,
(0xD1<<8)+SF +VF+NF+CF,
(0xD2<<8)+SF +VF+NF+CF,
(0xD3<<8)+SF +NF+CF,
(0xD4<<8)+SF +VF+NF+CF,
(0xD5<<8)+SF +NF+CF,
(0xD6<<8)+SF +NF+CF,
(0xD7<<8)+SF +VF+NF+CF,
(0xD8<<8)+SF +XF+VF+NF+CF,
(0xD9<<8)+SF +XF +NF+CF,
(0xDA<<8)+SF +HF+XF +NF+CF,
(0xDB<<8)+SF +HF+XF+VF+NF+CF,
(0xDC<<8)+SF +HF+XF +NF+CF,
(0xDD<<8)+SF +HF+XF+VF+NF+CF,
(0xDE<<8)+SF +HF+XF+VF+NF+CF,
(0xDF<<8)+SF +HF+XF +NF+CF,
(0xE0<<8)+SF +YF +NF+CF,
(0xE1<<8)+SF +YF +VF+NF+CF,
(0xE2<<8)+SF +YF +VF+NF+CF,
(0xE3<<8)+SF +YF +NF+CF,
(0xE4<<8)+SF +YF +VF+NF+CF,
(0xE5<<8)+SF +YF +NF+CF,
(0xE6<<8)+SF +YF +NF+CF,
(0xE7<<8)+SF +YF +VF+NF+CF,
(0xE8<<8)+SF +YF +XF+VF+NF+CF,
(0xE9<<8)+SF +YF +XF +NF+CF,
(0xEA<<8)+SF +YF+HF+XF +NF+CF,
(0xEB<<8)+SF +YF+HF+XF+VF+NF+CF,
(0xEC<<8)+SF +YF+HF+XF +NF+CF,
(0xED<<8)+SF +YF+HF+XF+VF+NF+CF,
(0xEE<<8)+SF +YF+HF+XF+VF+NF+CF,
(0xEF<<8)+SF +YF+HF+XF +NF+CF,
(0xF0<<8)+SF +YF +VF+NF+CF,
(0xF1<<8)+SF +YF +NF+CF,
(0xF2<<8)+SF +YF +NF+CF,
(0xF3<<8)+SF +YF +VF+NF+CF,
(0xF4<<8)+SF +YF +NF+CF,
(0xF5<<8)+SF +YF +VF+NF+CF,
(0xF6<<8)+SF +YF +VF+NF+CF,
(0xF7<<8)+SF +YF +NF+CF,
(0xF8<<8)+SF +YF +XF +NF+CF,
(0xF9<<8)+SF +YF +XF+VF+NF+CF,
(0xFA<<8)+SF +YF+HF+XF+VF+NF+CF,
(0xFB<<8)+SF +YF+HF+XF +NF+CF,
(0xFC<<8)+SF +YF+HF+XF+VF+NF+CF,
(0xFD<<8)+SF +YF+HF+XF +NF+CF,
(0xFE<<8)+SF +YF+HF+XF +NF+CF,
(0xFF<<8)+SF +YF+HF+XF+VF+NF+CF,
(0x00<<8) +ZF +VF+NF+CF,
(0x01<<8) +NF+CF,
(0x02<<8) +NF+CF,
(0x03<<8) +VF+NF+CF,
(0x04<<8) +NF+CF,
(0x05<<8) +VF+NF+CF,
(0x06<<8) +VF+NF+CF,
(0x07<<8) +NF+CF,
(0x08<<8) +XF +NF+CF,
(0x09<<8) +XF+VF+NF+CF,
(0x0A<<8) +HF+XF+VF+NF+CF,
(0x0B<<8) +HF+XF +NF+CF,
(0x0C<<8) +HF+XF+VF+NF+CF,
(0x0D<<8) +HF+XF +NF+CF,
(0x0E<<8) +HF+XF +NF+CF,
(0x0F<<8) +HF+XF+VF+NF+CF,
(0x10<<8) +NF+CF,
(0x11<<8) +VF+NF+CF,
(0x12<<8) +VF+NF+CF,
(0x13<<8) +NF+CF,
(0x14<<8) +VF+NF+CF,
(0x15<<8) +NF+CF,
(0x16<<8) +NF+CF,
(0x17<<8) +VF+NF+CF,
(0x18<<8) +XF+VF+NF+CF,
(0x19<<8) +XF +NF+CF,
(0x1A<<8) +HF+XF +NF+CF,
(0x1B<<8) +HF+XF+VF+NF+CF,
(0x1C<<8) +HF+XF +NF+CF,
(0x1D<<8) +HF+XF+VF+NF+CF,
(0x1E<<8) +HF+XF+VF+NF+CF,
(0x1F<<8) +HF+XF +NF+CF,
(0x20<<8) +YF +NF+CF,
(0x21<<8) +YF +VF+NF+CF,
(0x22<<8) +YF +VF+NF+CF,
(0x23<<8) +YF +NF+CF,
(0x24<<8) +YF +VF+NF+CF,
(0x25<<8) +YF +NF+CF,
(0x26<<8) +YF +NF+CF,
(0x27<<8) +YF +VF+NF+CF,
(0x28<<8) +YF +XF+VF+NF+CF,
(0x29<<8) +YF +XF +NF+CF,
(0x2A<<8) +YF+HF+XF +NF+CF,
(0x2B<<8) +YF+HF+XF+VF+NF+CF,
(0x2C<<8) +YF+HF+XF +NF+CF,
(0x2D<<8) +YF+HF+XF+VF+NF+CF,
(0x2E<<8) +YF+HF+XF+VF+NF+CF,
(0x2F<<8) +YF+HF+XF +NF+CF,
(0x30<<8) +YF +VF+NF+CF,
(0x31<<8) +YF +NF+CF,
(0x32<<8) +YF +NF+CF,
(0x33<<8) +YF +VF+NF+CF,
(0x34<<8) +YF +NF+CF,
(0x35<<8) +YF +VF+NF+CF,
(0x36<<8) +YF +VF+NF+CF,
(0x37<<8) +YF +NF+CF,
(0x38<<8) +YF +XF +NF+CF,
(0x39<<8) +YF +XF+VF+NF+CF,
(0x3A<<8) +YF+HF+XF+VF+NF+CF,
(0x3B<<8) +YF+HF+XF +NF+CF,
(0x3C<<8) +YF+HF+XF+VF+NF+CF,
(0x3D<<8) +YF+HF+XF +NF+CF,
(0x3E<<8) +YF+HF+XF +NF+CF,
(0x3F<<8) +YF+HF+XF+VF+NF+CF,
(0x40<<8) +NF+CF,
(0x41<<8) +VF+NF+CF,
(0x42<<8) +VF+NF+CF,
(0x43<<8) +NF+CF,
(0x44<<8) +VF+NF+CF,
(0x45<<8) +NF+CF,
(0x46<<8) +NF+CF,
(0x47<<8) +VF+NF+CF,
(0x48<<8) +XF+VF+NF+CF,
(0x49<<8) +XF +NF+CF,
(0x4A<<8) +HF+XF +NF+CF,
(0x4B<<8) +HF+XF+VF+NF+CF,
(0x4C<<8) +HF+XF +NF+CF,
(0x4D<<8) +HF+XF+VF+NF+CF,
(0x4E<<8) +HF+XF+VF+NF+CF,
(0x4F<<8) +HF+XF +NF+CF,
(0x50<<8) +VF+NF+CF,
(0x51<<8) +NF+CF,
(0x52<<8) +NF+CF,
(0x53<<8) +VF+NF+CF,
(0x54<<8) +NF+CF,
(0x55<<8) +VF+NF+CF,
(0x56<<8) +VF+NF+CF,
(0x57<<8) +NF+CF,
(0x58<<8) +XF +NF+CF,
(0x59<<8) +XF+VF+NF+CF,
(0x5A<<8) +HF+XF+VF+NF+CF,
(0x5B<<8) +HF+XF +NF+CF,
(0x5C<<8) +HF+XF+VF+NF+CF,
(0x5D<<8) +HF+XF +NF+CF,
(0x5E<<8) +HF+XF +NF+CF,
(0x5F<<8) +HF+XF+VF+NF+CF,
(0x60<<8) +YF +VF+NF+CF,
(0x61<<8) +YF +NF+CF,
(0x62<<8) +YF +NF+CF,
(0x63<<8) +YF +VF+NF+CF,
(0x64<<8) +YF +NF+CF,
(0x65<<8) +YF +VF+NF+CF,
(0x66<<8) +YF +VF+NF+CF,
(0x67<<8) +YF +NF+CF,
(0x68<<8) +YF +XF +NF+CF,
(0x69<<8) +YF +XF+VF+NF+CF,
(0x6A<<8) +YF+HF+XF+VF+NF+CF,
(0x6B<<8) +YF+HF+XF +NF+CF,
(0x6C<<8) +YF+HF+XF+VF+NF+CF,
(0x6D<<8) +YF+HF+XF +NF+CF,
(0x6E<<8) +YF+HF+XF +NF+CF,
(0x6F<<8) +YF+HF+XF+VF+NF+CF,
(0x70<<8) +YF +NF+CF,
(0x71<<8) +YF +VF+NF+CF,
(0x72<<8) +YF +VF+NF+CF,
(0x73<<8) +YF +NF+CF,
(0x74<<8) +YF +VF+NF+CF,
(0x75<<8) +YF +NF+CF,
(0x76<<8) +YF +NF+CF,
(0x77<<8) +YF +VF+NF+CF,
(0x78<<8) +YF +XF+VF+NF+CF,
(0x79<<8) +YF +XF +NF+CF,
(0x7A<<8) +YF+HF+XF +NF+CF,
(0x7B<<8) +YF+HF+XF+VF+NF+CF,
(0x7C<<8) +YF+HF+XF +NF+CF,
(0x7D<<8) +YF+HF+XF+VF+NF+CF,
(0x7E<<8) +YF+HF+XF+VF+NF+CF,
(0x7F<<8) +YF+HF+XF +NF+CF,
(0x80<<8)+SF +NF+CF,
(0x81<<8)+SF +VF+NF+CF,
(0x82<<8)+SF +VF+NF+CF,
(0x83<<8)+SF +NF+CF,
(0x84<<8)+SF +VF+NF+CF,
(0x85<<8)+SF +NF+CF,
(0x86<<8)+SF +NF+CF,
(0x87<<8)+SF +VF+NF+CF,
(0x88<<8)+SF +XF+VF+NF+CF,
(0x89<<8)+SF +XF +NF+CF,
(0x8A<<8)+SF +HF+XF +NF+CF,
(0x8B<<8)+SF +HF+XF+VF+NF+CF,
(0x8C<<8)+SF +HF+XF +NF+CF,
(0x8D<<8)+SF +HF+XF+VF+NF+CF,
(0x8E<<8)+SF +HF+XF+VF+NF+CF,
(0x8F<<8)+SF +HF+XF +NF+CF,
(0x90<<8)+SF +VF+NF+CF,
(0x91<<8)+SF +NF+CF,
(0x92<<8)+SF +NF+CF,
(0x93<<8)+SF +VF+NF+CF,
(0x94<<8)+SF +NF+CF,
(0x95<<8)+SF +VF+NF+CF,
(0x96<<8)+SF +VF+NF+CF,
(0x97<<8)+SF +NF+CF,
(0x98<<8)+SF +XF +NF+CF,
(0x99<<8)+SF +XF+VF+NF+CF
};
| 76,730
|
C++
|
.h
| 2,073
| 34.017849
| 71
| 0.317893
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,868
|
argparse.h
|
ColinPitrat_caprice32/src/argparse.h
|
#ifndef ARGPARSE_H
#define ARGPARSE_H
#include <map>
#include <string>
#include <vector>
class CapriceArgs
{
public:
CapriceArgs() = default;
std::string autocmd;
std::string cfgFilePath;
std::string binFile;
size_t binOffset;
std::map<std::string, std::map<std::string, std::string>> cfgOverrides;
std::string symFilePath;
};
std::string replaceCap32Keys(std::string command);
void parseArguments(int argc, char** argv, std::vector<std::string>& slot_list, CapriceArgs& args);
#endif
| 534
|
C++
|
.h
| 19
| 24.526316
| 99
| 0.710372
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,869
|
font.h
|
ColinPitrat_caprice32/src/font.h
|
/* Caprice32 - Amstrad CPC Emulator
(c) Copyright 1997-2004 Ulrich Doewich
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define FNT_CHAR_WIDTH 8
#define FNT_CHAR_HEIGHT 8
#define FNT_CHARS 96
#define FNT_MIN_CHAR 32
#define FNT_MAX_CHAR (FNT_MIN_CHAR+FNT_CHARS)
#define FNT_BAD_CHAR 95
static byte bFont[768] = {
0x00, 0x18, 0x6C, 0x6C, 0x18, 0x4C, 0x70, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x7C, 0x18, 0x7C, 0x7C, 0xC6, 0xFE, 0x7C, 0xFE, 0x7C, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x7C, 0x7C, 0xFC, 0x7C, 0xFC, 0xFE, 0xFE, 0x7C, 0xC6, 0x3C, 0x06, 0xC6, 0xC0, 0xC6, 0xC6, 0x7C, 0xFC, 0x7C, 0xFC, 0x7C, 0x7E, 0xC6, 0xC6, 0xC6, 0xC6, 0x66, 0xFE, 0x38, 0xC0, 0x1C, 0x38, 0x00, 0x18, 0x00, 0xC0, 0x00, 0x06, 0x00, 0x3C, 0x00, 0xC0, 0x18, 0x18, 0xC0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x18, 0x30, 0x00, 0x00,
0x00, 0x18, 0x6C, 0xFE, 0x3E, 0xEC, 0xC0, 0x18, 0x30, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xC6, 0x38, 0xC6, 0xC6, 0xC6, 0xC0, 0xC6, 0x06, 0xC6, 0xC6, 0x18, 0x18, 0x0C, 0x00, 0x30, 0x66, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC0, 0xC0, 0xC6, 0xC6, 0x18, 0x06, 0xC6, 0xC0, 0xEE, 0xE6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x18, 0xC6, 0xC6, 0xC6, 0xC6, 0x66, 0x0C, 0x30, 0xC0, 0x0C, 0x6C, 0x00, 0x18, 0x00, 0xC0, 0x00, 0x06, 0x00, 0x60, 0x00, 0xC0, 0x00, 0x00, 0xC0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x00, 0x00,
0x00, 0x18, 0x00, 0x6C, 0x78, 0x58, 0xCC, 0x30, 0x30, 0x0C, 0x6C, 0x18, 0x00, 0x00, 0x00, 0x18, 0xC6, 0x18, 0x06, 0x06, 0xC6, 0xC0, 0xC0, 0x0C, 0xC6, 0xC6, 0x18, 0x18, 0x18, 0x7E, 0x18, 0x06, 0xCE, 0xC6, 0xC6, 0xC0, 0xC6, 0xC0, 0xC0, 0xC0, 0xC6, 0x18, 0x06, 0xCC, 0xC0, 0xFE, 0xF6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC0, 0x18, 0xC6, 0xC6, 0xC6, 0x6C, 0x66, 0x18, 0x30, 0x60, 0x0C, 0xC6, 0x00, 0x0C, 0x7C, 0xFC, 0x7E, 0x7E, 0x7C, 0x78, 0x7E, 0xFC, 0x18, 0x18, 0xC6, 0x60, 0x7C, 0x7C, 0x7C, 0xFC, 0x7E, 0x7C, 0x7C, 0x78, 0xC6, 0xC6, 0xD6, 0x66, 0xC6, 0xFE, 0x18, 0x18, 0x18, 0x00, 0x00,
0x00, 0x18, 0x00, 0x6C, 0x3C, 0x30, 0xEE, 0x00, 0x30, 0x0C, 0x38, 0x7E, 0x00, 0x7E, 0x00, 0x30, 0xC6, 0x18, 0x7C, 0x1C, 0x7E, 0x7C, 0xFC, 0x18, 0x7C, 0x7E, 0x00, 0x00, 0x30, 0x00, 0x0C, 0x0C, 0xD6, 0xFE, 0xFC, 0xC0, 0xC6, 0xF8, 0xF8, 0xDE, 0xFE, 0x18, 0x06, 0xF8, 0xC0, 0xD6, 0xDE, 0xC6, 0xFC, 0xC6, 0xFC, 0x7C, 0x18, 0xC6, 0xC6, 0xD6, 0x38, 0x3C, 0x30, 0x30, 0x30, 0x0C, 0x00, 0x00, 0x00, 0x06, 0xC6, 0xC0, 0xC6, 0xC6, 0x60, 0xC6, 0xC6, 0x18, 0x18, 0xCC, 0x60, 0xD6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC0, 0xC0, 0x60, 0xC6, 0xC6, 0xD6, 0x3C, 0xC6, 0x18, 0x30, 0x18, 0x0C, 0x76, 0x00,
0x00, 0x18, 0x00, 0x6C, 0x1E, 0x68, 0xCC, 0x00, 0x30, 0x0C, 0x6C, 0x18, 0x18, 0x00, 0x00, 0x60, 0xD6, 0x18, 0xC0, 0x06, 0x06, 0x06, 0xC6, 0x30, 0xC6, 0x06, 0x18, 0x18, 0x18, 0x7E, 0x18, 0x18, 0xDC, 0xC6, 0xC6, 0xC0, 0xC6, 0xC0, 0xC0, 0xC6, 0xC6, 0x18, 0x06, 0xCC, 0xC0, 0xC6, 0xCE, 0xC6, 0xC0, 0xC2, 0xC6, 0x06, 0x18, 0xC6, 0xC6, 0xFE, 0x6C, 0x18, 0x60, 0x30, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x7E, 0xC6, 0xC0, 0xC6, 0xFE, 0x60, 0xC6, 0xC6, 0x18, 0x18, 0xF8, 0x60, 0xD6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC0, 0x7C, 0x60, 0xC6, 0xC6, 0xD6, 0x18, 0xC6, 0x30, 0x18, 0x18, 0x18, 0xDC, 0x00,
0x00, 0x00, 0x00, 0xFE, 0x7C, 0xDC, 0xCC, 0x00, 0x30, 0x0C, 0x00, 0x00, 0x18, 0x00, 0x18, 0xC0, 0xC6, 0x18, 0xC0, 0xC6, 0x06, 0x06, 0xC6, 0x30, 0xC6, 0xC6, 0x18, 0x18, 0x0C, 0x00, 0x30, 0x00, 0xC0, 0xC6, 0xC6, 0xC6, 0xC6, 0xC0, 0xC0, 0xC6, 0xC6, 0x18, 0xC6, 0xC6, 0xC0, 0xC6, 0xC6, 0xC6, 0xC0, 0xCC, 0xC6, 0xC6, 0x18, 0xC6, 0x6C, 0xEE, 0xC6, 0x18, 0xC0, 0x30, 0x0C, 0x0C, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC0, 0xC6, 0xC0, 0x60, 0x7E, 0xC6, 0x18, 0x18, 0xCC, 0x60, 0xD6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC0, 0x06, 0x60, 0xC6, 0x6C, 0xD6, 0x3C, 0x7E, 0x60, 0x18, 0x18, 0x18, 0x00, 0x00,
0x00, 0x18, 0x00, 0x6C, 0x18, 0xC8, 0x76, 0x00, 0x18, 0x18, 0x00, 0x00, 0x30, 0x00, 0x18, 0xC0, 0x7C, 0x3C, 0xFE, 0x7C, 0x06, 0xFC, 0x7C, 0x30, 0x7C, 0x7C, 0x00, 0x30, 0x00, 0x00, 0x00, 0x18, 0x7C, 0xC6, 0xFC, 0x7C, 0xFC, 0xFE, 0xC0, 0x7C, 0xC6, 0x3C, 0x7C, 0xC6, 0xFE, 0xC6, 0xC6, 0x7C, 0xC0, 0x76, 0xC6, 0x7C, 0x18, 0x7C, 0x38, 0xC6, 0xC6, 0x18, 0xFE, 0x38, 0x0C, 0x1C, 0x00, 0xFE, 0x00, 0x7E, 0xFC, 0x7E, 0x7E, 0x7C, 0x60, 0x06, 0xC6, 0x18, 0x18, 0xC6, 0x3C, 0xD6, 0xC6, 0x7C, 0xFC, 0x7E, 0xC0, 0xFC, 0x3C, 0x7C, 0x38, 0x7C, 0x66, 0x06, 0xFE, 0x0C, 0x18, 0x30, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
| 5,604
|
C++
|
.h
| 30
| 183.633333
| 578
| 0.682169
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
753,870
|
glfunclist.h
|
ColinPitrat_caprice32/src/glfunclist.h
|
GL_FUNC(void,glBegin,(GLenum))
GL_FUNC(void,glBindTexture,(GLenum,GLuint))
GL_FUNC(void,glBlendFunc,(GLenum,GLenum))
GL_FUNC(void,glColor4f,(GLfloat,GLfloat,GLfloat,GLfloat))
GL_FUNC(void,glDisable,(GLenum cap))
GL_FUNC(void,glEnable,(GLenum cap))
GL_FUNC(void,glEnd,())
GL_FUNC(void,glGenTextures,(GLsizei n, GLuint *textures))
GL_FUNC(void,glDeleteTextures,(GLsizei n, GLuint *textures))
GL_FUNC(void,glGetIntegerv,(GLenum pname, GLint *params))
GL_FUNC(const GLubyte *,glGetString,(GLenum name))
GL_FUNC(void,glLoadIdentity,())
GL_FUNC(void,glMatrixMode,(GLenum mode))
GL_FUNC(void,glOrtho,(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar))
GL_FUNC(void,glTexCoord2f,(GLfloat s, GLfloat t))
GL_FUNC(void,glTexImage2D,(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels))
GL_FUNC(void,glTexParameteri,(GLenum target, GLenum pname, GLint param))
GL_FUNC(void,glTexSubImage2D,(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels))
GL_FUNC(void,glVertex2i,(GLint x, GLint y))
GL_FUNC(void,glViewport,(GLint x, GLint y, GLsizei width, GLsizei height))
GL_FUNC(GLboolean,glIsTexture,( GLuint texture ))
GL_FUNC(void,glTexEnvf,(GLenum, GLenum, GLfloat))
GL_FUNC(void,glClear,(GLbitfield))
GL_FUNC(void,glClearColor,(GLclampf,GLclampf,GLclampf,GLclampf))
GL_FUNC_OPTIONAL(void,glColorTableEXT, (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *))
GL_FUNC_OPTIONAL(void,glActiveTextureARB, (GLenum))
GL_FUNC_OPTIONAL(void,glMultiTexCoord2fARB, (GLenum,GLfloat,GLfloat))
| 1,695
|
C++
|
.h
| 27
| 61.703704
| 172
| 0.794718
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,871
|
fileutils.h
|
ColinPitrat_caprice32/src/fileutils.h
|
// Caprice 32
// File IO functions
#include <dirent.h>
#include <string>
#include <vector>
// Returns the file size of the file specified by the file descriptor 'fd'.
int file_size (int fd);
// Copy the content of in to out. Returns true if successful, false otherwise.
bool file_copy(FILE *in, FILE *out);
// True if string passed is a directory. false otherwise.
bool is_directory(std::string filepath);
// Returns a vector containing the names of the files in the specified directory
std::vector<std::string> listDirectory(std::string &);
// Returns a vector containing the names of the files having extension "ext" in
// the specified directory
std::vector<std::string> listDirectoryExt(std::string &, const std::string &);
// Returns a string describing current date and time (YYYYMMDD_HHmmss format)
std::string getDateString();
| 842
|
C++
|
.h
| 18
| 45.388889
| 80
| 0.767442
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,872
|
devtools.h
|
ColinPitrat_caprice32/src/devtools.h
|
#ifndef DEVTOOLS_H
#define DEVTOOLS_H
#include <string>
#include "SDL.h"
#include "CapriceGui.h"
#include "CapriceDevToolsView.h"
class DevTools {
public:
bool Activate(int scale);
void Deactivate();
bool IsActive() const { return active; };
void LoadSymbols(const std::string& filename);
void PreUpdate();
void PostUpdate();
// Return true if the event was processed
// (i.e destined to this window)
bool PassEvent(SDL_Event& e);
private:
std::unique_ptr<CapriceGui> capriceGui;
std::unique_ptr<CapriceDevToolsView> devToolsView;
bool active = false;
SDL_Window* window = nullptr;
SDL_Renderer* renderer = nullptr;
SDL_Texture* texture = nullptr;
SDL_Surface* surface = nullptr;
int scale = 0;
};
#endif
| 785
|
C++
|
.h
| 28
| 24.178571
| 54
| 0.70494
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,873
|
phazer.h
|
ColinPitrat_caprice32/src/phazer.h
|
#ifndef PHAZER_H
#define PHAZER_H
#include <string>
class PhazerType {
public:
enum Value
{
None = 0,
AmstradMagnumPhaser = 1,
TrojanLightPhazer = 2,
LastPhazerType,
};
PhazerType() = default;
constexpr PhazerType(Value val) : value(val) { }
std::string ToString();
PhazerType Next();
operator Value() const { return value; };
// if(phazer_type)
operator bool() const { return value != None; };
private:
Value value;
};
#endif
| 508
|
C++
|
.h
| 23
| 17.565217
| 52
| 0.635983
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,875
|
cartridge.h
|
ColinPitrat_caprice32/src/cartridge.h
|
/* Caprice32 - Amstrad CPC Emulator
Loading of Plus range cartridge files (.cpr)
The file format is RIFF (Resource Interchange File Format) as described
here:
- http://www.cpcwiki.eu/index.php/Format:CPR_CPC_Plus_cartridge_file_format
- https://en.wikipedia.org/wiki/Resource_Interchange_File_Format
*/
#ifndef CARTRIDGE_H
#define CARTRIDGE_H
#include <string>
void cpr_eject ();
int cpr_load (const std::string &filename);
int cpr_load (FILE *pfile);
#endif
| 487
|
C++
|
.h
| 14
| 31.785714
| 79
| 0.750538
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,876
|
configuration.h
|
ColinPitrat_caprice32/src/configuration.h
|
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
#include <map>
#include <string>
namespace config
{
using ConfigSection = std::map<std::string, std::string>;
using ConfigMap = std::map<std::string, ConfigSection>;
bool hasValue(const ConfigMap& configMap, const std::string& section, const std::string& key);
class Config
{
public:
std::istream& parseStream(std::istream& configStream);
void parseString(const std::string& configString);
void parseFile(const std::string& configFilename);
std::ostream& toStream(std::ostream& out) const;
bool saveToFile(const std::string& configFilename) const;
void setOverrides(const ConfigMap& overrides);
int getIntValue(const std::string& section, const std::string& key, const int defaultValue) const;
void setIntValue(const std::string& section, const std::string& key, const int value);
std::string getStringValue(const std::string& section, const std::string& key, const std::string& defaultValue) const;
void setStringValue(const std::string& section, const std::string& key, const std::string& value);
// Do not use this for anything else than testing.
ConfigMap getConfigMapForTests() const;
private:
ConfigMap config_;
ConfigMap overrides_;
};
}
#endif
| 1,315
|
C++
|
.h
| 30
| 39
| 124
| 0.726845
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,877
|
slotshandler.h
|
ColinPitrat_caprice32/src/slotshandler.h
|
/* Caprice32 - Amstrad CPC Emulator
(c) Copyright 1997-2005 Ulrich Doewich
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "disk.h"
#include <string>
typedef enum {
DSK_A,
DSK_B,
OTHER,
} DRIVE;
FILE *extractFile(const std::string& zipfile, const std::string& filename, const std::string& ext);
int snapshot_load (FILE *pfile);
int snapshot_load (const std::string& filename);
int snapshot_save (const std::string& filename);
int dsk_load (FILE *pfile, t_drive *drive);
int dsk_load (const std::string& filename, t_drive *drive);
int dsk_save (const std::string& filename, t_drive *drive);
void dsk_eject (t_drive* drive);
int dsk_format (t_drive* drive, int iFormat);
int tape_insert (FILE *pfile);
int tape_insert (const std::string& filename);
int tape_insert_cdt (FILE *pfile);
int tape_insert_voc (FILE *pfile);
void tape_eject ();
void cartridge_load ();
int cartridge_load (const std::string& filepath);
int cartridge_load (FILE *file);
// Smart load: support loading DSK, SNA, CDT, VOC, CPR or a zip containing one of these.
// drive must be DSK_A or DSK_B for DSK, OTHER otherwise.
int file_load(const std::string& filepath, const DRIVE drive);
// Retrieve files that are passed as argument and update CPC fields so that they will be loaded properly
void fillSlots (std::vector<std::string> slot_list, t_CPC& CPC);
// Loads slot content in memory
void loadSlots();
#define MAX_DISK_FORMAT 8
#define DEFAULT_DISK_FORMAT 0
#define FIRST_CUSTOM_DISK_FORMAT 2
t_disk_format parseDiskFormat(const std::string& format);
std::string serializeDiskFormat(const t_disk_format& format);
| 2,272
|
C++
|
.h
| 50
| 43.42
| 104
| 0.754632
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,879
|
tape.h
|
ColinPitrat_caprice32/src/tape.h
|
/* Caprice32 - Amstrad CPC Emulator
(c) Copyright 1997-2004 Ulrich Doewich
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef TAPE_H
#define TAPE_H
#define TAPE_LEVEL_LOW 0
#define TAPE_LEVEL_HIGH 0x80
void Tape_UpdateLevel();
void Tape_Rewind();
#endif
| 915
|
C++
|
.h
| 21
| 40.52381
| 71
| 0.773393
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,880
|
z80.h
|
ColinPitrat_caprice32/src/z80.h
|
/* Caprice32 - Amstrad CPC Emulator
(c) Copyright 1997-2004 Ulrich Doewich
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef Z80_H
#define Z80_H
#include "SDL.h"
#include "types.h"
#include "crtc.h"
// A pair of register really only needs a word (16 bits).
// So in practice, b.h2, b.h3 and w.h should never be used (there's an
// exception in psg.cpp which uses the same structure for other purposes).
// However, using 32 bits allow to easily implement addition: we can just do the
// addition and handle the overflow after. It also allow for magic values
// outside of the 16 bits range (e.g. deactivating z80.break_point with an
// unreachable address).
typedef union {
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
struct { byte l, h, h2, h3; } b;
struct { word l, h; } w;
#else
struct { byte h3, h2, h, l; } b;
struct { word h, l; } w;
#endif
dword d;
} reg_pair;
#define Sflag 0x80 // sign flag
#define Zflag 0x40 // zero flag
#define Hflag 0x10 // halfcarry flag
#define Pflag 0x04 // parity flag
#define Vflag 0x04 // overflow flag
#define Nflag 0x02 // negative flag
#define Cflag 0x01 // carry flag
#define Xflags 0x28 // bit 5 & 3 flags
#define X1flag 0x20 // bit 5 - unused flag
#define X2flag 0x28 // bit 3 - unused flag
enum BreakpointType {
NORMAL = 0,
// Ephemeral breakpoint are removed next time the execution pauses.
EPHEMERAL = 1,
};
struct Breakpoint {
Breakpoint(word val, BreakpointType type = NORMAL) : address(val), type(type) {};
dword address;
BreakpointType type;
};
enum WatchpointType {
READ = 1,
WRITE = 2,
READWRITE = 3,
};
struct Watchpoint {
Watchpoint(word val, WatchpointType t) : address(val), type(t) {};
dword address;
WatchpointType type;
};
class t_z80regs {
public:
t_z80regs() {
AF.d = 0; BC.d = 0; DE.d = 0; HL.d = 0; PC.d = 0; SP.d = 0;
AFx.d = 0; BCx.d = 0; DEx.d = 0; HLx.d = 0; IX.d = 0; IY.d = 0;
I = 0; R = 0; Rb7 = 0; IFF1 = 0; IFF2 = 0; IM = 0; HALT = 0;
EI_issued = 0; int_pending = 0;
watchpoint_reached = 0; breakpoint_reached = 0;
step_in = 0; step_out = 0;
break_point = 0; trace = 0;
};
reg_pair AF, BC, DE, HL, PC, SP, AFx, BCx, DEx, HLx, IX, IY;
byte I, R, Rb7, IFF1, IFF2, IM, HALT, EI_issued, int_pending;
byte watchpoint_reached;
byte breakpoint_reached;
byte step_in;
byte step_out;
std::vector<word> step_out_addresses;
dword break_point, trace;
};
#define EC_BREAKPOINT 10
#define EC_TRACE 20
#define EC_FRAME_COMPLETE 30
#define EC_CYCLE_COUNT 40
#define EC_SOUND_BUFFER 50
byte z80_read_mem(word addr);
void z80_write_mem(word addr, byte val);
// TODO: put declaration or definition of these two methods somewhere else !!!
byte z80_IN_handler(reg_pair port); // not provided by Z80.c
void z80_OUT_handler(reg_pair port, byte val); // not provided by Z80.c
void z80_reset();
void z80_init_tables();
void z80_mf2stop();
int z80_execute();
// Handle main z80 instructions.
void z80_execute_instruction();
// Handle prefixed bits instructions.
void z80_execute_pfx_cb_instruction();
// Handle prefixed IX instructions.
void z80_execute_pfx_dd_instruction();
// Handle prefixed IX bit instructions.
void z80_execute_pfx_ddcb_instruction();
// Handle prefixed extended instructions.
void z80_execute_pfx_ed_instruction();
// Handle prefixed IY instructions.
void z80_execute_pfx_fd_instruction();
// Handle prefixed IY bit instructions.
void z80_execute_pfx_fdcb_instruction();
#endif
| 4,163
|
C++
|
.h
| 115
| 33.713043
| 83
| 0.710625
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,881
|
ipf.h
|
ColinPitrat_caprice32/src/ipf.h
|
#ifndef IPF_H
#define IPF_H
#ifdef WITH_IPF
#include "types.h"
#include "caps/capsimage.h"
#include "caps/fdc.h"
#include "caps/form.h"
#include "stdio.h"
#include "cap32.h"
#include "disk.h"
#include <string>
int ipf_load (FILE *, t_drive*);
int ipf_load (const std::string&, t_drive *);
#endif
#endif
| 308
|
C++
|
.h
| 15
| 19.2
| 45
| 0.722222
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,882
|
stringutils.h
|
ColinPitrat_caprice32/src/stringutils.h
|
#ifndef STRINGUTILS_H
#define STRINGUTILS_H
#include <vector>
#include <string>
namespace stringutils
{
std::vector<std::string> split(const std::string& s, char delim, bool ignore_empty=false);
std::string join(const std::vector<std::string>& v, const std::string& delim);
std::string trim(const std::string& s, char c);
std::string lower(const std::string& s);
std::string upper(const std::string& s);
std::string replace(std::string s, const std::string& search, const std::string& replace);
void splitPath(const std::string& path, std::string& dirname, std::string& filename);
bool caseInsensitiveCompare(const std::string& str1, const std::string& str2);
}
#endif
| 688
|
C++
|
.h
| 16
| 40.8125
| 92
| 0.738416
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,883
|
zip.h
|
ColinPitrat_caprice32/src/zip.h
|
#ifndef ZIP_H
#define ZIP_H
#include <string>
#include <vector>
#include "types.h"
namespace zip
{
typedef struct {
std::string filename;
std::string extensions;
std::vector<std::pair<std::string, dword>> filesOffsets;
unsigned int dwOffset;
} t_zip_info;
int dir (t_zip_info *zi);
int extract (const t_zip_info& zi, FILE **pfileOut);
}
#endif
| 372
|
C++
|
.h
| 17
| 19.235294
| 60
| 0.703704
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,884
|
savepng.h
|
ColinPitrat_caprice32/src/savepng.h
|
#ifndef _SDL_SAVEPNG
#define _SDL_SAVEPNG
/*
* SDL_SavePNG -- libpng-based SDL_Surface writer.
*
* This code is free software, available under zlib/libpng license.
* http://www.libpng.org/pub/png/src/libpng-LICENSE.txt
* Code was copied and slightly adapted from driedfruit savepng.
* See https://github.com/driedfruit/SDL_SavePNG
*/
#include <SDL_video.h>
#include <string>
/*
* Save an SDL_Surface as a PNG file.
*
* surface - the SDL_Surface structure containing the image to be saved
* file - the filename to save to
*
* Returns 0 success or -1 on failure, the error message is then retrievable
* via SDL_GetError().
*/
extern int SDL_SavePNG(SDL_Surface *surface, const std::string& file);
#endif
| 720
|
C++
|
.h
| 23
| 29.521739
| 76
| 0.745324
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,885
|
memutils.h
|
ColinPitrat_caprice32/src/memutils.h
|
#ifndef MEMUTILS_H
#define MEMUTILS_H
namespace memutils
{
template<typename cap32_cb>
class scope_exit {
cap32_cb cb;
bool upd {true};
public:
scope_exit(cap32_cb _cb) : cb(std::move(_cb)) {}
scope_exit(const scope_exit &) = delete;
scope_exit& operator=(const scope_exit &) = delete;
scope_exit(scope_exit &&d) : cb(d.cb), upd(d.upd)
{
d.upd = false;
}
~scope_exit()
{
if (upd)
cb();
}
};
}
#endif
| 475
|
C++
|
.h
| 24
| 15.666667
| 55
| 0.59375
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,886
|
crtc.h
|
ColinPitrat_caprice32/src/crtc.h
|
/* Caprice32 - Amstrad CPC Emulator
(c) Copyright 1997-2004 Ulrich Doewich
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef CRTC_H
#define CRTC_H
#include "types.h"
// The next 4 bytes must remain together
typedef union {
dword combined;
struct {
byte monVSYNC;
byte inHSYNC;
union {
word combined;
struct {
byte DISPTIMG;
byte HDSPTIMG;
};
} dt;
};
} t_flags1;
// The next two bytes must remain together
typedef union {
word combined;
struct {
byte NewDISPTIMG;
byte NewHDSPTIMG;
};
} t_new_dt;
void update_skew();
void CharMR1();
void CharMR2();
void prerender_border();
void prerender_border_half();
void prerender_sync();
void prerender_sync_half();
void prerender_normal();
void prerender_normal_half();
void prerender_normal_plus();
void prerender_normal_half_plus();
void crtc_cycle(int repeat_count);
void crtc_init();
void crtc_reset();
dword shiftLittleEndianDwordTriplet(dword val1, dword val2, dword val3, unsigned int byteShift);
void render8bpp();
void render8bpp_doubleY();
void render16bpp();
void render16bpp_doubleY();
void render24bpp();
void render24bpp_doubleY();
void render32bpp();
void render32bpp_doubleY();
#endif
| 1,910
|
C++
|
.h
| 64
| 26.5
| 96
| 0.735438
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,887
|
errors.h
|
ColinPitrat_caprice32/src/errors.h
|
#ifndef ERROR_H
#define ERROR_H
#define ERR_INPUT_INIT 1
#define ERR_VIDEO_INIT 2
#define ERR_VIDEO_SET_MODE 3
#define ERR_VIDEO_SURFACE 4
#define ERR_VIDEO_PALETTE 5
#define ERR_VIDEO_COLOUR_DEPTH 6
#define ERR_AUDIO_INIT 7
#define ERR_AUDIO_RATE 8
#define ERR_CPC_ROM_MISSING 10
#define ERR_NOT_A_CPC_ROM 11
#define ERR_ROM_NOT_FOUND 12
#define ERR_FILE_NOT_FOUND 13
#define ERR_FILE_BAD_ZIP 14
#define ERR_FILE_EMPTY_ZIP 15
#define ERR_FILE_UNZIP_FAILED 16
#define ERR_FILE_UNSUPPORTED 17
#define ERR_SNA_INVALID 18
#define ERR_SNA_SIZE 19
#define ERR_SNA_CPC_TYPE 20
#define ERR_SNA_WRITE 21
#define ERR_DSK_INVALID 22
#define ERR_DSK_SIDES 23
#define ERR_DSK_SECTORS 24
#define ERR_DSK_WRITE 25
#define MSG_DSK_ALTERED 26
#define ERR_TAP_INVALID 27
#define ERR_TAP_UNSUPPORTED 28
#define ERR_TAP_BAD_VOC 29
#define ERR_PRINTER 30
#define ERR_BAD_MF2_ROM 31
#define ERR_SDUMP 32
#define ERR_CPR_INVALID 33
#define ERR_IPF_DYNLIB_LOAD 34
#define ERR_JOYSTICKS_INIT 45
#endif
| 1,258
|
C++
|
.h
| 37
| 32.918919
| 35
| 0.617406
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,888
|
asic.h
|
ColinPitrat_caprice32/src/asic.h
|
/* Caprice32 - Amstrad CPC Emulator
The ASIC of the Plus range replaces multiple parts of the old CPC and
provides new additional features.
This file only concern the new features.
More details on what those features are is available here:
- http://www.cpcwiki.eu/index.php/Arnold_V_Specs_Revised
*/
#ifndef ASIC_H
#define ASIC_H
#include "types.h"
#include <stdint.h>
#define NB_DMA_CHANNELS 3
struct dma_channel {
unsigned int source_address;
unsigned int loop_address;
byte prescaler;
bool enabled;
bool interrupt;
int pause_ticks;
byte tick_cycles;
int loops;
};
struct dma_t {
dma_channel ch[NB_DMA_CHANNELS];
};
struct asic_t {
bool locked;
int lockSeqPos;
bool extend_border;
unsigned int hscroll;
unsigned int vscroll;
byte sprites[16][16][16];
int16_t sprites_x[16];
int16_t sprites_y[16];
short int sprites_mag_x[16];
short int sprites_mag_y[16];
bool raster_interrupt;
byte interrupt_vector;
dma_t dma;
};
extern asic_t asic;
extern byte *pbRegisterPage;
void asic_reset();
void asic_poke_lock_sequence(byte val);
void asic_dma_cycle();
bool asic_register_page_write(word addr, byte val);
void asic_draw_sprites();
#endif
| 1,206
|
C++
|
.h
| 48
| 22.604167
| 72
| 0.750218
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,889
|
z80_disassembly.h
|
ColinPitrat_caprice32/src/z80_disassembly.h
|
#ifndef Z80_DISASSEMBLY_H
#define Z80_DISASSEMBLY_H
#include "types.h"
#include <map>
#include <optional>
#include <set>
#include <string>
#include <vector>
class OpCode {
public:
OpCode() = default;
OpCode(int value, int length, int argsize, std::string instruction);
int value_;
int length_;
int argsize_;
std::string instruction_;
};
class DisassembledLine {
public:
DisassembledLine(word address, uint64_t opcode, std::string&& instruction, int64_t ref_address = -1);
int Size() const;
friend bool operator<(const DisassembledLine& l, const DisassembledLine& r);
friend bool operator==(const DisassembledLine& l, const DisassembledLine& r);
word address_;
uint64_t opcode_;
std::string instruction_;
word ref_address_ = 0;
std::string ref_address_string_;
};
std::ostream& operator<<(std::ostream& os, const DisassembledLine& line);
class DisassembledCode {
public:
DisassembledCode() = default;
std::optional<DisassembledLine> LineAt(word address) const;
uint64_t hash() const;
std::set<DisassembledLine> lines;
};
std::ostream& operator<<(std::ostream& os, const DisassembledCode& code);
std::map<int, OpCode> load_opcodes_table();
DisassembledLine disassemble_one(dword pos, DisassembledCode& result, std::vector<dword>& entry_points);
DisassembledCode disassemble(const std::vector<word>& entry_points);
#endif
| 1,416
|
C++
|
.h
| 42
| 30.404762
| 105
| 0.735099
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,890
|
log.h
|
ColinPitrat_caprice32/src/log.h
|
#ifndef LOG_H
#define LOG_H
#include <iostream>
extern bool log_verbose;
#define LOG_TO(stream,level,message) stream << (level) << " " << __FILE__ << ":" << __LINE__ << " - " << message << std::endl; // NOLINT(misc-macro-parentheses): Not having parentheses around message is a feature, it allows using streams in LOG macros
#define LOG_ERROR(message) LOG_TO(std::cerr, "ERROR ", message)
#define LOG_WARNING(message) LOG_TO(std::cerr, "WARNING", message)
#define LOG_INFO(message) LOG_TO(std::cerr, "INFO ", message)
#define LOG_VERBOSE(message) if(log_verbose) { LOG_TO(std::cout, "VERBOSE", message) }
#ifdef DEBUG
#define LOG_DEBUG(message) if(log_verbose) { LOG_TO(std::cout, "DEBUG ", message) }
#else
#define LOG_DEBUG(message)
#endif
#endif
| 759
|
C++
|
.h
| 15
| 49.2
| 251
| 0.700542
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,891
|
glfuncs.h
|
ColinPitrat_caprice32/src/glfuncs.h
|
/* Caprice32 - Amstrad CPC Emulator
(c) Copyright 1997-2004 Ulrich Doewich
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
// Makefile doesn't pass HAVE_GL directly to reduce the likelihood
// of using HAVE_GL without including this header.
// We need the header included for every use of HAVE_GL (at least) to be able to
// deactivate OpenGL on MacOS.
#ifdef WITH_GL
#define HAVE_GL
#endif
// It seems there's no OpenGL on MacOS anymore:
// https://github.com/ColinPitrat/caprice32/pull/201
#ifdef __APPLE__
#undef HAVE_GL
#endif
#ifdef HAVE_GL
#ifndef GLFUNCS_H
#define GLFUNCS_H
#include "SDL.h"
#include "SDL_opengl.h"
#ifdef __cplusplus
extern "C" {
#endif
#define GL_FUNC(ret,func,params) typedef ret (APIENTRY * ptr##func) params; // NOLINT(misc-macro-parentheses): Caller is expected to provide parenthesis otherwise this will cause a syntax error
#define GL_FUNC_OPTIONAL(ret,func,params) typedef ret (APIENTRY * ptr##func) params; // NOLINT(misc-macro-parentheses): Caller is expected to provide parenthesis otherwise this will cause a syntax error
#include "glfunclist.h"
#undef GL_FUNC
#undef GL_FUNC_OPTIONAL
#define GL_FUNC(ret,func,params) extern ptr##func e##func;
#define GL_FUNC_OPTIONAL(ret,func,params) extern ptr##func e##func;
#include "glfunclist.h"
#undef GL_FUNC
#undef GL_FUNC_OPTIONAL
extern int init_glfuncs();
#ifdef __cplusplus
}
#endif
#endif // GLFUNCS_H
#endif // HAVE_GL
| 2,069
|
C++
|
.h
| 50
| 39.36
| 202
| 0.771457
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,892
|
wg_message_client.h
|
ColinPitrat_caprice32/src/gui/includes/wg_message_client.h
|
// wg_message_client.h
//
// CMessageClient interface
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#ifndef _WG_MESSAGE_CLIENT_H_
#define _WG_MESSAGE_CLIENT_H_
#include "wg_message.h"
namespace wGui
{
class CApplication;
//! An Abstract class for handling wGui messages
//! \sa CMessage CMessageServer
class CMessageClient
{
public:
//! Standard constructor
explicit CMessageClient(CApplication& application);
//! Standard destructor
virtual ~CMessageClient();
//! This is the callback used by the Message Server to distribute messages
//! The client must first register with the server and indicate any messages it wishes to recieve
//! \sa CMessageServer::RegisterMessageClient()
virtual bool HandleMessage(CMessage* pMessage) = 0;
CApplication& Application() { return m_pApplication; };
const CApplication& Application() const { return m_pApplication; };
protected:
CApplication& m_pApplication;
};
}
#endif // _WG_MESSAGE_CLIENT_H_
| 1,735
|
C++
|
.h
| 48
| 34.395833
| 99
| 0.769277
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,893
|
wg_window.h
|
ColinPitrat_caprice32/src/gui/includes/wg_window.h
|
// wg_window.h
//
// CWindow interface
// this serves as the base of all window derived classes
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#ifndef _WG_WINDOW_H_
#define _WG_WINDOW_H_
#include "wg_rect.h"
#include "wg_color.h"
#include "wg_message_client.h"
#include <string>
#include <list>
#include <typeinfo>
#include "SDL.h"
namespace wGui
{
// forward declaration of the view class
class CView;
//! A base class with all the basic properties needed by a window
//! CWindow i inherits from the CMessageClient class so that any 'window' can recieve messages
//! CWindow provides the basic properties and methods needed to define a window
//! Almost all controls and views will be derived from this
class CWindow : public CMessageClient
{
public:
//! The constructor will automatically register the new window with the specified parent as a child (if a parent is given)
//! The parent is then responsible for destroying the window
//! \param WindowRect A CRect that defines the outer limits of the control
//! \param pParent A pointer to the parent window
CWindow(const CRect& WindowRect, CWindow* pParent);
//! The constructor is for creating a window without a parent.
//! In this case, an application must be provided.
//! \param pApplication A pointer to the CApplication
//! \param WindowRect A CRect that defines the outer limits of the control
CWindow(CApplication& application, const CRect& WindowRect);
// judb constructor without CRect; don't forget to call SetWindowRect before using the CWindow!
explicit CWindow(CWindow* pParent);
//! The CWindow destructor will automatically deregister itself with it's parent (if it had one)
~CWindow() override;
//! Return the classname for the object
//! \return The classname of the object
virtual std::string GetClassName() const { return typeid(*this).name(); }
//! Giving a control a new WindowRect will move and resize the control
//! \param WindowRect A CRect that defines the outer limits of the control
virtual void SetWindowRect(const CRect& WindowRect);
//! Gets the window's rectangle
//! This is represented in the window's parent's client coordinates
//! \return A copy of the CRect that the window represents
virtual CRect GetWindowRect() const { return m_WindowRect; }
//! Move the window and any child windows
//! \param MoveDistance The relative distance to move the window
virtual void MoveWindow(const CPoint& MoveDistance);
//! The ClientRect describes the internal area of the control
//! By default, this is initialized to the value of the WindowRect
//! The ClientRect is useful for windows that will contain other windows
//! Internally it's represented via the window's coordinates
//! \return The client area CRect
virtual CRect GetClientRect() const { return m_ClientRect; }
//! Set the window's background color
//! \param Color A CRGBColor that represents the background color
virtual void SetBackgroundColor(const CRGBColor& Color) { m_BackgroundColor = Color; }
//! Retrieve a window's background color
//! \return A CRGBColor object that represents the background color
virtual CRGBColor GetBackgroundColor() { return m_BackgroundColor; }
//! Describes the ancestor that is desired
enum EAncestor {
PARENT, //!< return the direct parent of the window
ROOT //!< climb the parent chain all the way until the root and return it
};
//! GetAncestor will return an ancestor of the window (using it's parent chain) based upon the requested ancestor
//! \param eAncestor The desired ancestor of the window
//! \return A pointer to the ancestor window, 0 is the window has no ancestors
virtual CWindow* GetAncestor(EAncestor eAncestor) const;
//! Gets the view the window is a part of
//! \return A pointer to the view object for the window (if one exists), this assumes that the view is the root ancestor
virtual CView* GetView() const;
//! Find out if the window is a child of another specified window
//! \param pWindow A pointer to the window that we're testing to see if this is a child of
//! \return true if the window is a child of the specified window, this will return false if the specified window is the same as the current window
virtual bool IsChildOf(CWindow* pWindow) const;
//! Get the visibility of the control
//! \return true if the control is visible
virtual bool IsVisible() { return m_bVisible; }
//! Set the visibility of the control, and all of it's children
//! \param bVisible Set to false to hide the control
virtual void SetVisible(bool bVisible);
//! Get whether the control has the focus
//! \return true if the control has the focus
virtual bool HasFocus() const { return m_bHasFocus; }
//! Set whether the control has the focus
//! \param bHasFocus Set to true to tell the control it has the focus
virtual void SetHasFocus(bool bHasFocus);
//! Get whether the control is focusable or not
//! \return true if the control can have the focus
virtual bool IsFocusable() { return m_bIsFocusable; }
//! Set whether the control has the focus
//! \param bHasFocus Set to true to tell the control it has the focus
virtual void SetIsFocusable(bool bIsFocusable);
//! Gets the SDL surface the window draws to
//! \return A pointer to the window's SDL surface
virtual SDL_Surface* GetSDLSurface() { return m_pSDLSurface; }
//! Translate the given CRect into view coordinates
//! \param Rect A CRect in client coordinates
virtual CRect ClientToView(const CRect& Rect) const;
//! Translate the given CPoint into view coordinates
//! \param Point A CPoint in client coordinates
virtual CPoint ClientToView(const CPoint& Point) const;
//! Translate the given CRect from view coordinates, to the window's client coordinates
//! \param Rect A CRect in view coordinates
virtual CRect ViewToClient(const CRect& Rect) const;
//! Translate the given CPoint from view coordinates, to the window's client coordinates
//! \param Point A CPoint in view coordinates
virtual CPoint ViewToClient(const CPoint& Point) const;
//! Translate the given CRect from view coordinates, to the window's coordinates
//! \param Rect A CRect in view coordinates
virtual CRect ViewToWindow(const CRect& Rect) const;
//! Translate the given CPoint from view coordinates, to the window's coordinates
//! \param Point A CPoint in view coordinates
virtual CPoint ViewToWindow(const CPoint& Point) const;
//! Set the WindowText of the control
//! \param sText The text to assign to the window
virtual void SetWindowText(const std::string& sText);
//! Return the WindowText for the current window
//! \return The WindowText
virtual std::string GetWindowText() const { return m_sWindowText; }
// judb return list of children
std::list<CWindow*> GetChildWindows() { return m_ChildWindows; }
//! Check to see if a point lies within the window or any of it's children
//! \param Point the point to check against in View coordinates
//! \return true if the point lies within the window rect, or any of it's children's window rects
virtual bool HitTest(const CPoint& Point) const;
//! Render the window itself
virtual void Draw() const;
//! Blit the window to the given surface, using m_WindowRect as the offset into the surface
//! \param ScreenSurface A reference to the surface that the window will be copied to
//! \param FloatingSurface A reference to the floating surface which is overlayed at the very end (used for tooltips, menus and such)
//! \param Offset This is the current offset into the Surface that should be used as reference
virtual void PaintToSurface(SDL_Surface& ScreenSurface, SDL_Surface& FloatingSurface, const CPoint& Offset) const;
//! Transfer the ownership of the window, so it has a new parent
//! \param pNewParent A pointer to a window that should be set as the parent
virtual void SetNewParent(CWindow* pNewParent);
//! This is called whenever the window is clicked on by the mouse
//! Only the topmost window that bounds the point will be called by the system
//! \param Point The point where the mouse clicked
//! \param Button A bitfield indicating which button the window was clicked with
//! \return False by default, if an overridden control uses the click, then it should return true if it's in the bounds of the window
virtual bool OnMouseButtonDown(CPoint Point, unsigned int Button);
//! This is called whenever the a mouse button is released in a window
//! Only the topmost window that bounds the point will be called by the system
//! \param Point The point where the mouse clicked
//! \param Button A bitfield indicating which button the window was clicked with
//! \return False by default, if an overridden control uses the click, then it should return true if it's in the bounds of the window
virtual bool OnMouseButtonUp(CPoint Point, unsigned int Button);
// CMessageClient overrides
//! Attempt to handle the given message
//! CWindows handle any APP_PAINT messages that have them marked as the destination
//! \return true if the object handled the message (the message will not be given to any other handlers)
bool HandleMessage(CMessage* pMessage) override;
virtual void AddFocusableWidget(CWindow *pWidget);
virtual void RemoveFocusableWidget(CWindow *pWidget);
protected:
// Registering and Deregistering child windows is automatically handled by the constructors and destructors
//! Register pWindow as a child
//! \param pWindow A pointer to the child window
virtual void RegisterChildWindow(CWindow* pWindow);
//! Deregister pWindow as a child
//! \param pWindow A pointer to the child window
virtual void DeregisterChildWindow(CWindow* pWindow);
//! The Window Text (not directly used by CWindow)
std::string m_sWindowText;
//! The area the control occupies, these coordinates are in respect to the parent's client rect
CRect m_WindowRect;
//! Background color of the window
CRGBColor m_BackgroundColor;
//! The client area of the window, represented in the window's coordinates where (0,0) is the top left corner of the window
CRect m_ClientRect;
//! Pointer to the parent window
CWindow* m_pParentWindow;
//! A list of child windows
std::list<CWindow*> m_ChildWindows;
//! A pointer to the SDL surface buffer that the window draws to
SDL_Surface* m_pSDLSurface;
//! If this is false, the control will not paint itself
bool m_bVisible;
//! If this window currently has the focus
bool m_bHasFocus;
//! If this window can have the focus
bool m_bIsFocusable;
private:
CWindow(const CWindow&) = delete;
CWindow& operator=(const CWindow&) = delete;
};
}
#endif // _WG_WINDOW_H_
| 11,400
|
C++
|
.h
| 211
| 51.853081
| 148
| 0.769985
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,894
|
wg_menu.h
|
ColinPitrat_caprice32/src/gui/includes/wg_menu.h
|
// wg_menu.h
//
// CMenu interface
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#ifndef _WG_MENU_H_
#define _WG_MENU_H_
#include "wg_window.h"
#include "wg_painter.h"
#include "wg_renderedstring.h"
#include "wg_resources.h"
#include "wg_timer.h"
#include <vector>
#include <string>
namespace wGui
{
class CPopupMenu;
//! The structure used to represent menu items
struct SMenuItem
{
public:
//! Constructs a new Menu Item
//! \param sItemText The text to display for the menu item
//! \param iItemId An identifier for the menu item, which gets returned in the CTRL_SINGLELCLICK message
//! \param pPopup A pointer to a popup menu, if the menu item is actually a submenu, this should be 0 if the item isn't a submenu (defaults to 0)
SMenuItem(std::string sItemText, long int iItemId = 0, CPopupMenu* pPopup = nullptr) :
sItemText(std::move(sItemText)), iItemId(iItemId), pPopup(pPopup), bSpacer(false) { }
//! Constructs a new Spacer Menu Item
SMenuItem() : iItemId(0), pPopup(nullptr), bSpacer(true) { }
std::string sItemText; //!< The caption to display for the menu item
long int iItemId; //!< An identifier for the menu item, which gets returned in the CTRL_SINGLELCLICK message
CPopupMenu* pPopup; //!< A pointer to a popup menu, if the menu item is actually a submenu
bool bSpacer; //!< Indicates if this is a spacer. If true, pPopup, iItemId and sItemText are ignored.
};
//! The menu base class
//! The CMenuBase is the base class for CMenus and CPopupMenus, and shouldn't be instantiated itself
//! Menus will generate CTRL_SINGLELCLICK messages when a menu item is selected
class CMenuBase : public CWindow
{
public:
//! Constructs a new MenuBase
//! \param WindowRect A CRect that defines the outer limits of the control
//! \param pParent A pointer to the parent window
//! \param pFontEngine A pointer to the font engine to use when drawing the control
//! If this is left out (or set to 0) it will use the default font engine specified by the CApplication (which must be set before instantiating this object)
CMenuBase(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine = nullptr);
//! Standard destructor
~CMenuBase() override;
//! Insert a menu item into the menu
//! \param MenuItem An SMenuItem struct that defines the menu item to add
//! \param iPosition The position to insert it at, -1 will insert it at the end, defaults to -1
virtual void InsertMenuItem(const SMenuItem& MenuItem, int iPosition = -1);
//! Removes a menu item or a submenu
//! \param iPosition The item to be removed
void RemoveMenuItem(int iPosition);
//! Gets the number of items in a menu
//! \return The number of items in the menu
unsigned int GetMenuItemCount() const { return m_MenuItems.size(); }
//! Hides the active popup window
void HideActivePopup();
//! Set the highlight color for the menu
//! \param HighlightColor The new color to use for highlighting
void SetHighlightColor(const CRGBColor& HighlightColor) { m_HighlightColor = HighlightColor; }
//! CWindow overrides
//! Draws the menu
void Draw() const override = 0;
//! This is called whenever the menu is clicked on by the mouse
//! Only the topmost window that bounds the point will be called by the system
//! \param Point The point where the mouse clicked
//! \param Button A bitfield indicating which button the window was clicked with
//! \return True if it's in the bounds of the menu
bool OnMouseButtonDown(CPoint Point, unsigned int Button) override;
// CMessageClient overrides
//! CMenus handle MOUSE_BUTTONDOWN and MOUSE_BUTTONUP messages
//! \param pMessage A pointer to the message
bool HandleMessage(CMessage* pMessage) override;
protected:
//! This updates the cached item rects if they are marked as invalid
virtual void UpdateCachedRects() const = 0;
//! Check to see where it will fit, then show the popup menu
//! \param ParentRect A CRect that defines the dimensions of the item that is spawning the popup
//! \param BoundingRect A CRect that defines the boundaries the popup has to fit in
virtual void ShowActivePopup(const CRect& ParentRect, const CRect& BoundingRect) = 0;
CFontEngine* m_pFontEngine; //!< A pointer to the font engine to use to render the text
//! A struct containing the menu item with some cached data
struct s_MenuItemInfo
{
//! struct constructor
//! \param MI the menu item
//! \param RS the rendered string for the menu item
//! \param R a CRect describing the boundaries of the menu item
s_MenuItemInfo(SMenuItem MI, CRenderedString RS, CRect R)
: MenuItem(std::move(MI)), RenderedString(std::move(RS)), Rect(std::move(R))
{ }
SMenuItem MenuItem; //!< The actual menu item
CRenderedString RenderedString; //!< A cached rendered string for the text of the menu item
CRect Rect; //!< The bounds rect for the menu item
};
using t_MenuItemVector = std::vector<s_MenuItemInfo>; //!< The type for menu items
mutable t_MenuItemVector m_MenuItems; //!< The vector of menu items
const SMenuItem* m_pHighlightedItem; //!< The item that should be highlighted
mutable bool m_bCachedRectsValid; //!< True if the cached item rects are valid
CPopupMenu* m_pActivePopup; //!< A pointer to the active popup
CwgBitmapResourceHandle m_hRightArrowBitmap; //!< A handle to the bitmap for the right arrow
CRGBColor m_HighlightColor; //!< Sets the highlight color to use, defaults to Dark Gray
CTimer* m_pPopupTimer; //!< A timer to be used for opening sub menus when the mouse hovers over an item
private:
CMenuBase(const CMenuBase&) = delete;
CMenuBase& operator=(const CMenuBase&) = delete;
};
//! A standard application level menu
class CMenu : public CMenuBase
{
public:
//! Constructs a new Menu
//! \param WindowRect A CRect that defines the outer limits of the control
//! \param pParent A pointer to the parent window
//! \param pFontEngine A pointer to the font engine to use when drawing the control
//! If this is left out (or set to 0) it will use the default font engine specified by the CApplication (which must be set before instantiating this object)
CMenu(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine = nullptr);
//! Standard destructor
~CMenu() override;
//! Insert a menu item into the menu
//! \param MenuItem An SMenuItem struct that defines the menu item to add
//! \param iPosition The position to insert it at, -1 will insert it at the end, defaults to -1
void InsertMenuItem(const SMenuItem& MenuItem, int iPosition = -1) override;
//! CWindow overrides
//! Draws the menu
void Draw() const override;
//! This is called whenever the menu is clicked on by the mouse
//! Only the topmost window that bounds the point will be called by the system
//! \param Point The point where the mouse clicked
//! \param Button A bitfield indicating which button the window was clicked with
//! \return True if it's in the bounds of the menu
bool OnMouseButtonDown(CPoint Point, unsigned int Button) override;
// CMessageClient overrides
//! CMenus handle MOUSE_BUTTONDOWN and MOUSE_BUTTONUP messages
//! \param pMessage A pointer to the message
bool HandleMessage(CMessage* pMessage) override;
protected:
//! This updates the cached item rects if they are marked as invalid
void UpdateCachedRects() const override;
//! Check to see where it will fit, then show the popup menu
//! \param ParentRect A CRect that defines the dimensions of the item that is spawning the popup
//! \param BoundingRect A CRect that defines the boundaries the popup has to fit in
void ShowActivePopup(const CRect& ParentRect, const CRect& BoundingRect) override;
private:
CMenu(const CMenu&) = delete;
CMenu& operator=(const CMenu&) = delete;
};
//! Popup menus are used for both context menus, and as the popups when a CMenu item is clicked that has a submenu
class CPopupMenu : public CMenuBase
{
public:
//! Constructs a new Popup Menu
//! \param WindowRect A CRect that defines the outer limits of the control
//! \param pParent A pointer to the parent window
//! \param pFontEngine A pointer to the font engine to use when drawing the control
//! If this is left out (or set to 0) it will use the default font engine specified by the CApplication (which must be set before instantiating this object)
CPopupMenu(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine = nullptr);
//! Standard destructor
~CPopupMenu() override;
//! Show the popup at the given point
//! \param Position The point to use for the top left corner of the popup, in view coordinates
void Show(CPoint Position);
//! Hide the popup and any popups hanging off of it
void Hide();
//! Hide the popup, along with it's popup parents and children
//! This method just searches for the root popup, and then calls Hide() on it
void HideAll();
//! Tests to see if any children are hit by the point
bool IsInsideChild(const CPoint& Point) const;
//! Indicates if the popup menu has any popup parents
//! \return true is the Popup menu doesn't have any popup parents
bool IsRootPopup() { return !(dynamic_cast<CPopupMenu*>(m_pParentWindow)); }
//! This is only for root popup menus that are dropped by a CMenu
//! This doesn't set the actual parent of the control since the root window (probably a CView) should be the real parent
//! This is called automatically when a popup menu is inserted into a CMenu (via InsertMenuItem)
//! \param pParentMenu A pointer to the CMenu object that acts as the Popup's parent
void SetParentMenu(CMenu* pParentMenu) { m_pParentMenu = pParentMenu; }
//! CWindow overrides
//! Draws the menu
void Draw() const override;
//! Blit the window to the given surface, using m_WindowRect as the offset into the surface
//! \param ScreenSurface A reference to the surface that the window will be copied to
//! \param FloatingSurface A reference to the floating surface which is overlayed at the very end (used for tooltips, menus and such)
//! \param Offset This is the current offset into the Surface that should be used as reference
void PaintToSurface(SDL_Surface& ScreenSurface, SDL_Surface& FloatingSurface, const CPoint& Offset) const override;
//! This is called whenever the popup is clicked on by the mouse
//! Only the topmost window that bounds the point will be called by the system
//! \param Point The point where the mouse clicked
//! \param Button A bitfield indicating which button the window was clicked with
//! \return True if it's in the bounds of the popup
bool OnMouseButtonDown(CPoint Point, unsigned int Button) override;
// CMessageClient overrides
//! CMenus handle MOUSE_BUTTONDOWN and MOUSE_BUTTONUP messages
//! \param pMessage A pointer to the message
bool HandleMessage(CMessage* pMessage) override;
protected:
//! This updates the cached item rects if they are marked as invalid
void UpdateCachedRects() const override;
//! Check to see where it will fit, then show the popup menu
//! \param ParentRect A CRect that defines the dimensions of the item that is spawning the popup
//! \param BoundingRect A CRect that defines the boundaries the popup has to fit in, this is in view coordinates
void ShowActivePopup(const CRect& ParentRect, const CRect& BoundingRect) override;
//! This is a pointer to the CMenu that acts as parent for the popup,
//! though it's not actually the parent, because the parent for root popups should be the CView
CMenu* m_pParentMenu;
private:
CPopupMenu(const CPopupMenu&) = delete;
CPopupMenu& operator=(const CPopupMenu&) = delete;
};
}
#endif // _WG_MENU_H_
| 12,389
|
C++
|
.h
| 231
| 51.484848
| 157
| 0.761298
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,895
|
CapriceLoadSave.h
|
ColinPitrat_caprice32/src/gui/includes/CapriceLoadSave.h
|
// 'Load/save' box for Caprice32
#ifndef _WG_CAPRICE32LOADSAVE_H_
#define _WG_CAPRICE32LOADSAVE_H_
#include "wg_button.h"
#include "wg_dropdown.h"
#include "wg_editbox.h"
#include "wg_label.h"
#include "wg_listbox.h"
#include "wg_frame.h"
#include "wg_navigationbar.h"
#include <string>
class CapriceLoadSaveTest;
namespace wGui
{
class CapriceLoadSave : public CFrame {
public:
//! \param pParent A pointer to the parent view
//! \param pFontEngine A pointer to the font engine to use when drawing the control
//! If this is set to 0 it will use the default font engine specified by the CApplication (which must be set before instantiating this object)
CapriceLoadSave(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine);
~CapriceLoadSave() override;
bool HandleMessage(CMessage* pMessage) override;
std::string simplifyDirPath(std::string path);
void UpdateFilesList();
bool MatchCurrentFileSpec(const char* filename);
protected:
friend CapriceLoadSaveTest;
std::list<std::string> m_fileSpec;
CLabel *m_pTypeLabel;
CDropDown *m_pTypeValue;
CLabel *m_pActionLabel;
CDropDown *m_pActionValue;
CLabel *m_pDirectoryLabel;
CEditBox *m_pDirectoryValue;
CListBox *m_pFilesList;
CLabel *m_pFileNameLabel;
CEditBox *m_pFileNameValue;
CButton *m_pCancelButton;
CButton *m_pLoadSaveButton;
private:
CapriceLoadSave(const CapriceLoadSave&) = delete;
CapriceLoadSave& operator=(const CapriceLoadSave&) = delete;
};
}
#endif // _WG_CAPRICE32LOADSAVE_H_
| 1,695
|
C++
|
.h
| 45
| 31.644444
| 150
| 0.694275
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,896
|
CapriceGuiView.h
|
ColinPitrat_caprice32/src/gui/includes/CapriceGuiView.h
|
#ifndef CAPRICEGUIVIEW_H
#define CAPRICEGUIVIEW_H
#include "wg_view.h"
#include "wg_frame.h"
class CapriceGuiView : public wGui::CView
{
protected:
wGui::CFrame *m_menuFrame;
public:
CapriceGuiView(wGui::CApplication& application, SDL_Surface* surface, SDL_Surface* backSurface, const wGui::CRect& WindowRect);
void PaintToSurface(SDL_Surface& ScreenSurface, SDL_Surface& FloatingSurface, const wGui::CPoint& Offset) const override;
};
#endif
| 464
|
C++
|
.h
| 13
| 33.076923
| 131
| 0.780269
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,897
|
wg_view.h
|
ColinPitrat_caprice32/src/gui/includes/wg_view.h
|
// wg_view.h
//
// CView interface
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#ifndef _WG_VIEW_H_
#define _WG_VIEW_H_
#include "wg_window.h"
#include "SDL.h"
#include "wg_menu.h"
#include <string>
namespace wGui
{
//! The directions in which focus can be toggled: forward or backward
enum class EFocusDirection {
FORWARD,
BACKWARD
};
//! A general view class
//! A CView creates itself as a root window (it has no parent)
//! and responds to APP_PAINT messages with itself or 0 as the destination, and will redraw all of it's children as well as itself
//! Because of a limitation in SDL, there can be only one View
class CView : public CWindow
{
public:
// judb; surface is an existing SDL surface, WindowRect is the area in which we want to draw the gui:
CView(CApplication& application, SDL_Surface* surface, SDL_Surface* backSurface, const CRect& WindowRect);
//! Standard Destructor
~CView() override;
//! Attaches a standard menu to the view, if the view already has a menu, the old menu will be deleted
//! \param pMenu A pointer to the menu, the CView is then responsible for cleaning it up, passing in 0 will delete the current menu
void AttachMenu(CMenu* pMenu);
//! Gets the menu for the view
//! \return A pointer to the view's menu, 0 if the view doesn't have a menu
CMenu* GetMenu() const { return m_pMenu; }
//! Sets the current floating window, which will be drawn on top of all other controls
//! \param pWindow A pointer to the window to set as the floating window
void SetFloatingWindow(CWindow* pWindow) { m_pFloatingWindow = pWindow; }
//! Gets teh current floating window
//! \return a pointer to the current floating window
CWindow* GetFloatingWindow() const { return m_pFloatingWindow; }
// judb ; sometimes the surface is re-created in caprice32; in this case, we have
// to pass it on here
void SetSurface(SDL_Surface* surface) { m_pScreenSurface = surface; }
SDL_Surface* GetSurface() { return m_pScreenSurface; }
// CWindow Overrides
//! Set the WindowText of the view, which is used as the window caption
//! \param sText The text to assign to the view
void SetWindowText(const std::string& sText) override;
// CMessageClient overrides
//! Handles APP_PAINT messages with itself or 0 as the destination, and will redraw all of it's children as well as itself
bool HandleMessage(CMessage* pMessage) override;
//! Display the view on the screen surface
virtual void Flip() const;
//! Callback to close this view when the application exit
virtual void Close() {};
protected:
CMenu* m_pMenu; //!< A pointer to the view's menu
CWindow* m_pFloatingWindow; //!< A pointer to the current floating window. This will be drawn overtop of everything else.
SDL_Window* m_pWindow; //!< A pointer to the window
SDL_Surface* m_pScreenSurface; //!< A pointer to the actual screen surface
SDL_Surface* m_pBackSurface; // Caprice32-specific; contains the current Caprice32 output surface
// so we can draw the gui on top of it.
private:
CView(const CView&) = delete;
CView& operator=(const CView&) = delete;
};
}
#endif // _WG_VIEW_H_
| 3,924
|
C++
|
.h
| 86
| 43.383721
| 132
| 0.745407
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,898
|
CapriceRomSlots.h
|
ColinPitrat_caprice32/src/gui/includes/CapriceRomSlots.h
|
// Caprice32 ROM slot selection window
// Inherited from CFrame
#ifndef _WG_CAPRICE32ROMSLOTS_H_
#define _WG_CAPRICE32ROMSLOTS_H_
#include "wg_button.h"
#include "wg_frame.h"
#include "wg_label.h"
#include "wg_listbox.h"
#include <string>
namespace wGui
{
class CapriceRomSlots : public CFrame {
public:
//! \param pParent A pointer to the parent view
//! \param pFontEngine A pointer to the font engine to use when drawing the control
//! If this is set to 0 it will use the default font engine specified by the CApplication (which must be set before instantiating this object)
// selectedRomButton is the button that was clicked to open this dialog (not the nicest solution, but it works...)
CapriceRomSlots(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine, std::string sTitle, int selectedRomSlot, CButton* pSelectedRomButton);
bool HandleMessage(CMessage* pMessage) override;
// Returns a list with the available ROM files (filenames)
std::vector<std::string> getAvailableRoms();
int getRomSlot() const { return romSlot; };
void setRomSlot(int newRomSlot) { romSlot = newRomSlot; } ;
protected:
int romSlot; // selected ROM slot number
CButton* m_pSelectedRomButton; // the button that was clicked to open this dialog
CButton* m_pButtonInsert; // Inserts the selected ROM in the ROM slot.
CButton* m_pButtonClear; // Clears the selected ROM slot.
CButton* m_pButtonCancel; // Close the dialog without action.
CListBox* m_pListBoxRoms; // Lists the available ROM files (in the ROMS subdirectory)
private:
CapriceRomSlots(const CapriceRomSlots&) = delete;
CapriceRomSlots& operator=(const CapriceRomSlots&) = delete;
};
}
#endif // _WG_CAPRICE32ROMSLOTS_H_
| 1,868
|
C++
|
.h
| 36
| 45.805556
| 163
| 0.71083
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,899
|
wg_checkbox.h
|
ColinPitrat_caprice32/src/gui/includes/wg_checkbox.h
|
//
// CCheckBox interface
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#ifndef _WG_CHECKBOX_H_
#define _WG_CHECKBOX_H_
#include "wg_window.h"
#include "wg_painter.h"
#include "wg_resources.h"
namespace wGui
{
//! A checkbox control
//! The checkbox will generate CTRL_xCLICK messages when clicked with the mouse (where x is the button L,M,R)
//! It will also generate a CTRL_VALUECHANGE message whenever the checkbox is toggled
//! Checkboxes do not display their own labels
class CCheckBox : public CWindow
{
public:
//! Constructs a new checkbox
//! \param WindowRect A CRect that defines the outer limits of the control
//! \param pParent A pointer to the parent window
CCheckBox(const CRect& WindowRect, CWindow* pParent);
//! Standard destructor
~CCheckBox() override;
//! Set the Read-only state of the control
//! \param bReadOnly If set to true, the control will not take any input
void SetReadOnly(bool bReadOnly);
//! Indicates if the check box is operating in read-only mode
//! \return true if the control is read-only
bool IsReadOnly() const { return m_bReadOnly; }
//! The checkbox state
enum EState {
UNCHECKED, //!< The checkbox is unchecked
CHECKED, //!< The checkbox is checked
DISABLED //!< The checkbox is disabled
};
//! Gets the current state of the checkbox
//! \return The current checkbox state
EState GetCheckBoxState() const { return m_eCheckBoxState; }
//! Set the checkbox state
//! \param eState The checkbox state
void SetCheckBoxState(EState eState);
//! Toggle the checkbox state
void ToggleCheckBoxState();
// CWindow overrides
//! Draws the checkbox
void Draw() const override;
//! This is called whenever the checkbox is clicked on by the mouse
//! Only the topmost window that bounds the point will be called by the system
//! \param Point The point where the mouse clicked
//! \param Button A bitfield indicating which button the window was clicked with
//! \return True if it's in the bounds of the checkbox
bool OnMouseButtonDown(CPoint Point, unsigned int Button) override;
//! This is called whenever the a mouse button is released in the checkbox
//! Only the topmost window that bounds the point will be called by the system
//! \param Point The point where the mouse clicked
//! \param Button A bitfield indicating which button the window was clicked with
//! \return True if it's in the bounds of the checkbox
bool OnMouseButtonUp(CPoint Point, unsigned int Button) override;
// CMessageClient overrides
//! CCheckBoxes handle MOUSE_BUTTONDOWN, MOUSE_BUTTONUP, and it's own CTRL_SINGLELCLICK messages
//! \param pMessage A pointer to the message
bool HandleMessage(CMessage* pMessage) override;
protected:
EState m_eCheckBoxState; //!< The checkbox's state
bool m_bReadOnly; //!< If true, the value of the control cannot be changed by the user
unsigned int m_MouseButton; //!< The last mouse button to be pushed over the control, it's used internally
CBitmapResourceHandle m_hBitmapCheck; // CheckMark defined as a bitmap resource.
private:
CCheckBox(const CCheckBox&) = delete;
CCheckBox& operator=(const CCheckBox&) = delete;
};
}
#endif // _WG_CHECKBOX_H_
| 3,963
|
C++
|
.h
| 91
| 41.604396
| 109
| 0.761508
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,900
|
wg_button.h
|
ColinPitrat_caprice32/src/gui/includes/wg_button.h
|
// wg_button.h
//
// CButton interface
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#ifndef _WG_BUTTON_H_
#define _WG_BUTTON_H_
#include "wg_window.h"
#include "wg_painter.h"
#include "wg_renderedstring.h"
#include "wg_picture.h"
#include <memory>
#include <string>
namespace wGui
{
//! A simple pushbutton class
//! The button will generate CTRL_xCLICK messages when clicked with the mouse (where x is the button L,M,R)
class CButton : public CWindow
{
public:
//! Constructs a new button
//! \param WindowRect A CRect that defines the outer limits of the control
//! \param pParent A pointer to the parent window
//! \param sText The text on the button
//! \param pFontEngine A pointer to the font engine to use when drawing the control
//! If this is left out (or set to 0) it will use the default font engine specified by the CApplication (which must be set before instantiating this object)
CButton(const CRect& WindowRect, CWindow* pParent, std::string sText, CFontEngine* pFontEngine = nullptr);
//! Standard destructor
~CButton() override;
//! The button state
enum EState {
UP, //!< The button is up
DOWN, //!< The button is down
DISABLED //!< The button is disabled
};
//! Gets the current state of the button
//! \return The current button state
EState GetButtonState() const { return m_eButtonState; }
//! Set the button state
//! \param eState The button state
void SetButtonState(EState eState);
// CWindow overrides
//! Draws the button and renders the button label
void Draw() const override;
//! Set the WindowText of the button
//! \param sWindowText The text to assign to the window
void SetWindowText(const std::string& sWindowText) override;
//! This is called whenever the button is clicked on by the mouse
//! Only the topmost window that bounds the point will be called by the system
//! \param Point The point where the mouse clicked
//! \param Button A bitfield indicating which button the window was clicked with
//! \return True if it's in the bounds of the button
bool OnMouseButtonDown(CPoint Point, unsigned int Button) override;
//! This is called whenever the a mouse button is released in the button
//! Only the topmost window that bounds the point will be called by the system
//! \param Point The point where the mouse clicked
//! \param Button A bitfield indicating which button the window was clicked with
//! \return True if it's in the bounds of the button
bool OnMouseButtonUp(CPoint Point, unsigned int Button) override;
// CMessageClient overrides
//! CButtons handle MOUSE_BUTTONDOWN and MOUSE_BUTTONUP messages
//! \param pMessage A pointer to the message
bool HandleMessage(CMessage* pMessage) override;
protected:
CFontEngine* m_pFontEngine; //!< A pointer to the font engine to use to render the text
std::unique_ptr<CRenderedString> m_pRenderedString; //!< An autopointer to the rendered version of the string
EState m_eButtonState; //!< The button's state
unsigned int m_MouseButton; //!< The last mouse button to be pushed over the control, it's used internally
private:
CButton(const CButton&) = delete;
CButton& operator=(const CButton&) = delete;
};
//! Picture Buttons are pushbuttons that display a bitmap in place of a text label
class CPictureButton : public CButton
{
public:
//! Constructs a new picture button
//! \param WindowRect A CRect that defines the outer limits of the control
//! \param pParent A pointer to the parent window
//! \param sPictureFile The file to use as the button's picture
CPictureButton(const CRect& WindowRect, CWindow* pParent, std::string sPictureFile);
//! Constructs a new picture button
//! \param WindowRect A CRect that defines the outer limits of the control
//! \param pParent A pointer to the parent window
//! \param hBitmap A handle for the bitmap resource
CPictureButton(const CRect& WindowRect, CWindow* pParent, const CBitmapResourceHandle& hBitmap);
//! Standard destructor
~CPictureButton() override;
//! Change the picture the button displays
//! \param sPictureFile The file to use as the button's picture
void SetPicture(std::string sPictureFile);
//! Change the picture the button displays
//! \param hBitmap A handle for the bitmap resource
void SetPicture(const CBitmapResourceHandle& hBitmap);
// CWindow overrides
//! Draws the button and renders the button label
void Draw() const override;
private:
std::unique_ptr<CBitmapResourceHandle> m_phBitmap; //!< An auto pointer to a handle for the bitmap resource
CPictureButton(const CPictureButton&) = delete;
CPictureButton& operator=(const CPictureButton&) = delete;
};
}
#endif // _WG_BUTTON_H_
| 5,454
|
C++
|
.h
| 121
| 43.07438
| 157
| 0.762984
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,901
|
CapriceVKeyboard.h
|
ColinPitrat_caprice32/src/gui/includes/CapriceVKeyboard.h
|
#ifndef _WG_CAPRICEVKEYBOARD_H_
#define _WG_CAPRICEVKEYBOARD_H_
#include "wg_button.h"
#include "wg_editbox.h"
#include "wg_frame.h"
#include <string>
namespace wGui
{
class CapriceVKeyboard : public CFrame
{
public:
CapriceVKeyboard(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine);
~CapriceVKeyboard() override;
void CloseFrame() override;
bool HandleMessage(CMessage* pMessage) override;
std::list<SDL_Event> GetEvents();
static std::list<SDL_Event> StringToEvents(std::string toTranslate);
protected:
void moveFocus(int dx, int dy);
CEditBox* m_result;
std::vector<std::vector<CButton*>> m_buttons;
std::pair<int, int> m_focused;
private:
CapriceVKeyboard(const CapriceVKeyboard&) = delete;
CapriceVKeyboard& operator=(const CapriceVKeyboard&) = delete;
};
}
#endif
| 887
|
C++
|
.h
| 28
| 27.214286
| 92
| 0.713615
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,902
|
wg_rect.h
|
ColinPitrat_caprice32/src/gui/includes/wg_rect.h
|
// wg_rect.h
//
// CRect class interface
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#ifndef _WG_RECT_H_
#define _WG_RECT_H_
#include "wg_point.h"
#include "std_ex.h"
#include "SDL.h"
#include <stdlib.h>
#include <math.h>
#include <string>
namespace wGui
{
//! A representation of a rectangle
class CRect
{
public:
//! The default constructor will initialize all 4 corners to (0, 0)
CRect() : m_Left(0), m_Right(0), m_Top(0), m_Bottom(0) { }
//! \param left The left edge of the rectangle
//! \param top The top edge of the rectangle
//! \param right The right edge of the rectangle
//! \param bottom The bottom edge of the rectangle
CRect(const int left, const int top, const int right, const int bottom) :
m_Left(left), m_Right(right), m_Top(top), m_Bottom(bottom) { } // constructor
//! Create a CRect using a pair of CPoints that represent the Top-Left, and Bottom-Right corners
//! \param p1 Top left corner
//! \param p2 Bottom right corner
CRect(const CPoint& p1, const CPoint& p2) :
m_Left(p1.XPos()), m_Right(p2.XPos()), m_Top(p1.YPos()), m_Bottom(p2.YPos()) { } // constructor
// judb create a CRect using a point (upper-left corner) , width and height.
CRect(const CPoint& p, const int width, const int height) :
m_Left(p.XPos()), m_Right(p.XPos() + width -1), m_Top(p.YPos()), m_Bottom(p.YPos() + height - 1) { }
//! Copy constructor
//! \param r A CRect that thie new CRect will be copied from
CRect(const CRect& r) = default;
//! Move constructor
//! \param r A CRect that thie new CRect will be moved from
CRect(CRect&& r) = default;
//! Standard Destructor
virtual ~CRect() = default;
//! Set the Top poisition
//! \param top The new Top coordinate
void SetTop(const int top) { m_Top = top; }
//! Set the Left poisition
//! \param left The new Left coordinate
void SetLeft(const int left) { m_Left = left; }
//! Set the Right poisition
//! \param right The new Right coordinate
void SetRight(const int right) { m_Right = right; }
//! Set the Bottom poisition
//! \param bottom The new Bottom coordinate
void SetBottom(const int bottom) { m_Bottom = bottom; }
//! Gets the top of the rectangle
//! \return The Top position
int Top() const { return m_Top; }
//! Gets the left of the rectangle
//! \return The Left position
int Left() const { return m_Left; }
//! Gets the right of the rectangle
//! \return The Right position
int Right() const { return m_Right; }
//! Gets the bottom of the rectangle
//! \return The Bottom position
int Bottom() const { return m_Bottom; }
//! Gets the top-left corner of the rectangle
//! \return A point representing the Top Left corner of the CRect
CPoint TopLeft() const { return CPoint(m_Left, m_Top); }
//! Gets the top-right corner of the rectangle
//! \return A point representing the Top Right corner of the CRect
CPoint TopRight() const { return CPoint(m_Right, m_Top); }
//! Gets the bottom left corner of the rectangle
//! \return A point representing the Bottom Left corner of the CRect
CPoint BottomLeft() const { return CPoint(m_Left, m_Bottom); }
//! Gets the bottom-right corner of the rectangle
//! \return A point representing the Bottom Right corner of the CRect
CPoint BottomRight() const { return CPoint(m_Right, m_Bottom); }
//! Gets the center of the rectangle
//! \return A point representing the center of the CRect
CPoint Center() const { return CPoint((m_Left + m_Right) / 2, (m_Top + m_Bottom) / 2); }
//! Gets the left side's center of the rectangle
//! \return A point representing the CenterLeft point of the CRect
CPoint CenterLeft() const { return CPoint( m_Left, (m_Top + m_Bottom) / 2); }
//! Get the top's center of the rectangle
//! \return A point representing the CenterTop point of the CRect
CPoint CenterTop() const { return CPoint( (m_Left + m_Right) / 2, m_Top ); }
//! Gets the bottom's center of the rectangle
//! \return A point representing the Bottom Left corner of the CRect
CPoint CenterBottom() const { return CPoint( (m_Left + m_Right) / 2, m_Bottom ); }
//! Gets the right side's center of the rectangle
//! \return A point representing the Bottom Right corner of the CRect
CPoint CenterRight() const { return CPoint( m_Right, (m_Top + m_Bottom) / 2); }
//! Converts the CRect into a SDL style rect
//! \return An SDL_Rect of the same size
SDL_Rect SDLRect() const;
//! Gets the width of the rectangle
//! \return The width (along the X axis) of the CRect
int Width() const { return abs(m_Right - m_Left + 1); }
//! Gets the height of the rectangle
//! \return The height (along the Y axis) of the CRect
int Height() const { return abs(m_Bottom - m_Top + 1); }
//! Creates a CRect that has the same width and height of the rect, but has 0, 0 as it's top left coordinate
//! \return A CRect
CRect SizeRect() const { return CRect(0, 0, abs(m_Right - m_Left), abs(m_Bottom - m_Top)); }
//! Assignment operator will copy the values of the other rect
CRect& operator=(const CRect& r); // assignment operator
//! Move assignment operator will copy the values of the other rect
CRect& operator=(CRect&& r) noexcept; // move assignment operator
//! Addition operator to add a CPoint, will offset the CRect
//! \param p A point to offset the CRect by
CRect operator+(const CPoint& p) const;
//! Addition operator to add a CPoint, will offset the CRect
//! \param p A point to offset the CRect by
CRect& operator+=(const CPoint& p);
//! Subtraction operator to subtract a CPoint, will offset the CRect
//! \param p A point to offset the CRect by
CRect operator-(const CPoint& p) const;
//! Subtraction operator to subtract a CPoint, will offset the CRect
//! \param p A point to offset the CRect by
CRect& operator-=(const CPoint& p);
//! Equality operator
//! \param r The rect to compare to
bool operator==(const CRect& r) const
{ return (m_Left == r.m_Left && m_Top == r.m_Top && m_Right == r.m_Right && m_Bottom == r.m_Bottom); }
//! Inequality operator
//! \param r The rect to compare to
bool operator!=(const CRect& r) const
{ return (m_Left != r.m_Left || m_Top != r.m_Top || m_Right != r.m_Right || m_Bottom != r.m_Bottom); }
//! Grow will increase (or decrease) all of the dimensions by the given amount.
//! This means that for a rect 20 wide by 10 tall, Grow(1) will increase the size to 22 wide, 12 tall.
//! (each side is moved out by 1)
//! \param iGrowAmount The amount to grow the CRect's dimensions by, negative values can be used to shrink the rect
//! \return A reference to the object
CRect& Grow(int iGrowAmount);
//! Move will move the rect by a offset specified
//! \param iOffsetX how many pixel to move on X axis ( + or - )
//! \param iOffsetY how many pixel to move on Y axis ( + or - )
//! \return A reference to the object
CRect& Move(int iOffsetX, int iOffsetY);
//! Tests to see if the two CRects overlap
//! \param r The other CRect to test with
//! \return true if the CRects overlap
bool Overlaps(const CRect& r) const;
//! Clips the CRect to fit in another CRect
//! \param r The CRect to clip to
CRect& ClipTo(const CRect& r);
enum ERelativePosition
{
RELPOS_INVALID = 0, //!< This usually indicates some form of error
RELPOS_ABOVE = 1, //!< The point is above the top of the CRect
RELPOS_BELOW = 2, //!< The point is below the bottom of the CRect
RELPOS_LEFT = 4, //!< The point is to the left of the CRect
RELPOS_RIGHT = 8, //!< The point is to the right of the CRect
RELPOS_INSIDE = 16 //!< The point lies within the bounds of the CRect
};
//! The HitTest will test to see where a point is in relation to the rect
//! \param p The point to test against the CRect
//! \return The appropriate values of the ERelativePosition enum are ORed together
unsigned int HitTest(const CPoint& p) const;
//! Returns the coordinates of the rectangle as a string
//! \return A std::string with the coordinates listed as "<left>,<top>,<right>,<bottom>", i.e. "1,2,3,4"
std::string ToString() const
{ return stdex::itoa(m_Left) + "," + stdex::itoa(m_Top) + "," + stdex::itoa(m_Right) + "," + stdex::itoa(m_Bottom); }
protected:
//! X position of the left border
int m_Left;
//! X position of the right border
int m_Right;
//! Y position of the top border
int m_Top;
//! Y position of the bottom border
int m_Bottom;
};
}
std::ostream& operator<<(std::ostream& os, const wGui::CRect r);
#endif // _WG_RECT_H_
| 9,218
|
C++
|
.h
| 195
| 45.107692
| 119
| 0.705521
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,903
|
wg_dropdown.h
|
ColinPitrat_caprice32/src/gui/includes/wg_dropdown.h
|
// wg_dropdown.h
//
// CDropDown interface
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#ifndef _WG_DROPDOWN_H_
#define _WG_DROPDOWN_H_
#include "wg_window.h"
#include "wg_painter.h"
#include "wg_editbox.h"
#include "wg_listbox.h"
#include <memory>
#include <string>
namespace wGui
{
//! A dropdown control, which combines an edit control and a listbox control
//! The CDropDown will generate CTRL_VALUECHANGE messages every time the text changes
class CDropDown : public CWindow
{
public:
//! Construct a new DropDown control
//! \param WindowRect A CRect that defines the outer limits of the control (this only controls the dimensions of the edit control portion of the drop down)
//! \param pParent A pointer to the parent window
//! \param bAllowEdit If false, the edit box will be read only, and the value can only be changed via the drop-down list (true by default)
//! \param iItemHeight The height of the items in the listbox portion of the control, defaults to 15
//! \param pFontEngine A pointer to the font engine to use when drawing the control
//! If this is left out (or set to 0) it will use the default font engine specified by the CApplication (which must be set before instantiating this object)
CDropDown(const CRect& WindowRect, CWindow* pParent, bool bAllowEdit = true, unsigned int iItemHeight = 15, CFontEngine* pFontEngine = nullptr);
//! Standard destructor
~CDropDown() override;
//! Adds a new item to the list
//! \param ListItem A SListItem structure with the data for the item
//! \return The index of the added item
int AddItem(SListItem ListItem) { return m_pListBox->AddItem(ListItem); }
//! Returns the desired item
//! \param iItemIndex The index of the item to check (will throw an exception if the index is out of range)
//! \return A reference to the SListItem struct
SListItem& GetItem(int iItemIndex) { return m_pListBox->GetItem(iItemIndex); }
//! Remove an item from the list
//! \param iItemIndex The index of the item to remove
void RemoveItem(int iItemIndex) { m_pListBox->RemoveItem(iItemIndex); }
//! Remove all items from the list
void ClearItems() { m_pListBox->ClearItems(); }
//! Gets the current number of items in the listbox
//! \return The number of items in the list
int Size() { return m_pListBox->Size(); }
//! \param iItemIndex The index of the item to check (will return false if the index is out of range)
//! \return true if the item is selected
bool IsSelected(unsigned int iItemIndex) { return m_pListBox->IsSelected(iItemIndex); }
// judb get index of the selected item (-1 if none)
int GetSelectedIndex();
// judb select the item with index iItemIndex in the list, and display the item's name
// (in the area to the left of the dropdown arrow)
void SelectItem(unsigned int iItemIndex);
//! Set an item as selected
//! \param iItemIndex The index of the item to change
//! \param bSelected Will select the item if true, or unselect if false
void SetSelection(int iItemIndex, bool bSelected) { m_pListBox->SetSelection(iItemIndex, bSelected); }
//! Set the selection for all of the items at once
//! \param bSelected Will select all items if true, or unselect if false
void SetAllSelections(bool bSelected) { m_pListBox->SetAllSelections(bSelected); }
//! Sets the height of the drop list
//! \param iItemCount The height of the listbox in number of items shown (this is set to 5 by default)
void SetListboxHeight(int iItemCount);
// CWindow overrides
//! Giving a control a new WindowRect will move and resize the control
//! \param WindowRect A CRect that defines the outer limits of the control
void SetWindowRect(const CRect& WindowRect) override;
//! Set the WindowText of the control
//! \param sWindowText The text to assign to the window
void SetWindowText(const std::string& sWindowText) override;
//! Get the WindowText of the control
std::string GetWindowText() const override;
//! Move the window and any child windows
//! \param MoveDistance The relative distance to move the window
void MoveWindow(const CPoint& MoveDistance) override;
// slight override from CWindow: if visible is set to "true", the dropdown part should stay invisible:
void SetVisible(bool bVisible) override;
// Override the default behaviour: a focused drop-down list is in fact it's button being focused
void SetIsFocusable(bool bFocusable) override;
// CMessageClient overrides
//! CDropDown will handle MOUSE_BUTTONDOWN messages
//! \param pMessage A pointer to the message that needs to be handled
bool HandleMessage(CMessage* pMessage) override;
protected:
//! Shows the drop down listbox
void ShowListBox();
//! Hides the drop down listbox
void HideListBox();
CEditBox* m_pEditBox; //!< A pointer to the drop down's edit box
CListBox* m_pListBox; //!< A pointer to teh drop down's list box
CPictureButton* m_pDropButton; //!< A pointer to the drop down's drop button
bool m_bAllowEdit; //!< If false, the edit box will be read only, and the value can only be changed via the drop-down list
int m_iItemCount; // !< Number of items to display in the drop down list.
private:
CDropDown(const CDropDown&) = delete;
CDropDown& operator=(const CDropDown&) = delete;
CView* m_pCViewAncestor; // pointer to the (unique) CView of the application.
};
}
#endif // _WG_DROPDOWN_H_
| 6,111
|
C++
|
.h
| 118
| 49.813559
| 157
| 0.760497
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,904
|
wg_frame.h
|
ColinPitrat_caprice32/src/gui/includes/wg_frame.h
|
// wg_frame.h
//
// CFrame interface
// Frames are windows within a view that have their own window management controls
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#ifndef _WG_FRAME_H_
#define _WG_FRAME_H_
#include "wg_window.h"
#include "wg_view.h"
#include "wg_button.h"
#include <string>
namespace wGui
{
//! Frames are windows within a view that have their own window management controls
//! The CFrame class allows the user to create multiple windows within the view. Unfortunately they're still bounded by the view
//! but it's a slight workaround for the SDL limitation of only 1 SDL view per app
class CFrame : public CWindow
{
public:
//! \param WindowRect A CRect that defines the outer limits of the control
//! \param pParent A pointer to the parent view
//! \param pFontEngine A pointer to the font engine to use when drawing the control
//! If this is set to 0 it will use the default font engine specified by the CApplication (which must be set before instantiating this object)
//! \param sTitle The window title, which will appear in the title bar of the view
//! \param bResizable If true, the window will be resizable
CFrame(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine, const std::string& sTitle, bool bResizable = true);
//! Standard destructor
~CFrame() override;
//! Set the color of the title bar
//! \param TitleBarColor The new color for the title bar
void SetTitleBarColor(CRGBColor& TitleBarColor) { m_TitleBarColor = TitleBarColor; }
//! Set the color of the title bar text
//! \param TitleBarTextColor The new color for the title bar text
void SetTitleBarTextColor(CRGBColor& TitleBarTextColor) { m_TitleBarTextColor = TitleBarTextColor; }
//! Set the height of the title bar
//! \param iTitleBarHeight
void SetTitleBarHeight(int iTitleBarHeight);
//! Indicates if the frame is resizable (set in the object constructor)
//! \return true if the frame is resizable
bool IsResizable() const { return m_bResizable; }
//! Attaches a standard menu to the frame, if the frame already has a menu, the old menu will be deleted
//! \param pMenu A pointer to the menu, the CFrame is then responsible for cleaning it up, passing in 0 will delete the current menu
void AttachMenu(CMenu* pMenu);
//! Gets the menu for a frame
//! \return A pointer to the frame's menu, 0 if the view doesn't have a menu
CMenu* GetMenu() const { return m_pMenu; }
//! Closes the frame and causes it to delete itself
virtual void CloseFrame();
//! Indicates if the frame is modal (doesn't allow input to any other windows)
//! \return true if the frame is modal
bool IsModal() const { return m_bModal; }
//! Sets the frame's modal state
//! param bModal the modal state to set (CFrames are non-modal by default)
void SetModal(bool bModal);
// CWindow overrides
//! Draws the frame and renders the title bar
void Draw() const override;
//! Blit the window to the given surface, using m_WindowRect as the offset into the surface
//! \param ScreenSurface A reference to the surface that the window will be copied to
//! \param FloatingSurface A reference to the floating surface which is overlayed at the very end (used for tooltips, menus and such)
//! \param Offset This is the current offset into the Surface that should be used as reference
void PaintToSurface(SDL_Surface& ScreenSurface, SDL_Surface& FloatingSurface, const CPoint& Offset) const override;
//! Giving a control a new WindowRect will move and resize the control
//! \param WindowRect A CRect that defines the outer limits of the control
void SetWindowRect(const CRect& WindowRect) override;
//! Set the title bar text of the frame
//! \param sWindowText The text to assign to the view
void SetWindowText(const std::string& sWindowText) override;
//! This is called whenever the frame is clicked on by the mouse
//! Only the topmost window that bounds the point will be called by the system
//! \param Point The point where the mouse clicked
//! \param Button A bitfield indicating which button the window was clicked with
//! \return True if it's in the bounds of the frame
bool OnMouseButtonDown(CPoint Point, unsigned int Button) override;
// CMessageClient overrides
//! CFrame handles no messages at the moment
//! \param pMessage A pointer to the message
bool HandleMessage(CMessage* pMessage) override;
void AddFocusableWidget(CWindow *pWidget) override;
void RemoveFocusableWidget(CWindow *pWidget) override;
virtual CWindow *GetFocused();
void FocusNext(EFocusDirection direction, bool loop = true);
protected:
CPictureButton* m_pFrameCloseButton; //!< The close button for the frame
CRGBColor m_TitleBarColor; //!< The title bar color, defaults to blue
CRGBColor m_TitleBarTextColor; //!< The title bar text color, defaults to the default line color
int m_iTitleBarHeight; //!< The height of the title bar, defaults to 12
CFontEngine* m_pFontEngine; //!< A pointer to the font engine to use to render the text
std::unique_ptr<CRenderedString> m_pRenderedString; //!< An autopointer to the rendered version of the string
bool m_bResizable; //!< Indicates if the frame is resizable
bool m_bModal; //!< Indicates if the frame is modal
CMenu* m_pMenu; //!< A pointer to the frame's menu
std::list<CWindow*> m_FocusableWidgets; //!< A list of all focusable widgets in this frame
private:
CRect m_TitleBarRect; //!< A place to cache the title bar rect
bool m_bDragMode; //!< Indicates if the window is currently being dragged
CPoint m_DragPointerStart; //!< The location of the cursor when the drag was started
CRect m_FrameGhostRect; //!< The rect of the frame while being dragged in a semi-transparent state
CFrame(const CFrame&) = delete;
CFrame& operator=(const CFrame&) = delete;
};
}
#endif // _WG_FRAME_H_
| 6,601
|
C++
|
.h
| 120
| 52.991667
| 143
| 0.763264
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,905
|
CapriceMemoryTool.h
|
ColinPitrat_caprice32/src/gui/includes/CapriceMemoryTool.h
|
// 'Memory tool' window for Caprice32
#ifndef _WG_CAPRICE32MEMORYTOOL_H_
#define _WG_CAPRICE32MEMORYTOOL_H_
#include "wg_button.h"
#include "wg_dropdown.h"
#include "wg_editbox.h"
#include "wg_frame.h"
#include "wg_label.h"
#include "wg_textbox.h"
namespace wGui
{
class CapriceMemoryTool : public CFrame {
public:
//! \param pParent A pointer to the parent view
//! \param pFontEngine A pointer to the font engine to use when drawing the control
//! If this is set to 0 it will use the default font engine specified by the CApplication (which must be set before instantiating this object)
CapriceMemoryTool(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine);
~CapriceMemoryTool() override;
bool HandleMessage(CMessage* pMessage) override;
protected:
CFontEngine *m_pMonoFontEngine;
CLabel *m_pPokeLabel;
CLabel *m_pPokeAdressLabel;
CEditBox *m_pPokeAdress;
CLabel *m_pPokeValueLabel;
CEditBox *m_pPokeValue;
CButton *m_pButtonPoke;
CLabel *m_pFilterLabel;
CEditBox *m_pFilterValue;
CButton *m_pButtonFilter;
CLabel *m_pAdressLabel;
CEditBox *m_pAdressValue;
CButton *m_pButtonDisplay;
CButton *m_pButtonCopy;
CButton *m_pButtonClose;
CLabel *m_pBytesPerLineLbl;
CDropDown *m_pBytesPerLine;
//CListBox *m_pListMemContent;
CTextBox *m_pTextMemContent;
int m_filterValue;
int m_displayValue;
unsigned int m_bytesPerLine;
private:
void UpdateTextMemory();
CapriceMemoryTool(const CapriceMemoryTool&) = delete;
CapriceMemoryTool& operator=(const CapriceMemoryTool&) = delete;
};
}
#endif
| 1,801
|
C++
|
.h
| 49
| 30
| 150
| 0.678326
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,906
|
CapriceDevToolsView.h
|
ColinPitrat_caprice32/src/gui/includes/CapriceDevToolsView.h
|
// Developers' tools for Caprice32
#ifndef _WG_CAPRICEDEVTOOLSVIEW_H
#define _WG_CAPRICEDEVTOOLSVIEW_H
#include <string>
#include "wg_point.h"
#include "wg_rect.h"
#include "wg_view.h"
#include "CapriceDevTools.h"
class DevTools;
constexpr int DEVTOOLS_WIDTH = 640;
constexpr int DEVTOOLS_HEIGHT = 480;
class CapriceDevToolsView : public wGui::CView
{
protected:
wGui::CapriceDevTools *m_pDevToolsFrame;
SDL_Renderer *m_pRenderer;
SDL_Texture *m_pTexture;
public:
CapriceDevToolsView(wGui::CApplication& application, SDL_Surface* surface, SDL_Renderer* renderer, SDL_Texture* texture, const wGui::CRect& WindowRect, DevTools* devtools);
~CapriceDevToolsView() final = default;
void LoadSymbols(const std::string& filename);
void PaintToSurface(SDL_Surface& ScreenSurface, SDL_Surface& FloatingSurface, const wGui::CPoint& Offset) const override;
void PreUpdate();
void PostUpdate();
void Flip() const override;
void Close() override;
};
#endif
| 1,003
|
C++
|
.h
| 28
| 32.714286
| 176
| 0.764523
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,907
|
wg_textbox.h
|
ColinPitrat_caprice32/src/gui/includes/wg_textbox.h
|
// wg_textbox.h
//
// CTextBox interface
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#ifndef _WG_TEXTBOX_H_
#define _WG_TEXTBOX_H_
#include "wg_window.h"
#include "wg_painter.h"
#include "wg_renderedstring.h"
#include "wg_timer.h"
#include "wg_resources.h"
#include "wg_scrollbar.h"
#include <vector>
#include <map>
#include <string>
namespace wGui
{
//! A multiline text box control
//! The CTextBox will generate CTRL_VALUECHANGE messages every time the text changes
class CTextBox : public CWindow
{
public:
//! Construct a new Edit control
//! \param WindowRect A CRect that defines the outer limits of the control
//! \param pParent A pointer to the parent window
//! \param pFontEngine A pointer to the font engine to use when drawing the control
//! If this is left out (or set to 0) it will use the default font engine specified by the CApplication (which must be set before instantiating this object)
CTextBox(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine = nullptr);
//! Standard destructor
~CTextBox() override;
//! Set the Read-only state of the control
//! \param bReadOnly If set to true, the control will not take any keyboard input
virtual void SetReadOnly(bool bReadOnly);
//! Indicates if the text box is in read-only mode
//! \return true if the control is read-only
virtual bool IsReadOnly() const { return m_bReadOnly; }
//! Gets the currently selected text
//! \return The currently selected text in the edit box, if the edit box is in Password Mask mode, this will always return an empty string
virtual std::string GetSelText() const;
//! Set the selection
//! \param iSelStart The index of the start of the selection
//! \param iSelLength The number of characters selected
virtual void SetSelection(std::string::size_type iSelStart, int iSelLength);
//! Gets the start of the selection
//! \return The index of the start of the selection
virtual std::string::size_type GetSelectionStart() const { return m_SelStart; }
//! Gets the selection length
//! \return The length of the selection
virtual int GetSelectionLength() const { return m_SelLength; }
//! The various states for the scrollbars
enum EScrollBarVisibility
{
SCROLLBAR_VIS_AUTO, //!< Display the scrollbar if the text extends beyond the right border of the client area
SCROLLBAR_VIS_NEVER, //!< Never display the scrollbar
SCROLLBAR_VIS_ALWAYS //!< Always show the scrollbar
};
//! Set the visibility mode for the scrollbars
//! \param ScrollBarType Indicates the vertical or the horizontal scrollbar
//! \param Visibility The visibility mode to set the scrollbar to
virtual void SetScrollBarVisibility(CScrollBar::EScrollBarType ScrollBarType, EScrollBarVisibility Visibility);
//! Gets the visibility mode for the indicated scrollbar
//! \param ScrollBarType Indicates the vertical or the horizontal scrollbar
//! \return An EScrollBarVisibility value indicating the mode for the bar
virtual EScrollBarVisibility GetScrollBarVisibility(CScrollBar::EScrollBarType ScrollBarType) const
{ return m_ScrollBarVisibilityMap.find(ScrollBarType)->second; }
// CWindow overrides
//! Renders the text contents of a control, and the cursor
void Draw() const override;
//! Giving a control a new WindowRect will move and resize the control
//! \param WindowRect A CRect that defines the outer limits of the control
void SetWindowRect(const CRect& WindowRect) override;
//! Set the WindowText of the control
//! \param sText The text to assign to the window
void SetWindowText(const std::string& sText) override;
//! This is called whenever the editbox is clicked on by the mouse
//! Only the topmost window that bounds the point will be called by the system
//! \param Point The point where the mouse clicked
//! \param Button A bitfield indicating which button the window was clicked with
//! \return True if it's in the bounds of the editbox
bool OnMouseButtonDown(CPoint Point, unsigned int Button) override;
// CMessageClient overrides
//! CTextBox will handle MOUSE_BUTTONDOWN and KEYBOARD_KEYDOWN messages
//! \param pMessage A pointer to the message that needs to be handled
bool HandleMessage(CMessage* pMessage) override;
protected:
//! Deletes the selected portion of the string
//! \internal
//! \param psString A pointer to the buffer
void SelDelete(std::string* psString);
//! Creates the rendered string objects and calculates some cached values for the string
//! \param sText The text to assign to the window
void PrepareWindowText(const std::string& sText);
//! Updates the visibility of the scrollbars
void UpdateScrollBars();
//! Convert an index to a row, column pair (in a CPoint object)
//! \param Index The index into the string
//! \return A CPoint object with the row as YPos and the column as XPos
CPoint RowColFromIndex(std::string::size_type Index) const;
//! Convert a row, column pair to an index
//! \param Row The row of the position to be converted
//! \param Col The column of the position to be converted
//! \return The index into the string of the specified position
std::string::size_type IndexFromRowCol(std::string::size_type Row, std::string::size_type Col) const;
CFontEngine* m_pFontEngine; //!< A pointer to the font engine to use to render the text
std::vector<CRenderedString*> m_vpRenderedString; //!< A vector of pointers to the rendered lines of text
std::string::size_type m_SelStart; //!< Selection start point, in characters
int m_SelLength; //!< Selection length, in characters
std::string::size_type m_DragStart; //!< The position where the draw started
bool m_bReadOnly; //!< If true, the text of the control cannot be changed
bool m_bMouseDown; //!< Set to true when the mouse button goes down
bool m_bLastMouseMoveInside; //!< True if the cursor was inside the control on the last MOUSE_MOVE message
CScrollBar* m_pVerticalScrollBar; //!< A pointer to the vertical scrollbar for the control.
CScrollBar* m_pHorizontalScrollBar; //!< A pointer to the horizontal scrollbar for the control.
std::map<CScrollBar::EScrollBarType, EScrollBarVisibility> m_ScrollBarVisibilityMap; //!< The visibility mode for the scrollbars
// cached values
unsigned int m_iLineCount; //!< The number of lines of the window text
unsigned int m_iRowHeight; //!< The row height
unsigned int m_iMaxWidth; //!< The width of the longest line (in pixels)
unsigned int m_iVisibleLines; //!< The number of lines visible in the window
private:
CTextBox(const CTextBox&) = delete;
CTextBox& operator=(const CTextBox&) = delete;
bool m_bDrawCursor; //!< Used to indicate if the cursor should be drawn on the next draw pass (used for the cursor blinking)
mutable bool m_bScrollToCursor; //!< Will force the text area to scroll so the cursor is visible on the next draw pass
CTimer* m_pDblClickTimer; //!< Timer to decide if we've double clicked or not.
CTimer* m_pCursorTimer; //!< Timer to blink the cursor
};
}
#endif // _WG_TEXTBOX_H_
| 7,785
|
C++
|
.h
| 147
| 50.979592
| 157
| 0.766316
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,908
|
cap_flag.h
|
ColinPitrat_caprice32/src/gui/includes/cap_flag.h
|
// cap_flag.h
//
// A widget combining a label, a field and a tooltip for displaying the content
// of a z80 flag.
#ifndef _CAP_FLAG_H_
#define _CAP_FLAG_H_
#include <string>
#include "wg_window.h"
#include "wg_painter.h"
#include "wg_label.h"
#include "wg_editbox.h"
#include "wg_tooltip.h"
namespace wGui
{
//! A composite widget for flag display, combining name, value and tooltips.
class CFlag : public CWindow
{
public:
//! Construct a new Flag control
//! \param WindowRect A CRect that defines the outer limits of the control
//! \param pParent A pointer to the parent window
//! \param name The name of the flag (e.g. S, Z, ...).
//! \param description The long name of the flag (e.g. Sign flag, Zero flag, ...).
//! \param pFontEngine A pointer to the font engine to use when drawing the control
//! If this is left out (or set to 0) it will use the default font engine specified by the CApplication (which must be set before instantiating this object)
CFlag(const CRect& WindowRect, CWindow* pParent, const std::string& name, const std::string& description, CFontEngine* pFontEngine = nullptr);
//! Standard destructor
~CFlag() override;
//! Set the value of the flag
//! \param c The value to assign to the control
void SetValue(const std::string& c);
protected:
CFontEngine* m_pFontEngine; //!< A pointer to the font engine to use to render the text
CLabel* m_pLabel;
CEditBox* m_pValue;
CToolTip* m_pTooltip;
private:
CFlag(const CFlag&) = delete;
CFlag& operator=(const CFlag&) = delete;
};
}
#endif // _CAP_FLAG_H_
| 1,567
|
C++
|
.h
| 42
| 35.428571
| 157
| 0.731304
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,909
|
CapriceMenu.h
|
ColinPitrat_caprice32/src/gui/includes/CapriceMenu.h
|
// 'Menu' window for Caprice32
// Inherited from CFrame
#ifndef _WG_CAPRICE32MENU_H_
#define _WG_CAPRICE32MENU_H_
#include "wg_frame.h"
#include "wg_button.h"
namespace wGui
{
enum class MenuItem {
NONE,
OPTIONS,
LOAD_SAVE,
MEMORY_TOOL,
RESET,
ABOUT,
RESUME,
QUIT
};
class CapriceGuiViewButton
{
public:
CapriceGuiViewButton(MenuItem item, CButton *button) : m_item(item), m_button(button) {};
~CapriceGuiViewButton() = default;
CButton *GetButton() const { return m_button.get(); };
MenuItem GetItem() const { return m_item; };
private:
MenuItem m_item;
std::shared_ptr<CButton> m_button;
};
class CapriceMenu : public CFrame {
public:
//! \param pParent A pointer to the parent view
//! \param pFontEngine A pointer to the font engine to use when drawing the control
//! If this is set to 0 it will use the default font engine specified by the CApplication (which must be set before instantiating this object)
CapriceMenu(const CRect& WindowRect, CWindow* pParent, SDL_Surface* screen, CFontEngine* pFontEngine);
~CapriceMenu() override;
void CloseFrame() override;
bool HandleMessage(CMessage* pMessage) override;
protected:
std::list<CapriceGuiViewButton> m_buttons;
SDL_Surface *m_pScreenSurface;
bool m_confirmed_quit = false;
CapriceMenu(const CapriceMenu&) = delete;
CapriceMenu& operator=(const CapriceMenu&) = delete;
};
}
#endif // _WG_CAPRICE32MENU_H_
| 1,552
|
C++
|
.h
| 47
| 28.042553
| 148
| 0.693548
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,910
|
wg_point.h
|
ColinPitrat_caprice32/src/gui/includes/wg_point.h
|
// wg_point.h
//
// CPoint class interface
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#ifndef _WG_POINT_H_
#define _WG_POINT_H_
#include "std_ex.h"
#include <string>
namespace wGui
{
//! CPoint defines a point in cartestian (X, Y) space.
//! Screen coordinates are assumed, where the origin is in the top left corner of the screen
//! and Y increases in the downward direction
class CPoint
{
public:
//! Initializes the point to (0, 0)
CPoint() : m_XPos(0), m_YPos(0) { }
//! Initialize the point to (x, y)
//! \param x X coordinate
//! \param y Y coordinate
CPoint(const int x, const int y) : m_XPos(x), m_YPos(y) { }
//! Copy constructor
CPoint(const CPoint& p) = default;
//! Standard Destructor
virtual ~CPoint() = default;
//! Set the X coordinate
//! \param x X coordinate
void SetX(const int x) { m_XPos = x; }
//! Set the Y coordinate
//! \param y Y coordinate
void SetY(const int y) { m_YPos = y; }
//! Gets the X coordinate
//! \return X coordinate
int XPos() const { return m_XPos; }
//! Gets the Y coordinate
//! \return Y coordinate
int YPos() const { return m_YPos; }
//! Add the X and Y coordinates of the points
CPoint operator+(const CPoint& p) const;
//! Subtract the X and Y coordinates of the points
CPoint operator-(const CPoint& p) const;
//! Assign the value of point p to the point
CPoint& operator=(const CPoint& p);
//! Equality operator evaluates to true if the x and y coordinates are the same for both points
bool operator==(const CPoint& p) const { return ((m_XPos == p.m_XPos) && (m_YPos == p.m_YPos)); }
//! Inequality operator evaluates to true if the x and y coordinates are the same for both points
bool operator!=(const CPoint& p) const { return ((m_XPos != p.m_XPos) || (m_YPos != p.m_YPos)); }
//! Indicates if a point is to the left of the point
//! \return true if the point is to the left of point p
bool leftof(const CPoint& p) const { return (m_XPos < p.m_XPos); }
//! Indicates if a point is to the right of the point
//! \return true if the point is to the right of point p
bool rightof(const CPoint& p) const { return (m_XPos > p.m_XPos); }
//! Indicates if a point is above the point
//! \return true if the point is above point p
bool above(const CPoint& p) const { return (m_YPos < p.m_YPos); }
//! Indicates if a point is below the point
//! \return true if the point is below point p
bool below(const CPoint& p) const { return (m_YPos > p.m_YPos); }
//! Gives a string representation of the coordinates
//! \return The coordinates in a string "<x>,<y>" i.e. "10,20"
std::string ToString() const { return stdex::itoa(m_XPos) + "," + stdex::itoa(m_YPos); }
protected:
//! The X coordinate
int m_XPos;
//! The Y coordinate
int m_YPos;
};
}
#endif // _WG_POINT_H_
| 3,557
|
C++
|
.h
| 89
| 38.067416
| 98
| 0.703693
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,911
|
wg_fontengine.h
|
ColinPitrat_caprice32/src/gui/includes/wg_fontengine.h
|
// wg_font.h
//
// CFontEngine interface
// CFontEngine uses the FreeType 2 library
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#ifndef _WG_FONTENGINE_H_
#define _WG_FONTENGINE_H_
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include <string>
#include <map>
namespace wGui
{
//! The CFont class is wGui's interface to FreeType2 and is used to render strings
//! This is used by the CRenderedString class, and shouldn't need to ever be called directly
//! \sa CRenderedString
class CFontEngine
{
public:
//! Construct a new CFont object, using the specified font
//! For most cases, there is no need to directly instantiate a CFontEngine object.
//! CApplication provides a GetFontEngine() method which should be used
//! \param sFontFileName The file that contains a file
//! \param FontSize The size of the font (in points)
CFontEngine(const std::string& sFontFileName, unsigned char FontSize);
//! Standard destructor
virtual ~CFontEngine();
//! Renders the specified character
//! \param Char The character to render
//! \return A pointer to a FreeType glyph
FT_BitmapGlyphRec* RenderGlyph(char Char);
//! Returns the metrics for a specified character
//! \param Char The character to render
//! \return A pointer to a FreeType metrics structure
FT_Glyph_Metrics* GetMetrics(char Char);
protected:
static FT_Library m_FTLibrary; //!< The FreeType library
static bool m_bFTLibraryLoaded; //!< Indicates if the FreeType library has been loaded
FT_Face m_FontFace; //!< The FreeType font face
std::map<char, FT_BitmapGlyphRec> m_CachedGlyphMap; //!< A cached map of the rendered glyphs
std::map<char, FT_Glyph_Metrics> m_CachedMetricsMap; //!< A cached map of the glyph metrics
};
}
#endif // _WG_FONTENGINE_
| 2,535
|
C++
|
.h
| 63
| 38.68254
| 94
| 0.762408
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,912
|
CapriceDevTools.h
|
ColinPitrat_caprice32/src/gui/includes/CapriceDevTools.h
|
// 'DevTools' window for Caprice32
#ifndef _WG_CAPRICE32DEVTOOLS_H_
#define _WG_CAPRICE32DEVTOOLS_H_
#include "z80_disassembly.h"
#include "cap32.h"
#include "symfile.h"
#include "types.h"
#include "cap_flag.h"
#include "cap_register.h"
#include "wg_checkbox.h"
#include "wg_dropdown.h"
#include "wg_frame.h"
#include "wg_groupbox.h"
#include "wg_label.h"
#include "wg_listbox.h"
#include "wg_textbox.h"
#include "wg_tooltip.h"
#include "wg_navigationbar.h"
#include <map>
#include <string>
class DevTools;
namespace wGui
{
enum class Format {
Hex,
Char,
U8,
U16,
U32,
I8,
I16,
I32
};
enum class SearchFrom {
Start, // Actually searching from end when searching backward
PositionIncluded,
PositionExcluded,
};
enum class SearchDir {
Forward,
Backward
};
int FormatSize(Format f);
std::ostream& operator<<(std::ostream& os, const Format& f);
std::ostream& operator<<(std::ostream& os, const std::vector<Format>& f);
class RAMConfig {
public:
std::string RAMConfigText();
static std::string RAMConfigText(int i);
static RAMConfig CurrentConfig();
bool LoROMEnabled;
bool HiROMEnabled;
int RAMBank = 0;
int RAMCfg = 0;
};
class CapriceDevTools : public CFrame {
public:
//! \param pParent A pointer to the parent view
//! \param pFontEngine A pointer to the font engine to use when drawing the control
//! If this is set to 0 it will use the default font engine specified by the CApplication (which must be set before instantiating this object)
CapriceDevTools(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine, DevTools* devtools);
~CapriceDevTools() override;
void LoadSymbols(const std::string& filename);
//! Prepare the update by saving the CPC state and updating this devtool's state.
//! This is separated from Step2 to allow having multiple devtools.
void PreUpdate();
//! The part of the update that modifies the CPC state.
void PostUpdate();
bool HandleMessage(CMessage* pMessage) override;
// activate the specified tab (make its controls visible)
void EnableTab(std::string sTabName);
void CloseFrame() override;
void UpdateAll();
// Exposed for testing
void SetDisassembly(std::vector<SListItem> items);
std::vector<SListItem> GetSelectedAssembly();
void SetAssemblySearch(const std::string& text);
void AsmSearch(SearchFrom from, SearchDir dir);
protected:
void PauseExecution();
void ResumeExecution();
byte ReadMem(word address);
void WriteMem(word address, byte value);
void PrepareMemBankConfig();
void RefreshDisassembly();
void UpdateZ80();
void UpdateDisassembly();
void UpdateDisassemblyPos();
void UpdateEntryPointsList();
void UpdateBreakPointsList();
void UpdateWatchPointsList();
void UpdateMemConfig();
void UpdateTextMemory();
void RemoveEphemeralBreakpoints();
CButton* m_pButtonStepOut;
CButton* m_pButtonStepIn;
CButton* m_pButtonStepOver;
CButton* m_pButtonPause;
CButton* m_pButtonClose;
CToolTip* m_pToolTipStepIn;
CToolTip* m_pToolTipStepOut;
CToolTip* m_pToolTipStepOver;
// New navigation bar control (to select the different pages or tabs on the options dialog)
CNavigationBar* m_pNavigationBar;
// groupbox to group the controls on each 'tab':
CGroupBox* m_pGroupBoxTabZ80;
CGroupBox* m_pGroupBoxTabAsm;
CGroupBox* m_pGroupBoxTabMemory;
CGroupBox* m_pGroupBoxTabVideo;
CGroupBox* m_pGroupBoxTabAudio;
CGroupBox* m_pGroupBoxTabChar;
// Z80 screen
// 8 bits registers
CRegister* m_pZ80RegA;
CRegister* m_pZ80RegAp;
CRegister* m_pZ80RegB;
CRegister* m_pZ80RegBp;
CRegister* m_pZ80RegC;
CRegister* m_pZ80RegCp;
CRegister* m_pZ80RegD;
CRegister* m_pZ80RegDp;
CRegister* m_pZ80RegE;
CRegister* m_pZ80RegEp;
CRegister* m_pZ80RegH;
CRegister* m_pZ80RegHp;
CRegister* m_pZ80RegL;
CRegister* m_pZ80RegLp;
CRegister* m_pZ80RegI;
CRegister* m_pZ80RegR;
CRegister* m_pZ80RegIXH;
CRegister* m_pZ80RegIXL;
CRegister* m_pZ80RegIYH;
CRegister* m_pZ80RegIYL;
// 16 bits registers
CRegister* m_pZ80RegAF;
CRegister* m_pZ80RegAFp;
CRegister* m_pZ80RegBC;
CRegister* m_pZ80RegBCp;
CRegister* m_pZ80RegDE;
CRegister* m_pZ80RegDEp;
CRegister* m_pZ80RegHL;
CRegister* m_pZ80RegHLp;
CRegister* m_pZ80RegIX;
CRegister* m_pZ80RegIY;
CRegister* m_pZ80RegSP;
CRegister* m_pZ80RegPC;
// Flags
CRegister* m_pZ80RegF;
CRegister* m_pZ80RegFp;
CLabel* m_pZ80FlagsLabel;
CFlag* m_pZ80FlagS;
CFlag* m_pZ80FlagZ;
CFlag* m_pZ80FlagX1;
CFlag* m_pZ80FlagH;
CFlag* m_pZ80FlagX2;
CFlag* m_pZ80FlagPV;
CFlag* m_pZ80FlagN;
CFlag* m_pZ80FlagC;
// Stack
CLabel* m_pZ80StackLabel;
CListBox* m_pZ80Stack;
// Assembly screen
CListBox *m_pAssemblyCode;
CLabel *m_pAssemblySearchLbl;
CEditBox *m_pAssemblySearch;
CButton *m_pAssemblySearchPrev;
CButton *m_pAssemblySearchNext;
CButton *m_pAssemblyRefresh;
CLabel* m_pAssemblyStatusLabel;
CEditBox* m_pAssemblyStatus;
CGroupBox* m_pAssemblyEntryPointsGrp;
CListBox* m_pAssemblyEntryPoints;
CEditBox* m_pAssemblyNewEntryPoint;
CButton *m_pAssemblyAddPCEntryPoint;
CButton *m_pAssemblyAddEntryPoint;
CButton *m_pAssemblyRemoveEntryPoint;
std::vector<word> m_EntryPoints;
CGroupBox* m_pAssemblyBreakPointsGrp;
CListBox* m_pAssemblyBreakPoints;
CEditBox* m_pAssemblyNewBreakPoint;
CButton *m_pAssemblyAddBreakPoint;
CButton *m_pAssemblyRemoveBreakPoint;
CGroupBox* m_pAssemblyMemConfigGrp;
CLabel* m_pAssemblyMemConfigAsmLbl;
CLabel* m_pAssemblyMemConfigCurLbl;
CLabel* m_pAssemblyMemConfigROMLbl;
CLabel* m_pAssemblyMemConfigLoLbl;
CLabel* m_pAssemblyMemConfigHiLbl;
CLabel* m_pAssemblyMemConfigRAMLbl;
CLabel* m_pAssemblyMemConfigBankLbl;
CLabel* m_pAssemblyMemConfigConfigLbl;
CCheckBox* m_pAssemblyMemConfigAsmLoROM;
CCheckBox* m_pAssemblyMemConfigAsmHiROM;
CEditBox* m_pAssemblyMemConfigAsmRAMBank;
CEditBox* m_pAssemblyMemConfigAsmRAMConfig;
CCheckBox* m_pAssemblyMemConfigCurLoROM;
CCheckBox* m_pAssemblyMemConfigCurHiROM;
CEditBox* m_pAssemblyMemConfigCurRAMBank;
CEditBox* m_pAssemblyMemConfigCurRAMConfig;
DisassembledCode m_Disassembled;
Symfile m_Symfile;
RAMConfig m_AsmRAMConfig;
// Memory screen
CLabel *m_pMemPokeLabel;
CLabel *m_pMemPokeAdressLabel;
CEditBox *m_pMemPokeAdress;
CLabel *m_pMemPokeValueLabel;
CEditBox *m_pMemPokeValue;
CButton *m_pMemButtonPoke;
CLabel *m_pMemFilterLabel;
CEditBox *m_pMemFilterValue;
CButton *m_pMemButtonFilter;
CButton *m_pMemButtonSaveFilter;
CButton *m_pMemButtonApplyFilter;
CLabel *m_pMemAdressLabel;
CEditBox *m_pMemAdressValue;
CButton *m_pMemButtonDisplay;
CButton *m_pMemButtonCopy;
CLabel *m_pMemBytesPerLineLbl;
CDropDown *m_pMemBytesPerLine;
CLabel *m_pMemFormatLbl;
CDropDown *m_pMemFormat;
CTextBox *m_pMemTextContent;
CGroupBox* m_pMemWatchPointsGrp;
CListBox* m_pMemWatchPoints;
CEditBox* m_pMemNewWatchPoint;
CButton *m_pMemAddWatchPoint;
CButton *m_pMemRemoveWatchPoint;
CDropDown* m_pMemWatchPointType;
CGroupBox* m_pMemConfigGrp;
CLabel* m_pMemConfigMemLbl;
CLabel* m_pMemConfigCurLbl;
CLabel* m_pMemConfigROMLbl;
CLabel* m_pMemConfigLoLbl;
CLabel* m_pMemConfigHiLbl;
CLabel* m_pMemConfigRAMLbl;
CLabel* m_pMemConfigBankLbl;
CLabel* m_pMemConfigConfigLbl;
CCheckBox* m_pMemConfigMemLoROM;
CCheckBox* m_pMemConfigMemHiROM;
CDropDown* m_pMemConfigMemRAMBank;
CDropDown* m_pMemConfigMemRAMConfig;
CCheckBox* m_pMemConfigCurLoROM;
CCheckBox* m_pMemConfigCurHiROM;
CEditBox* m_pMemConfigCurRAMBank;
CEditBox* m_pMemConfigCurRAMConfig;
RAMConfig m_MemRAMConfig;
// Variables for saved filters.
// Lines currently displayed
std::vector<word> m_currentlyDisplayed;
// Lines to filter in (if empty, do not apply saved filter)
std::vector<word> m_currentlyFiltered;
// Saved filter (only applied when its content is copied in m_currentlyFiltered)
std::vector<word> m_savedFilter;
int m_MemFilterValue;
int m_MemDisplayValue;
unsigned int m_MemBytesPerLine;
std::vector<Format> m_MemFormat;
// Video screen
CLabel* m_pVidLabel;
// Audio screen
CLabel* m_pAudLabel;
// Characters screen
CLabel* m_pChrLabel;
DevTools* m_pDevTools;
private:
std::map<std::string, CGroupBox*> TabMap; // mapping: <tab name> -> <groupbox that contains the 'tab'>.
CapriceDevTools(const CapriceDevTools&) = delete;
CapriceDevTools& operator=(const CapriceDevTools&) = delete;
};
}
#endif // _WG_CAPRICE32DEVTOOLS_H_
| 9,970
|
C++
|
.h
| 272
| 28.503676
| 150
| 0.66207
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,913
|
wg_navigationbar.h
|
ColinPitrat_caprice32/src/gui/includes/wg_navigationbar.h
|
// wg_navigationbar.h
//
// A navigation bar like in the Firefox 1.x preferences window.
// It is like a horizontal or vertical variant of a listbox,
// in which only 1 item can be selected at once.
// Besides text, each item can also have an picture.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#ifndef _WG_NAVIGATION_H_
#define _WG_NAVIGATION_H_
#include "wg_painter.h"
#include "wg_renderedstring.h"
#include "wg_resource_handle.h"
#include "wg_window.h"
#include <string>
#include <vector>
namespace wGui
{
//! A navigation bar item
class SNavBarItem {
public:
//! Standard constructor
SNavBarItem(std::string sItemTextIn, std::string PictureFilename ="" , CRGBColor ItemColorIn = DEFAULT_TEXT_COLOR) :
sItemText(std::move(sItemTextIn)), sPictureFilename(std::move(PictureFilename)), ItemColor(ItemColorIn) {
}
std::string sItemText; //!< The displayed text for the item
std::string sPictureFilename; //!< Name of the bmp file to display in the item.
CRGBColor ItemColor; //!< The text color to display the item in
};
//! Will generate CTRL_VALUECHANGE messages when a different item is selected.
//! The iNewValue of the message is the index of the item that was selected.
class CNavigationBar : public CWindow
{
public:
//! Constructs a new navigation bar
//! \param pParent A pointer to the parent window
//! \param UpperLeft a CPoint that is the upper-left corner of the navigation bar.
//! \param iMaxItems The (maximum) number of items that will fit in the navigation bar.
//! \param iItemWidth The width of one item in the navigation bar. Default is 50.
//! \param iItemHeight The height of one item in the navigation bar. Default is 50.
//! \param pFontEngine A pointer to the font engine to use when drawing the control
//! If this is left out (or set to 0) it will use the default font engine specified by the CApplication (which must be set before instantiating this object)
CNavigationBar(CWindow* pParent, const CPoint& UpperLeft, unsigned int iMaxItems,
unsigned int iItemWidth = 50, unsigned int iItemHeight = 50, CFontEngine* pFontEngine = nullptr);
//! Standard destructor
~CNavigationBar() override;
//! Gets the height of the items
//! \return The height of the items in the navigation bar
unsigned int GetItemHeight() const { return m_iItemHeight; }
//! Gets the width of the items
//! \return The width of the items in the navigation bar
unsigned int GetItemWidth() const { return m_iItemWidth; }
//! Sets the height of the items in the navigation bar
//! \param iItemHeight The height of the items in the navigation bar
void SetItemHeight(unsigned int iItemHeight);
//! Sets the width of the items in the navigation bar
//! \param iItemWidth The width of the items in the navigation bar
void SetItemWidth(unsigned int iItemWidth);
//! Adds a new item to the bar
//! \param NavBarItem A SNavBarItem structure with the data for the item
//! \return The index of the added item
unsigned int AddItem(SNavBarItem NavBarItem);
//! Returns the desired item
//! \param iItemIndex The index of the item to check (will throw an exception if the index is out of range)
//! \return A reference to the SNavBarItem struct
SNavBarItem& GetItem(unsigned int iItemIndex) { return m_Items.at(iItemIndex); }
//! Remove an item from the bar
//! \param iItemIndex The index of the item to remove
void RemoveItem(unsigned int iItemIndex);
//! Remove all items from the bar
void ClearItems();
//! Gets the number of items in the navigation bar
//! \return The number of items in the bar
unsigned int Size() { return m_Items.size(); }
//! \param iItemIndex The index of the item to check (will return false if the index is out of range)
//! \return true if the item is selected
bool IsSelected(unsigned int iItemIndex)
{ return (iItemIndex < m_Items.size() && m_iSelectedItem == iItemIndex); }
// Returns the index of the selected item; returns -1 if there is no selection.
unsigned int getSelectedIndex() const;
//! Selects an item in the navigation bar.
//! \param iItemIndex The index of the item to select.
void SelectItem(unsigned int iItemIndex);
// Returns the index of the focused item; returns -1 if there is no selection.
unsigned int getFocusedIndex() const;
//! Focus an item in the navigation bar.
//! \param iItemIndex The index of the item to focus.
void FocusItem(unsigned int iItemIndex);
// CWindow overrides
//! Draws the navigation bar
void Draw() const override;
//! Giving a control a new WindowRect will move and resize the control
//! \param WindowRect A CRect that defines the outer limits of the control
void SetWindowRect(const CRect& WindowRect) override;
//! Blit the window to the given surface, using m_WindowRect as the offset into the surface
//! \param ScreenSurface A reference to the surface that the window will be copied to
//! \param FloatingSurface A reference to the floating surface which is overlayed at the very end (used for tooltips, menus and such)
//! \param Offset This is the current offset into the Surface that should be used as reference
void PaintToSurface(SDL_Surface& ScreenSurface, SDL_Surface& FloatingSurface, const CPoint& Offset) const override;
//! This is called whenever the navigation bar is clicked on by the mouse
//! Only the topmost window that bounds the point will be called by the system
//! \param Point The point where the mouse clicked
//! \param Button A bitfield indicating which button the window was clicked with
//! \return True if it's in the bounds of the navigation bar
bool OnMouseButtonDown(CPoint Point, unsigned int Button) override;
// CMessageClient overrides
//! CNavigationBars handle MOUSE_BUTTONDOWN, MOUSE_BUTTONUP and CTRL_VALUECHANGE messages
//! \param pMessage A pointer to the message
bool HandleMessage(CMessage* pMessage) override;
protected:
CFontEngine* m_pFontEngine; //!< A pointer to the font engine to use to render the text
unsigned int m_iItemHeight; //!< The height of the items in the navigation bar
unsigned int m_iItemWidth; //!< The width of the items in the navigation bar
unsigned int m_iSelectedItem; //!< The currently selected item (selection color)
unsigned int m_iFocusedItem; //!< The currently focused item (rectangle)
std::vector<SNavBarItem> m_Items; //!< The list of items
std::vector<CRenderedString> m_RenderedStrings; //!< A vector of the rendered strings
std::vector<CBitmapResourceHandle *> m_Bitmaps; //!< A vector of the pictures (optional)
private:
CNavigationBar(const CNavigationBar&) = delete;
CNavigationBar& operator=(const CNavigationBar&) = delete;
};
}
#endif // _WG_NAVIGATION_H_
| 7,388
|
C++
|
.h
| 137
| 51.79562
| 157
| 0.761258
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
753,914
|
wg_toolbar.h
|
ColinPitrat_caprice32/src/gui/includes/wg_toolbar.h
|
// wg_toolbar.h
//
// CToolBar class interface
//
//
// Copyright (c) 2002-2004 Rob Wiskow
// rob-dev@boxedchaos.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#ifndef _WG_TOOLBAR_H_
#define _WG_TOOLBAR_H_
#include "wg_window.h"
#include "wg_button.h"
#include <vector>
namespace wGui
{
//! A Toolbar control that groups and organizes buttons
//! Toolbars support CButton derived controls
class CToolBar : public CWindow
{
public:
//! Constructs a new ToolBar
//! \param WindowRect A CRect that defines the outer limits of the control
//! \param pParent A pointer to the parent window
CToolBar(const CRect& WindowRect, CWindow* pParent);
//! Standard destructor
~CToolBar() override;
//! Add a button to the toolbar
//! The toolbar will become the button's parent
//! The toolbar will catch all CTRL_SINGLELCLICK messages from the buttons and will post a CTRL_SINGLELCLICK message from the toolbar with the iButtonID value as the iNewValue
//! \param pButton A pointer to the button to be inserted, inserts a spacer if this is NULL
//! \param iButtonID An identifier that the toolbar will return when a button is clicked on, defaults to 0
//! \param iPosition The position to insert the button at (defaults to adding to the beginning of the toolbar)
void InsertButton(CButton* pButton, long int iButtonID = 0, unsigned int iPosition = 0);
//! Add a button to the end of toolbar
//! The toolbar will become the button's parent
//! The toolbar will catch all CTRL_SINGLELCLICK messages from the buttons and will post a CTRL_SINGLELCLICK message from the toolbar with the iButtonID value as the iNewValue
//! \param pButton A pointer to the button to be inserted, inserts a spacer if this is NULL
//! \param iButtonID An identifier that the toolbar will return when a button is clicked on, defaults to 0
void AppendButton(CButton* pButton, long int iButtonID = 0);
//! Remove a button from the toolbar
//! This will automatically delete the button
//! \param iPosition The position of the button to remove, an exception will be thrown if this is out of range
void RemoveButton(unsigned int iPosition);
//! Remove all buttons from the ToolBar
void Clear();
//! Gets the number of items on the toolbar (including spacers)
//! \return The number of buttons in the toolbar
unsigned int GetButtonCount() { return stdex::safe_static_cast<unsigned int>(m_vpButtons.size()); }
//! \param iPosition The position of the button to get the ID for. An exception will be thrown if this is out of range.
//! \return The ButtonID of the button at the given position (spacers always return 0)
long int GetButtonID(unsigned int iPosition) { return m_vpButtons.at(iPosition).second; }
//! \param iButtonID The ID of the button to get the position for
//! \return The position of the button, or -1 if it can't find the ButtonID
int GetButtonPosition(long int iButtonID);
//! CWindow overrides
//! Giving a control a new WindowRect will move and resize the control
//! \param WindowRect A CRect that defines the outer limits of the control
void SetWindowRect(const CRect& WindowRect) override;
// CMessageClient overrides
//! CToolBars handle CTRL_SINGLELCLICK messages
//! \param pMessage A pointer to the message
bool HandleMessage(CMessage* pMessage) override;
protected:
//! Reposition all the buttons in the toolbar
void RepositionButtons();
using t_ButtonIDPair = std::pair<CButton*, long int>; //!< A typedef of CButton pointer to ID pair
using t_ButtonVector = std::vector<t_ButtonIDPair>; //!< A typedef of a vector of Button ID pairs
t_ButtonVector m_vpButtons; //!< A vector of pointers to the buttons and their IDs in the toolbar
private:
CToolBar(const CToolBar&) = delete;
CToolBar& operator=(const CToolBar&) = delete;
};
}
#endif // _WG_TOOLBAR_H_
| 4,524
|
C++
|
.h
| 88
| 49.465909
| 176
| 0.764813
|
ColinPitrat/caprice32
| 146
| 32
| 52
|
GPL-2.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.