예제 #1
0
파일: KEYWORDS.CPP 프로젝트: jcbaar/BCC
// Open the keysword editor.
void KeywordEdit::Edit( ClsWindow& Parent, LPPARSER pParser )
{
	// Save parser pointer.
	m_pParser = pParser;
	
	// Save current case setting.
	m_bCase = pParser->bCaseOn;

	// Convert the hash table into a list.
	if ( Hash2List( &m_KeyLst, pParser ))
	{
		// Open the dialog.
		if ( DoModal( Parent, IDD_KEYWORDS ) <= 0 )
			// Free the list.
			FreeKeyList( &m_KeyLst );
		else
		{
			// Use the changes.
			if ( UseKeywords( &m_KeyLst ) == FALSE )
				// Error...
				MessageBox( ClsString( MAKEINTRESOURCE( IDS_NO_MEMORY )), ClsGetApp()->GetAppTitle(), MB_ICONERROR | MB_OK );
			
			// Save case setting.
			pParser->bCaseOn = m_bCase;
			
			// Changes where made.
			pSettings->Changed( pParser );
		}
	}
	else
		// Error...
		MessageBox( ClsString( MAKEINTRESOURCE( IDS_NO_MEMORY )), ClsGetApp()->GetAppTitle(), MB_ICONERROR | MB_OK );
}
예제 #2
0
파일: main.cpp 프로젝트: x2on/NiLogViewer
	// WM_INITDIALOG handler.
	virtual LRESULT OnInitDialog( PROPSHEETPAGE *psp )
	{
		// This style will prevent flickering when the dialog
		// is resized.
		ModifyStyle( 0, WS_CLIPCHILDREN );
		
		// We must create the layout engine controls here. This way the "ClsDialog"
		// class will distribute it's font to the layout engine controls aswell.
		m_LHorz.Create(     *this, Offsets( 0, 0, 0, 0 ), LAYOUT_Horizontal, TRUE, TAG_END );
		m_LVert.Create(     *this, Offsets( 0, 0, 0, 0 ), LAYOUT_Horizontal, FALSE, TAG_END );
		m_LGrh[ 0 ].Create( *this, Offsets( 0, 0, 0, 0 ), LAYOUT_Horizontal, TRUE, TAG_END );
		m_LGrh[ 1 ].Create( *this, Offsets( 0, 0, 0, 0 ), LAYOUT_Horizontal, TRUE, TAG_END );
		m_LGrh[ 2 ].Create( *this, Offsets( 0, 0, 0, 0 ), LAYOUT_Horizontal, TRUE, TAG_END );
		m_LGrv.Create(      *this, Offsets( 0, 0, 0, 0 ), LAYOUT_Horizontal, FALSE, TAG_END );
		m_HorVerGr.Create(  *this, Offsets( 0, 0, 0, 0 ), LAYOUT_Horizontal, TRUE, LAYOUT_FrameGroup, TRUE, LAYOUT_Title, _T( "Horizontal, Vertical && Grid:" ), TAG_END );
		m_LWeight.Create(   *this, Offsets( 0, 0, 0, 0 ), LAYOUT_Horizontal, TRUE, LAYOUT_FrameGroup, TRUE, LAYOUT_Title, _T( "Weight controlled:" ), TAG_END );
		m_FrFix.Create(     *this, Offsets( 0, 0, 0, 0 ), LAYOUT_Horizontal, TRUE, LAYOUT_FrameGroup, TRUE, LAYOUT_Title, _T( "Free && Fixed sizes:" ), TAG_END );
		m_HorzOK.Create(    *this, Offsets( 0, 0, 0, 0 ), LAYOUT_Horizontal, TRUE, TAG_END );
		m_Master.Create(    *this, Offsets( 6, 6, 6, 6 ), LAYOUT_Spacing, 6, LAYOUT_Horizontal, FALSE, LAYOUT_Master, TRUE, TAG_END );

		// Loadup and set icon.
		m_hIcon = ( HICON )::LoadImage( ClsGetApp()->GetResourceHandle(), MAKEINTRESOURCE( IDI_ICON ), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR );
		SetIcon( m_hIcon, FALSE );

		// Call the base class. ClsDialog will distribute the dialog
		// font to all of it's childdren.
		return ClsSizeDialog::OnInitDialog( psp );
	}
예제 #3
0
파일: Main.cpp 프로젝트: x2on/NiLogViewer
// Entry point.
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nShowCmd )
{
	// Setup app.
	if ( ClsGetApp()->Setup( hInstance, lpCmdLine, nShowCmd ))
	{
		// Check OS version.
		if ( ClsGetApp()->GetPlatformID() != VER_PLATFORM_WIN32_WINDOWS &&
		     ClsGetApp()->GetPlatformID() != VER_PLATFORM_WIN32_NT )
		{
			MessageBox( NULL, _T( "Windows 95/98/ME/NT/2000/XP required!" ), _T( "\"FastFind\" Sample" ), MB_OK );
			return NULL;
		}

		// Create and open the dialog.
		FastFindDlg	dlg;
		dlg.DoModal( IDD_FIF );
	}
	return 0;
}
예제 #4
0
파일: main.cpp 프로젝트: x2on/NiLogViewer
// Entry point.
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nShowCmd )
{
	int		rc = 0;

	// Setup app.
	if ( ClsGetApp()->Setup( hInstance, lpCmdLine, nShowCmd ))
	{
		// Check OS version.
		if ( ClsGetApp()->GetPlatformID() != VER_PLATFORM_WIN32_WINDOWS &&
		     ClsGetApp()->GetPlatformID() != VER_PLATFORM_WIN32_NT )
		{
			MessageBox( NULL, _T( "Windows 98/ME/NT/2000/XP required!" ), _T( "\"ClsLayoutEngine\" Sample" ), MB_OK );
			return NULL;
		}
		// Build and show the dialog.
		LayoutDlg dlg;
		dlg.DoModal( IDD_LAYOUT );
	}
	return rc;
}
예제 #5
0
// For the layout engine.
BOOL ClsFlatButton::OnGetMinSize( ClsSize& szMinSize )
{
	// Add room for the frame.
	szMinSize.CX() += ::GetSystemMetrics( SM_CXFRAME ) * 3;

	// For vista and up we use different numbers.
	if ( ClsGetApp()->GetMajorVersion() >= 6 )
	{
		szMinSize.CY() += ::GetSystemMetrics( SM_CYFRAME ) * 1 + 4;
	}
	else
	{
		szMinSize.CY() += ::GetSystemMetrics( SM_CYFRAME ) * 3;
	}

	// Images?
	int cxi = 0, cyi = 0;
	if ( m_hImages && ImageList_GetImageCount( m_hImages ))
	{
		// Get the image size.
		ImageList_GetIconSize( m_hImages, &cxi, &cyi );

		// Make room.
		cxi += 4;

		// Add sizes.
		szMinSize.CX() += cxi;
		szMinSize.CY() += cyi;
	}

	// Do we have a caption?
	ClsString str( GetSafeHWND());
	if ( str.GetStringLength())
	{
		// Setup the DC.
		ClsGetDC dc( this );
		ClsFont font;
		GetFont( font );
		ClsSelector sel( &dc, font );

		// Measure the caption.
		ClsRect rc;
		dc.DrawText( str, rc, DT_CALCRECT );

		// Add the width of the caption.
		szMinSize.CX() += rc.Width() + 4;

		// Adjust the height if necessary.
		if ( rc.Height() > cyi )
			szMinSize.CY() += rc.Height() - cyi;
	}
	return TRUE;
}
예제 #6
0
파일: xpmenu.cpp 프로젝트: jcbaar/ClassLib
// Measure the frame.
void ClsXPMenu::OnMeasureFrame( LPRECT pRect )
{
	// Old style, let the baseclass decide.
	if ( m_bDrawOldStyle )
	{
		ClsBitmapMenu::OnMeasureFrame( pRect );
		return;
	}

	// Setup frame size in pixels.
	pRect->left = pRect->top = 2;
	pRect->right = pRect->bottom = m_bDrawShadow ? ( ClsGetApp()->IsShadowEnabled() ? 2 : 6 ) : 2;
}
예제 #7
0
파일: CPL.CPP 프로젝트: x2on/NiLogViewer
// DLL entry point.
BOOL WINAPI DllMain( HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved )
{
	// Why are we called?
	switch ( dwReason )
	{
		case	DLL_PROCESS_ATTACH:
			// Setup the application.
			return ClsGetApp()->Setup( hModule, NULL, SW_NORMAL, MAKEINTRESOURCE( IDI_MAIN ), MAKEINTRESOURCE( IDS_APP_TITLE ));

		case	DLL_PROCESS_DETACH:
			break;
	}
	return TRUE;
}
예제 #8
0
// Constructor. Defaults the data.
ClsSplitter::ClsSplitter()
{
	// Setup defaults.
	m_bIsHorizontal = TRUE;
	m_bIsMoving	= FALSE;
	m_bIsVisible	= FALSE;
	m_nPosition	= 0;
	m_nMinPane1	= m_nMinPane2 = 10;
	m_hPane1	= m_hPane2 = ( HWND )NULL;

	// Get cursors.
	m_hHorz = ClsGetCursor( ClsApp::STC_HSPLIT );
	m_hVert = ClsGetCursor( ClsApp::STC_VSPLIT );

	// Attach brush.
	m_HatchBrush.Attach( ClsGetApp()->GetPatternBrush(), FALSE );
}
예제 #9
0
파일: Main.cpp 프로젝트: x2on/NiLogViewer
	// WM_INITDIALOG message handler...
	virtual LRESULT OnInitDialog( PROPSHEETPAGE *p )
	{
		// Loadup and set icon.
		m_hIcon = ( HICON )::LoadImage( ClsGetApp()->GetResourceHandle(), MAKEINTRESOURCE( IDI_FIND ), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR );
		SetIcon( m_hIcon, FALSE );

		// Create layout engine controls. We do this before "ClsDialog" get's
		// a chance to distribute it's font to it's children so that when it does
		// the layout engine controls will get the font set too.
		m_Master.Create( *this, Offsets( 6, 6, 6, ::GetSystemMetrics( SM_CYHSCROLL )), LAYOUT_Master, TRUE, LAYOUT_Horizontal, FALSE, TAG_END );
		m_Left.Create( *this, Offsets( 0, 0, 0, 0 ), LAYOUT_Horizontal, FALSE, LAYOUT_EqualMinWidth, TRUE, TAG_END );
		m_Right.Create( *this, Offsets( 0, 0, 0, 0 ), LAYOUT_Horizontal, FALSE, TAG_END );
		m_StatBut.Create( *this, Offsets( 0, 0, 0, 0 ), LAYOUT_Horizontal, TRUE, TAG_END );
		m_LeftRight.Create( *this, Offsets( 0, 0, 0, 0 ), LAYOUT_Spacing, 6, LAYOUT_Horizontal, TRUE, TAG_END );

		// Setup infobar control.
		m_Proc.Attach( GetDlgItemHandle( IDC_PROC ));
		m_Proc.CompactAsPath() = TRUE;

		// Setup list.
		m_List.Attach( GetDlgItemHandle( IDC_LIST ));
		m_List.SetExtendedListViewStyle( LVS_EX_FULLROWSELECT );
		m_List.InsertColumn( 0, _T( "File" ));
		m_List.InsertColumn( 1, _T( "Line Nr." ));
		m_List.InsertColumn( 2, _T( "Line" ));

		// Setup other controls.
		m_Find.Attach( GetDlgItemHandle( IDC_FIND ));
		m_Type.Attach( GetDlgItemHandle( IDC_TYPES ));
		m_Case.Attach( GetDlgItemHandle( IDC_CASE ));
		m_Recur.Attach( GetDlgItemHandle( IDC_RECUR ));
		m_Folder.Attach( GetDlgItemHandle( IDC_FOLDER ));
		m_Folder.ShowFiles() = FALSE;
		m_Folder.LoadingTextColor() = RGB( 255, 0, 0 );
		m_Occ.Attach( GetDlgItemHandle( IDC_OCC ));
		m_Go.Attach( GetDlgItemHandle( IDC_GO ));
		m_About.Attach( GetDlgItemHandle( IDC_ABOUT ));

		// Call the base class. The base will also distribute the
		// dialog font.
		return ClsSizeDialog::OnInitDialog( p );
	}
예제 #10
0
파일: KEYBOARD.CPP 프로젝트: jcbaar/BCC
// Create a command list node.
void KeyboardPage::CreateNode( int nType, LPVOID lpvData )
{
	// Get the currently selected keyboard hash.
	LPHASH pHash = GetSelection();
	LPCNODE pCNode = NULL;
	if ( pHash )
	{
		// Allocate node.
		pCNode = ( LPCNODE )::AllocPooled( pParserPool, sizeof( CNODE ));
		if ( pCNode != NULL )
		{
			// Setup type.
			pCNode->nType = nType;

			// Hardcoded?
			if ( nType == CTYPE_HARDCODED )
				// Setup function.
				pCNode->lpFunc = ::FindCommand(( int )lpvData );
			else
			{
				// Allocate string copy.
				pCNode->pcStr = ::CopyStringPool( pParserPool, ( LPCTSTR )lpvData );
				if ( pCNode->pcStr == NULL )
				{
					// Failure.
					MessageBox( ClsString( MAKEINTRESOURCE( IDS_NO_MEMORY )), ClsGetApp()->GetAppTitle(), MB_ICONERROR | MB_OK );
					::FreePooled( pParserPool, pCNode );
					pCNode = NULL;
				}
			}
		}
		else
			MessageBox( ClsString( MAKEINTRESOURCE( IDS_NO_MEMORY )), ClsGetApp()->GetAppTitle(), MB_ICONERROR | MB_OK );
	}

	// Still there?
	if ( pCNode )
	{
		// Add the node to the list.
		AddTail(( LPLIST )pHash->lpCommands, ( LPNODE )pCNode );

		// Add it to the listview.
		int nSel = m_Commands.AddString(( LPCTSTR )pCNode );
		if ( nSel != LB_ERR )
		{
			// Select the entry.
			m_Commands.SetCurSel( nSel );

			// Edit the node.
			SendMessage( WM_COMMAND, MAKEWPARAM( IDC_COMMANDS, LBN_DBLCLK ), ( LPARAM )m_Commands.GetSafeHWND());

			// Changes have been made.
			pSettings->Changed( m_pParser );
			SetupControls();
		}
		else
		{
			// Show out of memory error. Guess this should be the
			// only reason this could fail.
			MessageBox( ClsString( MAKEINTRESOURCE( IDS_NO_MEMORY )), ClsGetApp()->GetAppTitle(), MB_ICONERROR | MB_OK );

			// Free the node and
			// it's string.
			if ( nType != CTYPE_HARDCODED ) ::FreePooled( pParserPool, pCNode->pcStr );
			::FreePooled( pParserPool, pCNode );
		}
	}
}
예제 #11
0
파일: KEYBOARD.CPP 프로젝트: jcbaar/BCC
// Add a keyboard mapping.
void KeyboardPage::AddKeyMapping( ClsString strKey )
{
	// Convert the string to a code and qualifier.
	TCHAR cCode, cQual;
	if ( ::Str2CodeQual( strKey, &cCode, &cQual ) == FALSE )
		return;

	// Is the hash for this key already defined?
	LPHASH lpHash;
	for ( lpHash = m_pParser->aHash[ cCode & HASHMASK ]; lpHash; lpHash = lpHash->lpNext )
	{
		// Is this the one?
		if ( lpHash->cCode == cCode && lpHash->cQual == cQual )
		{
			// Find the entry in the
			// listview control.
			for ( int i = 0; ; i++ )
			{
				// Find it in the list control.
				int nKey = m_Keys.FindString( 0, strKey );
				if ( nKey != LB_ERR )
				{
					// Select the key.
					m_Keys.SetCurSel( nKey );
					SendMessage( WM_COMMAND, MAKEWPARAM( IDC_KEYS, LBN_SELCHANGE ), ( LPARAM )m_Keys.GetSafeHWND());
					return;
				}
			}
		}
	}

	// Hash not available. Allocate
	// an empty command list.
	LPCLIST lpCList = ( LPCLIST )::AllocPooled( pParserPool, sizeof( CLIST ));
	if ( lpCList )
	{
		// Initialize list.
		NewList(( LPLIST )lpCList );

		// Add the hash to the hash table.
		if (( lpHash = ::AddHash( pParserPool, m_pParser->aHash, cCode, cQual, lpCList )) != NULL )
		{
			// Add the string to the
			// listview control.
			int nAdd = m_Keys.AddString( strKey );

			// Select it.
			m_Keys.SetCurSel( nAdd );
			SendMessage( WM_COMMAND, MAKEWPARAM( IDC_KEYS, LBN_SELCHANGE ), ( LPARAM )m_Keys.GetSafeHWND());
			
			// Changes made...
			pSettings->Changed( m_pParser );
			return;
		}
		else
			// Emit an error.
			MessageBox( ClsString( MAKEINTRESOURCE( IDS_NO_MEMORY )), ClsGetApp()->GetAppTitle(), MB_ICONERROR | MB_OK );

		// De-allocate command list.
		::FreePooled( pParserPool, lpCList );
	}
	else
		// Emit an error.
		MessageBox( ClsString( MAKEINTRESOURCE( IDS_NO_MEMORY )), ClsGetApp()->GetAppTitle(), MB_ICONERROR | MB_OK );
}
예제 #12
0
파일: main.cpp 프로젝트: x2on/NiLogViewer
// Entry point.
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nShowCmd )
{
	int		rc = 0;

	// Setup app.
	if ( ClsGetApp()->Setup( hInstance, lpCmdLine, nShowCmd ))
	{
		// Check OS version.
		if ( ClsGetApp()->GetPlatformID() != VER_PLATFORM_WIN32_WINDOWS &&
		     ClsGetApp()->GetPlatformID() != VER_PLATFORM_WIN32_NT )
		{
			MessageBox( NULL, _T( "Windows 95/98/ME/NT/2000 required!" ), _T( "\"ClsFileDirTree\" Sample" ), MB_OK );
			return NULL;
		}
		
		// Create and open the dialog.
		ClsMessageBox mb;

		mb.Body() = ISEQ_CENTER ISEQ_BOLD _T( "ClsMessageBox\n\n" ) ISEQ_NORMAL
			    ISEQ_LEFT _T( "This class allows you to create dialogs simular to the way the\n" )
				      _T( "system MessageBox() API does. The major difference between the\n" )
				      _T( "system solution and the solution of this class is that this class\n" )
				      _T( "uses the \"" ) 
				      ISEQ_BOLD ISEQ_TEXTRGB( _T( "200,0,0" )) 
				      _T( "ClsInfoControl" ) 
				      ISEQ_NORMAL ISEQ_TEXTSYSCOLOR( IG_COLOR_BTNTEXT ) 
				      _T( "\" control to display it's body text.\n\n" )
				_T( "By using command sequences in the text this control can show\ntext styles like:\n\n" )
				ISEQ_CENTER ISEQ_BOLD _T( "Bold" ) ISEQ_NORMAL _T( "," ) 
				ISEQ_ITALIC _T( "Italic" ) ISEQ_NORMAL _T( "," )
				ISEQ_UNDERLINE _T( "Underline" ) ISEQ_NORMAL _T( ", and " )
				ISEQ_BOLD ISEQ_ITALIC ISEQ_UNDERLINE _T( "Combinations" ) ISEQ_NORMAL
				_T( "\n\n" )
				_T( "Also text in " )
				ISEQ_BACKRGB( _T( "255,255,245" ))
				ISEQ_TEXTRGB( _T( "255,0,0C" ))
				ISEQ_TEXTRGB( _T( "0,155,0o" ))
				ISEQ_TEXTRGB( _T( "0,0,255l" ))
				ISEQ_TEXTRGB( _T( "0,155,0o" ))
				ISEQ_TEXTRGB( _T( "255,0,0r" ))
				ISEQ_TEXTRGB( _T( "0,155,0s" ))
				ISEQ_TEXTSYSCOLOR( IG_COLOR_BTNTEXT )
				ISEQ_BACKSYSCOLOR( IG_COLOR_BTNFACE )
				_T( " is possible...\n\n" )
				_T( "Besides that text can also be\n\n" )
				ISEQ_LEFT _T( "left aligned\n" )
				ISEQ_RIGHT _T( "right aligned\n" )
				ISEQ_CENTER _T( "or centered" );
		mb.Buttons() = _T( "&OK" );
		mb.Title() = _T( "A litle test..." );
		mb.Flags() = ClsMessageBox::MBF_ICONQUESTION;

		FONTDATA fd;
		fd.sPointSize = 9;
		fd.sWeight = FW_NORMAL;
		fd.bItalic = FALSE;
		_tcscpy( fd.szFacename, _T( "Courier New"));

		mb.MsgBox( NULL );
	}
	return rc;
}
예제 #13
0
파일: KEYWORDS.CPP 프로젝트: jcbaar/BCC
// Read keywords from a file.
BOOL KeywordEdit::ReadKeywords( LPCTSTR pszFileName )
{
	// Get item position and data.
	int		nPos = m_List.GetCurSel();
	_ASSERT( nPos != LB_ERR );
	LPKEYWORDS	pKey = ( LPKEYWORDS )m_List.GetItemData( nPos );
	ClsStdioFile	file;

	// Valid node?
	if ( pKey != ( LPKEYWORDS )LB_ERR )
	{
		try
		{
			// Open the file.
			file.Open( pszFileName, _T( "r" ));

			// Read the file...
			TCHAR szBuffer[ 1024 ], *pszPtr, *pszCopy;
			while (( pszPtr = file.GetS( szBuffer, 1024 )) != NULL )
			{
				// Skip leading blanks.
				while ( _istspace( *pszPtr )) pszPtr++;

				// Also remove trailing
				// blanks.
				RemoveTrailingBlanks( pszPtr );

				// Any text left?
				if ( _tcslen( pszPtr ))
				{
					// Create a copy of the
					// input string.
					if (( pszCopy = StringArrayCopy( pKey->lpaKeywords, pszPtr )) != NULL )
					{
						 // Add it to the array.
						if ( ::ArrayAdd( pKey->lpaKeywords, &pszCopy, 1 ) == FALSE )
						 {
							// Error...
							MessageBox( ClsString( MAKEINTRESOURCE( IDS_NO_MEMORY )), ClsGetApp()->GetAppTitle(), MB_ICONERROR | MB_OK );
							break;
						 }
					}
					else
					{
						// Error...
						MessageBox( ClsString( MAKEINTRESOURCE( IDS_NO_MEMORY )), ClsGetApp()->GetAppTitle(), MB_ICONERROR | MB_OK );
						break;
					}
				}
			}

			// Close the input file.
			file.Close();
		}
		catch( ClsException& ex )
		{
			UNREFERENCED_PARAMETER( ex );
			return FALSE;
		}
	}
	// Sort the array.
	::ArraySort( pKey->lpaKeywords, ( COMPFUNC )CompareKeywords );
	return TRUE;
}
예제 #14
0
파일: KEYWORDS.CPP 프로젝트: jcbaar/BCC
// WM_COMMAND message handler.
LRESULT KeywordEdit::OnCommand( UINT nNotifyCode, UINT nCtrlID, HWND hWndCtrl )
{
	// What's the ID?
	switch ( nCtrlID )
	{
		case	EditToolbar::ETID_EDIT:
		{
			// Valid entry?
			LPKEYWORDS pKW = ( LPKEYWORDS )m_List.GetItemData( m_List.GetCurSel());
			if ( pKW != ( LPKEYWORDS )LB_ERR )
			{
				// Edit the keywords.
				KWEdit kwe;
				kwe.Edit( *this, pKW, this );
			}
			return 0;
		}

		case	EditToolbar::ETID_INSERT:
		{
			// Popup the file dialog.
			ClsFileDialog fd;
			fd.Filters() = _T( "Text files (*.txt)\0*.txt\0All files (*.*)\0*.*\0\0" );
			fd.Caption().LoadString( IDS_INSERT_KEYWORDS );
			
			if ( fd.DoModal( this, NULL, NULL, TRUE, OFN_FILEMUSTEXIST ))
			{
				// Get the selected filename.
				ClsString name;
				fd.GetName( 0, name );

				// Read the file and add the read keywords
				// to the selected node.
				ReadKeywords( name );

				// Make sure the keywords are
				// displayed.
				SendMessage( WM_COMMAND, MAKEWPARAM( IDC_LIST, LBN_SELCHANGE ), ( LPARAM )m_List.GetSafeHWND());
			}
			return 0;
		}

			
		case	EditToolbar::ETID_COLOR:
		{
			// Get the current selection.
			int nSel = m_List.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_Tools.GetItemRect( 6, rc );
				m_Tools.ClientToScreen( rc );

				// Obtain the entry data.
				LPKEYWORDS pKW = ( LPKEYWORDS )m_List.GetItemData( nSel );
				if ( pKW != ( LPKEYWORDS )LB_ERR )
				{
					// Create the popup. The popup will automatically destroy
					// itself.
					new ClsColorPopup( ClsPoint( rc.Left(), rc.Bottom()), 
							   pKW->crColor, 
							   this,
							   CS_FORE,
							   NULL, 
							   ClsString( MAKEINTRESOURCE( IDS_CUSTOM )), 
							   NULL, 
							   TRUE,
							   FALSE );
				}
			}
			return 0;
		}

		case	EditToolbar::ETID_BGCOLOR:
		{
			// Get the current selection.
			int nSel = m_List.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_Tools.GetItemRect( 7, rc );
				m_Tools.ClientToScreen( rc );

				// Obtain the entry data.
				LPKEYWORDS pKW = ( LPKEYWORDS )m_List.GetItemData( nSel );
				if ( pKW != ( LPKEYWORDS )LB_ERR )
				{
					// Create the popup. The popup will automatically destroy
					// itself.
					new ClsColorPopup( ClsPoint( rc.Left(), rc.Bottom()), 
							   pKW->crBgColor, 
							   this,
							   CS_BACK,
							   ClsString( MAKEINTRESOURCE( IDS_TRANSPARENT )), 
							   ClsString( MAKEINTRESOURCE( IDS_CUSTOM )), 
							   NULL, 
							   TRUE,
							   FALSE );
				}
			}
			return 0;
		}

		case	IDC_LIST:
		{
			// Selection change?
			if ( nNotifyCode == LBN_SELCHANGE )
			{
				// Valid entry?
				LPKEYWORDS pKW = ( LPKEYWORDS )m_List.GetItemData( m_List.GetCurSel());
				if ( pKW != ( LPKEYWORDS )LB_ERR )
				{
					// Reset words content.
					m_KeyList.ResetContent();

					// Add keywords.
					m_KeyList.SetRedraw( FALSE );
					for ( int i = 0; i < ::ArrayGetSize( pKW->lpaKeywords ); i++ )
						m_KeyList.AddString(( LPCTSTR )*(( LPTSTR * )::ArrayGetAt( pKW->lpaKeywords, i )));
					m_KeyList.SetRedraw();

					// Setup UI.
					SetupControls();
				}
			}
			return 0;
		}

		case	EditToolbar::ETID_DELETE:
		{			
			// Valid entry?
			LPKEYWORDS pKW = ( LPKEYWORDS )m_List.GetItemData( m_List.GetCurSel());
			if ( pKW != ( LPKEYWORDS )LB_ERR )
			{
				ClsMessageBox mb;
				mb.Title() = ClsGetApp()->GetAppTitle();
				mb.Buttons().LoadString( IDS_YESNO );
				mb.Body().LoadString( IDS_KEYWORD_DELETE );
				mb.Flags() = ClsMessageBox::MBF_ICONEXCLAMATION;
				// Sure?
				if ( mb.MsgBox( GetSafeHWND()))
				{
					// Save current selection
					// position.
					int nSel = m_List.GetCurSel();
					int nPos = nSel;

					// Select the next one or
					// the previous one.
					if ( nSel == m_List.GetCount() - 1 ) nSel--;
					else				     nSel++;

					// Select the other item.
					m_List.SetCurSel( nSel );
					
					// Setup UI.
					SetupControls();

					// Clear the list contents
					m_KeyList.ResetContent();

					// Reset selection.
					SendMessage( WM_COMMAND, MAKEWPARAM( IDC_LIST, LBN_SELCHANGE ), ( LPARAM )m_List.GetSafeHWND());

					// Remove the selection.
					m_List.DeleteString( nPos );

					// Remove the node.
					Remove(( LPNODE )pKW );

					// Free the keyword array and the node.
					if ( pKW->lpaKeywords ) ::ArrayDelete( pKW->lpaKeywords );
					::FreePooled( pParserPool, pKW );
				}	
			}
			return 0;
		}

		case	EditToolbar::ETID_NEW:
		{
			// Allocate a new node.
			LPKEYWORDS pKW = ( LPKEYWORDS )::AllocPooled( pParserPool, sizeof( KEYWORDS ));
			if ( pKW )
			{
				// Allocate an array.
				pKW->lpaKeywords = ::ArrayCreate( 0, 500, sizeof( LPTSTR * ));
				if ( pKW->lpaKeywords )
				{
					// Set color.
					pKW->crColor   = ::GetSysColor( COLOR_WINDOWTEXT );
					pKW->crBgColor = CLR_DEFAULT;

					// Add the node to the list.
					AddTail(( LPLIST )&m_KeyLst, ( LPNODE )pKW );

					// Add it to the listview and select it.
					int nPos = m_List.AddString(( LPCTSTR )pKW );
					m_List.SetCurSel( nPos );

					// Clear the keywords list.
					m_KeyList.ResetContent();

					// Setup UI.
					SetupControls();
					return 0;
				}
				else
					::FreePooled( pParserPool, pKW );
			}
			// Error.
			MessageBox( ClsString( MAKEINTRESOURCE( IDS_NO_MEMORY )), ClsGetApp()->GetAppTitle(), MB_ICONERROR | MB_OK );
			return 0;
		}

		case	IDC_CASE:
			// Get value.
			m_bCase = ( BOOL )( m_Case.GetCheck() == BST_CHECKED );
			return 0;

		case	IDC_OK:
			// Return OK
			EndDialog( TRUE );
			return 0;

		case	IDC_CANCEL:
			// Cancel.
			EndDialog( FALSE );
			return 0;
	}
	// Pass onto the base class.
	return ClsDialog::OnCommand( nNotifyCode, nCtrlID, hWndCtrl );
}
예제 #15
0
파일: xpmenu.cpp 프로젝트: jcbaar/ClassLib
// Render the menu frame.
void ClsXPMenu::OnDrawFrame( HDC hDC, LPCRECT pRect, LPCRECT pRectScr )
{
	// Old style, let the baseclass decide.
	if ( m_bDrawOldStyle )
	{
		ClsBitmapMenu::OnDrawFrame( hDC, pRect, pRectScr );
		return;
	}

	// Wrap the input DC.
	ClsDC *pDC = ClsDC::FromHandle( hDC );
	if ( pDC == NULL ) return;

	// Copy the input rectangle.
	ClsRect rc( *pRect );

	// Are shadows enabled? If so we only render the frame.
	// If not we have room to render the shadow ourselves.
	if ( ! ClsGetApp()->IsShadowEnabled() && m_bDrawShadow )
	{
		// Adjust for the shadow pixels.
		rc.Right()  -= 4;
		rc.Bottom() -= 4;
	}

	// Create brush and render the outer frame.
	ClsBrush brush( XPColors.GetXPColor( ClsXPColors::XPC_MENU_FRAME ));
	pDC->FrameRect( rc, &brush );

	// Do the same for the inner frame.
	brush.Delete();
	rc.Deflate( 1, 1 );
	brush.CreateSolidBrush( XPColors.GetXPColor( ClsXPColors::XPC_TEXT_BACKGROUND ));
	pDC->FrameRect( rc, &brush );

	// Do we render the shadow ourselves?
	if ( ! ClsGetApp()->IsShadowEnabled() && m_bDrawShadow )
	{
		// Do we have a parent rectangle?
		if ( m_LastParent.IsEmpty() == FALSE )
		{
			// If the right-sides match we adjust the shadow rectangle to
			// be a union of both rectangle.
			if ( m_LastParent.Right() == pRectScr->right - 4 )
			{
				ClsRect rc2;
				rc2.Union( m_LastParent, *pRectScr );
				rc2.Offset( -pRectScr->left, -pRectScr->top );
				ClsDrawTools::DrawShadow( hDC, rc2 );
			}
			else
				ClsDrawTools::DrawShadow( hDC, pRect );
		}
		else
			ClsDrawTools::DrawShadow( hDC, pRect );
	}

	// Valid parent?
	if ( m_LastParent.IsEmpty() == FALSE )
	{
		// Create an intersection of the menu rectangle and the
		// parent-item rectangle.
		ClsRect RealRect( *pRectScr );

		// Do we have a shadow?
		if ( ! ClsGetApp()->IsShadowEnabled() && m_bDrawShadow )
			RealRect.Right() -= 4;

		// Clear the intersection.
		if ( rc.Intersect( RealRect, m_LastParent ))
		{
			// Create a rectangle relative to the menu top-left.
			rc.Offset( -pRectScr->left, -pRectScr->top );

			// Adjust to fit.
			if ( rc.Width() > rc.Height()) rc.Deflate( 1, 0 ); else rc.Deflate( 0, 1 );

			// Create a brush to erase the rectangle, which actually
			// is a line instead of a true rectangle.
			brush.Delete();
			brush.CreateSolidBrush( XPColors.GetXPColor( ClsXPColors::XPC_IMAGE_BACKGROUND ));

			// Render.
			pDC->FillRect( rc, brush );
		}
	}
}
예제 #16
0
파일: CPL.CPP 프로젝트: x2on/NiLogViewer
// Control Panel callback function.
LONG WINAPI CALLBACK CPlApplet( HWND hWnd, UINT uMsg, LPARAM lParam1, LPARAM lParam2 )
{
	// What do they want...
	switch ( uMsg )
	{
		case	CPL_INIT:
			// Load brainchild.dll
			if (( hBrainchild = ::LoadLibrary( _T( "brainchild.dll" ))) != NULL )
			{
				// Create memory pool.
				if (( pParserPool = ::GetMemoryPool( 4096L )) != NULL )
				{
					// Initialize lists.
					NewList(( LPLIST )&plParsers );

					// Loadup parser files.
					if ( ::LoadParserFiles( pParserPool, &plParsers ) == TRUE )
						return TRUE;
					else
						MessageBox( hWnd, ClsString( MAKEINTRESOURCE( IDS_NO_SETTINGS )), ClsGetApp()->GetAppTitle(), MB_ICONERROR | MB_OK );

					// Free the memory pool.
					::FreeMemoryPool( pParserPool, TRUE );
				}
				else
					MessageBox( hWnd, ClsString( MAKEINTRESOURCE( IDS_NO_MEMORY )), ClsGetApp()->GetAppTitle(), MB_ICONERROR | MB_OK );
				
				// Unload the library.
				::FreeLibrary( hBrainchild );
			}
			else
				MessageBox( hWnd, ClsString( MAKEINTRESOURCE( IDS_NO_BRAINCHILD )), ClsGetApp()->GetAppTitle(), MB_ICONERROR | MB_OK );
			return FALSE;

		case	CPL_GETCOUNT:
			// We only support one dialog...
			return 1;

		case	CPL_INQUIRE:
		{
			LPCPLINFO	lpCPlInfo = ( LPCPLINFO )lParam2;

			// Setup the Control Panel
			// information...
			lpCPlInfo->idIcon = IDI_MAIN;
			lpCPlInfo->idInfo = IDS_CPL_INFO;
			lpCPlInfo->idName = IDS_CPL_NAME;
			break;
		}

		case	CPL_DBLCLK:
		{
			// Create a dialog object.
			pSettings = new SettingsDialog;

			// Launch dialog box.
			if ( hWnd )
			{
				ClsWindow Wnd;
				Wnd.Attach( hWnd );
				pSettings->DoModal( Wnd, IDD_MAIN );
			}
			else
				// Popup the dialog.
				pSettings->DoModal( IDD_MAIN );
			break;
		}

		case	CPL_STOP:
			// Free the parser list.
			FreeParserList( pParserPool, &plParsers );

			// Free the memory pool.
			FreeMemoryPool( pParserPool, TRUE );

			// Unload the library.
			FreeLibrary( hBrainchild );

			// Free the dialog object.
			delete pSettings;
			break;

		case	CPL_EXIT:
			break;

		default:
			break;
	}
	return 0;
}
예제 #17
0
파일: Syntax.cpp 프로젝트: jcbaar/BCC
// 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 );
}