debugger: Formatting;
This commit is contained in:
+11
-11
@@ -2,18 +2,18 @@
|
|||||||
#ifndef DEBUGGER_H
|
#ifndef DEBUGGER_H
|
||||||
#define DEBUGGER_H
|
#define DEBUGGER_H
|
||||||
|
|
||||||
class Debugger{
|
class Debugger {
|
||||||
public:
|
public:
|
||||||
virtual void debugRun()=0;
|
virtual void debugRun() = 0;
|
||||||
virtual void debugStop()=0;
|
virtual void debugStop() = 0;
|
||||||
virtual void debugStmt( int srcpos,const char *file )=0;
|
virtual void debugStmt(int srcpos, const char* file) = 0;
|
||||||
virtual void debugEnter( void *frame,void *env,const char *func )=0;
|
virtual void debugEnter(void* frame, void* env, const char* func) = 0;
|
||||||
virtual void debugLeave()=0;
|
virtual void debugLeave() = 0;
|
||||||
virtual void debugLog( const char *msg )=0;
|
virtual void debugLog(const char* msg) = 0;
|
||||||
virtual void debugMsg( const char *msg,bool serious )=0;
|
virtual void debugMsg(const char* msg, bool serious) = 0;
|
||||||
virtual void debugSys( void *msg )=0;
|
virtual void debugSys(void* msg) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" _declspec(dllexport) Debugger * _cdecl debuggerGetDebugger( void *mod,void *env );
|
extern "C" _declspec(dllexport) Debugger* _cdecl debuggerGetDebugger(void* mod, void* env);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+22
-22
@@ -1,50 +1,50 @@
|
|||||||
|
|
||||||
#include "stdafx.hpp"
|
|
||||||
#include "debugger.hpp"
|
|
||||||
#include "debuggerapp.hpp"
|
#include "debuggerapp.hpp"
|
||||||
#include "resource.hpp"
|
#include "debugger.hpp"
|
||||||
#include "prefs.hpp"
|
#include "prefs.hpp"
|
||||||
|
#include "resource.hpp"
|
||||||
|
#include "stdafx.hpp"
|
||||||
|
|
||||||
DebuggerApp debuggerApp;
|
DebuggerApp debuggerApp;
|
||||||
|
|
||||||
DebuggerApp::~DebuggerApp(){
|
DebuggerApp::~DebuggerApp() {}
|
||||||
}
|
|
||||||
|
|
||||||
BOOL DebuggerApp::InitInstance(){
|
|
||||||
|
|
||||||
|
BOOL DebuggerApp::InitInstance()
|
||||||
|
{
|
||||||
AfxInitRichEdit();
|
AfxInitRichEdit();
|
||||||
|
|
||||||
main_frame=new MainFrame();
|
main_frame = new MainFrame();
|
||||||
|
|
||||||
m_pMainWnd=main_frame;
|
m_pMainWnd = main_frame;
|
||||||
|
|
||||||
RECT rect;
|
RECT rect;
|
||||||
SystemParametersInfo( SPI_GETWORKAREA,0,&rect,0 );
|
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
|
||||||
|
|
||||||
int x=rect.left;
|
int x = rect.left;
|
||||||
int w=rect.right-x;
|
int w = rect.right - x;
|
||||||
int h=240;
|
int h = 240;
|
||||||
int y=rect.bottom-h;
|
int y = rect.bottom - h;
|
||||||
|
|
||||||
main_frame->Create( 0,"Blitz Debugger",
|
main_frame->Create(0, "Blitz Debugger", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CRect(x, y, x + w, y + h));
|
||||||
WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,
|
main_frame->ShowWindow(SW_SHOW);
|
||||||
CRect( x,y,x+w,y+h ) );
|
|
||||||
main_frame->ShowWindow( SW_SHOW );
|
|
||||||
main_frame->UpdateWindow();
|
main_frame->UpdateWindow();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DebuggerApp::ExitInstance(){
|
int DebuggerApp::ExitInstance()
|
||||||
|
{
|
||||||
main_frame->DestroyWindow();
|
main_frame->DestroyWindow();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainFrame *DebuggerApp::mainFrame(){
|
MainFrame* DebuggerApp::mainFrame()
|
||||||
|
{
|
||||||
return debuggerApp.main_frame;
|
return debuggerApp.main_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debugger * _cdecl debuggerGetDebugger( void *mod,void *env ){
|
Debugger* _cdecl debuggerGetDebugger(void* mod, void* env)
|
||||||
debuggerApp.mainFrame()->setRuntime( mod,env );
|
{
|
||||||
|
debuggerApp.mainFrame()->setRuntime(mod, env);
|
||||||
return debuggerApp.mainFrame();
|
return debuggerApp.mainFrame();
|
||||||
}
|
}
|
||||||
@@ -4,16 +4,16 @@
|
|||||||
|
|
||||||
#include "mainframe.hpp"
|
#include "mainframe.hpp"
|
||||||
|
|
||||||
class DebuggerApp : public CWinApp{
|
class DebuggerApp : public CWinApp {
|
||||||
MainFrame *main_frame;
|
MainFrame* main_frame;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~DebuggerApp();
|
~DebuggerApp();
|
||||||
|
|
||||||
virtual BOOL InitInstance();
|
virtual BOOL InitInstance();
|
||||||
virtual int ExitInstance();
|
virtual int ExitInstance();
|
||||||
|
|
||||||
MainFrame *mainFrame();
|
MainFrame* mainFrame();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern DebuggerApp debuggerApp;
|
extern DebuggerApp debuggerApp;
|
||||||
|
|||||||
+160
-144
@@ -1,225 +1,241 @@
|
|||||||
|
|
||||||
#include "stdafx.hpp"
|
|
||||||
#include "debugtree.hpp"
|
#include "debugtree.hpp"
|
||||||
#include "prefs.hpp"
|
#include "prefs.hpp"
|
||||||
|
#include "stdafx.hpp"
|
||||||
|
|
||||||
//#include "basic.hpp"
|
//#include "basic.hpp"
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC( DebugTree,CTreeCtrl )
|
IMPLEMENT_DYNAMIC(DebugTree, CTreeCtrl)
|
||||||
BEGIN_MESSAGE_MAP( DebugTree,CTreeCtrl )
|
BEGIN_MESSAGE_MAP(DebugTree, CTreeCtrl)
|
||||||
ON_WM_CREATE()
|
ON_WM_CREATE()
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
DebugTree::DebugTree():st_nest(0){
|
DebugTree::DebugTree() : st_nest(0) {}
|
||||||
}
|
|
||||||
|
|
||||||
DebugTree::~DebugTree(){
|
DebugTree::~DebugTree() {}
|
||||||
}
|
|
||||||
|
|
||||||
int DebugTree::OnCreate( LPCREATESTRUCT lpCreateStruct ){
|
int DebugTree::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||||
CTreeCtrl::OnCreate( lpCreateStruct );
|
{
|
||||||
|
CTreeCtrl::OnCreate(lpCreateStruct);
|
||||||
|
|
||||||
SetBkColor( prefs.rgb_bkgrnd );
|
SetBkColor(prefs.rgb_bkgrnd);
|
||||||
SetTextColor( prefs.rgb_default );
|
SetTextColor(prefs.rgb_default);
|
||||||
SetFont( &prefs.debugFont );
|
SetFont(&prefs.debugFont);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string typeTag( Type *t ){
|
static string typeTag(Type* t)
|
||||||
if( t->intType() ) return "";
|
{
|
||||||
if( t->floatType() ) return "#";
|
if (t->intType())
|
||||||
if( t->stringType() ) return "$";
|
return "";
|
||||||
if( StructType *s=t->structType() ) return "."+s->ident;
|
if (t->floatType())
|
||||||
if( VectorType *v=t->vectorType() ){
|
return "#";
|
||||||
string s=typeTag( v->elementType )+"[";
|
if (t->stringType())
|
||||||
for( int k=0;k<v->sizes.size();++k ){
|
return "$";
|
||||||
if( k ) s+=",";
|
if (StructType* s = t->structType())
|
||||||
s+=itoa( v->sizes[k]-1 );
|
return "." + s->ident;
|
||||||
|
if (VectorType* v = t->vectorType()) {
|
||||||
|
string s = typeTag(v->elementType) + "[";
|
||||||
|
for (int k = 0; k < v->sizes.size(); ++k) {
|
||||||
|
if (k)
|
||||||
|
s += ",";
|
||||||
|
s += itoa(v->sizes[k] - 1);
|
||||||
}
|
}
|
||||||
return s+"]";
|
return s + "]";
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
HTREEITEM DebugTree::insertVar( void *var,Decl *d,const string &name,HTREEITEM it,HTREEITEM parent ){
|
HTREEITEM DebugTree::insertVar(void* var, Decl* d, const string& name, HTREEITEM it, HTREEITEM parent)
|
||||||
|
{
|
||||||
|
string s = name;
|
||||||
|
|
||||||
string s=name;
|
ConstType* ct = d->type->constType();
|
||||||
|
StructType* st = d->type->structType();
|
||||||
|
VectorType* vt = d->type->vectorType();
|
||||||
|
|
||||||
ConstType *ct=d->type->constType();
|
if (ct) {
|
||||||
StructType *st=d->type->structType();
|
Type* t = ct->valueType;
|
||||||
VectorType *vt=d->type->vectorType();
|
s += typeTag(t);
|
||||||
|
if (t->intType()) {
|
||||||
if( ct ){
|
s += "=" + itoa(ct->intValue);
|
||||||
Type *t=ct->valueType;
|
} else if (t->floatType()) {
|
||||||
s+=typeTag(t);
|
s += "=" + ftoa(ct->floatValue);
|
||||||
if( t->intType() ){
|
} else if (t->stringType()) {
|
||||||
s+="="+itoa( ct->intValue );
|
s += "=\"" + ct->stringValue + '\"';
|
||||||
}else if( t->floatType() ){
|
|
||||||
s+="="+ftoa( ct->floatValue );
|
|
||||||
}else if( t->stringType() ){
|
|
||||||
s+="=\""+ct->stringValue+'\"';
|
|
||||||
}
|
}
|
||||||
}else if( var ){
|
} else if (var) {
|
||||||
Type *t=d->type;
|
Type* t = d->type;
|
||||||
s+=typeTag( t );
|
s += typeTag(t);
|
||||||
if( t->intType() ){
|
if (t->intType()) {
|
||||||
s+="="+itoa( *(int*)var );
|
s += "=" + itoa(*(int*)var);
|
||||||
}else if( t->floatType() ){
|
} else if (t->floatType()) {
|
||||||
s+="="+ftoa( *(float*)var );
|
s += "=" + ftoa(*(float*)var);
|
||||||
}else if( t->stringType() ){
|
} else if (t->stringType()) {
|
||||||
BBStr *str=*(BBStr**)var;
|
BBStr* str = *(BBStr**)var;
|
||||||
if( str ) s+="=\""+*str+'\"';
|
if (str)
|
||||||
else s+="=\"\"";
|
s += "=\"" + *str + '\"';
|
||||||
}else if( st ){
|
else
|
||||||
var=*(void**)var;
|
s += "=\"\"";
|
||||||
if( var ) var=*(void**)var;
|
} else if (st) {
|
||||||
if( !var ) s+=" (Null)";
|
var = *(void**)var;
|
||||||
|
if (var)
|
||||||
|
var = *(void**)var;
|
||||||
|
if (!var)
|
||||||
|
s += " (Null)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( it ){
|
if (it) {
|
||||||
if( GetItemText( it )!=s.c_str() ){
|
if (GetItemText(it) != s.c_str()) {
|
||||||
SetItemText( it,s.c_str() );
|
SetItemText(it, s.c_str());
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
it=InsertItem( s.c_str(),parent );
|
it = InsertItem(s.c_str(), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
++st_nest;
|
++st_nest;
|
||||||
if( st ){
|
if (st) {
|
||||||
if( var ){
|
if (var) {
|
||||||
if( st_nest<4 ){
|
if (st_nest < 4) {
|
||||||
HTREEITEM st_it=GetChildItem( it );
|
HTREEITEM st_it = GetChildItem(it);
|
||||||
for( int k=0;k<st->fields->size();++k ){
|
for (int k = 0; k < st->fields->size(); ++k) {
|
||||||
Decl *st_d=st->fields->decls[k];
|
Decl* st_d = st->fields->decls[k];
|
||||||
void *st_var=(char*)var+st_d->offset;
|
void* st_var = (char*)var + st_d->offset;
|
||||||
|
|
||||||
char name[256];
|
char name[256];
|
||||||
st_d->getName( name );
|
st_d->getName(name);
|
||||||
|
|
||||||
st_it=insertVar( st_var,st_d,name,st_it,it );
|
st_it = insertVar(st_var, st_d, name, st_it, it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
while( HTREEITEM t=GetChildItem( it ) ){
|
while (HTREEITEM t = GetChildItem(it)) {
|
||||||
DeleteItem( t );
|
DeleteItem(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--st_nest;
|
--st_nest;
|
||||||
|
|
||||||
return it ? GetNextSiblingItem( it ) : 0;
|
return it ? GetNextSiblingItem(it) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************* CONSTS ***********************************/
|
/******************************* CONSTS ***********************************/
|
||||||
|
|
||||||
ConstsTree::ConstsTree(){
|
ConstsTree::ConstsTree() {}
|
||||||
}
|
|
||||||
|
|
||||||
void ConstsTree::reset( Environ *env ){
|
void ConstsTree::reset(Environ* env)
|
||||||
|
{
|
||||||
HTREEITEM it=GetChildItem( TVI_ROOT );
|
HTREEITEM it = GetChildItem(TVI_ROOT);
|
||||||
|
|
||||||
for( int k=0;k<env->decls->size();++k ){
|
|
||||||
|
|
||||||
Decl *d=env->decls->decls[k];
|
|
||||||
if( !(d->kind & (DECL_GLOBAL) ) ) continue;
|
|
||||||
if( d->type->constType() ){
|
|
||||||
|
|
||||||
|
for (int k = 0; k < env->decls->size(); ++k) {
|
||||||
|
Decl* d = env->decls->decls[k];
|
||||||
|
if (!(d->kind & (DECL_GLOBAL)))
|
||||||
|
continue;
|
||||||
|
if (d->type->constType()) {
|
||||||
char name[256];
|
char name[256];
|
||||||
d->getName( name );
|
d->getName(name);
|
||||||
|
|
||||||
it=insertVar( 0,d,name,it,TVI_ROOT );
|
it = insertVar(0, d, name, it, TVI_ROOT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************* GLOBALS **********************************/
|
/******************************* GLOBALS **********************************/
|
||||||
|
|
||||||
GlobalsTree::GlobalsTree():module(0),envron(0){
|
GlobalsTree::GlobalsTree() : module(0), envron(0) {}
|
||||||
|
|
||||||
|
void GlobalsTree::reset(Module* mod, Environ* env)
|
||||||
|
{
|
||||||
|
module = mod;
|
||||||
|
envron = env;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalsTree::reset( Module *mod,Environ *env ){
|
void GlobalsTree::refresh()
|
||||||
module=mod;
|
{
|
||||||
envron=env;
|
if (!module || !envron)
|
||||||
}
|
return;
|
||||||
|
|
||||||
void GlobalsTree::refresh(){
|
HTREEITEM it = GetChildItem(TVI_ROOT);
|
||||||
if( !module || !envron ) return;
|
|
||||||
|
|
||||||
HTREEITEM it=GetChildItem( TVI_ROOT );
|
|
||||||
|
|
||||||
for( int k=0;k<envron->decls->size();++k ){
|
|
||||||
Decl *d=envron->decls->decls[k];
|
|
||||||
if( !(d->kind & (DECL_GLOBAL) ) ) continue;
|
|
||||||
if( !d->type->constType() ){
|
|
||||||
|
|
||||||
|
for (int k = 0; k < envron->decls->size(); ++k) {
|
||||||
|
Decl* d = envron->decls->decls[k];
|
||||||
|
if (!(d->kind & (DECL_GLOBAL)))
|
||||||
|
continue;
|
||||||
|
if (!d->type->constType()) {
|
||||||
char name[256];
|
char name[256];
|
||||||
d->getName( name );
|
d->getName(name);
|
||||||
|
|
||||||
void *var=0;
|
void* var = 0;
|
||||||
module->findSymbol( ("_v"+string(name)).c_str(),(int*)&var );
|
module->findSymbol(("_v" + string(name)).c_str(), (int*)&var);
|
||||||
it=insertVar( var,d,name,it,TVI_ROOT );
|
it = insertVar(var, d, name, it, TVI_ROOT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************** LOCALS **********************************/
|
/******************************** LOCALS **********************************/
|
||||||
|
|
||||||
LocalsTree::LocalsTree():envron(0){
|
LocalsTree::LocalsTree() : envron(0) {}
|
||||||
|
|
||||||
|
void LocalsTree::reset(Environ* env)
|
||||||
|
{
|
||||||
|
envron = env;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalsTree::reset( Environ *env ){
|
void LocalsTree::refresh()
|
||||||
envron=env;
|
{
|
||||||
|
if (!envron || !frames.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
HTREEITEM item = GetChildItem(TVI_ROOT);
|
||||||
|
|
||||||
|
int n = 0;
|
||||||
|
for (n = 0; n < frames.size(); ++n) {
|
||||||
|
if (!item || item != frames[n].item)
|
||||||
|
break;
|
||||||
|
item = GetNextSiblingItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (item) {
|
||||||
|
HTREEITEM next = GetNextSiblingItem(item);
|
||||||
|
DeleteItem(item);
|
||||||
|
item = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; n < frames.size(); ++n) {
|
||||||
|
item = frames[n].item = InsertItem(frames[n].func, TVI_ROOT, TVI_LAST);
|
||||||
|
if (n < frames.size() - 1)
|
||||||
|
refreshFrame(frames[n]);
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshFrame(frames.back());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalsTree::refresh(){
|
void LocalsTree::refreshFrame(const Frame& f)
|
||||||
if( !envron || !frames.size() ) return;
|
{
|
||||||
|
HTREEITEM it = GetChildItem(f.item);
|
||||||
|
|
||||||
HTREEITEM item=GetChildItem( TVI_ROOT );
|
for (int n = 0; n < f.env->decls->size(); ++n) {
|
||||||
|
Decl* d = f.env->decls->decls[n];
|
||||||
int n=0;
|
if (!(d->kind & (DECL_LOCAL | DECL_PARAM)))
|
||||||
for( n=0;n<frames.size();++n ){
|
continue;
|
||||||
if( !item || item!=frames[n].item ) break;
|
|
||||||
item=GetNextSiblingItem( item );
|
|
||||||
}
|
|
||||||
|
|
||||||
while( item ){
|
|
||||||
HTREEITEM next=GetNextSiblingItem( item );
|
|
||||||
DeleteItem( item );
|
|
||||||
item=next;
|
|
||||||
}
|
|
||||||
|
|
||||||
for( ;n<frames.size();++n ){
|
|
||||||
item=frames[n].item=InsertItem( frames[n].func,TVI_ROOT,TVI_LAST );
|
|
||||||
if( n<frames.size()-1 ) refreshFrame( frames[n] );
|
|
||||||
}
|
|
||||||
|
|
||||||
refreshFrame( frames.back() );
|
|
||||||
}
|
|
||||||
|
|
||||||
void LocalsTree::refreshFrame( const Frame &f ){
|
|
||||||
|
|
||||||
HTREEITEM it=GetChildItem( f.item );
|
|
||||||
|
|
||||||
for( int n=0;n<f.env->decls->size();++n ){
|
|
||||||
Decl *d=f.env->decls->decls[n];
|
|
||||||
if( !(d->kind & (DECL_LOCAL|DECL_PARAM) ) ) continue;
|
|
||||||
|
|
||||||
char name[256];
|
char name[256];
|
||||||
d->getName( name );
|
d->getName(name);
|
||||||
|
|
||||||
if( !isalpha( name[0] ) ) continue;
|
if (!isalpha(name[0]))
|
||||||
it=insertVar( (char*)f.frame+d->offset,d,name,it,f.item );
|
continue;
|
||||||
|
it = insertVar((char*)f.frame + d->offset, d, name, it, f.item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalsTree::pushFrame( void *f,void *e,const char *func ){
|
void LocalsTree::pushFrame(void* f, void* e, const char* func)
|
||||||
frames.push_back( Frame( f,(Environ*)e,func ) );
|
{
|
||||||
|
frames.push_back(Frame(f, (Environ*)e, func));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalsTree::popFrame(){
|
void LocalsTree::popFrame()
|
||||||
|
{
|
||||||
frames.pop_back();
|
frames.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+32
-28
@@ -2,69 +2,73 @@
|
|||||||
#ifndef DEBUGTREE_H
|
#ifndef DEBUGTREE_H
|
||||||
#define DEBUGTREE_H
|
#define DEBUGTREE_H
|
||||||
|
|
||||||
#include "linker.hpp"
|
|
||||||
#include "environ.hpp"
|
#include "environ.hpp"
|
||||||
|
#include "linker.hpp"
|
||||||
|
|
||||||
class DebugTree : public CTreeCtrl{
|
class DebugTree : public CTreeCtrl {
|
||||||
int st_nest;
|
int st_nest;
|
||||||
protected:
|
|
||||||
|
|
||||||
HTREEITEM insertVar( void *var,Decl *d,const string &name,HTREEITEM it,HTREEITEM parent );
|
protected:
|
||||||
|
HTREEITEM insertVar(void* var, Decl* d, const string& name, HTREEITEM it, HTREEITEM parent);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DebugTree();
|
DebugTree();
|
||||||
~DebugTree();
|
~DebugTree();
|
||||||
|
|
||||||
DECLARE_DYNAMIC( DebugTree )
|
DECLARE_DYNAMIC(DebugTree)
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
|
|
||||||
afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
|
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConstsTree : public DebugTree{
|
class ConstsTree : public DebugTree {
|
||||||
public:
|
public:
|
||||||
ConstsTree();
|
ConstsTree();
|
||||||
|
|
||||||
void reset( Environ *env );
|
void reset(Environ* env);
|
||||||
};
|
};
|
||||||
|
|
||||||
class GlobalsTree : public DebugTree{
|
class GlobalsTree : public DebugTree {
|
||||||
Module *module;
|
Module* module;
|
||||||
Environ *envron;
|
Environ* envron;
|
||||||
public:
|
|
||||||
|
public:
|
||||||
GlobalsTree();
|
GlobalsTree();
|
||||||
|
|
||||||
void reset( Module *mod,Environ *env );
|
void reset(Module* mod, Environ* env);
|
||||||
|
|
||||||
void refresh();
|
void refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
class LocalsTree : public DebugTree{
|
class LocalsTree : public DebugTree {
|
||||||
Module *module;
|
Module* module;
|
||||||
Environ *envron;
|
Environ* envron;
|
||||||
struct Frame{
|
struct Frame {
|
||||||
void *frame;
|
void* frame;
|
||||||
Environ *env;
|
Environ* env;
|
||||||
const char *func;
|
const char* func;
|
||||||
HTREEITEM item;
|
HTREEITEM item;
|
||||||
Frame( void *f,Environ *e,const char *fn ):frame(f),env(e),func(fn),item(0){}
|
Frame(void* f, Environ* e, const char* fn) : frame(f), env(e), func(fn), item(0) {}
|
||||||
};
|
};
|
||||||
vector<Frame> frames;
|
vector<Frame> frames;
|
||||||
|
|
||||||
void refreshFrame( const Frame &f );
|
void refreshFrame(const Frame& f);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LocalsTree();
|
LocalsTree();
|
||||||
|
|
||||||
void reset( Environ *env );
|
void reset(Environ* env);
|
||||||
|
|
||||||
void refresh();
|
void refresh();
|
||||||
|
|
||||||
void pushFrame( void *frame,void *env,const char *func );
|
void pushFrame(void* frame, void* env, const char* func);
|
||||||
|
|
||||||
void popFrame();
|
void popFrame();
|
||||||
|
|
||||||
int size()const{ return frames.size(); }
|
int size() const
|
||||||
|
{
|
||||||
|
return frames.size();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+199
-186
@@ -1,325 +1,338 @@
|
|||||||
|
|
||||||
#include "stdafx.hpp"
|
|
||||||
#include "mainframe.hpp"
|
#include "mainframe.hpp"
|
||||||
#include "resource.hpp"
|
|
||||||
#include "debuggerapp.hpp"
|
#include "debuggerapp.hpp"
|
||||||
#include "prefs.hpp"
|
#include "prefs.hpp"
|
||||||
|
#include "resource.hpp"
|
||||||
|
#include "stdafx.hpp"
|
||||||
|
|
||||||
#define WM_IDLEUPDATECMDUI 0x0363 // wParam == bDisableIfNoHandler
|
#define WM_IDLEUPDATECMDUI 0x0363 // wParam == bDisableIfNoHandler
|
||||||
|
|
||||||
enum{
|
enum { WM_STOP = WM_USER + 1, WM_RUN, WM_END };
|
||||||
WM_STOP=WM_USER+1,WM_RUN,WM_END
|
|
||||||
};
|
|
||||||
|
|
||||||
enum{
|
enum { STARTING, RUNNING, STOPPED, ENDING };
|
||||||
STARTING,RUNNING,STOPPED,ENDING
|
|
||||||
};
|
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC( MainFrame,CFrameWnd )
|
IMPLEMENT_DYNAMIC(MainFrame, CFrameWnd)
|
||||||
BEGIN_MESSAGE_MAP( MainFrame,CFrameWnd )
|
BEGIN_MESSAGE_MAP(MainFrame, CFrameWnd)
|
||||||
ON_WM_CREATE()
|
ON_WM_CREATE()
|
||||||
ON_WM_SIZE()
|
ON_WM_SIZE()
|
||||||
ON_WM_CLOSE()
|
ON_WM_CLOSE()
|
||||||
ON_WM_WINDOWPOSCHANGING()
|
ON_WM_WINDOWPOSCHANGING()
|
||||||
|
|
||||||
ON_COMMAND( ID_STOP,cmdStop )
|
ON_COMMAND(ID_STOP, cmdStop)
|
||||||
ON_COMMAND( ID_RUN,cmdRun )
|
ON_COMMAND(ID_RUN, cmdRun)
|
||||||
ON_COMMAND( ID_STEPOVER,cmdStepOver )
|
ON_COMMAND(ID_STEPOVER, cmdStepOver)
|
||||||
ON_COMMAND( ID_STEPINTO,cmdStepInto )
|
ON_COMMAND(ID_STEPINTO, cmdStepInto)
|
||||||
ON_COMMAND( ID_STEPOUT,cmdStepOut )
|
ON_COMMAND(ID_STEPOUT, cmdStepOut)
|
||||||
ON_COMMAND( ID_END,cmdEnd )
|
ON_COMMAND(ID_END, cmdEnd)
|
||||||
|
|
||||||
ON_UPDATE_COMMAND_UI( ID_STOP,updateCmdUI )
|
ON_UPDATE_COMMAND_UI(ID_STOP, updateCmdUI)
|
||||||
ON_UPDATE_COMMAND_UI( ID_RUN,updateCmdUI )
|
ON_UPDATE_COMMAND_UI(ID_RUN, updateCmdUI)
|
||||||
ON_UPDATE_COMMAND_UI( ID_STEPOVER,updateCmdUI )
|
ON_UPDATE_COMMAND_UI(ID_STEPOVER, updateCmdUI)
|
||||||
ON_UPDATE_COMMAND_UI( ID_STEPINTO,updateCmdUI )
|
ON_UPDATE_COMMAND_UI(ID_STEPINTO, updateCmdUI)
|
||||||
ON_UPDATE_COMMAND_UI( ID_STEPOUT,updateCmdUI )
|
ON_UPDATE_COMMAND_UI(ID_STEPOUT, updateCmdUI)
|
||||||
ON_UPDATE_COMMAND_UI( ID_END,updateCmdUI )
|
ON_UPDATE_COMMAND_UI(ID_END, updateCmdUI)
|
||||||
|
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
MainFrame::MainFrame():state(STARTING),step_level(-1),cur_pos(0),cur_file(0){
|
MainFrame::MainFrame() : state(STARTING), step_level(-1), cur_pos(0), cur_file(0) {}
|
||||||
|
|
||||||
|
MainFrame::~MainFrame()
|
||||||
|
{
|
||||||
|
map<const char*, SourceFile*>::iterator it;
|
||||||
|
for (it = files.begin(); it != files.end(); ++it)
|
||||||
|
delete it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainFrame::~MainFrame(){
|
int MainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||||
map<const char*,SourceFile*>::iterator it;
|
{
|
||||||
for( it=files.begin();it!=files.end();++it ) delete it->second;
|
CFrameWnd::OnCreate(lpCreateStruct);
|
||||||
}
|
|
||||||
|
|
||||||
int MainFrame::OnCreate( LPCREATESTRUCT lpCreateStruct ){
|
|
||||||
CFrameWnd::OnCreate( lpCreateStruct );
|
|
||||||
|
|
||||||
prefs.open();
|
prefs.open();
|
||||||
|
|
||||||
string tb=prefs.homeDir+"/cfg/dbg_toolbar.bmp";
|
string tb = prefs.homeDir + "/cfg/dbg_toolbar.bmp";
|
||||||
|
|
||||||
//Toolbar
|
//Toolbar
|
||||||
HBITMAP toolbmp=(HBITMAP)LoadImage(
|
HBITMAP toolbmp = (HBITMAP)LoadImage(0, tb.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_LOADMAP3DCOLORS);
|
||||||
0,tb.c_str(),IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_LOADMAP3DCOLORS );
|
|
||||||
|
|
||||||
BITMAP bm;
|
BITMAP bm;
|
||||||
GetObject( toolbmp,sizeof(bm),&bm );
|
GetObject(toolbmp, sizeof(bm), &bm);
|
||||||
|
|
||||||
int n=0;
|
int n = 0;
|
||||||
UINT toolbuts[]={ ID_STOP,ID_RUN,ID_STEPOVER,ID_STEPINTO,ID_STEPOUT,ID_END };
|
UINT toolbuts[] = {ID_STOP, ID_RUN, ID_STEPOVER, ID_STEPINTO, ID_STEPOUT, ID_END};
|
||||||
int toolcnt=sizeof(toolbuts)/sizeof(UINT);
|
int toolcnt = sizeof(toolbuts) / sizeof(UINT);
|
||||||
for( int k=0;k<toolcnt;++k ) if( toolbuts[k]!=ID_SEPARATOR ) ++n;
|
for (int k = 0; k < toolcnt; ++k)
|
||||||
|
if (toolbuts[k] != ID_SEPARATOR)
|
||||||
|
++n;
|
||||||
|
|
||||||
SIZE imgsz,butsz;
|
SIZE imgsz, butsz;
|
||||||
imgsz.cx=bm.bmWidth/n;imgsz.cy=bm.bmHeight;
|
imgsz.cx = bm.bmWidth / n;
|
||||||
butsz.cx=imgsz.cx+7;butsz.cy=imgsz.cy+6;
|
imgsz.cy = bm.bmHeight;
|
||||||
|
butsz.cx = imgsz.cx + 7;
|
||||||
|
butsz.cy = imgsz.cy + 6;
|
||||||
|
|
||||||
toolBar.CreateEx( this,TBSTYLE_FLAT,WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_TOOLTIPS );
|
toolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS);
|
||||||
toolBar.SetBitmap( toolbmp );
|
toolBar.SetBitmap(toolbmp);
|
||||||
toolBar.SetSizes( butsz,imgsz );
|
toolBar.SetSizes(butsz, imgsz);
|
||||||
toolBar.SetButtons( toolbuts,toolcnt );
|
toolBar.SetButtons(toolbuts, toolcnt);
|
||||||
|
|
||||||
//Tabber
|
//Tabber
|
||||||
tabber.Create(
|
tabber.Create(WS_VISIBLE | WS_CHILD | TCS_HOTTRACK, CRect(0, 0, 0, 0), this, 1);
|
||||||
WS_VISIBLE|WS_CHILD|
|
tabber.SetFont(&prefs.tabsFont);
|
||||||
TCS_HOTTRACK,
|
|
||||||
CRect( 0,0,0,0 ),this,1 );
|
|
||||||
tabber.SetFont( &prefs.tabsFont );
|
|
||||||
|
|
||||||
//Second tabber
|
//Second tabber
|
||||||
tabber2.Create(
|
tabber2.Create(WS_VISIBLE | WS_CHILD | TCS_HOTTRACK, CRect(0, 0, 0, 0), this, 2);
|
||||||
WS_VISIBLE|WS_CHILD|
|
tabber2.SetFont(&prefs.tabsFont);
|
||||||
TCS_HOTTRACK,
|
|
||||||
CRect( 0,0,0,0 ),this,2 );
|
|
||||||
tabber2.SetFont( &prefs.tabsFont );
|
|
||||||
|
|
||||||
//Debug Log
|
//Debug Log
|
||||||
debug_log.Create(
|
debug_log.Create(WS_CHILD | WS_HSCROLL | WS_VSCROLL | ES_NOHIDESEL | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
|
||||||
WS_CHILD|WS_HSCROLL|WS_VSCROLL|
|
CRect(0, 0, 0, 0), &tabber, 1);
|
||||||
ES_NOHIDESEL|ES_MULTILINE|ES_AUTOHSCROLL|ES_AUTOVSCROLL,
|
tabber.insert(0, &debug_log, "Debug log");
|
||||||
CRect( 0,0,0,0 ),&tabber,1 );
|
|
||||||
tabber.insert( 0,&debug_log,"Debug log" );
|
|
||||||
|
|
||||||
//Debug trees
|
//Debug trees
|
||||||
locals_tree.Create(
|
locals_tree.Create(WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS, CRect(0, 0, 0, 0),
|
||||||
WS_VISIBLE|WS_CHILD|
|
&tabber2, 3);
|
||||||
TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS,
|
|
||||||
CRect( 0,0,0,0 ),&tabber2,3 );
|
|
||||||
|
|
||||||
globals_tree.Create(
|
globals_tree.Create(WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS, CRect(0, 0, 0, 0),
|
||||||
WS_VISIBLE|WS_CHILD|
|
&tabber2, 3);
|
||||||
TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS,
|
|
||||||
CRect( 0,0,0,0 ),&tabber2,3 );
|
|
||||||
|
|
||||||
consts_tree.Create(
|
consts_tree.Create(WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS, CRect(0, 0, 0, 0),
|
||||||
WS_VISIBLE|WS_CHILD|
|
&tabber2, 3);
|
||||||
TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS,
|
|
||||||
CRect( 0,0,0,0 ),&tabber2,3 );
|
|
||||||
|
|
||||||
tabber2.insert( 0,&locals_tree,"Locals" );
|
tabber2.insert(0, &locals_tree, "Locals");
|
||||||
tabber2.insert( 1,&globals_tree,"Globals" );
|
tabber2.insert(1, &globals_tree, "Globals");
|
||||||
tabber2.insert( 2,&consts_tree,"Consts" );
|
tabber2.insert(2, &consts_tree, "Consts");
|
||||||
tabber2.setCurrent(0);
|
tabber2.setCurrent(0);
|
||||||
|
|
||||||
setState( STARTING );
|
setState(STARTING);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::setState( int n ){
|
void MainFrame::setState(int n)
|
||||||
state=n;
|
{
|
||||||
SendMessageToDescendants( WM_IDLEUPDATECMDUI,(WPARAM)TRUE,0,TRUE,TRUE );
|
state = n;
|
||||||
if( shouldRun() ){
|
SendMessageToDescendants(WM_IDLEUPDATECMDUI, (WPARAM)TRUE, 0, TRUE, TRUE);
|
||||||
if( HWND app=::FindWindow( "Blitz Runtime Class",0 ) ){
|
if (shouldRun()) {
|
||||||
::SetActiveWindow( app );
|
if (HWND app = ::FindWindow("Blitz Runtime Class", 0)) {
|
||||||
|
::SetActiveWindow(app);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
SetActiveWindow();
|
SetActiveWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::OnClose(){
|
void MainFrame::OnClose()
|
||||||
|
{
|
||||||
cmdEnd();
|
cmdEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::OnSize( UINT type,int sw,int sh ){
|
void MainFrame::OnSize(UINT type, int sw, int sh)
|
||||||
CFrameWnd::OnSize( type,sw,sh );
|
{
|
||||||
|
CFrameWnd::OnSize(type, sw, sh);
|
||||||
|
|
||||||
CRect r,t;GetClientRect( &r );
|
CRect r, t;
|
||||||
int x=r.left,y=r.top,w=r.Width(),h=r.Height();
|
GetClientRect(&r);
|
||||||
|
int x = r.left, y = r.top, w = r.Width(), h = r.Height();
|
||||||
|
|
||||||
toolBar.GetWindowRect( &t );y+=t.Height();h-=t.Height();
|
toolBar.GetWindowRect(&t);
|
||||||
|
y += t.Height();
|
||||||
|
h -= t.Height();
|
||||||
|
|
||||||
tabber.MoveWindow( x,y,w-240,h );
|
tabber.MoveWindow(x, y, w - 240, h);
|
||||||
|
|
||||||
tabber2.MoveWindow( x+w-240,y,240,h );
|
tabber2.MoveWindow(x + w - 240, y, 240, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::setRuntime( void *mod,void *env ){
|
void MainFrame::setRuntime(void* mod, void* env)
|
||||||
consts_tree.reset( (Environ*)env );
|
{
|
||||||
globals_tree.reset( (Module*)mod,(Environ*)env );
|
consts_tree.reset((Environ*)env);
|
||||||
locals_tree.reset( (Environ*)env );
|
globals_tree.reset((Module*)mod, (Environ*)env);
|
||||||
|
locals_tree.reset((Environ*)env);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::showCurStmt(){
|
void MainFrame::showCurStmt()
|
||||||
if( !cur_file ) return;
|
{
|
||||||
|
if (!cur_file)
|
||||||
|
return;
|
||||||
|
|
||||||
SourceFile *t=sourceFile(cur_file);
|
SourceFile* t = sourceFile(cur_file);
|
||||||
|
|
||||||
int row=(cur_pos>>16)&0xffff,col=cur_pos&0xffff;
|
int row = (cur_pos >> 16) & 0xffff, col = cur_pos & 0xffff;
|
||||||
t->highLight( row,col );
|
t->highLight(row, col);
|
||||||
|
|
||||||
globals_tree.refresh();
|
globals_tree.refresh();
|
||||||
locals_tree.refresh();
|
locals_tree.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::debugRun(){
|
void MainFrame::debugRun()
|
||||||
setState( RUNNING );
|
{
|
||||||
|
setState(RUNNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::debugStop(){
|
void MainFrame::debugStop()
|
||||||
step_level=locals_tree.size();
|
{
|
||||||
setState( STOPPED );
|
step_level = locals_tree.size();
|
||||||
|
setState(STOPPED);
|
||||||
showCurStmt();
|
showCurStmt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::debugStmt( int pos,const char *file ){
|
void MainFrame::debugStmt(int pos, const char* file)
|
||||||
cur_pos=pos;
|
{
|
||||||
cur_file=file;
|
cur_pos = pos;
|
||||||
|
cur_file = file;
|
||||||
|
|
||||||
if( shouldRun() ) return;
|
if (shouldRun())
|
||||||
|
return;
|
||||||
|
|
||||||
::PostMessage( 0,WM_STOP,0,0 );
|
::PostMessage(0, WM_STOP, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::debugEnter( void *frame,void *env,const char *func ){
|
void MainFrame::debugEnter(void* frame, void* env, const char* func)
|
||||||
locals_tree.pushFrame( frame,env,func );
|
{
|
||||||
|
locals_tree.pushFrame(frame, env, func);
|
||||||
|
|
||||||
if( locals_tree.size()>1 ) return;
|
if (locals_tree.size() > 1)
|
||||||
|
return;
|
||||||
|
|
||||||
globals_tree.refresh();
|
globals_tree.refresh();
|
||||||
locals_tree.refresh();
|
locals_tree.refresh();
|
||||||
|
|
||||||
setState( RUNNING );
|
setState(RUNNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::debugLeave(){
|
void MainFrame::debugLeave()
|
||||||
|
{
|
||||||
locals_tree.popFrame();
|
locals_tree.popFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::debugMsg( const char *msg,bool serious ){
|
void MainFrame::debugMsg(const char* msg, bool serious)
|
||||||
if( serious ){
|
{
|
||||||
::MessageBox( 0,msg,"Runtime Error",MB_OK|MB_ICONWARNING|MB_TOPMOST|MB_SETFOREGROUND );
|
if (serious) {
|
||||||
}else{
|
::MessageBox(0, msg, "Runtime Error", MB_OK | MB_ICONWARNING | MB_TOPMOST | MB_SETFOREGROUND);
|
||||||
::MessageBox( 0,msg,"Runtime Message",MB_OK|MB_ICONINFORMATION|MB_TOPMOST|MB_SETFOREGROUND );
|
} else {
|
||||||
|
::MessageBox(0, msg, "Runtime Message", MB_OK | MB_ICONINFORMATION | MB_TOPMOST | MB_SETFOREGROUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::debugLog( const char *msg ){
|
void MainFrame::debugLog(const char* msg)
|
||||||
debug_log.ReplaceSel( msg );
|
{
|
||||||
debug_log.ReplaceSel( "\n" );
|
debug_log.ReplaceSel(msg);
|
||||||
tabber.setCurrent( 0 );
|
debug_log.ReplaceSel("\n");
|
||||||
setState( state );
|
tabber.setCurrent(0);
|
||||||
|
setState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::debugSys( void *m ){
|
void MainFrame::debugSys(void* m) {}
|
||||||
|
|
||||||
|
void MainFrame::cmdStop()
|
||||||
|
{
|
||||||
|
::PostMessage(0, WM_STOP, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::cmdStop(){
|
void MainFrame::cmdRun()
|
||||||
::PostMessage( 0,WM_STOP,0,0 );
|
{
|
||||||
|
step_level = -1;
|
||||||
|
::PostMessage(0, WM_RUN, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::cmdRun(){
|
void MainFrame::cmdEnd()
|
||||||
step_level=-1;
|
{
|
||||||
::PostMessage( 0,WM_RUN,0,0 );
|
::PostMessage(0, WM_END, 0, 0);
|
||||||
|
setState(ENDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::cmdEnd(){
|
void MainFrame::cmdStepOver()
|
||||||
::PostMessage( 0,WM_END,0,0 );
|
{
|
||||||
setState( ENDING );
|
::PostMessage(0, WM_RUN, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::cmdStepOver(){
|
void MainFrame::cmdStepInto()
|
||||||
::PostMessage( 0,WM_RUN,0,0 );
|
{
|
||||||
|
step_level = locals_tree.size() + 1;
|
||||||
|
::PostMessage(0, WM_RUN, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::cmdStepInto(){
|
void MainFrame::cmdStepOut()
|
||||||
step_level=locals_tree.size()+1;
|
{
|
||||||
::PostMessage( 0,WM_RUN,0,0 );
|
step_level = locals_tree.size() - 1;
|
||||||
|
::PostMessage(0, WM_RUN, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::cmdStepOut(){
|
SourceFile* MainFrame::sourceFile(const char* file)
|
||||||
step_level=locals_tree.size()-1;
|
{
|
||||||
::PostMessage( 0,WM_RUN,0,0 );
|
if (!file)
|
||||||
}
|
file = "<unknown>";
|
||||||
|
|
||||||
SourceFile *MainFrame::sourceFile(const char *file){
|
map<const char*, SourceFile*>::const_iterator it = files.find(file);
|
||||||
|
|
||||||
if( !file ) file="<unknown>";
|
if (it != files.end()) {
|
||||||
|
tabber.setCurrent(file_tabs[file]);
|
||||||
map<const char*,SourceFile*>::const_iterator it=files.find( file );
|
|
||||||
|
|
||||||
if( it!=files.end() ){
|
|
||||||
tabber.setCurrent( file_tabs[file] );
|
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
//crete new source file
|
//crete new source file
|
||||||
SourceFile *t=new SourceFile();
|
SourceFile* t = new SourceFile();
|
||||||
|
|
||||||
it=files.insert( make_pair(file,t) ).first;
|
it = files.insert(make_pair(file, t)).first;
|
||||||
|
|
||||||
int tab=files.size();
|
int tab = files.size();
|
||||||
|
|
||||||
t->Create(
|
t->Create(WS_CHILD | WS_HSCROLL | WS_VSCROLL | ES_NOHIDESEL | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
|
||||||
WS_CHILD|WS_HSCROLL|WS_VSCROLL|
|
CRect(0, 0, 0, 0), &tabber, 1);
|
||||||
ES_NOHIDESEL|ES_MULTILINE|ES_AUTOHSCROLL|ES_AUTOVSCROLL,
|
|
||||||
CRect( 0,0,0,0 ),&tabber,1 );
|
|
||||||
|
|
||||||
if( FILE *f=fopen( file,"rb" ) ){
|
if (FILE* f = fopen(file, "rb")) {
|
||||||
fseek( f,0,SEEK_END );
|
fseek(f, 0, SEEK_END);
|
||||||
int sz=ftell( f );
|
int sz = ftell(f);
|
||||||
fseek( f,0,SEEK_SET );
|
fseek(f, 0, SEEK_SET);
|
||||||
char *buf=new char[sz+1];
|
char* buf = new char[sz + 1];
|
||||||
fread( buf,sz,1,f );
|
fread(buf, sz, 1, f);
|
||||||
buf[sz]=0;
|
buf[sz] = 0;
|
||||||
t->ReplaceSel( buf );
|
t->ReplaceSel(buf);
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
file_tabs.insert( make_pair(file,tab) );
|
file_tabs.insert(make_pair(file, tab));
|
||||||
|
|
||||||
if(const char *p=strrchr(file,'/') ) file=p+1;
|
if (const char* p = strrchr(file, '/'))
|
||||||
if(const char *p=strrchr(file,'\\') ) file=p+1;
|
file = p + 1;
|
||||||
tabber.insert( tab,t,file );
|
if (const char* p = strrchr(file, '\\'))
|
||||||
|
file = p + 1;
|
||||||
|
tabber.insert(tab, t, file);
|
||||||
|
|
||||||
tabber.setCurrent( tab );
|
tabber.setCurrent(tab);
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::updateCmdUI( CCmdUI *ui ){
|
void MainFrame::updateCmdUI(CCmdUI* ui)
|
||||||
if( state!=RUNNING && state!=STOPPED ){
|
{
|
||||||
ui->Enable( false );
|
if (state != RUNNING && state != STOPPED) {
|
||||||
|
ui->Enable(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch( ui->m_nID ){
|
switch (ui->m_nID) {
|
||||||
case ID_STOP:
|
case ID_STOP:
|
||||||
ui->Enable( shouldRun() );
|
ui->Enable(shouldRun());
|
||||||
break;
|
break;
|
||||||
case ID_RUN:
|
case ID_RUN:
|
||||||
case ID_STEPOVER:
|
case ID_STEPOVER:
|
||||||
case ID_STEPINTO:
|
case ID_STEPINTO:
|
||||||
case ID_STEPOUT:
|
case ID_STEPOUT:
|
||||||
ui->Enable( !shouldRun() );
|
ui->Enable(!shouldRun());
|
||||||
break;
|
break;
|
||||||
case ID_END:
|
case ID_END:
|
||||||
ui->Enable( true );
|
ui->Enable(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::OnWindowPosChanging( WINDOWPOS *pos ){
|
void MainFrame::OnWindowPosChanging(WINDOWPOS* pos)
|
||||||
|
{
|
||||||
RECT rect;
|
RECT rect;
|
||||||
SystemParametersInfo( SPI_GETWORKAREA,0,&rect,0 );
|
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
|
||||||
|
|
||||||
pos->x=rect.left;
|
pos->x = rect.left;
|
||||||
pos->cx=rect.right-pos->x;
|
pos->cx = rect.right - pos->x;
|
||||||
pos->cy=rect.bottom-pos->y;
|
pos->cy = rect.bottom - pos->y;
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-23
@@ -2,13 +2,12 @@
|
|||||||
#ifndef MAINFRAME_H
|
#ifndef MAINFRAME_H
|
||||||
#define MAINFRAME_H
|
#define MAINFRAME_H
|
||||||
|
|
||||||
#include "tabber.hpp"
|
|
||||||
#include "debugger.hpp"
|
#include "debugger.hpp"
|
||||||
#include "sourcefile.hpp"
|
|
||||||
#include "debugtree.hpp"
|
#include "debugtree.hpp"
|
||||||
|
#include "sourcefile.hpp"
|
||||||
|
#include "tabber.hpp"
|
||||||
|
|
||||||
class MainFrame : public CFrameWnd,public Debugger{
|
class MainFrame : public CFrameWnd, public Debugger {
|
||||||
|
|
||||||
Tabber tabber;
|
Tabber tabber;
|
||||||
Tabber tabber2;
|
Tabber tabber2;
|
||||||
CToolBar toolBar;
|
CToolBar toolBar;
|
||||||
@@ -16,37 +15,40 @@ class MainFrame : public CFrameWnd,public Debugger{
|
|||||||
ConstsTree consts_tree;
|
ConstsTree consts_tree;
|
||||||
GlobalsTree globals_tree;
|
GlobalsTree globals_tree;
|
||||||
LocalsTree locals_tree;
|
LocalsTree locals_tree;
|
||||||
map<const char*,int> file_tabs;
|
map<const char*, int> file_tabs;
|
||||||
map<const char*,SourceFile*> files;
|
map<const char*, SourceFile*> files;
|
||||||
|
|
||||||
int state,step_level,cur_pos;
|
int state, step_level, cur_pos;
|
||||||
const char *cur_file;
|
const char* cur_file;
|
||||||
|
|
||||||
bool shouldRun()const{ return step_level<locals_tree.size(); }
|
bool shouldRun() const
|
||||||
|
{
|
||||||
|
return step_level < locals_tree.size();
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainFrame();
|
MainFrame();
|
||||||
~MainFrame();
|
~MainFrame();
|
||||||
|
|
||||||
void debugRun();
|
void debugRun();
|
||||||
void debugStop();
|
void debugStop();
|
||||||
void debugStmt( int srcpos,const char *file );
|
void debugStmt(int srcpos, const char* file);
|
||||||
void debugEnter( void *frame,void *env,const char *func );
|
void debugEnter(void* frame, void* env, const char* func);
|
||||||
void debugLeave();
|
void debugLeave();
|
||||||
void debugLog( const char *msg );
|
void debugLog(const char* msg);
|
||||||
void debugMsg( const char *msg,bool serious );
|
void debugMsg(const char* msg, bool serious);
|
||||||
void debugSys( void *msg );
|
void debugSys(void* msg);
|
||||||
|
|
||||||
void showCurStmt();
|
void showCurStmt();
|
||||||
void setState( int n );
|
void setState(int n);
|
||||||
void setRuntime( void *mod,void *env );
|
void setRuntime(void* mod, void* env);
|
||||||
SourceFile *sourceFile(const char*file);
|
SourceFile* sourceFile(const char* file);
|
||||||
|
|
||||||
DECLARE_DYNAMIC( MainFrame )
|
DECLARE_DYNAMIC(MainFrame)
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
|
|
||||||
afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
|
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||||
afx_msg void OnSize( UINT type,int w,int h );
|
afx_msg void OnSize(UINT type, int w, int h);
|
||||||
afx_msg void OnClose();
|
afx_msg void OnClose();
|
||||||
|
|
||||||
afx_msg void cmdStop();
|
afx_msg void cmdStop();
|
||||||
@@ -56,9 +58,9 @@ public:
|
|||||||
afx_msg void cmdStepOut();
|
afx_msg void cmdStepOut();
|
||||||
afx_msg void cmdEnd();
|
afx_msg void cmdEnd();
|
||||||
|
|
||||||
afx_msg void updateCmdUI( CCmdUI *ui );
|
afx_msg void updateCmdUI(CCmdUI* ui);
|
||||||
|
|
||||||
afx_msg void OnWindowPosChanging( WINDOWPOS *pos );
|
afx_msg void OnWindowPosChanging(WINDOWPOS* pos);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+158
-126
@@ -1,78 +1,107 @@
|
|||||||
|
|
||||||
#include "stdafx.hpp"
|
|
||||||
#include "prefs.hpp"
|
#include "prefs.hpp"
|
||||||
#include "debuggerapp.hpp"
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include "debuggerapp.hpp"
|
||||||
|
#include "stdafx.hpp"
|
||||||
|
|
||||||
#define SWAPRB(x) ( (((x)>>16)&0xff) | ((x)&0xff00) | (((x)&0xff)<<16) )
|
#define SWAPRB(x) ((((x) >> 16) & 0xff) | ((x)&0xff00) | (((x)&0xff) << 16))
|
||||||
|
|
||||||
Prefs prefs;
|
Prefs prefs;
|
||||||
|
|
||||||
void Prefs::open(){
|
void Prefs::open()
|
||||||
|
{
|
||||||
|
homeDir = getenv("blitzpath");
|
||||||
|
|
||||||
homeDir=getenv( "blitzpath" );
|
AddFontResource((homeDir + "/cfg/blitz.fon").c_str());
|
||||||
|
|
||||||
AddFontResource( (homeDir+"/cfg/blitz.fon").c_str() );
|
|
||||||
setDefault();
|
setDefault();
|
||||||
|
|
||||||
bool prg_windowed;
|
bool prg_windowed;
|
||||||
|
|
||||||
ifstream in( (homeDir+"/cfg/blitzide.prefs").c_str() );
|
ifstream in((homeDir + "/cfg/blitzide.prefs").c_str());
|
||||||
if( !in.good() ) return;
|
if (!in.good())
|
||||||
|
return;
|
||||||
|
|
||||||
while( !in.eof() ){
|
while (!in.eof()) {
|
||||||
string t;in>>t;
|
string t;
|
||||||
if( !t.size() ) continue;
|
in >> t;
|
||||||
while( in.peek()=='\t' ) in.ignore();
|
if (!t.size())
|
||||||
if( t=="prg_debug" ) in>>prg_debug;
|
continue;
|
||||||
else if( t=="prg_lastbuild" ) getline( in,prg_lastbuild );
|
while (in.peek() == '\t')
|
||||||
else if( t=="prg_windowed" ) in>>prg_windowed;
|
in.ignore();
|
||||||
else if( t=="win_maximized" ) in>>win_maximized;
|
if (t == "prg_debug")
|
||||||
else if( t=="win_notoolbar" ) in>>win_notoolbar;
|
in >> prg_debug;
|
||||||
else if( t=="win_rect" ){
|
else if (t == "prg_lastbuild")
|
||||||
in>>win_rect.left;in>>win_rect.top;
|
getline(in, prg_lastbuild);
|
||||||
in>>win_rect.right;in>>win_rect.bottom;
|
else if (t == "prg_windowed")
|
||||||
}else if( t.substr( 0,5 )=="font_" ){
|
in >> prg_windowed;
|
||||||
string s;int h;in>>s;in>>h;
|
else if (t == "win_maximized")
|
||||||
t=t.substr( 5 );
|
in >> win_maximized;
|
||||||
if( t=="editor" ){
|
else if (t == "win_notoolbar")
|
||||||
font_editor=s;font_editor_height=h;
|
in >> win_notoolbar;
|
||||||
}else if( t=="tabs" ){
|
else if (t == "win_rect") {
|
||||||
font_tabs=s;font_tabs_height=h;
|
in >> win_rect.left;
|
||||||
}else if( t=="debug" ){
|
in >> win_rect.top;
|
||||||
font_debug=s;font_debug_height=h;
|
in >> win_rect.right;
|
||||||
|
in >> win_rect.bottom;
|
||||||
|
} else if (t.substr(0, 5) == "font_") {
|
||||||
|
string s;
|
||||||
|
int h;
|
||||||
|
in >> s;
|
||||||
|
in >> h;
|
||||||
|
t = t.substr(5);
|
||||||
|
if (t == "editor") {
|
||||||
|
font_editor = s;
|
||||||
|
font_editor_height = h;
|
||||||
|
} else if (t == "tabs") {
|
||||||
|
font_tabs = s;
|
||||||
|
font_tabs_height = h;
|
||||||
|
} else if (t == "debug") {
|
||||||
|
font_debug = s;
|
||||||
|
font_debug_height = h;
|
||||||
}
|
}
|
||||||
}else if( t.substr( 0,4 )=="rgb_" ){
|
} else if (t.substr(0, 4) == "rgb_") {
|
||||||
t=t.substr(4);
|
t = t.substr(4);
|
||||||
string s;in>>s;int rgb=0;
|
string s;
|
||||||
for( int k=0;k<s.size();++k ){
|
in >> s;
|
||||||
int n=s[k];rgb=(rgb<<4)|(n<='9'?n-'0':(n&31)+9);
|
int rgb = 0;
|
||||||
|
for (int k = 0; k < s.size(); ++k) {
|
||||||
|
int n = s[k];
|
||||||
|
rgb = (rgb << 4) | (n <= '9' ? n - '0' : (n & 31) + 9);
|
||||||
}
|
}
|
||||||
rgb=SWAPRB(rgb);
|
rgb = SWAPRB(rgb);
|
||||||
|
|
||||||
if( t=="bkgrnd" ) rgb_bkgrnd=rgb;
|
if (t == "bkgrnd")
|
||||||
else if( t=="string" ) rgb_string=rgb;
|
rgb_bkgrnd = rgb;
|
||||||
else if( t=="ident" ) rgb_ident=rgb;
|
else if (t == "string")
|
||||||
else if( t=="keyword" ) rgb_keyword=rgb;
|
rgb_string = rgb;
|
||||||
else if( t=="comment" ) rgb_comment=rgb;
|
else if (t == "ident")
|
||||||
else if( t=="digit" ) rgb_digit=rgb;
|
rgb_ident = rgb;
|
||||||
else if( t=="default" ) rgb_default=rgb;
|
else if (t == "keyword")
|
||||||
}else if( t=="edit_tabs" ){
|
rgb_keyword = rgb;
|
||||||
in>>edit_tabs;
|
else if (t == "comment")
|
||||||
}else if( t=="edit_blkcursor" ){
|
rgb_comment = rgb;
|
||||||
in>>edit_blkcursor;
|
else if (t == "digit")
|
||||||
}else if( t=="edit_backup" ){
|
rgb_digit = rgb;
|
||||||
in>>edit_backup;
|
else if (t == "default")
|
||||||
}else if( t=="img_toolbar" ){
|
rgb_default = rgb;
|
||||||
getline( in,img_toolbar );
|
} else if (t == "edit_tabs") {
|
||||||
}else if( t=="cmd_line" ){
|
in >> edit_tabs;
|
||||||
getline( in,cmd_line );
|
} else if (t == "edit_blkcursor") {
|
||||||
}else if( t=="file_recent" ){
|
in >> edit_blkcursor;
|
||||||
string l;getline( in,l );
|
} else if (t == "edit_backup") {
|
||||||
if( recentFiles.size()<10 ) recentFiles.push_back( l );
|
in >> edit_backup;
|
||||||
}else{
|
} else if (t == "img_toolbar") {
|
||||||
string s="Unrecognized option '"+t+"' in blitzide.prefs";
|
getline(in, img_toolbar);
|
||||||
MessageBox( 0,s.c_str(),"Error in preferences",MB_OK );
|
} else if (t == "cmd_line") {
|
||||||
|
getline(in, cmd_line);
|
||||||
|
} else if (t == "file_recent") {
|
||||||
|
string l;
|
||||||
|
getline(in, l);
|
||||||
|
if (recentFiles.size() < 10)
|
||||||
|
recentFiles.push_back(l);
|
||||||
|
} else {
|
||||||
|
string s = "Unrecognized option '" + t + "' in blitzide.prefs";
|
||||||
|
MessageBox(0, s.c_str(), "Error in preferences", MB_OK);
|
||||||
setDefault();
|
setDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -80,95 +109,98 @@ void Prefs::open(){
|
|||||||
createFonts();
|
createFonts();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Prefs::close(){
|
void Prefs::close()
|
||||||
|
{
|
||||||
|
ofstream out((homeDir + "cfg\\blitzide.prefs").c_str());
|
||||||
|
if (!out.good())
|
||||||
|
return;
|
||||||
|
|
||||||
ofstream out( (homeDir+"cfg\\blitzide.prefs").c_str() );
|
out << "prg_debug\t" << prg_debug << endl;
|
||||||
if( !out.good() ) return;
|
out << "prg_lastbuild\t" << prg_lastbuild << endl;
|
||||||
|
out << "win_maximized\t" << win_maximized << endl;
|
||||||
out<<"prg_debug\t"<<prg_debug<<endl;
|
out << "win_notoolbar\t" << win_notoolbar << endl;
|
||||||
out<<"prg_lastbuild\t"<<prg_lastbuild<<endl;
|
out << "win_rect\t" << win_rect.left << ' ' << win_rect.top << ' ' << win_rect.right << ' ' << win_rect.bottom
|
||||||
out<<"win_maximized\t"<<win_maximized<<endl;
|
<< endl;
|
||||||
out<<"win_notoolbar\t"<<win_notoolbar<<endl;
|
out << "font_editor\t" << font_editor << ' ' << font_editor_height << endl;
|
||||||
out<<"win_rect\t"<<win_rect.left<<' '<<win_rect.top<<' '<<win_rect.right<<' '<<win_rect.bottom<<endl;
|
out << "font_tabs\t" << font_tabs << ' ' << font_tabs_height << endl;
|
||||||
out<<"font_editor\t"<<font_editor<<' '<<font_editor_height<<endl;
|
out << "font_debug\t" << font_debug << ' ' << font_debug_height << endl;
|
||||||
out<<"font_tabs\t"<<font_tabs<<' '<<font_tabs_height<<endl;
|
out << hex;
|
||||||
out<<"font_debug\t"<<font_debug<<' '<<font_debug_height<<endl;
|
out << "rgb_bkgrnd\t" << SWAPRB(rgb_bkgrnd) << endl;
|
||||||
out<<hex;
|
out << "rgb_string\t" << SWAPRB(rgb_string) << endl;
|
||||||
out<<"rgb_bkgrnd\t"<<SWAPRB(rgb_bkgrnd)<<endl;
|
out << "rgb_ident\t" << SWAPRB(rgb_ident) << endl;
|
||||||
out<<"rgb_string\t"<<SWAPRB(rgb_string)<<endl;
|
out << "rgb_keyword\t" << SWAPRB(rgb_keyword) << endl;
|
||||||
out<<"rgb_ident\t"<<SWAPRB(rgb_ident)<<endl;
|
out << "rgb_comment\t" << SWAPRB(rgb_comment) << endl;
|
||||||
out<<"rgb_keyword\t"<<SWAPRB(rgb_keyword)<<endl;
|
out << "rgb_digit\t" << SWAPRB(rgb_digit) << endl;
|
||||||
out<<"rgb_comment\t"<<SWAPRB(rgb_comment)<<endl;
|
out << "rgb_default\t" << SWAPRB(rgb_default) << endl;
|
||||||
out<<"rgb_digit\t"<<SWAPRB(rgb_digit)<<endl;
|
out << "edit_tabs\t" << edit_tabs << endl;
|
||||||
out<<"rgb_default\t"<<SWAPRB(rgb_default)<<endl;
|
out << "edit_blkcursor\t" << edit_blkcursor << endl;
|
||||||
out<<"edit_tabs\t"<<edit_tabs<<endl;
|
out << "edit_backup\t" << edit_backup << endl;
|
||||||
out<<"edit_blkcursor\t"<<edit_blkcursor<<endl;
|
out << "img_toolbar\t" << img_toolbar << endl;
|
||||||
out<<"edit_backup\t"<<edit_backup<<endl;
|
out << "cmd_line\t" << cmd_line << endl;
|
||||||
out<<"img_toolbar\t"<<img_toolbar<<endl;
|
for (int k = 0; k < recentFiles.size(); ++k) {
|
||||||
out<<"cmd_line\t"<<cmd_line<<endl;
|
out << "file_recent\t" << recentFiles[k] << endl;
|
||||||
for( int k=0;k<recentFiles.size();++k ){
|
|
||||||
out<<"file_recent\t"<<recentFiles[k]<<endl;
|
|
||||||
}
|
}
|
||||||
out<<dec;
|
out << dec;
|
||||||
|
|
||||||
RemoveFontResource( (homeDir+"cfg\\blitz.fon").c_str() );
|
RemoveFontResource((homeDir + "cfg\\blitz.fon").c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Prefs::setDefault(){
|
void Prefs::setDefault()
|
||||||
|
{
|
||||||
|
prg_debug = true;
|
||||||
|
|
||||||
prg_debug=true;
|
win_rect.left = win_rect.top = 0;
|
||||||
|
win_rect.right = 640;
|
||||||
|
win_rect.bottom = 480;
|
||||||
|
win_maximized = false;
|
||||||
|
win_notoolbar = false;
|
||||||
|
|
||||||
win_rect.left=win_rect.top=0;
|
font_editor = "blitz";
|
||||||
win_rect.right=640;win_rect.bottom=480;
|
font_editor_height = 12;
|
||||||
win_maximized=false;
|
font_tabs = "verdana";
|
||||||
win_notoolbar=false;
|
font_tabs_height = 8;
|
||||||
|
font_debug = "verdana";
|
||||||
font_editor="blitz";
|
font_debug_height = 8;
|
||||||
font_editor_height=12;
|
|
||||||
font_tabs="verdana";
|
|
||||||
font_tabs_height=8;
|
|
||||||
font_debug="verdana";
|
|
||||||
font_debug_height=8;
|
|
||||||
|
|
||||||
#ifdef PRO
|
#ifdef PRO
|
||||||
rgb_bkgrnd=RGB( 0x22,0x55,0x88 );
|
rgb_bkgrnd = RGB(0x22, 0x55, 0x88);
|
||||||
rgb_string=RGB( 0x00,0xff,0x66 );
|
rgb_string = RGB(0x00, 0xff, 0x66);
|
||||||
rgb_ident=RGB( 0xff,0xff,0xff );
|
rgb_ident = RGB(0xff, 0xff, 0xff);
|
||||||
rgb_keyword=RGB( 0xaa,0xff,0xff );
|
rgb_keyword = RGB(0xaa, 0xff, 0xff);
|
||||||
rgb_comment=RGB( 0xff,0xee,0x00 );
|
rgb_comment = RGB(0xff, 0xee, 0x00);
|
||||||
rgb_digit=RGB( 0x33,0xff,0xdd );
|
rgb_digit = RGB(0x33, 0xff, 0xdd);
|
||||||
rgb_default=RGB( 0xee,0xee,0xee );
|
rgb_default = RGB(0xee, 0xee, 0xee);
|
||||||
rgb_unsel=RGB( 0x88,0x88,0x88 );
|
rgb_unsel = RGB(0x88, 0x88, 0x88);
|
||||||
#else
|
#else
|
||||||
rgb_bkgrnd=RGB( 32,96,96 );
|
rgb_bkgrnd = RGB(32, 96, 96);
|
||||||
rgb_string=RGB( 0,255,0 );
|
rgb_string = RGB(0, 255, 0);
|
||||||
rgb_ident=RGB( 255,255,255 );
|
rgb_ident = RGB(255, 255, 255);
|
||||||
rgb_keyword=RGB( 255,231,95 );
|
rgb_keyword = RGB(255, 231, 95);
|
||||||
rgb_comment=RGB( 0,255,255 );
|
rgb_comment = RGB(0, 255, 255);
|
||||||
rgb_digit=RGB( 200,240,255 );
|
rgb_digit = RGB(200, 240, 255);
|
||||||
rgb_default=RGB( 255,240,200 );
|
rgb_default = RGB(255, 240, 200);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
edit_tabs=4;
|
edit_tabs = 4;
|
||||||
edit_blkcursor=false;
|
edit_blkcursor = false;
|
||||||
edit_backup=2;
|
edit_backup = 2;
|
||||||
|
|
||||||
img_toolbar="toolbar.bmp";
|
img_toolbar = "toolbar.bmp";
|
||||||
|
|
||||||
recentFiles.clear();
|
recentFiles.clear();
|
||||||
|
|
||||||
createFonts();
|
createFonts();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Prefs::createFonts(){
|
void Prefs::createFonts()
|
||||||
|
{
|
||||||
editFont.Detach();
|
editFont.Detach();
|
||||||
tabsFont.Detach();
|
tabsFont.Detach();
|
||||||
debugFont.Detach();
|
debugFont.Detach();
|
||||||
conFont.Detach();
|
conFont.Detach();
|
||||||
|
|
||||||
editFont.CreatePointFont( font_editor_height*10,font_editor.c_str() );
|
editFont.CreatePointFont(font_editor_height * 10, font_editor.c_str());
|
||||||
tabsFont.CreatePointFont( font_tabs_height*10,font_tabs.c_str() );
|
tabsFont.CreatePointFont(font_tabs_height * 10, font_tabs.c_str());
|
||||||
debugFont.CreatePointFont( font_debug_height*10,font_debug.c_str() );
|
debugFont.CreatePointFont(font_debug_height * 10, font_debug.c_str());
|
||||||
conFont.CreatePointFont( 80,"courier" );
|
conFont.CreatePointFont(80, "courier");
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-7
@@ -2,8 +2,8 @@
|
|||||||
#ifndef PREFS_H
|
#ifndef PREFS_H
|
||||||
#define PREFS_H
|
#define PREFS_H
|
||||||
|
|
||||||
class Prefs{
|
class Prefs {
|
||||||
public:
|
public:
|
||||||
bool prg_debug;
|
bool prg_debug;
|
||||||
string prg_lastbuild;
|
string prg_lastbuild;
|
||||||
|
|
||||||
@@ -11,8 +11,8 @@ public:
|
|||||||
bool win_maximized;
|
bool win_maximized;
|
||||||
bool win_notoolbar;
|
bool win_notoolbar;
|
||||||
|
|
||||||
string font_editor,font_tabs,font_debug;
|
string font_editor, font_tabs, font_debug;
|
||||||
int font_editor_height,font_tabs_height,font_debug_height;
|
int font_editor_height, font_tabs_height, font_debug_height;
|
||||||
|
|
||||||
int rgb_bkgrnd; //0
|
int rgb_bkgrnd; //0
|
||||||
int rgb_string; //1
|
int rgb_string; //1
|
||||||
@@ -31,7 +31,7 @@ public:
|
|||||||
string img_toolbar;
|
string img_toolbar;
|
||||||
|
|
||||||
string homeDir;
|
string homeDir;
|
||||||
CFont conFont,editFont,tabsFont,debugFont;
|
CFont conFont, editFont, tabsFont, debugFont;
|
||||||
|
|
||||||
vector<string> recentFiles;
|
vector<string> recentFiles;
|
||||||
|
|
||||||
@@ -40,8 +40,7 @@ public:
|
|||||||
void open();
|
void open();
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void setDefault();
|
void setDefault();
|
||||||
void createFonts();
|
void createFonts();
|
||||||
};
|
};
|
||||||
|
|||||||
+33
-31
@@ -1,51 +1,53 @@
|
|||||||
|
|
||||||
#include "stdafx.hpp"
|
|
||||||
#include "sourcefile.hpp"
|
#include "sourcefile.hpp"
|
||||||
#include "prefs.hpp"
|
#include "prefs.hpp"
|
||||||
|
#include "stdafx.hpp"
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC( SourceFile,CRichEditCtrl )
|
IMPLEMENT_DYNAMIC(SourceFile, CRichEditCtrl)
|
||||||
BEGIN_MESSAGE_MAP( SourceFile,CRichEditCtrl )
|
BEGIN_MESSAGE_MAP(SourceFile, CRichEditCtrl)
|
||||||
ON_WM_CREATE()
|
ON_WM_CREATE()
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
SourceFile::SourceFile(){
|
SourceFile::SourceFile() {}
|
||||||
}
|
|
||||||
|
|
||||||
SourceFile::~SourceFile(){
|
SourceFile::~SourceFile() {}
|
||||||
}
|
|
||||||
|
|
||||||
int SourceFile::OnCreate( LPCREATESTRUCT lpCreateStruct ){
|
int SourceFile::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||||
CRichEditCtrl::OnCreate( lpCreateStruct );
|
{
|
||||||
|
CRichEditCtrl::OnCreate(lpCreateStruct);
|
||||||
|
|
||||||
SetReadOnly( true );
|
SetReadOnly(true);
|
||||||
SetFont( &prefs.editFont );
|
SetFont(&prefs.editFont);
|
||||||
SetBackgroundColor( false,prefs.rgb_bkgrnd );
|
SetBackgroundColor(false, prefs.rgb_bkgrnd);
|
||||||
|
|
||||||
CHARFORMAT fmt={sizeof( fmt )};
|
CHARFORMAT fmt = {sizeof(fmt)};
|
||||||
fmt.dwMask=CFM_COLOR;
|
fmt.dwMask = CFM_COLOR;
|
||||||
fmt.crTextColor=prefs.rgb_default;
|
fmt.crTextColor = prefs.rgb_default;
|
||||||
|
|
||||||
SetSel( 0,-1 );
|
SetSel(0, -1);
|
||||||
SetDefaultCharFormat( fmt );
|
SetDefaultCharFormat(fmt);
|
||||||
SetSelectionCharFormat( fmt );
|
SetSelectionCharFormat(fmt);
|
||||||
SetSel( 0,0 );
|
SetSel(0, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SourceFile::highLight( int row,int col ){
|
void SourceFile::highLight(int row, int col)
|
||||||
int pos=LineIndex( row )+col;
|
{
|
||||||
HideSelection( true,false );
|
int pos = LineIndex(row) + col;
|
||||||
bool quote=false;
|
HideSelection(true, false);
|
||||||
int end=pos,len=GetTextLength();
|
bool quote = false;
|
||||||
while( end<len ){
|
int end = pos, len = GetTextLength();
|
||||||
SetSel( end,end+1 );
|
while (end < len) {
|
||||||
|
SetSel(end, end + 1);
|
||||||
auto txt = GetSelText();
|
auto txt = GetSelText();
|
||||||
|
|
||||||
if( txt[0]=='\"' ) quote=!quote;
|
if (txt[0] == '\"')
|
||||||
if( !quote && (txt[0]==':' || !isprint(txt[0] )) ) break;
|
quote = !quote;
|
||||||
|
if (!quote && (txt[0] == ':' || !isprint(txt[0])))
|
||||||
|
break;
|
||||||
++end;
|
++end;
|
||||||
}
|
}
|
||||||
HideSelection( false,false );
|
HideSelection(false, false);
|
||||||
SetSel( pos,end );
|
SetSel(pos, end);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,17 +2,17 @@
|
|||||||
#ifndef SOURCEFILE_H
|
#ifndef SOURCEFILE_H
|
||||||
#define SOURCEFILE_H
|
#define SOURCEFILE_H
|
||||||
|
|
||||||
class SourceFile : public CRichEditCtrl{
|
class SourceFile : public CRichEditCtrl {
|
||||||
public:
|
public:
|
||||||
SourceFile();
|
SourceFile();
|
||||||
~SourceFile();
|
~SourceFile();
|
||||||
|
|
||||||
void highLight( int row,int col );
|
void highLight(int row, int col);
|
||||||
|
|
||||||
DECLARE_DYNAMIC( SourceFile )
|
DECLARE_DYNAMIC(SourceFile)
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
|
|
||||||
afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
|
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+13
-13
@@ -2,28 +2,28 @@
|
|||||||
#ifndef STDAFX_H
|
#ifndef STDAFX_H
|
||||||
#define STDAFX_H
|
#define STDAFX_H
|
||||||
|
|
||||||
#pragma warning(disable:4786)
|
#pragma warning(disable : 4786)
|
||||||
|
|
||||||
#include <afxwin.h> // Core
|
|
||||||
#include <afxcmn.h> // Common Controls
|
#include <afxcmn.h> // Common Controls
|
||||||
#include <afxrich.h> // CRich edit
|
#include <afxrich.h> // CRich edit
|
||||||
|
#include <afxwin.h> // Core
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
//some stuff that should be in std libs
|
//some stuff that should be in std libs
|
||||||
int atoi( const string &s );
|
int atoi(const string& s);
|
||||||
double atof( const string &s );
|
double atof(const string& s);
|
||||||
string itoa( int n );
|
string itoa(int n);
|
||||||
string ftoa( float n );
|
string ftoa(float n);
|
||||||
string tolower( const string &s );
|
string tolower(const string& s);
|
||||||
string toupper( const string &s );
|
string toupper(const string& s);
|
||||||
string fullfilename( const string &t );
|
string fullfilename(const string& t);
|
||||||
string filenamepath( const string &t );
|
string filenamepath(const string& t);
|
||||||
string filenamefile( const string &t );
|
string filenamefile(const string& t);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+64
-54
@@ -1,17 +1,21 @@
|
|||||||
|
|
||||||
#include "stdafx.hpp"
|
#include "stdafx.hpp"
|
||||||
|
|
||||||
int atoi( const string &s ){
|
int atoi(const string& s)
|
||||||
return atoi( s.c_str() );
|
{
|
||||||
|
return atoi(s.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
double atof( const string &s ){
|
double atof(const string& s)
|
||||||
return atof( s.c_str() );
|
{
|
||||||
|
return atof(s.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
string itoa( int n ){
|
string itoa(int n)
|
||||||
char buff[32]; _itoa( n,buff,10 );
|
{
|
||||||
return string( buff );
|
char buff[32];
|
||||||
|
_itoa(n, buff, 10);
|
||||||
|
return string(buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
//static int _finite( double n ){ // definition: exponent anything but 2047.
|
//static int _finite( double n ){ // definition: exponent anything but 2047.
|
||||||
@@ -50,9 +54,9 @@ string itoa( int n ){
|
|||||||
/////////////
|
/////////////
|
||||||
//By FLOYD!//
|
//By FLOYD!//
|
||||||
/////////////
|
/////////////
|
||||||
string ftoa( float n ){
|
string ftoa(float n)
|
||||||
|
{
|
||||||
static const int digits=6;
|
static const int digits = 6;
|
||||||
|
|
||||||
int eNeg = -4, ePos = 8; // limits for e notation.
|
int eNeg = -4, ePos = 8; // limits for e notation.
|
||||||
|
|
||||||
@@ -60,16 +64,14 @@ string ftoa( float n ){
|
|||||||
string t;
|
string t;
|
||||||
int dec, sign;
|
int dec, sign;
|
||||||
|
|
||||||
if ( _finite( n ) ){
|
if (_finite(n)) {
|
||||||
|
// if ( digits < 1 ) digits = 1; // less than one digit is nonsense
|
||||||
|
// if ( digits > 8 ) digits = 8; // practical maximum for float
|
||||||
|
|
||||||
// if ( digits < 1 ) digits = 1; // less than one digit is nonsense
|
t = _ecvt(n, digits, &dec, &sign);
|
||||||
// if ( digits > 8 ) digits = 8; // practical maximum for float
|
|
||||||
|
|
||||||
t = _ecvt( n, digits, &dec, &sign );
|
if (dec <= eNeg + 1 || dec > ePos) {
|
||||||
|
_gcvt(n, digits, buffer);
|
||||||
if ( dec <= eNeg + 1 || dec > ePos ){
|
|
||||||
|
|
||||||
_gcvt( n, digits, buffer );
|
|
||||||
t = buffer;
|
t = buffer;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
@@ -77,37 +79,35 @@ string ftoa( float n ){
|
|||||||
// Here is the tricky case. We want a nicely formatted
|
// Here is the tricky case. We want a nicely formatted
|
||||||
// number with no e-notation or multiple trailing zeroes.
|
// number with no e-notation or multiple trailing zeroes.
|
||||||
|
|
||||||
if ( dec <= 0 ){
|
if (dec <= 0) {
|
||||||
|
t = "0." + string(-dec, '0') + t;
|
||||||
t = "0." + string( -dec, '0' ) + t;
|
|
||||||
dec = 1; // new location for decimal point
|
dec = 1; // new location for decimal point
|
||||||
|
|
||||||
}
|
} else if (dec < digits) {
|
||||||
else if( dec < digits ){
|
t = t.substr(0, dec) + "." + t.substr(dec);
|
||||||
|
|
||||||
t = t.substr( 0, dec ) + "." + t.substr( dec );
|
} else {
|
||||||
|
t = t + string(dec - digits, '0') + ".0";
|
||||||
}
|
|
||||||
else{
|
|
||||||
|
|
||||||
t = t + string( dec - digits, '0' ) + ".0";
|
|
||||||
dec += dec - digits;
|
dec += dec - digits;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, trim off excess zeroes.
|
// Finally, trim off excess zeroes.
|
||||||
|
|
||||||
int dp1 = dec + 1, p = t.length();
|
int dp1 = dec + 1, p = t.length();
|
||||||
while( --p > dp1 && t[p] == '0' );
|
while (--p > dp1 && t[p] == '0')
|
||||||
t = string( t, 0, ++p );
|
;
|
||||||
|
t = string(t, 0, ++p);
|
||||||
|
|
||||||
return sign ? "-" + t : t;
|
return sign ? "-" + t : t;
|
||||||
|
|
||||||
} // end of finite case
|
} // end of finite case
|
||||||
|
|
||||||
if ( _isnan( n ) ) return "NaN";
|
if (_isnan(n))
|
||||||
if ( n > 0.0 ) return "Infinity";
|
return "NaN";
|
||||||
if ( n < 0.0 ) return "-Infinity";
|
if (n > 0.0)
|
||||||
|
return "Infinity";
|
||||||
|
if (n < 0.0)
|
||||||
|
return "-Infinity";
|
||||||
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
@@ -149,34 +149,44 @@ string ftoa( float n ){
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
string tolower( const string &s ){
|
string tolower(const string& s)
|
||||||
string t=s;
|
{
|
||||||
for( int k=0;k<t.size();++k ) t[k]=tolower(t[k]);
|
string t = s;
|
||||||
|
for (int k = 0; k < t.size(); ++k)
|
||||||
|
t[k] = tolower(t[k]);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
string toupper( const string &s ){
|
string toupper(const string& s)
|
||||||
string t=s;
|
{
|
||||||
for( int k=0;k<t.size();++k ) t[k]=toupper(t[k]);
|
string t = s;
|
||||||
|
for (int k = 0; k < t.size(); ++k)
|
||||||
|
t[k] = toupper(t[k]);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
string fullfilename( const string &t ){
|
string fullfilename(const string& t)
|
||||||
char buff[MAX_PATH+1],*p;
|
{
|
||||||
GetFullPathName( t.c_str(),MAX_PATH,buff,&p );
|
char buff[MAX_PATH + 1], *p;
|
||||||
|
GetFullPathName(t.c_str(), MAX_PATH, buff, &p);
|
||||||
return string(buff);
|
return string(buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
string filenamepath( const string &t ){
|
string filenamepath(const string& t)
|
||||||
char buff[MAX_PATH+1],*p;
|
{
|
||||||
GetFullPathName( t.c_str(),MAX_PATH,buff,&p );
|
char buff[MAX_PATH + 1], *p;
|
||||||
if( !p ) return "";
|
GetFullPathName(t.c_str(), MAX_PATH, buff, &p);
|
||||||
*p=0;return string(buff);
|
if (!p)
|
||||||
|
return "";
|
||||||
|
*p = 0;
|
||||||
|
return string(buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
string filenamefile( const string &t ){
|
string filenamefile(const string& t)
|
||||||
char buff[MAX_PATH+1],*p;
|
{
|
||||||
GetFullPathName( t.c_str(),MAX_PATH,buff,&p );
|
char buff[MAX_PATH + 1], *p;
|
||||||
if( !p ) return "";
|
GetFullPathName(t.c_str(), MAX_PATH, buff, &p);
|
||||||
return string( p );
|
if (!p)
|
||||||
|
return "";
|
||||||
|
return string(p);
|
||||||
}
|
}
|
||||||
|
|||||||
+141
-93
@@ -1,162 +1,210 @@
|
|||||||
|
|
||||||
#include "stdafx.hpp"
|
|
||||||
#include "tabber.hpp"
|
#include "tabber.hpp"
|
||||||
#include <WinUser.h>
|
#include <WinUser.h>
|
||||||
|
#include "stdafx.hpp"
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC( Tabber,CTabCtrl )
|
IMPLEMENT_DYNAMIC(Tabber, CTabCtrl)
|
||||||
BEGIN_MESSAGE_MAP( Tabber,CTabCtrl )
|
BEGIN_MESSAGE_MAP(Tabber, CTabCtrl)
|
||||||
ON_WM_SIZE()
|
ON_WM_SIZE()
|
||||||
ON_WM_ERASEBKGND()
|
ON_WM_ERASEBKGND()
|
||||||
ON_NOTIFY_REFLECT( TCN_SELCHANGE,tcn_selChange )
|
ON_NOTIFY_REFLECT(TCN_SELCHANGE, tcn_selChange)
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
static CRect tabsRect( CTabCtrl &t ){
|
static CRect tabsRect(CTabCtrl& t)
|
||||||
CRect r(0,0,0,0);
|
{
|
||||||
int n=t.GetItemCount();
|
CRect r(0, 0, 0, 0);
|
||||||
for( int k=0;k<n;++k ){
|
int n = t.GetItemCount();
|
||||||
|
for (int k = 0; k < n; ++k) {
|
||||||
CRect c;
|
CRect c;
|
||||||
t.GetItemRect( k,&c );
|
t.GetItemRect(k, &c);
|
||||||
if( c.left<r.left ) r.left=c.left;
|
if (c.left < r.left)
|
||||||
if( c.right>r.right ) r.right=c.right;
|
r.left = c.left;
|
||||||
if( c.top<r.top ) r.top=c.top;
|
if (c.right > r.right)
|
||||||
if( c.bottom>r.bottom ) r.bottom=c.bottom;
|
r.right = c.right;
|
||||||
|
if (c.top < r.top)
|
||||||
|
r.top = c.top;
|
||||||
|
if (c.bottom > r.bottom)
|
||||||
|
r.bottom = c.bottom;
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
CRect Tabber::getInnerRect(){
|
CRect Tabber::getInnerRect()
|
||||||
|
{
|
||||||
CRect r;
|
CRect r;
|
||||||
GetClientRect( &r );
|
GetClientRect(&r);
|
||||||
int x=2,y=2,w=r.Width()-4,h=r.Height()-4;
|
int x = 2, y = 2, w = r.Width() - 4, h = r.Height() - 4;
|
||||||
|
|
||||||
r=tabsRect( *this );
|
r = tabsRect(*this);
|
||||||
h-=r.Height();y+=r.Height();
|
h -= r.Height();
|
||||||
|
y += r.Height();
|
||||||
|
|
||||||
r.left=x;r.top=y;r.right=x+w;r.bottom=y+h;
|
r.left = x;
|
||||||
|
r.top = y;
|
||||||
|
r.right = x + w;
|
||||||
|
r.bottom = y + h;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tabber::Tabber():
|
Tabber::Tabber() : listener(0), curr(-1) {}
|
||||||
listener(0),curr(-1){
|
|
||||||
|
Tabber::~Tabber()
|
||||||
|
{
|
||||||
|
for (; tabs.size(); tabs.pop_back())
|
||||||
|
delete tabs.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
Tabber::~Tabber(){
|
void Tabber::OnSize(UINT type, int w, int h)
|
||||||
for( ;tabs.size();tabs.pop_back() ) delete tabs.back();
|
{
|
||||||
}
|
CTabCtrl::OnSize(type, w, h);
|
||||||
|
|
||||||
void Tabber::OnSize( UINT type,int w,int h ){
|
|
||||||
CTabCtrl::OnSize( type,w,h );
|
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Tabber::OnEraseBkgnd( CDC *dc ){
|
BOOL Tabber::OnEraseBkgnd(CDC* dc)
|
||||||
CRect c;GetClientRect( &c );
|
{
|
||||||
|
CRect c;
|
||||||
|
GetClientRect(&c);
|
||||||
|
|
||||||
HBRUSH hb=(HBRUSH)GetClassLong( m_hWnd,GCL_HBRBACKGROUND );
|
HBRUSH hb = (HBRUSH)GetClassLong(m_hWnd, GCL_HBRBACKGROUND);
|
||||||
CBrush br;br.Attach( hb );
|
CBrush br;
|
||||||
|
br.Attach(hb);
|
||||||
|
|
||||||
if( curr<0 ) dc->FillRect( &c,&br );
|
if (curr < 0)
|
||||||
else{
|
dc->FillRect(&c, &br);
|
||||||
CRect i=getInnerRect();
|
else {
|
||||||
CRect t( c.left,c.top,i.right,i.top );dc->FillRect( &t,&br );
|
CRect i = getInnerRect();
|
||||||
CRect r( i.right,c.top,c.right,i.bottom );dc->FillRect( &r,&br );
|
CRect t(c.left, c.top, i.right, i.top);
|
||||||
CRect b( i.left,i.bottom,c.right,c.bottom );dc->FillRect( &b,&br );
|
dc->FillRect(&t, &br);
|
||||||
CRect l( c.left,i.top,i.left,c.bottom );dc->FillRect( &l,&br );
|
CRect r(i.right, c.top, c.right, i.bottom);
|
||||||
|
dc->FillRect(&r, &br);
|
||||||
|
CRect b(i.left, i.bottom, c.right, c.bottom);
|
||||||
|
dc->FillRect(&b, &br);
|
||||||
|
CRect l(c.left, i.top, i.left, c.bottom);
|
||||||
|
dc->FillRect(&l, &br);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tabber::setListener( TabberListener *l ){
|
void Tabber::setListener(TabberListener* l)
|
||||||
listener=l;
|
{
|
||||||
|
listener = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tabber::refresh(){
|
void Tabber::refresh()
|
||||||
if( curr<0 ) return;
|
{
|
||||||
|
if (curr < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
CRect r=getInnerRect();
|
CRect r = getInnerRect();
|
||||||
CWnd *wnd=getTabWnd( curr );
|
CWnd* wnd = getTabWnd(curr);
|
||||||
wnd->MoveWindow( r.left,r.top,r.Width(),r.Height() );
|
wnd->MoveWindow(r.left, r.top, r.Width(), r.Height());
|
||||||
wnd->ShowWindow( SW_SHOWNA );
|
wnd->ShowWindow(SW_SHOWNA);
|
||||||
}
|
}
|
||||||
|
|
||||||
Tabber::Tab *Tabber::getTab( int index )const{
|
Tabber::Tab* Tabber::getTab(int index) const
|
||||||
if( index<0 || index>=tabs.size() ) return 0;
|
{
|
||||||
Tabs::const_iterator it=tabs.begin();
|
if (index < 0 || index >= tabs.size())
|
||||||
while( index-- ) ++it;
|
return 0;
|
||||||
|
Tabs::const_iterator it = tabs.begin();
|
||||||
|
while (index--)
|
||||||
|
++it;
|
||||||
return *it;
|
return *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tabber::tcn_selChange( NMHDR *p,LRESULT *result ){
|
void Tabber::tcn_selChange(NMHDR* p, LRESULT* result)
|
||||||
setCurrent( GetCurSel() );
|
{
|
||||||
|
setCurrent(GetCurSel());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tabber::insert( int index,CWnd *w,const string &t ){
|
void Tabber::insert(int index, CWnd* w, const string& t)
|
||||||
if( index<0 || index>tabs.size() ) return;
|
{
|
||||||
|
if (index < 0 || index > tabs.size())
|
||||||
|
return;
|
||||||
|
|
||||||
Tabs::iterator it=tabs.begin();
|
Tabs::iterator it = tabs.begin();
|
||||||
for( int k=0;k<index;++k ) ++it;
|
for (int k = 0; k < index; ++k)
|
||||||
Tab *tab=new Tab( w,t );
|
++it;
|
||||||
tabs.insert( it,tab );
|
Tab* tab = new Tab(w, t);
|
||||||
|
tabs.insert(it, tab);
|
||||||
|
|
||||||
InsertItem( index,t.c_str() );
|
InsertItem(index, t.c_str());
|
||||||
if( curr<0 ) setCurrent( index );
|
if (curr < 0)
|
||||||
|
setCurrent(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tabber::remove( int index ){
|
void Tabber::remove(int index)
|
||||||
if( index<0 || index>=tabs.size() ) return;
|
{
|
||||||
|
if (index < 0 || index >= tabs.size())
|
||||||
|
return;
|
||||||
|
|
||||||
CWnd *w=getTabWnd( index );
|
CWnd* w = getTabWnd(index);
|
||||||
|
|
||||||
Tabs::iterator it=tabs.begin();
|
Tabs::iterator it = tabs.begin();
|
||||||
for( int k=0;k<index;++k ) ++it;
|
for (int k = 0; k < index; ++k)
|
||||||
delete *it;tabs.erase( it );
|
++it;
|
||||||
DeleteItem( index );
|
delete *it;
|
||||||
|
tabs.erase(it);
|
||||||
|
DeleteItem(index);
|
||||||
|
|
||||||
if( curr>=tabs.size() ) curr=tabs.size()-1;
|
if (curr >= tabs.size())
|
||||||
|
curr = tabs.size() - 1;
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
if( curr>=0 ) SetCurSel( curr );
|
if (curr >= 0)
|
||||||
if( w ) w->ShowWindow( SW_HIDE );
|
SetCurSel(curr);
|
||||||
if( listener ) listener->currentSet( this,curr );
|
if (w)
|
||||||
|
w->ShowWindow(SW_HIDE);
|
||||||
|
if (listener)
|
||||||
|
listener->currentSet(this, curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tabber::setCurrent( int index ){
|
void Tabber::setCurrent(int index)
|
||||||
if( index<0 || index>=tabs.size() ) return;
|
{
|
||||||
|
if (index < 0 || index >= tabs.size())
|
||||||
|
return;
|
||||||
|
|
||||||
if( index!=curr ){
|
if (index != curr) {
|
||||||
CWnd *w=getTabWnd( curr );
|
CWnd* w = getTabWnd(curr);
|
||||||
curr=index;
|
curr = index;
|
||||||
refresh();
|
refresh();
|
||||||
SetCurSel( curr );
|
SetCurSel(curr);
|
||||||
if( w ) w->ShowWindow( SW_HIDE );
|
if (w)
|
||||||
|
w->ShowWindow(SW_HIDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( listener ) listener->currentSet( this,curr );
|
if (listener)
|
||||||
|
listener->currentSet(this, curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tabber::setTabText( int index,const string &t ){
|
void Tabber::setTabText(int index, const string& t)
|
||||||
if( index<0 || index>=tabs.size() ) return;
|
{
|
||||||
|
if (index < 0 || index >= tabs.size())
|
||||||
|
return;
|
||||||
|
|
||||||
string s=t+'\0';
|
string s = t + '\0';
|
||||||
TCITEM tc={ TCIF_TEXT };
|
TCITEM tc = {TCIF_TEXT};
|
||||||
tc.pszText=(char*)s.data();
|
tc.pszText = (char*)s.data();
|
||||||
SetItem( index,&tc );
|
SetItem(index, &tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Tabber::size()const{
|
int Tabber::size() const
|
||||||
|
{
|
||||||
return tabs.size();
|
return tabs.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Tabber::getCurrent()const{
|
int Tabber::getCurrent() const
|
||||||
|
{
|
||||||
return curr;
|
return curr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CWnd *Tabber::getTabWnd( int index )const{
|
CWnd* Tabber::getTabWnd(int index) const
|
||||||
Tab *t=getTab( index );
|
{
|
||||||
|
Tab* t = getTab(index);
|
||||||
return t ? t->wnd : 0;
|
return t ? t->wnd : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Tabber::getTabText( int index )const{
|
string Tabber::getTabText(int index) const
|
||||||
Tab *t=getTab( index );
|
{
|
||||||
|
Tab* t = getTab(index);
|
||||||
return t ? t->text : "";
|
return t ? t->text : "";
|
||||||
}
|
}
|
||||||
+24
-25
@@ -4,43 +4,42 @@
|
|||||||
|
|
||||||
class Tabber;
|
class Tabber;
|
||||||
|
|
||||||
class TabberListener{
|
class TabberListener {
|
||||||
public:
|
public:
|
||||||
virtual void currentSet( Tabber *tabber,int index )=0;
|
virtual void currentSet(Tabber* tabber, int index) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Tabber : public CTabCtrl{
|
class Tabber : public CTabCtrl {
|
||||||
public:
|
public:
|
||||||
Tabber();
|
Tabber();
|
||||||
~Tabber();
|
~Tabber();
|
||||||
|
|
||||||
void setListener( TabberListener *l );
|
void setListener(TabberListener* l);
|
||||||
|
|
||||||
void insert( int index,CWnd *wnd,const string &text );
|
void insert(int index, CWnd* wnd, const string& text);
|
||||||
void remove( int index );
|
void remove(int index);
|
||||||
void setCurrent( int index );
|
void setCurrent(int index);
|
||||||
void setTabText( int index,const string &t );
|
void setTabText(int index, const string& t);
|
||||||
|
|
||||||
int size()const;
|
int size() const;
|
||||||
int getCurrent()const;
|
int getCurrent() const;
|
||||||
CWnd *getTabWnd( int index )const;
|
CWnd* getTabWnd(int index) const;
|
||||||
string getTabText( int index )const;
|
string getTabText(int index) const;
|
||||||
|
|
||||||
DECLARE_DYNAMIC( Tabber )
|
DECLARE_DYNAMIC(Tabber)
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
|
|
||||||
afx_msg void OnSize( UINT type,int w,int h );
|
afx_msg void OnSize(UINT type, int w, int h);
|
||||||
afx_msg BOOL OnEraseBkgnd( CDC *dc );
|
afx_msg BOOL OnEraseBkgnd(CDC* dc);
|
||||||
afx_msg void tcn_selChange( NMHDR *p,LRESULT *result );
|
afx_msg void tcn_selChange(NMHDR* p, LRESULT* result);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TabberListener *listener;
|
TabberListener* listener;
|
||||||
|
|
||||||
struct Tab{
|
struct Tab {
|
||||||
CWnd *wnd;
|
CWnd* wnd;
|
||||||
string text;
|
string text;
|
||||||
Tab( CWnd *w,const string &t ):wnd(w),text(t){
|
Tab(CWnd* w, const string& t) : wnd(w), text(t) {}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef list<Tab*> Tabs;
|
typedef list<Tab*> Tabs;
|
||||||
@@ -50,7 +49,7 @@ private:
|
|||||||
|
|
||||||
void refresh();
|
void refresh();
|
||||||
CRect getInnerRect();
|
CRect getInnerRect();
|
||||||
Tab *getTab( int index )const;
|
Tab* getTab(int index) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user