vpemain.cpp
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C++ 代码 · 共 2,090 行 · 第 1/5 页
CPP
2,090 行
WPopupMenu* pop6 = getMdiPopup();
pop6->onPopup( this, (cbp)&VpeMain::onPopup6 );
menuBar->insertPopup( pop6, 6 );
pop6->insertItem( new WMenuItem( "&Refresh", this, (cbm)&VpeMain::mRefresh, (cbh)&VpeMain::mHint, "Refresh target and file attributes from disk directories" ), 0 );
unsigned helpcnt;
MAction *action;
WString mname;
WMenuItem *mi;
int i;
WPopupMenu* pop7 = makeMenu( &popup7, toolBar );
menuBar->insertPopup( pop7, 7 );
helpcnt = _config->helpactions().count();
if( helpcnt > 0 ) pop7->insertSeparator();
for( i = 0; i < helpcnt; i++ ) {
action = (MAction *)_config->helpactions()[i];
action->menuName( &mname );
mi = new WMenuItem( mname, this, (cbm)&VpeMain::mHelpItem,
(cbh)&VpeMain::mHint, action->hint() );
mi->setTagPtr( action );
pop7->insertItem( mi );
}
pop7->insertSeparator();
mi = new WMenuItem( "&About the Open Watcom IDE...", this,
(cbm)&VpeMain::about, (cbh)&VpeMain::mHint,
"About the Open Watcom IDE" );
pop7->insertItem( mi );
setMenu( menuBar );
for( i=0; i<_compViews.count(); i++ ) {
VComponent* vc = (VComponent*)_compViews[i];
vc->resetPopups();
}
WVList& toolItems = _config->toolItems();
for( i=0; i<toolItems.count(); i++ ) {
MToolItem* mt = (MToolItem*)toolItems[i];
VToolItem* t = new VToolItem( mt->toolType(), mt->toolId(), this, (cbtbi)&VpeMain::toolPicked, mt->hint() );
t->setTagPtr( mt );
toolBar->addTool( t );
}
setToolBar( toolBar );
_toolBarActive = TRUE;
addAccelKey( WKeyInsert, this, (bcbk)&VpeMain::kAddItem );
addAccelKey( WKeyDelete, this, (bcbk)&VpeMain::kRemoveItem );
addAccelKey( WKeyCtrlN, this, (bcbk)&VpeMain::kNewProject );
addAccelKey( WKeyCtrlO, this, (bcbk)&VpeMain::kOpenProject );
addAccelKey( WKeyCtrlS, this, (bcbk)&VpeMain::kSaveProject );
setUpdates();
}
WPopupMenu* VpeMain::makeMenu( MenuPop* popup, VToolBar* tools )
{
WPopupMenu* pop = new WPopupMenu( popup->name );
pop->onPopup( this, popup->onpop );
MenuData* menu = popup->menu;
if( menu ) {
for( int i=0; i<popup->count; i++ ) {
if( menu[i].pop ) {
WPopupMenu* p = makeMenu( menu[i].pop, tools );
pop->insertPopup( p, i );
} else if( !menu[i].name ) {
pop->insertSeparator( i );
} else {
WMenuItem* m = new WMenuItem( menu[i].name, this, menu[i].callback, (cbh)&VpeMain::mHint, menu[i].hint );
pop->insertItem( m, i );
if( tools && menu[i].toolId ) {
VToolItem* t = new VToolItem( TOOL_MENU, menu[i].toolId, this, (cbtbi)&VpeMain::toolPicked, menu[i].hint );
t->setTagPtr( m );
tools->addTool( t );
}
}
}
}
return( pop );
}
MenuPop VpeMain::popup0a = { "Set Sou&rce Control", (cbp)&VpeMain::onPopup0a, menu0a, 7 };
MenuData VpeMain::menu0a[] = {
"MKS &SI", (cbm)&VpeMain::setMksSi, "Use MKS Source Integrity revision control", 0, NULL,
"MKS &RCS", (cbm)&VpeMain::setMksRcs, "Use MKS RCS revision control", 0, NULL,
"&PVCS", (cbm)&VpeMain::setPvcs, "Use Intersolv PVCS revision control", 0, NULL,
"&Other", (cbm)&VpeMain::setOtherRcs, "Use another revision control system", 0, NULL,
"&None", (cbm)&VpeMain::setNoRcs, "Disable revision control functions", 0, NULL,
"Object &Cycle", (cbm)&VpeMain::setObjectCycle, "Use Object Cycle", 0, NULL,
"P&erforce", (cbm)&VpeMain::setPerforce, "Use Perforce", 0, NULL,
};
MenuPop VpeMain::popup0 = { "&File", (cbp)&VpeMain::onPopup0, menu0, 16 };
MenuData VpeMain::menu0[] = {
"&New Project...\tCTRL+N", (cbm)&VpeMain::newProject, "Create a new project", B_newproj, NULL,
"&Open Project...\tCTRL+O", (cbm)&VpeMain::openProject, "Open existing project", B_openproj, NULL,
"&Save Project\tCTRL+S", (cbm)&VpeMain::saveProject, "Save current project", B_saveproj, NULL,
"Save Project &As...", (cbm)&VpeMain::saveProjectAs, "Save project with new name", 0, NULL,
"&Close Project", (cbm)&VpeMain::closeProject, "Close current project", 0, NULL,
NULL, NULL, NULL, 0, NULL,
"Show &Tool Bar", (cbm)&VpeMain::toolBar, "Show/hide tool bar", 0, NULL,
"Show Stat&us Bar", (cbm)&VpeMain::statusBar, "Show/hide status bar", 0, NULL,
"Auto Refres&h", (cbm)&VpeMain::toggleAutoRefresh, "Turn frequent file list refreshes on/off", 0, NULL,
"Set Text E&ditor...", (cbm)&VpeMain::setEditor, "Set the text editor", 0, NULL,
"", NULL, NULL, 0, &popup0a,
NULL, NULL, NULL, 0, NULL,
"B&efore...", (cbm)&VpeMain::setBefore, "Setup commands to execute before any make", 0, NULL,
"A&fter...", (cbm)&VpeMain::setAfter, "Setup commands to execute after any successful make", 0, NULL,
NULL, NULL, NULL, 0, NULL,
"E&xit", (cbm)&VpeMain::exit, "Terminate the session", 0, NULL,
};
void VpeMain::onPopup0a( WPopupMenu* pop )
{
int systype;
unsigned i;
for( i=0; i < popup0a.count; i++ ) {
pop->checkItem( FALSE, i );
}
systype = _rcsClient.QuerySystem();
switch( systype ) {
case GENERIC:
pop->checkItem( TRUE, 3 );
break;
case NO_RCS:
pop->checkItem( TRUE, 4 );
break;
case MKS_RCS:
pop->checkItem( TRUE, 1 );
break;
case MKS_SI:
pop->checkItem( TRUE, 0 );
break;
case O_CYCLE:
pop->checkItem( TRUE, 5 );
break;
case PVCS:
pop->checkItem( TRUE, 2 );
break;
case PERFORCE:
pop->checkItem( TRUE, 6 );
break;
}
}
void VpeMain::onPopup0( WPopupMenu* pop )
{
int base = popup0.count;
int jcount = pop->childCount();
for( int j=jcount; j>base; ) {
j--;
delete pop->removeItemAt( j );
}
if( _oldProjects.count() > 0 ) {
pop->insertSeparator( base );
for( int i=0; i<_oldProjects.count(); i++ ) {
WFileName* fn = (WFileName*)_oldProjects[ i ];
WString str; str.printf( "&%d. %s", i+1, (const char*)*fn );
WMenuItem* mi = new WMenuItem( str, this, (cbm)&VpeMain::openOldProject );
mi->setTagPtr( fn );
pop->insertItem( mi, i+1+base );
}
}
bool isp = (_project!=NULL);
pop->enableItem( TRUE, 0 ); //new
pop->enableItem( TRUE, 1 ); //open
pop->enableItem( isp, 2 ); //save
pop->enableItem( isp, 3 ); //save as
pop->enableItem( isp, 4 ); //close
pop->enableItem( TRUE, 6 ); //toolbar
pop->checkItem( _toolBarActive, 6 );//...
pop->enableItem( TRUE, 7 ); //statusbar
pop->checkItem( (_statusBar!=NULL), 7 );//...
pop->enableItem( TRUE, 8 ); //AutoRefresh
pop->checkItem( _autoRefresh, 8 ); //...
pop->enableItem( TRUE, 9 ); //set editor
pop->enableItem( TRUE, 10 ); //set source control
pop->enableItem( isp, 12 ); //set before
pop->enableItem( isp, 13 ); //set after
pop->enableItem( TRUE, 15 ); //always true //exit
}
MenuPop VpeMain::popup1 = { "&Actions", (cbp)&VpeMain::onPopup1, menu1, 1 };
MenuData VpeMain::menu1[] = {
"Dummy", (cbm)&VpeMain::mDummy, "Dummy", 0, NULL,
};
void VpeMain::onPopup1( WPopupMenu* pop )
{
int jcount = pop->childCount();
for( int j=jcount; j>0; ) {
j--;
delete pop->removeItemAt( j );
}
int icount = _config->actions().count();
int i;
for( i=0; i<icount; i++ ) {
MAction* action = (MAction*)_config->actions()[i];
WString mname;
action->menuName( &mname );
WMenuItem* mi = new WMenuItem( mname, this, (cbm)&VpeMain::mAction, (cbh)&VpeMain::mHint, action->hint() );
mi->setTagPtr( action );
pop->insertItem( mi, i);
}
WMenuItem* mi = new WMenuItem( "Source &Control Shell", this,
(cbm)&VpeMain::mRcsShell,
(cbh)&VpeMain::mHint,
"Invoke Source Control Shell" );
pop->insertItem( mi, i);
if( _rcsClient.HasShell() ) {
pop->enableItem( TRUE, i );
} else {
pop->enableItem( FALSE, i );
}
}
MenuPop VpeMain::popup2 = { "&Targets", (cbp)&VpeMain::onPopup2, menu2, 5 };
MenuData VpeMain::menu2[] = {
"&New Target...", (cbm)&VpeMain::vAddComponent,"Create a new target", 0, NULL,
"Remo&ve Target", (cbm)&VpeMain::removeComponent, "Remove/delete current target", 0, NULL,
"Ren&ame Target...", (cbm)&VpeMain::renameComponent, "Rename current target", 0, NULL,
"", NULL, NULL, 0, &popup2a,
"Mar&k Target for Remake", (cbm)&VpeMain::touchComponent, "Mark current target and (optionally) all its components files for remake", 0, NULL,
};
void VpeMain::onPopup2( WPopupMenu* pop )
{
int base = popup2.count;
int jcount = pop->childCount();
for( int j=jcount; j>base; ) {
j--;
delete pop->removeItemAt( j );
}
if( _activeVComp ) {
MItem* m = _activeVComp->target();
WVList actlist;
if( m ) {
m->addActions( actlist );
int icount = actlist.count();
int ii = 0;
for( int i=0; i<icount; i++ ) {
MAction* action = (MAction*)actlist[i];
if( !action->button() ) {
if( ii == 0 ) {
pop->insertSeparator( base );
ii++;
}
WString mname;
action->menuName( &mname );
WMenuItem* mi = new WMenuItem( mname, this, (cbm)&VpeMain::mActionComponent, (cbh)&VpeMain::mHint, action->hint() );
mi->setTagPtr( action );
pop->insertItem( mi, ii+base );
ii++;
}
}
}
}
bool isp = (_project!=NULL);
bool ist = (_activeVComp!=NULL);
pop->enableItem( isp, 0 ); //new target
pop->enableItem( ist, 1 ); //remove target
pop->enableItem( ist, 2 ); //rename target
pop->enableItem( ist, 3 ); //setup target
pop->enableItem( ist, 4 ); //touch target
}
MenuPop VpeMain::popup2a = { "Target &Options", (cbp)&VpeMain::onPopup2a, menu2a, 10 };
MenuData VpeMain::menu2a[] = {
"&Switches...", (cbm)&VpeMain::setupComponent, "Set switch values for making current target", 0, NULL,
"Show Make &Command...", (cbm)&VpeMain::showCompCommand, "Show command for making current target", 0, NULL,
NULL, NULL, NULL, 0, NULL,
"Execute B&efore...", (cbm)&VpeMain::setCompBefore, "Setup commands to execute before making current target", 0, NULL,
"Execute A&fter...", (cbm)&VpeMain::setCompAfter, "Setup commands to do after successfully making current target", 0, NULL,
NULL, NULL, NULL, 0, NULL,
"Use &Autodepend", (cbm)&VpeMain::mAutodepend, "Enable/disable autodepend feature of makefile", 0, NULL,
"Use &Autotrack", (cbm)&VpeMain::mAutotrack, "Enable/disable target autotrack feature", 0, NULL,
"Use De&velopment Switches", (cbm)&VpeMain::mDebugMode, "Use development switches during make", 0, NULL,
"Use Re&lease Switches", (cbm)&VpeMain::mDebugMode, "Use release switches during make", 0, NULL,
};
void VpeMain::onPopup2a( WPopupMenu* pop )
{
int base = popup2a.count;
int jcount = pop->childCount();
for( int j=jcount; j>base; ) {
j--;
delete pop->removeItemAt( j );
}
addComponentActionSetups( pop, base );
WString ss;
if( _activeVComp ) {
MTool* tool = _activeVComp->target()->rule()->tool();
if( tool != _config->nilTool() ) {
tool->name( ss );
ss.concat( ' ' );
}
}
ss.concat( menu2a[0].name );
pop->setItemText( ss, 0 ); //set target switch text
bool isv = (_activeVComp!= NULL);
pop->enableItem( isv, 0 ); //setup target
pop->enableItem( isv, 1 ); //show command
pop->enableItem( isv, 3 ); //set before
pop->enableItem( isv, 4 ); //set after
bool isa = isv && _activeVComp->target()->rule()->autodepend();
pop->enableItem( isa, 6 ); //autodepend
pop->checkItem( isa && _activeVComp->component()->autodepend(), 6 ); //...
bool ist = isv && _activeVComp->target()->rule()->autotrack();
pop->enableItem( ist, 7 ); //autotrack
pop->checkItem( ist && _activeVComp->component()->autotrack(), 7 ); //...
bool isd = isv && _activeVComp->debugMode();
pop->enableItem( isv && !isd, 8 ); //debug mode
pop->checkItem( isv && isd, 8 ); //...
pop->enableItem( isv && isd, 9 ); //release mode
pop->checkItem( isv && !isd, 9 ); //...
}
MenuPop VpeMain::popup3 = { "&Sources", (cbp)&VpeMain::onPopup3, menu3, 9 };
MenuData VpeMain::menu3[] = {
"Check &Out Source", (cbm)&VpeMain::mCheckout, "Checkout the current source file", 0, NULL,
"&Check In Source", (cbm)&VpeMain::mCheckin, "Checkin the current source file", 0, NULL,
NULL, NULL, NULL, 0, NULL,
"&New Source...\tIns", (cbm)&VpeMain::mAddItem, "Create/add a new source file to the target", 0, NULL,
"Remo&ve Source\tDel", (cbm)&VpeMain::mRemoveItem, "Remove current source file from target", 0, NULL,
"Ren&ame Source...", (cbm)&VpeMain::mRenameItem, "Rename current source file in the target", 0, NULL,
"", NULL, NULL, 0, &popup3a,
"Mar&k Source for Remake", (cbm)&VpeMain::mTouchItem, "Mark current source file for remake", 0, NULL,
"&Included Files...", (cbm)&VpeMain::mIncludedItems, "Edit included source files", 0, NULL,
};
void VpeMain::onPopup3( WPopupMenu* pop )
{
int base = popup3.count;
int jcount = pop->childCount();
for( int j=jcount; j>base; ) {
j--;
delete pop->removeItemAt( j );
}
MItem* m = NULL;
if( _activeVComp ) {
m = _activeVComp->selectedItem();
}
if( m ) {
WVList actlist;
m->addActions( actlist );
int icount = actlist.count();
if( icount > 0 ) {
pop->insertSeparator( base );
int addcnt = 0;
for( int i=0; i<icount; i++ ) {
MAction* action = (MAction*)actlist[i];
if( !m->isMask() || action->okForMask() ) {
WString mname;
action->menuName( &mname );
WMenuItem* mi = new WMenuItem( mname, this,
(cbm)&VpeMain::mActionItem,
(cbh)&VpeMain::mHint,
action->hint() );
mi->setTagPtr( action );
pop->insertItem( mi, addcnt + base + 1 );
addcnt ++;
}
}
}
}
bool isv = (_activeVComp!=NULL);
bool isp = (m != NULL);
bool ism = isp && m->isMask();
bool rcs = isp && !ism && _rcsClient.QuerySystem() != NO_RCS;
pop->enableItem( rcs, 0 ); //checkin item
pop->enableItem( rcs, 1 ); //checkout item
pop->enableItem( isv, 3 ); //add item
pop->enableItem( isp, 4 ); //remove item
pop->enableItem( isp && !ism, 5 ); //rename item
pop->enableItem( isp, 6 ); //setup item
pop->enableItem( isp , 7 ); //touch item
pop->enableItem( isp && !ism && m->ismakeable(), 8 );//included items
}
MenuPop VpeMain::popup3a = { "Source &Options", (cbp)&VpeMain::onPopup3a, menu3a, 2 };
MenuData VpeMain::menu3a[] = {
"&Switches...", (cbm)&VpeMain::mSetupItem, "Set switch values for making current source file", 0, NULL,
"Show Make &Command...", (cbm)&VpeMain::showItemCommand, "Show command for making current source file", 0, NULL,
};
void VpeMain::onPopup3a( WPopupMenu* pop )
{
int base = popup3a.count;
int jcount = pop->childCount();
for( int j=jcount; j>base; ) {
j--;
delete pop->removeItemAt( j );
}
MItem* m = NULL;
if( _activeVComp ) {
m = _activeVComp->selectedItem();
}
if( m ) {
WVList actlist;
m->addActions( actlist );
int icount = actlist.count();
int ii = 0;
for( int i=0; i<icount; i++ ) {
MAction* action = (MAction*)actlist[i];
if( action->hasSwitches( TRUE ) ) {
if( ii == 0 ) {
pop->insertSeparator( base );
ii++;
}
WString n( action->name() ); n.concat( " switches..." );
WString h( "Setup switches for '" );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?