Example #1
0
/*!
 * Creates a new code editor widget.
 */
CodeEditorWidget::CodeEditorWidget( QWidget *parent, Qt::WindowFlags f )
:QWidget( parent, f ),
 m_currentScritFileName( QString( "" ) )
{

	setupUi( this );

	SetupToolbar();

	lineNumberWidget->SetCodeEditor( codeEditor );

	connect( codeEditor, SIGNAL( updateRequest( QRect, int ) ), lineNumberWidget, SLOT( UpdateLineNumberArea( QRect, int ) ) );

}
INT_PTR CManageBookmarksDialog::OnInitDialog()
{
	/* TODO: Enable drag and drop for listview and treeview. */
	SetDialogIcon();
	SetupSearchField();
	SetupToolbar();
	SetupTreeView();
	SetupListView();

	CBookmarkItemNotifier::GetInstance().AddObserver(this);

	UpdateToolbarState();

	SetFocus(GetDlgItem(m_hDlg,IDC_MANAGEBOOKMARKS_LISTVIEW));

	return 0;
}
Example #3
0
// Refresh page contents.
void SyntaxPage::RefreshData( LPPARSER pParser )
{
	_ASSERT_VALID( pParser );

	// Save parser.
	m_pParser = pParser;

	// Setup lists.
	m_Blocks.SetParser( pParser );
	m_Common.SetParser( pParser );
	m_Blocks.SetBlockList();
	m_Common.SetCommonList();

	// Setup other controls.
	m_Escape.SetWindowText( pParser->cEscape ? ( LPCTSTR )ClsString( pParser->cEscape ) : NULL );
	m_Syntax.SetCheck( pParser->bSyntaxColoring ? BST_CHECKED : BST_UNCHECKED );

	// Setup the toolbar.
	SetupToolbar();
}
Example #4
0
LRESULT MainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
   SetupCmdBar();
   SetupRibbonBar();
   SetupToolbar();
   SetupMRUList();
   SetupStatusBar();
   SetupView();

   // register object for message filtering and idle updates
   CMessageLoop* pLoop = _Module.GetMessageLoop();
   ATLASSERT(pLoop != NULL);
   pLoop->AddMessageFilter(this);
   pLoop->AddIdleHandler(this);

   {
      bool bRibbonUI = RunTimeHelper::IsRibbonUIAvailable();
      ShowRibbonUI(bRibbonUI);
      UISetCheck(ID_VIEW_RIBBON, bRibbonUI);
   }

   if (m_cszFilenameOpenAtStart.IsEmpty())
      DoFileNew();
   else
   {
      CString cszTitle = Path(m_cszFilenameOpenAtStart).FilenameAndExt();
      if (DoFileOpen(m_cszFilenameOpenAtStart, cszTitle))
      {
         m_mru.AddToList(m_cszFilenameOpenAtStart);
         m_mru.WriteToRegistry(c_pszSettingsRegkey);
      }
   }

   UIEnable(ID_SCRIPT_RUN, true);
   UIEnable(ID_SCRIPT_STOP, false);

   return 0;
}
Example #5
0
// WM_COMMAND handler.
LRESULT SyntaxPage::OnCommand( UINT nNotifyCode, UINT nCtrlID, HWND hWndCtrl )
{
	// What's the trouble...
	switch ( nCtrlID )
	{
		case	EditToolbar::ETID_COLOR:
		{
			// Get the current selection.
			int nSel = m_Common.GetCurSel();

			// Only show the popup when there is
			// a valid selection.
			if ( nSel != LB_ERR )
			{
				// Get the position of the selected entry.
				ClsRect rc;
				m_Color.GetItemRect( 6, rc );
				m_Color.ClientToScreen( rc );

				// Get the color index.
				int nColorIndex = m_Common.GetIndexArray()[ nSel ];

				// Create the popup. The popup will automatically destroy
				// itself.
				new ClsColorPopup( ClsPoint( rc.Left(), rc.Bottom()), 
						   m_pParser->dwColorFlags & m_Common.GetFlagArray()[ nSel ] ? CLR_DEFAULT : m_pParser->crColors[ nColorIndex ], 
						   this,
						   0,
						   ClsString( MAKEINTRESOURCE( IDS_DEFAULT )), 
						   ClsString( MAKEINTRESOURCE( IDS_CUSTOM )), 
						   NULL, 
						   TRUE,
						   FALSE );
			} 
			return 0;
		}

		case	EditToolbar::ETID_UP:
			// Move entry up.
			m_Blocks.MoveSelUp();
			SetupToolbar();
			return 0;

		case	EditToolbar::ETID_DOWN:
			// Move entry down.
			m_Blocks.MoveSelDown();
			SetupToolbar();
			return 0;

		case	EditToolbar::ETID_DELETE:
			// Remove entry.
			m_Blocks.RemoveSel();
			SetupToolbar();
			return 0;

		case	EditToolbar::ETID_NEW:
		{
			// Create a block as follows:
			//
			//		Name=New Block...
			//			RGB=50,100,150
			//			Start=;
			//			End=\n
			//		EndBlock
			ClsString strName( MAKEINTRESOURCE( IDS_NEW_BLOCK ));
			BLOCK	  bBlock = { 0 };
			bBlock.pszName = ( LPTSTR )::ArrayAllocMem( m_pParser->lpaBlocks, ( strName.GetStringLength() + 1 ) * sizeof( TCHAR ));
			if ( bBlock.pszName )
			{
				// Copy the name.
				_tcscpy( bBlock.pszName, strName );

				// Allocate start string.
				bBlock.pszStart = ( LPTSTR )::ArrayAllocMem( m_pParser->lpaBlocks, ( _tcslen( _T( ";" )) + 1 ) * sizeof( TCHAR ));
				if ( bBlock.pszStart )
				{
					// Copy the name.
					_tcscpy( bBlock.pszStart, _T( ";" ));

					// Setup the length.
					bBlock.nStart = _tcslen( _T( ";" ));

					// Block end is EOL.
					bBlock.pszEnd = END_OF_LINE;

					// Add it to the array.
					if ( ::ArrayAdd( m_pParser->lpaBlocks, &bBlock, 1 ))
					{
						// Get the added block.
						LPBLOCK	lpAdded = ( LPBLOCK )::ArrayGetAt( m_pParser->lpaBlocks, ::ArrayGetSize( m_pParser->lpaBlocks ) - 1 );

						// Setup color.
						lpAdded->crColor = RGB( 50, 100, 150 );
						lpAdded->crBgColor = CLR_DEFAULT;

						// We have to re-add the array contents since
						// adding items to the array may have
						// caused a re-allocation of the array
						// elements which, in turn, causes the
						// listview contents to be faulty.
						m_Blocks.ResetContent();
						for ( int i = 0; i < ::ArrayGetSize( m_pParser->lpaBlocks ); i++ )
							m_Blocks.AddString(( LPCTSTR )::ArrayGetAt( m_pParser->lpaBlocks, i ));

						// Select last added entry.
						m_Blocks.SetCurSel( ::ArrayGetSize( m_pParser->lpaBlocks ) - 1 );

						// Setup toolbar.
						SetupToolbar();
						
						// Changes made...
						pSettings->Changed( m_pParser );

						// Edit it.
						BlockEdit be;
						if ( be.EditBlock( *GetParent(), lpAdded, m_pParser ))
							// Refresh the list.
							m_Blocks.Invalidate();
						return 0;
					}
					::ArrayFreeMem( m_pParser->lpaBlocks, bBlock.pszStart );
				}
				::ArrayFreeMem( m_pParser->lpaBlocks, bBlock.pszName );
			}
			MessageBox( ClsString( MAKEINTRESOURCE( IDS_NO_MEMORY )), ClsGetApp()->GetAppTitle(), MB_ICONERROR | MB_OK );
			return 0;
		}

		case	IDC_COMMON:
			// Setup toolbar.
			SetupToolbar();
			return 0;
			
		case	IDC_BLOCKS:
			// Double-click?
			if ( nNotifyCode == LBN_DBLCLK )
			{
				// Get the current selection.
				int nSel = m_Blocks.GetCurSel();

				// Edit it.
				BlockEdit be;
				if ( be.EditBlock( *GetParent(), ( LPBLOCK )::ArrayGetAt( m_pParser->lpaBlocks, nSel ), m_pParser ))
				{
					// Refresh the list.
					m_Blocks.Invalidate();
					pSettings->Changed( m_pParser );
				}
			}
			else
				// Setup the toolbar.
				SetupToolbar();
			return 0;

		case	IDC_ESCAPE:
		{
			TCHAR	szBuf[ 2 ] = { 0 };

			// Pickup the buffer.
			m_Escape.GetWindowText( szBuf, 2 );

			// did it really change?
			if ( m_pParser->cEscape != szBuf[ 0 ] )
			{
				// Save escape character.
				m_pParser->cEscape = szBuf[ 0 ];
			
				// Changes made...
				pSettings->Changed( m_pParser );
			}
			return 0;
		}

		case	IDC_SYNTAX:
			// Get setting.
			m_pParser->bSyntaxColoring = ( BOOL )( m_Syntax.GetCheck() == BST_CHECKED );
			pSettings->Changed( m_pParser );
			return 0;

		case	IDC_FONT:
		{
			// Copy the font input.
			LOGFONT lf = m_pParser->lfScreenFont;

			// Popup font dialog.
			ClsFontDialog fd;
			if ( fd.DoModal( this, &lf, CF_BOTH | CF_FIXEDPITCHONLY | CF_INITTOLOGFONTSTRUCT ))
			{
				// Copy the contents.
				m_pParser->lfScreenFont = lf;
			
				// Changes made...
				pSettings->Changed( m_pParser );
			}
			return 0;
		}

		case	IDC_KEYWORDS:
		{
			// Open the keyword editor...
			KeywordEdit ke;
			ke.Edit( *GetParent(), m_pParser );
			return 0;
		}
	}
	// Pass to the base class.
	return Page::OnCommand( nNotifyCode, nCtrlID, hWndCtrl );
}