-use tab control class for left tabs

-add a way to hide tab titles
-accelerator for GEDebugger
This commit is contained in:
Kingcom 2013-09-30 15:56:08 +02:00
parent 6b3d78adfc
commit a5ae03cae1
7 changed files with 110 additions and 107 deletions

View File

@ -103,24 +103,13 @@ CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Di
rl->setCPU(cpu);
symbolMap.FillSymbolComboBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION);
HWND tabs = GetDlgItem(m_hDlg, IDC_LEFTTABS);
TCITEM tcItem;
ZeroMemory (&tcItem,sizeof (tcItem));
tcItem.mask = TCIF_TEXT;
tcItem.dwState = 0;
tcItem.pszText = L"Regs";
tcItem.cchTextMax = (int)wcslen(tcItem.pszText)+1;
tcItem.iImage = 0;
int result1 = TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem);
tcItem.pszText = L"Funcs";
tcItem.cchTextMax = (int)wcslen(tcItem.pszText)+1;
int result2 = TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem);
ShowWindow(GetDlgItem(m_hDlg, IDC_REGLIST), SW_NORMAL);
ShowWindow(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST), SW_HIDE);
SetTimer(m_hDlg,1,1000,0);
leftTabs = new TabControl(GetDlgItem(m_hDlg,IDC_LEFTTABS));
leftTabs->SetIgnoreBottomMargin(true);
leftTabs->AddTab(GetDlgItem(m_hDlg,IDC_REGLIST),L"Regs");
leftTabs->AddTab(GetDlgItem(m_hDlg,IDC_FUNCTIONLIST),L"Funcs");
leftTabs->ShowTab(0);
// subclass the goto edit box
HWND editWnd = GetDlgItem(m_hDlg,IDC_ADDRESS);
DefGotoEditProc = (WNDPROC)GetWindowLongPtr(editWnd,GWLP_WNDPROC);
@ -129,7 +118,6 @@ CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Di
// init bottom tabs
bottomTabs = new TabControl(GetDlgItem(m_hDlg,IDC_DEBUG_BOTTOMTABS));
// init memory viewer
HWND memHandle = GetDlgItem(m_hDlg,IDC_DEBUGMEMVIEW);
CtrlMemView *mem = CtrlMemView::getFrom(memHandle);
mem->setDebugger(_cpu);
@ -293,29 +281,11 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam)
}
break;
case WM_TIMER:
{
int iPage = TabCtrl_GetCurSel (GetDlgItem(m_hDlg, IDC_LEFTTABS));
ShowWindow(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST), iPage?SW_NORMAL:SW_HIDE);
ShowWindow(GetDlgItem(m_hDlg, IDC_REGLIST), iPage?SW_HIDE:SW_NORMAL);
}
break;
case WM_NOTIFY:
switch (wParam)
{
case IDC_LEFTTABS:
{
HWND tabs = GetDlgItem(m_hDlg, IDC_LEFTTABS);
NMHDR* pNotifyMessage = NULL;
pNotifyMessage = (LPNMHDR)lParam;
if (pNotifyMessage->hwndFrom == tabs)
{
int iPage = TabCtrl_GetCurSel (tabs);
ShowWindow(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST), iPage?SW_NORMAL:SW_HIDE);
ShowWindow(GetDlgItem(m_hDlg, IDC_REGLIST), iPage?SW_HIDE:SW_NORMAL);
}
}
leftTabs->HandleNotify(lParam);
break;
case IDC_BREAKPOINTLIST:
breakpointList->HandleNotify(lParam);
@ -417,6 +387,10 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam)
}
break;
case ID_DEBUG_TOGGLEBOTTOMTABTITLES:
bottomTabs->SetShowTabTitles(!bottomTabs->GetShowTabTitles());
break;
case IDC_SHOWVFPU:
vfpudlg->Show(true);
break;
@ -694,12 +668,7 @@ void CDisasm::UpdateSize(WORD width, WORD height)
Position positions[3];
HWND disasm = GetDlgItem(m_hDlg, IDC_DISASMVIEW);
HWND leftTabs[2] = {
GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),
GetDlgItem(m_hDlg, IDC_REGLIST)
};
HWND leftTabs = GetDlgItem(m_hDlg,IDC_LEFTTABS);
HWND bottomTabs = GetDlgItem(m_hDlg, IDC_DEBUG_BOTTOMTABS);
// ignore the status bar
@ -717,11 +686,11 @@ void CDisasm::UpdateSize(WORD width, WORD height)
positions[0].y = windowRect.top;
// left tabs
GetWindowRect(leftTabs[0],&windowRect);
GetWindowRect(leftTabs,&windowRect);
MapWindowPoints(HWND_DESKTOP,m_hDlg,(LPPOINT)&windowRect,2);
positions[1].x = windowRect.left;
positions[1].y = windowRect.top;
positions[1].w = windowRect.right-windowRect.left;
positions[1].w = positions[0].x-2*windowRect.left;
int borderMargin = positions[1].x;
float weight = hideBottomTabs ? 1.f : 390.f/500.f;
@ -740,22 +709,9 @@ void CDisasm::UpdateSize(WORD width, WORD height)
// now actually move all the windows
MoveWindow(disasm,positions[0].x,positions[0].y,positions[0].w,positions[0].h,TRUE);
for (int i = 0; i < 2; i++)
{
MoveWindow(leftTabs[i],positions[1].x,positions[1].y,positions[1].w,positions[1].h,TRUE);
}
MoveWindow(leftTabs,positions[1].x,positions[1].y,positions[1].w,positions[1].h,TRUE);
MoveWindow(bottomTabs,positions[2].x,positions[2].y,positions[2].w,positions[2].h,TRUE);
ShowWindow(bottomTabs,hideBottomTabs ? SW_HIDE : SW_NORMAL);
RECT tabRect;
HWND hwnd = GetDlgItem(m_hDlg,IDC_LEFTTABS);
GetWindowRect(hwnd,&tabRect);
MapWindowPoints(HWND_DESKTOP,hwnd,(LPPOINT)&tabRect,2);
TabCtrl_AdjustRect(hwnd, FALSE, &tabRect);
printf("");
}
void CDisasm::SavePosition()

View File

@ -27,6 +27,7 @@ private:
CtrlBreakpointList* breakpointList;
CtrlThreadList* threadList;
CtrlStackTraceView* stackTraceView;
TabControl* leftTabs;
TabControl* bottomTabs;
std::vector<BreakPoint> displayedBreakPoints_;
std::vector<MemCheck> displayedMemChecks_;

View File

@ -6,27 +6,18 @@
const DWORD tabControlStyleMask = ~(WS_POPUP | WS_TILEDWINDOW);
TabControl::TabControl(HWND handle): hwnd(handle)
TabControl::TabControl(HWND handle): hwnd(handle), showTabTitles(true),currentTab(0),ignoreBottomMargin(false)
{
SetWindowLongPtr(hwnd,GWLP_USERDATA,(LONG_PTR)this);
oldProc = (WNDPROC) SetWindowLongPtr(hwnd,GWLP_WNDPROC,(LONG_PTR)wndProc);
}
HWND TabControl::AddTabWindow(wchar_t* className, wchar_t* title, DWORD style)
{
style = (style |WS_CHILD) & tabControlStyleMask;
TCITEM tcItem;
ZeroMemory (&tcItem,sizeof (tcItem));
tcItem.mask = TCIF_TEXT;
tcItem.dwState = 0;
tcItem.pszText = title;
tcItem.cchTextMax = (int)wcslen(tcItem.pszText)+1;
tcItem.iImage = 0;
int index = TabCtrl_GetItemCount(hwnd);
int result = TabCtrl_InsertItem(hwnd,index,&tcItem);
if (showTabTitles)
AppendPageToControl(title);
int index = tabs.size();
RECT tabRect;
GetWindowRect(hwnd,&tabRect);
@ -36,7 +27,11 @@ HWND TabControl::AddTabWindow(wchar_t* className, wchar_t* title, DWORD style)
HWND tabHandle = CreateWindowEx(0,className,title,style,
tabRect.left,tabRect.top,tabRect.right-tabRect.left,tabRect.bottom-tabRect.top,
GetParent(hwnd),0,MainWindow::GetHInstance(),0);
tabs.push_back(tabHandle);
TabInfo info;
info.pageHandle = tabHandle;
wcscpy(info.title,title);
tabs.push_back(info);
ShowTab(index);
return tabHandle;
@ -50,16 +45,9 @@ void TabControl::AddTabDialog(Dialog* dialog, wchar_t* title)
void TabControl::AddTab(HWND handle, wchar_t* title)
{
TCITEM tcItem;
ZeroMemory (&tcItem,sizeof (tcItem));
tcItem.mask = TCIF_TEXT;
tcItem.dwState = 0;
tcItem.pszText = title;
tcItem.cchTextMax = (int)wcslen(tcItem.pszText)+1;
tcItem.iImage = 0;
int index = TabCtrl_GetItemCount(hwnd);
int result = TabCtrl_InsertItem(hwnd,index,&tcItem);
if (showTabTitles)
AppendPageToControl(title);
int index = tabs.size();
RECT tabRect;
GetWindowRect(hwnd,&tabRect);
@ -70,19 +58,40 @@ void TabControl::AddTab(HWND handle, wchar_t* title)
DWORD style = (GetWindowLong(handle,GWL_STYLE) | WS_CHILD) & tabControlStyleMask;
SetWindowLong(handle, GWL_STYLE, style);
MoveWindow(handle,tabRect.left,tabRect.top,tabRect.right-tabRect.left,tabRect.bottom-tabRect.top,TRUE);
tabs.push_back(handle);
TabInfo info;
info.pageHandle = handle;
wcscpy(info.title,title);
tabs.push_back(info);
ShowTab(index);
}
int TabControl::AppendPageToControl(wchar_t* title)
{
TCITEM tcItem;
ZeroMemory (&tcItem,sizeof (tcItem));
tcItem.mask = TCIF_TEXT;
tcItem.dwState = 0;
tcItem.pszText = title;
tcItem.cchTextMax = (int)wcslen(tcItem.pszText)+1;
tcItem.iImage = 0;
int index = TabCtrl_GetItemCount(hwnd);
int result = TabCtrl_InsertItem(hwnd,index,&tcItem);
return index;
}
void TabControl::ShowTab(int index, bool setControlIndex)
{
currentTab = index;
for (size_t i = 0; i < tabs.size(); i++)
{
ShowWindow(tabs[i],i == index ? SW_NORMAL : SW_HIDE);
ShowWindow(tabs[i].pageHandle,i == index ? SW_NORMAL : SW_HIDE);
}
if (setControlIndex)
if (setControlIndex && showTabTitles)
{
TabCtrl_SetCurSel(hwnd,index);
}
@ -92,17 +101,36 @@ void TabControl::ShowTab(HWND pageHandle)
{
for (size_t i = 0; i < tabs.size(); i++)
{
if (tabs[i] == pageHandle)
if (tabs[i].pageHandle == pageHandle)
{
TabCtrl_SetCurSel(hwnd,i);
currentTab = i;
if (showTabTitles)
TabCtrl_SetCurSel(hwnd,i);
}
ShowWindow(tabs[i],tabs[i] == pageHandle ? SW_NORMAL : SW_HIDE);
ShowWindow(tabs[i].pageHandle,tabs[i].pageHandle == pageHandle ? SW_NORMAL : SW_HIDE);
}
}
int TabControl::CurrentTabIndex()
void TabControl::SetShowTabTitles(bool enabled)
{
return TabCtrl_GetCurSel(hwnd);
showTabTitles = enabled;
int itemCount = TabCtrl_GetItemCount(hwnd);
for (int i = 0; i < itemCount; i++)
{
TabCtrl_DeleteItem(hwnd,0);
}
if (showTabTitles)
{
for (int i = 0; i < (int) tabs.size(); i++)
{
AppendPageToControl(tabs[i].title);
}
TabCtrl_SetCurSel(hwnd,CurrentTabIndex());
}
OnResize();
}
void TabControl::NextTab(bool cycle)
@ -154,18 +182,20 @@ void TabControl::OnResize()
UpdateWindow(hwnd);
// now resize tab children
int bottom = tabRect.bottom;
TabCtrl_AdjustRect(hwnd, FALSE, &tabRect);
int current = TabCtrl_GetCurSel(hwnd);
if (ignoreBottomMargin) tabRect.bottom = bottom;
int current = CurrentTabIndex();
for (size_t i = 0; i < tabs.size(); i++)
{
InvalidateRect(tabs[i],NULL,FALSE);
MoveWindow(tabs[i],tabRect.left,tabRect.top,tabRect.right-tabRect.left,tabRect.bottom-tabRect.top,TRUE);
InvalidateRect(tabs[i].pageHandle,NULL,FALSE);
MoveWindow(tabs[i].pageHandle,tabRect.left,tabRect.top,tabRect.right-tabRect.left,tabRect.bottom-tabRect.top,TRUE);
if (i == current)
{
InvalidateRect(tabs[i],NULL,TRUE);
UpdateWindow(tabs[i]);
InvalidateRect(tabs[i].pageHandle,NULL,TRUE);
UpdateWindow(tabs[i].pageHandle);
}
}
}

View File

@ -16,13 +16,26 @@ public:
void ShowTab(HWND pageHandle);
void NextTab(bool cycle);
void PreviousTab(bool cycle);
int CurrentTabIndex();
HWND CurrentTabHandle() { return tabs[CurrentTabIndex()]; };
int CurrentTabIndex() { return currentTab; };
HWND CurrentTabHandle() { return tabs[currentTab].pageHandle; };
void SetShowTabTitles(bool enabled);
void SetIgnoreBottomMargin(bool enabled) { ignoreBottomMargin = enabled; };
bool GetShowTabTitles() { return showTabTitles; };
private:
static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
void OnResize();
int AppendPageToControl(wchar_t* title);
struct TabInfo
{
HWND pageHandle;
wchar_t title[128];
};
HWND hwnd;
WNDPROC oldProc;
std::vector<HWND> tabs;
std::vector<TabInfo> tabs;
bool showTabTitles;
bool ignoreBottomMargin;
int currentTab;
};

View File

@ -503,7 +503,7 @@ namespace MainWindow
TranslateMenuItem(ID_DEBUG_IGNOREILLEGALREADS);
TranslateMenuItem(ID_DEBUG_RUNONLOAD);
TranslateMenuItem(ID_DEBUG_DISASSEMBLY, L"\tCtrl+D");
TranslateMenuItem(ID_DEBUG_GEDEBUGGER);
TranslateMenuItem(ID_DEBUG_GEDEBUGGER,L"\tCtrl+G");
TranslateMenuItem(ID_DEBUG_LOG, L"\tCtrl+L");
TranslateMenuItem(ID_DEBUG_MEMORYVIEW, L"\tCtrl+M");

View File

@ -67,8 +67,9 @@ BEGIN
"O", ID_FILE_LOAD, VIRTKEY, CONTROL, NOINVERT
"W", ID_EMULATION_STOP, VIRTKEY, CONTROL, NOINVERT
"B", ID_EMULATION_RESET, VIRTKEY, CONTROL, NOINVERT
"T", ID_EMULATION_CHEATS, VIRTKEY, CONTROL, NOINVERT
"T", ID_EMULATION_CHEATS, VIRTKEY, CONTROL, NOINVERT
"D", ID_DEBUG_DISASSEMBLY, VIRTKEY, CONTROL, NOINVERT
"G", ID_DEBUG_GEDEBUGGER, VIRTKEY, CONTROL, NOINVERT
"L", ID_DEBUG_LOG, VIRTKEY, CONTROL, NOINVERT
"E", ID_DEBUG_MEMORYCHECKS, VIRTKEY, CONTROL, NOINVERT
"F", ID_DEBUG_MEMORYSEARCH, VIRTKEY, CONTROL, NOINVERT
@ -104,6 +105,7 @@ BEGIN
VK_F11, ID_DEBUG_STEPINTO, VIRTKEY, NOINVERT
VK_F11, ID_DEBUG_STEPOUT, VIRTKEY, SHIFT, NOINVERT
"X", ID_DEBUG_HIDEBOTTOMTABS, VIRTKEY, CONTROL, NOINVERT
"Y", ID_DEBUG_TOGGLEBOTTOMTABTITLES, VIRTKEY, CONTROL, NOINVERT
END
@ -155,13 +157,13 @@ BEGIN
CONTROL "Custom1",IDC_DISASMVIEW,"CtrlDisAsmView",WS_BORDER | WS_TABSTOP,111,16,397,304
GROUPBOX "Go to",IDC_STATIC,5,12,102,47
CONTROL "Custom1",IDC_REGLIST,"CtrlRegisterList",WS_BORDER | WS_TABSTOP,1,81,102,255
CONTROL "",IDC_LEFTTABS,"SysTabControl32",TCS_BUTTONS,1,63,78,15
CONTROL "",IDC_LEFTTABS,"SysTabControl32",TCS_BUTTONS | TCS_FOCUSNEVER,1,63,78,15
LISTBOX IDC_FUNCTIONLIST,1,83,103,255,LBS_SORT | LBS_NOINTEGRALHEIGHT | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "VFPU",IDC_SHOWVFPU,83,63,24,12
CONTROL "",IDC_BREAKPOINTLIST,"SysListView32",LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_REPORT,1,338,513,93
CONTROL "Custom2",IDC_DEBUGMEMVIEW,"CtrlMemView",0,1,338,513,93
CONTROL "",IDC_THREADLIST,"SysListView32",LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_REPORT | WS_BORDER,1,338,513,93
CONTROL "",IDC_STACKFRAMES,"SysListView32",LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_REPORT | WS_BORDER,1,338,513,93
CONTROL "",IDC_THREADLIST,"SysListView32",LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_REPORT,1,338,513,93
CONTROL "",IDC_STACKFRAMES,"SysListView32",LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_REPORT,1,338,513,93
CONTROL "",IDC_DEBUG_BOTTOMTABS,"SysTabControl32",TCS_TABS | TCS_FOCUSNEVER,1,338,513,93
END
@ -176,7 +178,7 @@ BEGIN
PUSHBUTTON "Resume",IDC_GEDBG_RESUME,104,0,48,14
CONTROL "",IDC_GEDBG_TEX,"SimpleGLWindow",WS_CHILD | WS_VISIBLE,10,20,128,128
CONTROL "",IDC_GEDBG_FRAME,"SimpleGLWindow",WS_CHILD | WS_VISIBLE,148,20,256,136
CONTROL "",IDC_GEDBG_MAINTAB,"SysTabControl32",TCS_TABS ,10,216,480,180
CONTROL "",IDC_GEDBG_MAINTAB,"SysTabControl32",TCS_TABS | TCS_FOCUSNEVER ,10,216,480,180
END

View File

@ -272,6 +272,7 @@
#define ID_OPTIONS_FXAA 40126
#define IDC_DEBUG_BOTTOMTABS 40127
#define ID_DEBUG_HIDEBOTTOMTABS 40128
#define ID_DEBUG_TOGGLEBOTTOMTABTITLES 40129
// Dummy option to let the buffered rendering hotkey cycle through all the options.
#define ID_OPTIONS_BUFFEREDRENDERINGDUMMY 40500
@ -284,7 +285,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 252
#define _APS_NEXT_COMMAND_VALUE 40129
#define _APS_NEXT_COMMAND_VALUE 40130
#define _APS_NEXT_CONTROL_VALUE 1181
#define _APS_NEXT_SYMED_VALUE 101
#endif