Ejemplo n.º 1
0
void CStrategyInfoDlg::OnRclickListStrategyInfo(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	DWORD   dwPos   =   GetMessagePos(); 
	CPoint   point1(   LOWORD(dwPos),   HIWORD(dwPos)   ); 
	CPoint   point2(   LOWORD(dwPos),   HIWORD(dwPos)   ); 
	
	m_listStrategyInfo.ScreenToClient(&point2); 
	m_nRSelItem   =   m_listStrategyInfo.HitTest(point2); 
	
	if   (point1.x   ==   -1   &&   point1.y   ==   -1) 
		point1.Offset(5,   5); 
	
	CMenu   menu; 
	VERIFY(menu.LoadMenu(IDR_POP_MENU)); 
	CMenu*   pPopup   =   menu.GetSubMenu(0); 
	ASSERT(pPopup   !=   NULL); 
	SetMenuState(m_nRSelItem, pPopup);
	
	pPopup-> TrackPopupMenu(TPM_LEFTALIGN   |   TPM_RIGHTBUTTON,   point1.x,   point1.y,   this); 

	*pResult = 0;

}
Ejemplo n.º 2
0
// Builds the GSiegeWindowClass main class and registers it
HWND MainWindowClassBuilder()
{
	WNDCLASSEX wc;
	RECT rc;

	// Load user settings
	UserSettings.MainWidth = MAINWIDTH;
	if ( UserSettings.EnableChat )
	{
		TAB_CHAT_HEIGHT = TAB_STATIC_HEIGHT;
		UserSettings.MainHeight = (MAINHEIGHT + GetSystemMetrics(SM_CYMENU)) + TAB_CHAT_HEIGHT;
	}
	else
	{
		TAB_CHAT_HEIGHT = 0;
		UserSettings.MainHeight = MAINHEIGHT + GetSystemMetrics(SM_CYMENU);
	}

	// Define class properties and register.
	wc.cbSize			= sizeof(WNDCLASSEX);
	wc.style			= 0;
	wc.lpfnWndProc		= MainWindowProc;
    wc.cbClsExtra		= 0;
    wc.cbWndExtra		= 0;
    wc.hInstance		= GlobalSettings.hInstance;
    wc.hIcon			= LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor			= LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground	= (HBRUSH)(COLOR_WINDOW);
    wc.lpszMenuName		= GSIEGE_MENU_NAME;
    wc.lpszClassName	= GSIEGE_MAIN_CLASS;
    wc.hIconSm			= LoadIcon(NULL, IDI_APPLICATION);

	if( !RegisterClassEx(&wc) )
	{
		MessageBox(NULL, "Failed to register g_szMainWindow class.", "Error", MB_ICONEXCLAMATION | MB_OK);
		return 0;
	}

	// Build main window.
	GlobalSettings.hMainWindow = CreateWindowEx(
		WS_EX_WINDOWEDGE,
		GSIEGE_MAIN_CLASS,
		GSIEGE_VERSION_STRING,
		WS_OVERLAPPEDWINDOW,
		(UserSettings.MainX ? UserSettings.MainX : CW_USEDEFAULT),
		(UserSettings.MainY ? UserSettings.MainY : CW_USEDEFAULT),
		UserSettings.MainWidth, UserSettings.MainHeight,
		NULL, NULL, GlobalSettings.hInstance, NULL);

	if( GlobalSettings.hMainWindow == NULL )
	{
		MessageBox(NULL, "Failed to create g_hMainWindow.", "Error", MB_ICONEXCLAMATION | MB_OK);
		return 0;
	}

	// Load menu items
	GlobalSettings.hMenu = GetMenu(GlobalSettings.hMainWindow);

	// Set window position in z-order
	SetWindowState();
	SetMenuState();

	memset(&rc, 0, sizeof(rc));
	GetClientRect(GlobalSettings.hMainWindow, &rc);
	UserSettings.ClientWidth = rc.right - rc.left;
	UserSettings.ClientHeight = rc.bottom - rc.top;

	// Draw main window.
	ShowWindow(GlobalSettings.hMainWindow, GlobalSettings.nCmdShow);
	UpdateWindow(GlobalSettings.hMainWindow);
	return GlobalSettings.hMainWindow;
}
Ejemplo n.º 3
0
void AudacityProject::OnUpdateMenus(wxUpdateUIEvent & event)
{
   if (mMenusDirtyCheck != gMenusDirty) {
      /*
         TODO!
       */
   }

/*
#define AUDACITY_MENUS_COMMANDS_ACCELL_TABLE
#include "commands.h"
#undef AUDACITY_MENUS_COMMANDS_ACCELL_TABLE
*/

   SetMenuState(mFileMenu, SaveID, mUndoManager.UnsavedChanges());

   bool nonZeroRegionSelected = (mViewInfo.sel1 > mViewInfo.sel0);

   int numTracks = 0;
   int numTracksSelected = 0;
   int numWaveTracks = 0;
   int numWaveTracksSelected = 0;
   int numLabelTracks = 0;
   int numLabelTracksSelected = 0;

   TrackListIterator iter(mTracks);
   VTrack *t = iter.First();
   while (t) {
      numTracks++;
      // JH: logically, we only want to count a stereo pair as one track. Right??
      // I'm changing it and hoping I don't break anything
      if (t->GetKind() == VTrack::Wave && t->GetLinked() == false)
         numWaveTracks++;
      if (t->GetKind() == VTrack::Label)
         numLabelTracks++;
      if (t->GetSelected()) {
         numTracksSelected++;
         // JH: logically, we only want to count a stereo pair as one track. Right??
         // I'm changing it and hoping I don't break anything
         if (t->GetKind() == VTrack::Wave && t->GetLinked() == false)
            numWaveTracksSelected++;
         else if(t->GetKind() == VTrack::Label)
            numLabelTracksSelected++;

      }
      t = iter.Next();
   }

   SetMenuState(mEditMenu, PasteID, numTracksSelected > 0 && msClipLen > 0.0);

   //Calculate the ToolBarCheckSum (uniquely specifies state of all toolbars):
   int toolBarCheckSum = 0;
   toolBarCheckSum += gControlToolBarStub->GetWindowedStatus() ? 2 : 1;
   if (gEditToolBarStub) {
      if (gEditToolBarStub->GetLoadedStatus()) {
         if(gEditToolBarStub->GetWindowedStatus())
            toolBarCheckSum += 6;
         else
            toolBarCheckSum += 3;
      }
   }
   
   
   // Get ahold of the clipboard status
   bool clipboardStatus = static_cast<bool>(GetActiveProject()->Clipboard());

   // Return from this function if nothing's changed since
   // the last time we were here.
 
   if (!mFirstTimeUpdateMenus &&
       mLastNonZeroRegionSelected == nonZeroRegionSelected &&
       mLastNumTracks == numTracks &&
       mLastNumTracksSelected == numTracksSelected &&
       mLastNumWaveTracks == numWaveTracks &&
       mLastNumWaveTracksSelected == numWaveTracksSelected &&
       mLastNumLabelTracks == numLabelTracks &&
       mLastZoomLevel == mViewInfo.zoom &&
       mLastToolBarCheckSum == toolBarCheckSum &&
       mLastUndoState == mUndoManager.UndoAvailable() &&
       mLastRedoState == mUndoManager.RedoAvailable() &&
       mLastClipboardState == clipboardStatus  ) 
      return;
   
   // Otherwise, save state and then update all of the menus

   mFirstTimeUpdateMenus = false;
   mLastNonZeroRegionSelected = nonZeroRegionSelected;
   mLastNumTracks = numTracks;
   mLastNumTracksSelected = numTracksSelected;
   mLastNumWaveTracks = numWaveTracks;
   mLastNumWaveTracksSelected = numWaveTracksSelected;
   mLastNumLabelTracks = numLabelTracks;
   mLastZoomLevel = mViewInfo.zoom;
   mLastToolBarCheckSum = toolBarCheckSum;
   mLastUndoState = mUndoManager.UndoAvailable();
   mLastRedoState = mUndoManager.RedoAvailable();  
   mLastClipboardState = clipboardStatus;

   bool anySelection = numTracksSelected > 0 && nonZeroRegionSelected;

   SetMenuState(mFileMenu, ExportMixID, numTracks > 0);
   SetMenuState(mFileMenu, ExportSelectionID, anySelection);
   SetMenuState(mFileMenu, ExportLossyMixID, numTracks > 0);
   SetMenuState(mFileMenu, ExportLossySelectionID, anySelection);
   SetMenuState(mFileMenu, ExportLabelsID, numLabelTracks > 0);

   SetMenuState(mEditMenu, CutID, anySelection);
   SetMenuState(mEditMenu, CopyID, anySelection);
   SetMenuState(mEditMenu, TrimID, anySelection);
   SetMenuState(mEditMenu, DeleteID, anySelection);
   SetMenuState(mEditMenu, SilenceID, anySelection);
   SetMenuState(mEditMenu, InsertSilenceID, numTracksSelected > 0);
   SetMenuState(mEditMenu, SplitID, anySelection);
   SetMenuState(mEditMenu, SplitLabelsID, numLabelTracksSelected == 1 && numWaveTracksSelected == 1);
   SetMenuState(mEditMenu, DuplicateID, anySelection);
   SetMenuState(mEditMenu, SelectAllID, numTracks > 0);

   SetMenuState(mEditMenu, UndoID, mUndoManager.UndoAvailable());
   SetMenuState(mEditMenu, RedoID, mUndoManager.RedoAvailable());


   SetMenuState(mViewMenu, PlotSpectrumID, numWaveTracksSelected > 0
                     && nonZeroRegionSelected);

#ifndef __WXMAC__
   //Modify toolbar-specific Menus

   wxMenuItemBase   *dock = mViewMenu->FindItem(FloatEditToolBarID);
 
   if (gEditToolBarStub) {

      // Loaded or unloaded?
      if (gEditToolBarStub->GetLoadedStatus()) {
         dock->Enable(true);
      } else {
         dock->Enable(false);
      }

      // Floating or docked?
      if (gEditToolBarStub->GetWindowedStatus())
         dock->SetName(_("Dock Edit Toolbar"));
      else
         dock->SetName(_("Float Edit Toolbar"));
   }
   else
      {
         dock->Enable(false);
      }
#endif

   SetMenuState(mProjectMenu, QuickMixID, numWaveTracksSelected > 1);
   SetMenuState(mProjectMenu, AlignID, numTracksSelected > 1);
   SetMenuState(mProjectMenu, AlignZeroID, numTracksSelected > 0);
   SetMenuState(mProjectMenu, RemoveTracksID, numTracksSelected > 0);


   //Enable the effects menu
   int e;
   for (e = 0; e < Effect::GetNumEffects(false); e++) {
      mEffectMenu->Enable(FirstEffectID + e,
                          numWaveTracksSelected > 0
                          && nonZeroRegionSelected);
   }
   
//STM: This makes sub-menus for the plugin menu.  It might only work well
//on wxGTK, so I'm doing conditional compilation.  

#if defined __WXGTK__

	//Enable/disable the Plugins menu options.
   int numPlugins = Effect::GetNumEffects(true);


   //enable or disable each menu item based on whether there is a selection.
   for (e = 0; e < numPlugins; e++) {
      mPluginMenu->Enable(FirstPluginID + e,
                          numWaveTracksSelected > 0
                          && nonZeroRegionSelected);
   }
#else
   
   for (e = 0; e < Effect::GetNumEffects(true); e++) {
      mPluginMenu->Enable(FirstPluginID + e,
                          numWaveTracksSelected > 0
                          && nonZeroRegionSelected);
   }

#endif

   //Now, go through each toolbar, and and call EnableDisableButtons()
   unsigned int i;
   for (i = 0; i < mToolBarArray.GetCount(); i++) {
      mToolBarArray[i]->EnableDisableButtons();
   }

   //Now, do the same thing for the (possibly invisible) floating toolbars
   gControlToolBarStub->GetToolBar()->EnableDisableButtons();

   //gEditToolBarStub might be null:
   if(gEditToolBarStub){
      gEditToolBarStub->GetToolBar()->EnableDisableButtons();
   }
}