Esempio n. 1
0
BOOL GetIniPath( LPSTR lpIniFile )
/************************************************************************/
{
FNAME szFileName;
BOOL bRet;

#ifdef _MAC
	// The macintosh ALWAYS uses the "Root:System:Preferences:" path when
	// acessing preferences - ALWAYS.
	// Do not use path information in the INI filename.
	return TRUE;
#else

if ( GetProfileString( "Micrografx", PRIVATE_INI, "",
	szFileName, sizeof(FNAME) ) > 2 )
	{
	FixPath( szFileName );
	lstrcat( szFileName, lpIniFile );
	if ( bRet = FileExists( szFileName ) )
		goto Found;
	}

#ifdef CDBUILD
if ( GetWindowsDirectory( szFileName, sizeof(FNAME) ) > 2 )
	{
	FixPath( szFileName );
	lstrcat( szFileName, lpIniFile );
	if ( bRet = FileExists( szFileName ) )
		goto Found;
	}
#endif

lstrcpy( szFileName, Control.ProgHome );
lstrcat( szFileName, lpIniFile );
if ( !(bRet = FileExists( szFileName )) )
	Message( IDS_INI_NOEXIST, Lowercase(lpIniFile) );

Found:
lstrcpy( lpIniFile, szFileName );

#ifndef CDBUILD
if ( bRet && !FilePermission( lpIniFile, 2 /*WRITE*/ ) )
	Message( IDS_INI_NOWRITE, Lowercase(lpIniFile) );
#endif

// Set the network variable if the INI and EXE are not in the same place
lstrcpy( szFileName, lpIniFile );
stripfile( szFileName );
FixPath( szFileName );
Control.bNetworkInstall = !StringsEqual( Control.ProgHome, szFileName );
return( bRet );
#endif // #ifdef _MAC
}
Esempio n. 2
0
void LoadComboWithDrives(
/************************************************************************/
HWND hWnd,
WORD idComboBox)
{
#ifdef WIN32

#else
int i, count, drive;
WORD wType;
char szString[MAX_STR_LEN];

drive = CURRENTDRIVE;
SetDlgItemText( hWnd, IDC_DISKSPACE, DriveSize(drive,szString) );
count = 0;
SendDlgItemMessage( hWnd, idComboBox, CB_RESETCONTENT, 0, 0L );
for ( i=0; i<=26; i++ )
	{
	if ( !(wType = GetDriveType( i )) )
		continue;
	DriveName( i, szString );
	CombineStringID( szString, IDC_PATHICON_DRIVE );
	SendDlgItemMessage( hWnd, idComboBox, CB_ADDSTRING, 0,
		(long)Lowercase(szString) );
	if ( i == drive )
		SendDlgItemMessage( hWnd, idComboBox, CB_SETCURSEL, count, 0L);
	count++;
	}
#endif  // WIN32
}
Esempio n. 3
0
BOOL CPluginPrefPage::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	HWND   	hActiveWnd = GetActiveDoc();
	HWND	hDlg = GetSafeHwnd();
	int 	id = GET_WM_COMMAND_ID(wParam, lParam);
	UINT 	codeNotify = GET_WM_COMMAND_CMD(wParam, lParam);

	switch (id)
	{
		case IDC_PREF_USEPLUGINS:
			Control.UsePlugins = !Control.UsePlugins;
			::CheckDlgButton( hDlg, id, Control.UsePlugins );
			SetModified(TRUE);
		break;

		case IDC_PREF_PLUGINPATH1:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
		    	break;
			::GetDlgItemText( hDlg, id, Control.PluginPath1,
				sizeof(Control.PluginPath1));
			FixPath( Lowercase( Control.PluginPath1 ) );
			SetModified(TRUE);
		break;

		case IDC_PREF_PLUGINPATH2:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
		    	break;
			if ( codeNotify != EN_CHANGE )
		    	break;
			::GetDlgItemText( hDlg, id, Control.PluginPath2,
				sizeof(Control.PluginPath2));
			FixPath( Lowercase( Control.PluginPath2 ) );
			SetModified(TRUE);
		break;

	   	default:
			return (CPPPropertyPage::OnCommand(wParam, lParam));   	
		break;
   	}
	return(TRUE);
}
Esempio n. 4
0
BOOL CMemoryPrefPage::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	BOOL 	Bool;
	HWND   	hActiveWnd = GetActiveDoc();
	HWND	hDlg = GetSafeHwnd();
	int 	id = GET_WM_COMMAND_ID(wParam, lParam);
	UINT 	codeNotify = GET_WM_COMMAND_CMD(wParam, lParam);

	switch (id)
	{
		case IDC_PREF_RAMDISK:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id, Control.RamDisk,
				sizeof(Control.RamDisk));
			FixPath( Lowercase( Control.RamDisk ) );
			SetModified(TRUE);
		break;

		case IDC_PREF_MEMMIN:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			Control.MainMemMin = ::GetDlgItemSpin( hDlg, id, &Bool, NO );
			SetModified(TRUE);
		break;

		case IDC_PREF_MEMFACTOR:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			Control.MainMemFactor = ::GetDlgItemSpin( hDlg, id, &Bool, NO );
			SetModified(TRUE);
		break;

		case IDC_PREF_LINEART:
			Control.LineArtAsGray = !Control.LineArtAsGray;
			::CheckDlgButton( hDlg, id, Control.LineArtAsGray );
			SetModified(TRUE);
		break;

	   	default:
			return (CPPPropertyPage::OnCommand(wParam, lParam));   	
		break;
    	}
	return(TRUE);
}
Esempio n. 5
0
BOOL CLocationsPrefPage::OnInitDialog() 
{
	HWND	hDlg = GetSafeHwnd();

 	CPPPropertyPage::OnInitDialog();
	::SetDlgItemText( hDlg, IDC_LOCATE_CLIPBITS, Lowercase(m_Clipbits) );
	::SetDlgItemText( hDlg, IDC_LOCATE_PRNSTYLES, Lowercase(m_Printstyles) );
	::SetDlgItemText( hDlg, IDC_LOCATE_BRUSHES, Lowercase(m_Brushes) );
	::SetDlgItemText( hDlg, IDC_LOCATE_PALETTES, Lowercase(m_Palettes) );
	::SetDlgItemText( hDlg, IDC_LOCATE_TEXTURES, Lowercase(m_Textures) );
	::SetDlgItemText( hDlg, IDC_LOCATE_DEVICES, Lowercase(m_Devices) );
	::SetDlgItemText( hDlg, IDC_LOCATE_FILTERS, Lowercase(m_Effects) );
	if (::GetDlgItem(hDlg, IDC_LOCATE_MACROS))
	    ::SetDlgItemText( hDlg, IDC_LOCATE_MACROS, Lowercase(m_Macros) );
	if (::GetDlgItem(hDlg, IDC_LOCATE_IMPORTFILTERS))
	    ::SetDlgItemText( hDlg, IDC_LOCATE_IMPORTFILTERS, Lowercase(m_Importfilters));
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Esempio n. 6
0
void SetFileName(
/***********************************************************************/
HWND	hDlg,
int		idCtl,
LPSTR	lpFileSpec,
LPSTR	lpSaveName,
BOOL	bSaving)
{
FNAME szName, szSpec, szExt;

if (bSaving && !fUntitled)
	{
	lstrcpy( szName, stripdir(lpSaveName) );
	stripext( szName );
	lstrcpy( szExt, extension(lpFileSpec) );
	lstrcpy( szSpec, lpFileSpec );
	stripfile( szSpec );
	FixPath( szSpec );
	lstrcat( szSpec, szName );
	lstrcat( szSpec, szExt );
	SetDlgItemText( hDlg, idCtl, Lowercase(szSpec) );
	}
else	SetDlgItemText( hDlg, idCtl, Lowercase(lpFileSpec) );
}
Esempio n. 7
0
LPSTR GetFileName(
/***********************************************************************/
HWND	hDlg,
LPSTR	lpFileName)
{
FNAME	szFileName;
STRING	szString;

GetDlgItemText( hDlg, IDC_FNAME, szFileName, sizeof(szFileName) );
FixFileName(szFileName);
GetDlgItemText( hDlg, IDC_FPATH, szString, sizeof(szString) );
FixPath( szString );
lstrcat( szString, szFileName );
Lowercase(szString);
lstrcpy(lpFileName, szString);
return(lpFileName);
}
Esempio n. 8
0
    CommandLine::StringType CommandLine::GetSwitchValueNative(
        const std::string& switch_string) const
    {
        std::string lowercased_switch(switch_string);
        Lowercase(&lowercased_switch);

        std::map<std::string, StringType>::const_iterator result =
            switches_.find(lowercased_switch);

        if(result == switches_.end())
        {
            return CommandLine::StringType();
        }
        else
        {
            return result->second;
        }
    }
Esempio n. 9
0
bool ImportImage(const char* fn, Image& img)
{
	const char* ext = FileExtension(fn);
	if(!ext) {
	  fprintf(stderr,"Couldnt detect an extension on image import file %s\n", fn);
		return false;
	}
	if(strlen(ext) > 8) {
	  fprintf(stderr,"Unknown extension \"%s\" on image import file %s\n", ext, fn);
		return false;
	}
	char extbuf[8];
	strcpy(extbuf, ext);
	Lowercase(extbuf);
	if(0 == strcmp(extbuf, "bit")) {
		return img.Read(fn);
	}
	else if(0 == strcmp(extbuf, "ppm")) {
		return ImportImagePPM(fn, img);
	}
	else if(0 == strcmp(extbuf, "bmp")) {
		return ImportImageBMP(fn, img);
	}
	else if(0 == strcmp(extbuf, "tga")) {
		return ImportImageTGA(fn, img);
	}
	else {
#ifdef _WIN32
		return ImportImageGDIPlus(fn, img);
#else
		fprintf(stderr,"ImportImage: Unknown file extension \"%s\" on image import file %s\n",extbuf,fn);
		return false;
#endif //_WIN32
	}
	/*
	{
		ReportError("Unknown extension \"%s\" on image import file %s", ext, fn);
		return false;
	}*/
}
Esempio n. 10
0
    bool CommandLine::IsSwitch(const StringType& parameter_string,
        std::string* switch_string, StringType* switch_value)
    {
        switch_string->clear();
        switch_value->clear();

        for(size_t i=0; i<arraysize(kSwitchPrefixes); ++i)
        {
            StringType prefix(kSwitchPrefixes[i]);
            if(parameter_string.find(prefix) != 0)
            {
                continue;
            }

            const size_t switch_start = prefix.length();
            const size_t equals_position = parameter_string.find(
                kSwitchValueSeparator, switch_start);
            StringType switch_native;
            if(equals_position == StringType::npos)
            {
                switch_native = parameter_string.substr(switch_start);
            }
            else
            {
                switch_native = parameter_string.substr(
                    switch_start, equals_position-switch_start);
                *switch_value = parameter_string.substr(equals_position+1);
            }
            *switch_string = WideToASCII(switch_native);
            Lowercase(switch_string);

            return true;
        }

        return false;
    }
Esempio n. 11
0
FiletypeIdentifierMap ExtractIdentifiersFromTagsFile(
  const fs::path &path_to_tag_file ) {
  FiletypeIdentifierMap filetype_identifier_map;
  std::string tags_file_contents;

  try {
    tags_file_contents = ReadUtf8File( path_to_tag_file );
  } catch ( ... ) {
    return filetype_identifier_map;
  }

  std::string::const_iterator start = tags_file_contents.begin();
  std::string::const_iterator end   = tags_file_contents.end();

  boost::smatch matches;
  const boost::regex expression( TAG_REGEX );
  const boost::match_flag_type options = boost::match_not_dot_newline;

  while ( boost::regex_search( start, end, matches, expression, options ) ) {
    start = matches[ 0 ].second;

    std::string language( matches[ 3 ] );
    std::string filetype = FindWithDefault( LANG_TO_FILETYPE,
                                            language.c_str(),
                                            Lowercase( language ).c_str() );

    std::string identifier( matches[ 1 ] );
    fs::path path( matches[ 2 ].str() );
    path = fs::absolute( path, path_to_tag_file.parent_path() )
           .make_preferred();

    filetype_identifier_map[ filetype ][ path.string() ].push_back( identifier );
  }

  return filetype_identifier_map;
}
Esempio n. 12
0
void main(void)
{	
	M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts
	
	// Start the UART(with no parity), and Counter16
	UART_Start(UART_PARITY_NONE);
	// clock for moving serial
	Counter16_Start();
	
	// Start I2CHW
	I2CHW_Start();
	I2CHW_EnableMstr();
	I2CHW_EnableInt();
	
	// This is the command usage string
	UART_CPutString("########################## I2C External SRAM ########################\r\n\
#	W # XX T [Data]\r\n\
#		W    - Write command\r\n\
#		#    - Group Address (0 - 7)\r\n\
#		XX   - Memory Location in hex (00 - FF)\r\n\
#		T    - Data Type, either A for ASCII or H for Hexadecimal\r\n\
#		Data - Either ASCII string or Hexadecimal separates by spaces\r\n\
#\t\t\tA - Mary had a little lamb\r\n\
#\t\t\tH - 01 FF A0 0F D8 C3\r\n\
#\r\n\
#	R # XX T NN\r\n\
#		R    - Read command\r\n\
#		#    - Group Address (0 - 7)\r\n\
#		XX   - Memory Location in hex (00 - FF)\r\n\
#		T    - Data Type, either A for ASCII or H for Hexadecimal\r\n\
#		NN	 - Number of bytes to read in hexadecimal\r\n\
#####################################################################\r\n");
	while (1)
	{
		char *cmd;
		char *params;
		char slaveAddress = 0x50;		// 010100000 R/W shifted to front
		
		GetLine(buf, 79); // Retrieves a line with a maximum length of 70 characters and put it in buf.
		
		memset(data, 0x00, 256);	// Initialize all the set {data} to NULL bytes
		cmd = Lowercase(cstrtok(buf, " ")); // Get the first word from the entered string and lowercase it.
		if (strlen(cmd) == 1 && cmd[0] == 'w') // If the command is one letter and it is w, then write command
		{	
			int groupAddress; // only 1 and 2 actually go to SRAM
			int memLoc;
			char dataType;
			
			int len;

			params = cstrtok(0x00, " ");  // 0x00 indicates it will continue from last cstrtok command and get next word. This gets the next parameter
			
			// csscanf if used to parse the string into values such as hexadecimal or integers
			// It returns the number of parameters it parsed which should be one
			// If the length of the params is not right or it does not parse the right amount, it returns an error
			// %d gets an integer, this is the groupAddress
			if (strlen(params) != 1 || csscanf(params, "%d", &groupAddress) != 1) goto error;
			
			// %x gets a hexadecimal value, this can read capital or lowercase letters, this is the memory location
			params = cstrtok(0x00, " ");
			if (strlen(params) != 2 || csscanf(params, "%x", &memLoc) != 1) goto error;
			
			// %c gets a character, the data type character
			params = cstrtok(0x00, " ");
			if (strlen(params) != 1 || csscanf(params, "%c", &dataType) != 1) goto error;
			
			// This reads the rest of the string and stores it in params. 
			// If the length is zero or if cstrtok returns 0, this means that there was no valid string/hex entered
			params = cstrtok(0x00, "\0");
			if (strlen(params) == 0 || params == 0x00) goto error;	// They did all the params but didn't write anything
			
			dataType = tolower(dataType); // Lowercase the data type
			if (groupAddress < 0 || groupAddress > 7)
				goto error; // groupAddress was not in range
			
			data[0] = memLoc;	// First byte needs to be the memory location according to PCF8570 datasheet
			slaveAddress |= groupAddress;	// ORs the group 2 address to the group 1 address to get slaveAddress
			
			if (dataType == 'a') // If the data type is ASCII
			{
				strcpy((data + 1), params); // Copy the string from params and put it right after the data[0] byte
				len = strlen((data + 1)) + 1; // len is the number of bytes to write, it is the length of the string and then +1 because of the memLoc byte
				// Cant just do strlen(data) because data[0] could be 0x00 and it would return 0 as the string length
			}
			else if (dataType == 'h') // If the data type is hex
			{
				// Take ASCII encoded hex data params and put it after data[0], returns number of bytes converted
				if ((len = HexConversion(params, (data + 1))) == -1)
					goto error;
				len++; // Add one to the length because of the memLoc byte at data[0]
			}
			else
				goto error;
			
			I2CHW_bWriteBytes(slaveAddress, data, len, I2CHW_CompleteXfer); // Write len bytes from data 
			while (!(I2CHW_bReadI2CStatus() & I2CHW_WR_COMPLETE)); // Wait while it is writing
			I2CHW_ClrWrStatus(); // Clear the write bit

			csprintf(data, "%x bytes were written", len); // csprintf takes the string and substitutes %x for len, puts into data str
			UART_PutString(data); // Print the string to UART
			UART_PutCRLF();
		}
		else if (strlen(cmd) == 1 && cmd[0] == 'r') // If the command is one letter and it is r, then read command
		{
			int groupAddress;
			int memLoc;
			char dataType;
			int numBytes;
			
			char hexStr[4];
			int i;

			// csscanf if used to parse the string into values such as hexadecimal or integers
			// It returns the number of parameters it parsed which should be one
			// If the length of the params is not right or it does not parse the right amount, it returns an error
			// %d gets an integer, this is the groupAddress
			params = cstrtok(0x00, " ");
			if (strlen(params) != 1 || csscanf(params, "%d", &groupAddress) != 1) goto error;
	
			// %x gets a hexadecimal value, this can read capital or lowercase letters, this is the memory location
			params = cstrtok(0x00, " ");
			if (strlen(params) != 2 || csscanf(params, "%x", &memLoc) != 1) goto error;
			
			// %c gets a character, the data type character
			params = cstrtok(0x00, " ");
			if (strlen(params) != 1 || csscanf(params, "%c", &dataType) != 1) goto error;
			
			// %x gets a hexadecimal value, number of bytes to read
			params = cstrtok(0x00, " ");
			if (strlen(params) != 2 || csscanf(params, "%x", &numBytes) != 1) goto error;
			
			// If there is any data after the number of bytes, then the format is invalid and it should return an error
			if (cstrtok(0x00, " ") != 0x00) goto error;
			
			dataType = tolower(dataType); // Lowercase the data type
			if (groupAddress < 0 || groupAddress > 7)
				goto error; // groupAddress was not in range
			
			data[0] = memLoc;	// First byte needs to be the memory location according to PCF8570 datasheet
			slaveAddress |= groupAddress;	// ORs the group 2 address to the group 1 address to get slaveAddress
			
			I2CHW_bWriteBytes(slaveAddress, data, 1, I2CHW_NoStop); // Write one byte to the RAM, the slaveAddress so it knows who were talking to
			while (!(I2CHW_bReadI2CStatus() & I2CHW_WR_COMPLETE)); // Wait while it is writing
			I2CHW_ClrWrStatus(); // Clear the write bit
			
			I2CHW_fReadBytes(slaveAddress, data, numBytes, I2CHW_CompleteXfer); // Read numBytes from the RAM, put it in data
			while(!(I2CHW_bReadI2CStatus() & I2CHW_RD_COMPLETE)); // Wait while it is reading
			I2CHW_ClrRdStatus(); // Clear the read bit
			
			if (dataType == 'a') // If the data type is ASCII
			{
				for (i = 0; i < numBytes; ++i) // Loop through each byte
					UART_PutChar(data[i]); // Put the character in PuTTy
				UART_PutCRLF();
			}
			else if (dataType == 'h') // If the data type is Hex
			{
				for (i = 0; i < numBytes; ++i) // Loop through each byte
				{
					csprintf(hexStr, "%X ", data[i]); // csprintf prints into hexStr a hexadecimal with a space
					UART_PutString(hexStr); // Print hexStr
				}
				UART_PutCRLF();
			}
			else
				goto error;
		}
		else 
			goto error;
		
		continue; // This is so that the error is skipped when everything goes right
		error: // This outputs an invalid format message and continues on to read another line
			UART_CPutString("Invalid format entered. Valid formats are:\r\n\tW [GroupAddress] [MemoryLocation] [h|a] Hex/ASCII\r\n\tR [GroupAddress] [MemoryLocation] [h|a] [NumBytes]\r\n");
	}
}
Esempio n. 13
0
int TextProc(
/************************************************************************/
HWND 	hWindow,
LPARAM 	lParam,
UINT 	msg)
{
int x, y;
BOOL fCancel = NO;
WORD wKey;
STRING szString;
static BOOL bTrackObject;
static int xMove, yMove;

if ( bTrackObject )
	{
	ToyProc( hWindow, lParam, msg );
	bTrackObject = Tool.bActive;
	Tool.bActive = YES;
	return( TRUE );
	}

x = LOWORD( lParam );
y = HIWORD( lParam );
switch (msg)
    {
    case WM_CREATE:	// The first mouse down message
	Tool.bActive = YES;
	break; // Never get sent since Tool.bActive is already set in the dialog

    case WM_LBUTTONDOWN:
	// Call the sticker mover tool first to see if he wants to take over
	Tool.bActive = NO;
	ToyProc( hWindow, lParam, WM_CREATE );
	if ( bTrackObject = Tool.bActive )
		{
		ToyProc( hWindow, lParam, msg );
		break;
		}
	if ( bTextBegun )
		Tool.bActive = YES;
	xMove = x;
	yMove = y;
//	TextMove(hWindow, x, y);
	break;

    case WM_LBUTTONUP:
	break;

	case WM_SETCURSOR:
	return( SetToolCursor( hWindow, ID_MOVE_OBJECT, ID_PLAY_OBJECT ) );

    case WM_MOUSEMOVE:	// sent when ToolActive is on
	if ( Tool.bActive && Window.fLButtonDown )
		TextOffset(hWindow, x - xMove, y - yMove);
	xMove = x;
	yMove = y;
	break;

    case WM_KILLFOCUS:
	break;

    case WM_SETFOCUS:
//	TextDisplayCaret( hWindow, NULL );
	break;

    case WM_CHAR:
	wKey = (WORD)lParam;
	TextKeystroke(hWindow, wKey);
	if ( wKey == VK_RETURN )
		{
		TextAnchor( hWindow );
		RandomizeActiveColor();
		break;
		}
	szString[0] = '_';
	szString[1] = wKey;
	szString[2] = '\0';
	Lowercase( szString );
	SoundStartResource( szString, NO/*bLoop*/, NULL/*hInstance*/ );
	break;

    case WM_KEYDOWN:
	wKey = lParam;
	switch (wKey)
		{
		case VK_UP:
			TextRMove(hWindow, 0, -1);
			break;
		case VK_DOWN:
			TextRMove(hWindow, 0, 1);
			break;
		case VK_LEFT:
			TextRMove(hWindow, -1, 0);
			break;
		case VK_RIGHT:
			TextRMove(hWindow, 1, 0);
			break;
		default:
			break;
		}
	break;

    case WM_DESTROY:	// The cancel and DeactivateTool() message
	fCancel = (lParam == 1L);
	if ( fCancel )
		{ // an "escape" cancel
		TextKeystroke( hWindow, VK_ESCAPE );
		}
	else
		{ // a deactivate
		TextKeystroke( hWindow, VK_RETURN );
		TextAnchor( hWindow );
		RandomizeActiveColor();
		HideCaret( hWindow );
		DestroyCaret();
		AstralUpdateWindow( hWindow );
		}
	break;

    case WM_LBUTTONDBLCLK:
	break;
    }
return(TRUE);
}
Esempio n. 14
0
BOOL WINPROC EXPORT DlgTextProc(
/***********************************************************************/
HWND 	hDlg,
UINT 	msg,
WPARAM 	wParam,
LPARAM 	lParam)
{
int i;
WORD wKey;
HFONT hFont;
STRING szString;

switch (msg)
    {
    case WM_INITDIALOG:
	RibbonInit( hDlg );
	ColorInit( hDlg );
	GetFonts( hDlg );
	CheckRadioButton( hDlg, IDC_TEXT_T1, IDC_TEXT_T10, Text.nFont+IDC_TEXT_T1 );
	Text.Size = 48;
	InitSlide( hDlg, IDC_TEXT_SIZE, Text.Size, 24, 200 );
	Text.Angle = 0;
	InitSlide( hDlg, IDC_TEXT_ANGLE, 0, -2, 2 );
	ControlEnable(hDlg, IDC_TEXT_ANGLE, TextCanRotate(hDlg, Text.nFont));
	for ( i=0; i<max(10,Text.nFont); i++ )
		{
		hFont = CreateFont(
				/* Height */ 45,
				/* Width */ 0,
				/* Escapement */ 0,
				/* Orientation */ 0,
				/* Weight */ FW_NORMAL,
				/* Italic */ FALSE,
				/* UnderLine */ FALSE,
				/* StrikeOut */ FALSE,
				/* CharSet */ Text.lpFontList[i].fdCharSet,
				/* Output Precis */ OUT_CHARACTER_PRECIS,
				/* Clip Precis */ CLIP_DEFAULT_PRECIS,
				/* Quality */ PROOF_QUALITY,
				/* PitchAndFamily */ Text.lpFontList[i].fdPitchAndFamily,
				/* Face */ Text.lpFontList[i].fdFaceName );
		if ( hFont )
			SendDlgItemMessage( hDlg, IDC_TEXT_T1+i, WM_SETFONT, (WPARAM)hFont, 0L );
		}
	if ( lpImage )
		{
		bTextBegun = TextBegin( lpImage->hWnd, 10/*x*/, 40/*y*/ );
		Tool.bActive = YES;
		SetFocus( lpImage->hWnd );
		}
	else
		bTextBegun = NO;
	// fall thru

    case WM_CONTROLENABLE:
    case WM_DOCACTIVATED:
	break;

	case WM_DESTROY:
	if ( bTextBegun )
		{
		if ( lpImage )
			{
			TextEnd( lpImage->hWnd, NO/*fCancel*/ );
			Tool.bActive = NO;
			AstralUpdateWindow( lpImage->hWnd );
			}
		bTextBegun = NO;
		}
	for ( i=0; i<max(10,Text.nFont); i++ )
		{
		if ( hFont = (HFONT)SendDlgItemMessage( hDlg, IDC_TEXT_T1+i, WM_GETFONT, (WPARAM)0, 0L ) )
			DeleteObject( hFont );
		}
	if ( Text.lpFontList )
		{
		FreeUp((LPTR)Text.lpFontList);
		Text.lpFontList = NULL;
		}
	break;

    case WM_CHAR:
	if ( !lpImage || !bTextBegun )
		return( FALSE );
	TextSetFocus();
	wKey = (WORD)lParam;
	TextKeystroke( lpImage->hWnd, wKey );
	if ( wKey == VK_RETURN )
		{
		TextAnchor( lpImage->hWnd );
		RandomizeActiveColor();
		break;
		}
	szString[0] = '_';
	szString[1] = wKey;
	szString[2] = '\0';
	Lowercase( szString );
	SoundStartResource( szString, NO/*bLoop*/, NULL/*hInstance*/ );
	break;

    case WM_KEYDOWN:
	if ( !lpImage || !bTextBegun )
		return( FALSE );
	wKey = lParam;
	switch (wKey)
		{
		case VK_UP:
			TextRMove( lpImage->hWnd, 0, -1 );
			break;
		case VK_DOWN:
			TextRMove( lpImage->hWnd, 0, 1);
			break;
		case VK_LEFT:
			TextRMove( lpImage->hWnd, -1, 0);
			break;
		case VK_RIGHT:
			TextRMove( lpImage->hWnd, 1, 0);
			break;
		default:
			break;
		}
	break;

    case WM_SETCURSOR:
	return( SetupCursor( wParam, lParam, IDD_TEXT ) );

    case WM_ERASEBKGND:
	break; // handle ERASEBKGND and do nothing; PAINT covers everything

    case WM_PAINT:
	LayoutPaint( hDlg );
	break;

    case WM_CLOSE:
	AstralDlgEnd( hDlg, FALSE );
	break;

    case WM_MEASUREITEM:
    case WM_DRAWITEM:
	return( OwnerDraw( hDlg, msg, lParam, NO ) );

    case WM_CTLCOLOR:
// We don't get this message
//	Print( "%u", HIWORD(lParam) );
//	if ( HIWORD(lParam) == CTLCOLOR_BTN )
//		{
//		SetTextColor( (HDC)wParam, RGB(0,0,255) ); // Blue text...
//		SetBkColor( (HDC)wParam, RGB(255,255,255) ); // on a white background
//		return( GetStockObject(WHITE_BRUSH) );
//		}
	return( (BOOL)SetControlColors( (HDC)wParam, hDlg, (HWND)LOWORD(lParam),
		HIWORD(lParam) ) );

    case WM_COMMAND:
	switch (wParam)
	    {
		case IDC_ACTIVECOLOR:
		case IDC_COLORS_TEXT:
		ColorCommand( hDlg, wParam, lParam );
		TextSetFocus();
		if (bTextBegun)
			TextFontChanged(lpImage->hWnd);
		break;

		case IDC_TEXT_T1:
		case IDC_TEXT_T2:
		case IDC_TEXT_T3:
		case IDC_TEXT_T4:
		case IDC_TEXT_T5:
		case IDC_TEXT_T6:
		case IDC_TEXT_T7:
		case IDC_TEXT_T8:
		case IDC_TEXT_T9:
		case IDC_TEXT_T10:
		CheckRadioButton( hDlg, IDC_TEXT_T1, IDC_TEXT_T10, wParam );
		Text.nFont = wParam - IDC_TEXT_T1;
		ControlEnable(hDlg, IDC_TEXT_ANGLE, TextCanRotate(hDlg, Text.nFont));
		TextSetFocus();
		if (bTextBegun)
			TextFontChanged(lpImage->hWnd);
		break;

	    case IDC_TEXT_SIZE:
		Text.Size = HandleSlide( hDlg, (ITEMID)wParam, (UINT)lParam, NULL );
		Text.Size = bound( Text.Size, 16, 216 );
		if ( !LBUTTON )
			TextSetFocus();
		if (bTextBegun)
			TextFontChanged(lpImage->hWnd);
		break;

	    case IDC_TEXT_ANGLE:
		i = HandleSlide( hDlg, (ITEMID)wParam, (UINT)lParam, NULL ); // -2 to 2
		Text.Angle = (i * 45);
		if ( Text.Angle < 0 )
			Text.Angle += 360;
		i = (Text.Angle + 22) / 45; // down to 0-8
		if ( i > 4 )
				i = bound( i - 8, -2, 0 );
		else	i = bound( i, 0, 2 );
		SetSlide( hDlg, wParam, i );
		if ( !LBUTTON )
			TextSetFocus();
		if (bTextBegun)
			TextFontChanged(lpImage->hWnd);
		break;

	    default:
		return( FALSE );
	    }

    default:
	return( FALSE );
    }

return( TRUE );
}
Esempio n. 15
0
BOOL CLocationsPrefPage::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	HWND   	hActiveWnd = GetActiveDoc();
	HWND	hDlg = GetSafeHwnd();
	int 	id = GET_WM_COMMAND_ID(wParam, lParam);
	UINT 	codeNotify = GET_WM_COMMAND_CMD(wParam, lParam);

	switch (id)
	{
		case IDC_LOCATE_CLIPBITS:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id, m_Clipbits,
				sizeof(m_Clipbits));
			FixPath( Lowercase( m_Clipbits ) );
			SetModified(TRUE);
		break;

		case IDC_LOCATE_PRNSTYLES:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id, m_Printstyles,
				sizeof(m_Printstyles));
			FixPath( Lowercase( m_Printstyles ) );
			SetModified(TRUE);
		break;
	
		case IDC_LOCATE_BRUSHES:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id, m_Brushes,
				sizeof(m_Brushes));
			FixPath( Lowercase( m_Brushes ) );
			SetModified(TRUE);
		break;

		case IDC_LOCATE_PALETTES:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id,m_Palettes ,
				sizeof(m_Palettes));
			FixPath( Lowercase( m_Palettes ) );
			SetModified(TRUE);
		break;

		case IDC_LOCATE_TEXTURES:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id,m_Textures ,
				sizeof(m_Textures));
			FixPath( Lowercase( m_Textures ) );
			SetModified(TRUE);
		break;

		case IDC_LOCATE_DEVICES:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id,m_Devices ,
				sizeof(m_Devices));
			FixPath( Lowercase( m_Devices ) );
			SetModified(TRUE);
		break;

		case IDC_LOCATE_FILTERS:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id,m_Effects ,
				sizeof(m_Effects));
			FixPath( Lowercase( m_Effects ) );
			SetModified(TRUE);
		break;

		case IDC_LOCATE_MACROS:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id,m_Macros ,
				sizeof(m_Macros));
			FixPath( Lowercase( m_Macros ) );
			SetModified(TRUE);
		break;

		case IDC_LOCATE_IMPORTFILTERS:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id,m_Importfilters ,
				sizeof(m_Importfilters));
			FixPath( Lowercase( m_Importfilters ) );
			SetModified(TRUE);
		break;

		default:
			return (CPPPropertyPage::OnCommand(wParam, lParam));   	
		break;
   	}
	return(TRUE);
}
Esempio n. 16
0
void main(void)
{	
	M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts
	M8C_EnableIntMask(INT_MSK1, INT_MSK1_DBB01); // Enable DBB01 Interrupt for TempCounter
	M8C_EnableIntMask(INT_MSK1, INT_MSK1_DBB11); // Enable DBB01 Interrupt for MotorDriver
	M8C_EnableIntMask(INT_MSK0, INT_MSK0_GPIO); // Enable GPIO interrupt for Tout
	
	// Start the UART(with no parity), LCD, TempCounter and MotorDriver
	UART_Start(UART_PARITY_NONE);
	LCD_Start();
	TempCounter_EnableInt(); // Enable interrupts for counter
	TempCounter_Start();
	MotorDriver_EnableInt(); // Enable interrupts for counter
	
	// Start I2CHW
	I2CHW_Start();
	I2CHW_EnableMstr();
	I2CHW_EnableInt();
	
	WriteI2C(slaveAddress, 0xAC, 1, 0x02); // Write to access config, sets mode to cooling(POL = 1), also turns 1-SHOT off, continuous conversions
	
	WriteI2C(slaveAddress, 0xA1, 2, (setTemp + tolerance), 0x00); // Sets initial high temp to be setTemp + tolerance
	WriteI2C(slaveAddress, 0xA2, 2, (setTemp - tolerance), 0x00); // Sets initial low temp to be setTemp - tolerance
	WriteI2C(slaveAddress, 0xEE, 0); // This tells the temperature IC to start converting the temperatures
	
	// Writes initial string to LCD. When LCD is updated, only the numbers will be changed
	LCD_Position(0,0); LCD_PrCString("CUR: 00 OFF     ");
	LCD_Position(1,0); LCD_PrCString("SET: 00 FAN OFF ");
	
	// This is the command usage string
	UART_CPutString("#################### Heating/Cooling Stepper Motors ##################\r\n\
#	S ##\r\n\
#		S - Set the desired Temperature\r\n\
#		## - Desired temperature in celsius\r\n\
#\r\n\
#	T ##\r\n\
#		T - Set the desired tolerance\r\n\
#		## - Desired tolerance in celsius\r\n\
#\r\n\
#	M X\r\n\
#		M - Change the mode of the thermostat\r\n\
#		X - C is for cool, H is for heat, F is for off\r\n\
#\r\n\
#	F X S\r\n\
#		F - Change the mode of the fan\r\n\
#		X - A is for automatic fan control, M is for always on\r\n\
#		S - Speed of the fan, H = high, M = medium, L = low\r\n\
#####################################################################\r\n");
	while (1)
	{
		char *cmd;
		char *params;
		
		if (GetLine(buf, &strPos, 79)) // Only process the data if GetLine returns true
		{
			cmd = Lowercase(cstrtok(buf, " ")); // Lowercase the first word from the inputted string
			
			if (strlen(cmd) == 1 && cmd[0] == 's') // If the person entered s
			{	
				int temp;
			
				params = cstrtok(0x00, " "); // Read next word 							
				// If next word isnt number or isnt 1 or 2 characters long, then return error
				if (!IsNumber(params) || strlen(params) < 1 || strlen(params) > 2 || csscanf(params, "%d", &temp) != 1) goto error;
				
				// If there is additional data at end of string or if number is not within 0-99, return error
				if (cstrtok(0x00, " ") != 0x00) goto error;
				if ( temp > 99 || temp < 0) goto error; 
				
				setTemp = temp;
				WriteI2C(slaveAddress, 0xA1, 2, (setTemp + tolerance), 0x00); // Sets high temp to be setTemp + tolerance
				WriteI2C(slaveAddress, 0xA2, 2, (setTemp - tolerance), 0x00); // Sets low temp to be setTemp - tolerance
				updateLCD = TRUE; // Update the LCD
			}
			else if (strlen(cmd) == 1 && cmd[0] == 't') // If the person entered t
			{	
				int tol; 
			
				params = cstrtok(0x00, " "); // Read next word					
				// If next word isnt number or isnt 1 or 2 characters long, then return error
				if (!IsNumber(params) || strlen(params) < 1 || strlen(params) > 2 || csscanf(params, "%d", &tol) != 1) goto error;
				
				// If there is additional data at end of string or if number is not within 0-10, return error
				if (cstrtok(0x00, " ") != 0x00) goto error;
				if (tol < 0 || tol > 10) goto error;
				
				tolerance = tol;
				
				WriteI2C(slaveAddress, 0xA1, 2, (setTemp + tolerance), 0x00); // Sets high temp to be setTemp + tolerance
				WriteI2C(slaveAddress, 0xA2, 2, (setTemp - tolerance), 0x00); // Sets low temp to be setTemp - tolerance
				updateLCD = TRUE; // Update the LCD
				
			}
			else if (strlen(cmd) == 1 && cmd[0] == 'm') // If the person entered m
			{	
				char mode;
			
				params = cstrtok(0x00, " "); // Read next word
				
				// If next word isnt 1 character long, return error
				if (strlen(params) != 1 || csscanf(params, "%c", &mode) != 1) goto error;
				// If there is additional data at end of string, return error
				if (cstrtok(0x00, " ") != 0x00) goto error;
				
				mode = tolower(mode); // Lowercase the character
				
				switch (mode)
				{
					case 'h':
						thermostatMode = 1; // Set mode to heating
						WriteI2C(slaveAddress,0xAC, 1, 0x00); // Change access config on DS1621 to heating(POL = 0)
						break;
						
					case 'c':
						thermostatMode = 2; // Set mode to cooling
						WriteI2C(slaveAddress, 0xAC, 1, 0x02); // Change access config on DS1621 to cooling(POL = 1)
						break;
						
					case 'f': 
						thermostatMode = 0; // Set mode to off
						break;
						
					default:
						goto error; // Invalid character entered, goto error
				}
				CheckFan(); // Check the fan to see if it should be on
			}
			else if (strlen(cmd) == 1 && cmd[0] == 'f') // If the person entered f
			{	
				char mode;
				char speed;
			
				params = cstrtok(0x00, " "); // Read next word
				// If next word isnt 1 character long, then return error
				if (strlen(params) != 1 || csscanf(params, "%c", &mode) != 1) goto error;
				
				params = cstrtok(0x00, " "); // Read next word
				// If next word isnt 1 character long, then return error
				if (strlen(params) != 1 || csscanf(params, "%c", &speed) != 1) goto error;
				// If there is additional data at end of string, return error
				if (cstrtok(0x00, " ") != 0x00) goto error;
				
				speed = tolower(speed); // Lowercase the speed and mode characters entered
				mode = tolower(mode);
				
				switch (mode)
				{
					case 'm':
						fanMode = 0; // Set fan mode to manual
						break;
						
					case 'a':
						fanMode = 1; // Set fan mode to automatic
						break;
						
					default: // Otherwise go to error
						goto error;
				}
				
				MotorDriver_Stop(); // Stop the motor to change the period values
				switch (speed)
				{
					case 'l':
						fanSpeed = 0; // Set fan speed to low
						MotorDriver_WritePeriod(49999); // See report for where these numbers came from
						MotorDriver_WriteCompareValue(25000);
						break;
						
					case 'm':
						fanSpeed = 1; // Set fan speed to medium
						MotorDriver_WritePeriod(9999); // See report for where these numbers came from
						MotorDriver_WriteCompareValue(5000);
						break;
						
					case 'h':
						fanSpeed = 2; // Set fan speed to high
						MotorDriver_WritePeriod(1999); // See report for where these numbers came from
						MotorDriver_WriteCompareValue(1000);
						break;
						
					default: // Otherwise go to error if invalid input entered
						goto error;
				}
				CheckFan(); // Check the fan to see if it should be on
			}
			else 
				goto error;
		}
			
		if (checkTemp) // Check the temperature
		{	
			char buf[2];
			
			ReadI2C(slaveAddress, 0xAA, 2, buf); // Read the temperature from IC, returns 2 bytes
			curTemp = buf[0]; // We just care about the first byte
			checkTemp = FALSE; // Turn flag off so it doesnt keep doing this
		}
		
		if (updateLCD) // Update the LCD
		{	
			char buf[3];
			
			NumToStr(buf, curTemp, 2); // Convert current temp to str
			LCD_Position(0, 5); LCD_PrString(buf); // Print it
			
			LCD_Position(0, 8);
			switch(thermostatMode) // Print thermostat mode
			{
				case 0: LCD_PrCString("OFF "); break;
				case 1: LCD_PrCString("HEAT"); break;
				case 2: LCD_PrCString("COOL"); break;
			}
			
			NumToStr(buf, setTemp, 2); // Convert set temp to str
			LCD_Position(1, 5); LCD_PrString(buf); // Print it
			
			LCD_Position(1, 12);
			if (fanMode == 1 && thermostatMode == 0) LCD_PrCString("OFF"); // Print current fan state
			else if (fanSpeed == 0) LCD_PrCString("LOW");
			else if (fanSpeed == 1) LCD_PrCString("MED");
			else if (fanSpeed == 2) LCD_PrCString("HI ");
			updateLCD = FALSE;
		}
		
		continue;
		error:	
			UART_CPutString("# Invalid format entered. Valid formats are:\r\n\
#	S ##\r\n\
#		S - Set the desired Temperature\r\n\
#		## - Desired temperature in celsius\r\n\
#\r\n\
#	T ##\r\n\
#		T - Set the desired tolerance\r\n\
#		## - Desired tolerance in celsius\r\n\
#\r\n\
#	M X\r\n\
#		M - Change the mode of the thermostat\r\n\
#		X - C is for cool, H is for heat, F is for off\r\n\
#\r\n\
#	F X S\r\n\
#		F - Change the mode of the fan\r\n\
#		X - A is for automatic fan control, M is for always on\r\n\
#		S - Speed of the fan, H = high, M = medium, L = low\r\n\
#####################################################################\r\n");
	}
}
Esempio n. 17
0
void LoadAllPreferences(BOOL fMemOnly)
/************************************************************************/
{
LPSTR lp;
int i, English, Didot;
STRING tmp;

if (fMemOnly) // memory related info only
	{
	// Memory Group Preferences
	GetDefStr( Control.RamDisk, Control.ProgHome );
	FixPath( Lowercase( Control.RamDisk ) );
	GetDefInt( Control.MainMemMin, 1024 );
	GetDefInt( Control.MainMemFactor, 100 );
	if (  Control.MainMemFactor < 10 )
		Control.MainMemFactor = 10;
	if (  Control.MainMemFactor > 100 )
		Control.MainMemFactor = 100;
	GetDefInt( Control.LineArtAsGray, NO );
	FrameSettings( Control.RamDisk, Control.MainMemMin, Control.MainMemFactor);

	// Get Gamma settings
	GetDefFix( BltSettings.RGamma, 1 );
	GetDefFix( BltSettings.GGamma, 1 );
	GetDefFix( BltSettings.BGamma, 1 );
	return;
	}

AstralCursor( IDC_WAIT );
if ( !szPreferenceFile[0] )
	{
	if ( !AstralStr( IDS_INIFILE, &lp ) ) lp = PRIVATE_INI;
	lstrcpy( szPreferenceFile, lp );
	GetIniPath( szPreferenceFile );
	}

// Recall List
Control.RecallCount = 0;
for ( i=0; i<MAX_RECALL; i++ )
	{
	GetDefaultString( itoa(i,tmp,10), "",
		Control.RecallImage[i], sizeof(Control.RecallImage[i]) );
	if ( *Control.RecallImage[i] )
		Control.RecallCount++;
	}

// Undo Group Preferences
GetDefInt( Control.NoUndo, FALSE );
GetDefInt( Control.UseApply, NO );
GetDefInt( Control.UndoObjects, NO );
GetDefInt( Control.UndoMasks, NO );

// Miscellaneous Group Preferences
#ifdef _MAC
lstrcpy(Control.PouchPath, ":files:");
#else
GetDefStr( Control.PouchPath, Control.ProgHome );
if ( Control.PouchPath[1] != ':' )
	{
	lstrcpy( tmp, Control.ProgHome );
	lstrcat( tmp, Control.PouchPath );
	lstrcpy( Control.PouchPath, tmp );
	}
FixPath( Lowercase( Control.PouchPath ) );
#endif // _MAC	
GetDefInt( Control.UseWacom, 0 );
GetDefInt( Control.MaskTint, 0 ); // Red
GetDefInt( Control.IndependentSettings, YES );
GetDefInt( Control.bNoTheme, NO );

#ifdef USEWAVEMIX
GetDefInt( Control.bUseWaveMix, YES );
#endif // USEWAVEMIX

GetPrivateProfileString( "Drivers", "Wave", "none", tmp, sizeof(STRING),
  "system.ini");

// if they have no wave driver or the speaker.drv installed, disable
// using the wavemix.dll
#ifdef USEWAVEMIX
if ( (! lstrcmpi( tmp, "none")) || (! lstrcmpi( tmp, "Speaker.drv")) ||
  (! lstrcmpi( tmp, "")) )
	Control.bUseWaveMix = NO;
#endif // USEWAVEMIX

GetDefInt( Control.iAdventBrush, BRUSH_SIZE_MEDIUM );
GetDefInt( Control.iMaxAnimations, 10 );
GetDefInt( Control.iScrnSaverTime, 2 );
IntermissionSetTimeout ((DWORD)Control.iScrnSaverTime * 60000);

// Units Group Preferences
English = GetProfileInt( "intl", "iMeasure", 1 ); // 1 = English
if ( GetDefInt( Didot, -1 ) >= 0 ) // If Didot is overridden...
	Control.Points = ( !Didot ? 723 : 676 );
else	Control.Points = ( English ? 723 : 676 );
GetDefInt( Control.Units, !English ); Control.Units += IDC_PREF_UNITINCHES;
GetDefFix( Control.ScreenWidth, 9 );
GetDefInt( View.UseRulers, NO );
GetDefInt( Control.DisplayPixelValue, NO );

// Object Group Preferences
GetDefInt( Control.MultipleObjects, YES );
GetDefInt( Control.UseMaskAndObjects, YES );

// New Dialog
GetDefInt( Control.NewDepth, 3 );
GetDefInt( Control.NewWidth, 480 );
GetDefInt( Control.NewHeight, 360 );
GetDefInt( Control.NewResolution, 50 );

// Monitor Gamma Dialog
GetDefInt( Control.GammaLock, NO );

// Save file options
GetDefInt( Save.bSaveMask, NO );
GetDefInt( Save.OKtoSavePath, NO );
GetDefInt( Save.Compressed, YES );

// Clipboard settings
GetDefInt( Control.DoPicture, NO );
GetDefInt( Control.DoBitmap, YES );

// Miscellaneous
GetDefInt( Control.ScreenColor, NO );
GetDefRGB( Control.rgbBackground, "0,0,0" );
GetDefInt( Control.xImage, 4 );
GetDefInt( Control.yImage, 4 );
GetDefInt( Control.Hints, YES );
GetDefInt( Control.Save24BitWallpaper, FALSE);
GetDefInt( Control.UseObjectMarquee, NO );

// Extended Names
GetDefStr( Names.ColorMap, "" );
GetDefStr( Names.Special, "" );
GetDefStr( Names.Mask, "" );
GetDefStr( Names.Printer, "" );
GetDefStr( Names.PrintStyle, "" );
GetDefStr( Names.Clipboard, "" );
GetDefStr( Names.CustomBrush, "" );

// Print Style
LoadPrintStyle( Names.PrintStyle );

// Print Dialog
GetDefInt( Page.Type, 1 ); Page.Type += IDC_PRINTER_IS_MONO;
GetDefInt( Page.PrintNumeric, NO );
GetDefInt( Page.OutputType, 0 ); Page.OutputType += IDC_PRINT_GRAY;
GetDefInt( Page.ScatterPrint, NO );
GetDefInt( Page.Centered, YES );
GetDefFix( Page.OffsetX, 0 );
GetDefFix( Page.OffsetY, 0 );
GetDefInt( Page.SepFlags, 0 );
GetDefInt( Page.TrimMarks, NO );
GetDefInt( Page.RegMarks, NO );
GetDefInt( Page.Labels, NO );
GetDefInt( Page.StepScale, NO );
GetDefInt( Page.Negative, NO );
GetDefInt( Page.EmulsionDown, NO );
GetDefInt( Page.BinaryPS, NO ); // Binary Postscript
GetDefInt( Page.BinaryEPS, NO ); // Binary Encapsulated Postscript
GetDefInt( Page.UsePrinterScreening, YES );

// Size Dialog
GetDefInt( Edit.SmartSize, NO );

// Convert settings
GetDefInt( Convert.MiniType, 0); Convert.MiniType += IDC_MINI256;
GetDefInt( Convert.fOptimize, YES );
GetDefInt( Convert.fScatter, NO );
GetDefInt( Convert.fDither, NO );

// Selector Tool

// Mask Transformer Tool
GetDefInt( Mask.TransformImage, 1 );
Mask.TransformImage = Mask.TransformImage + IDC_COPYIMAGE;

// Object Transformer Tool
GetDefInt( Mask.iTransformModes, SHAPE_DEFAULT );
GetDefInt( Mask.PasteQuality, NO );
GetDefInt( Mask.TransMode, 0 ); Mask.TransMode += IDC_TRANSMODEFIRST;
GetDefInt( Mask.TransformOpacity, 255 );
Mask.TransformOpacity = bound( Mask.TransformOpacity, 0, 255 );
GetDefMergeMode( Mask.TransformMergeMode, (int)MM_NORMAL );

// Paint Tools
HandleBrushSettings( IDC_PAINT, NO );
HandleBrushSettings( IDC_CRAYON, NO );
HandleBrushSettings( IDC_MARKER, NO );
HandleBrushSettings( IDC_LINES, NO );
HandleBrushSettings( IDC_SHAPES, NO );
HandleBrushSettings( IDC_ERASER, NO );

// Gradient Tool
GetDefInt( Vignette.Gradient, 0 ); Vignette.Gradient += IDC_VIGLINEAR;
GetDefInt( Vignette.RepeatCount, 1 );
GetDefInt( Vignette.SoftTransition, YES );
GetDefInt( Vignette.VigColorModel, 0);
GetDefInt( Vignette.VigOpacity, 255 );
GetDefMergeMode( Vignette.VigMergeMode, (int)MM_NORMAL );
GetDefInt( Vignette.Midpoint, 128 );

// Texture Fill Tool
GetDefStr( Texture.TextureName, "" );
GetDefInt( Texture.fHorzFlip, NO );
GetDefInt( Texture.fVertFlip, NO );
GetDefInt( Texture.TextureOpacity, 255 );
GetDefMergeMode( Texture.TextureMergeMode, (int)MM_NORMAL );

// Tint Fill Tool
GetDefInt( Fill.FillOpacity, 255 );
GetDefMergeMode( Fill.FillMergeMode, (int)MM_NORMAL );

// Magic Fill Tool
GetDefInt( Fill.FloodRange, 2 );
GetDefInt( Fill.idFillColorModel, 0);
GetDefInt( Fill.FloodOpacity, 255 );
GetDefMergeMode( Fill.FloodMergeMode, (int)MM_NORMAL );

// Custom View Tool
GetDefInt( View.ZoomOut, NO );
GetDefInt( View.ZoomWindow, NO );
GetDefInt( View.ZoomDefaultSize, 0x6000);
GetDefInt( View.FullScreen, NO );

// Text Tool
GetDefInt( Text.nFont, 0 );
GetDefInt( Text.Size, 48 );
GetDefInt( Text.Italic, NO );
GetDefInt( Text.Underline, NO );
GetDefInt( Text.Strikeout, NO );
GetDefInt( Text.Weight, NO );
GetDefInt( Text.AntiAlias, NO );
GetDefInt( Text.AutoFill, YES );
GetDefMergeMode( Text.TextMergeMode, (int)MM_NORMAL );
GetDefInt( Text.TextOpacity, 255 );

// Load Common Tool Settings
GetDefInt( Common.Opacity, 255 );
GetDefMergeMode( Common.MergeMode, (int)MM_NORMAL );
GetDefInt( Common.BrushSize, 15 );

SetCommonSettings();
Shields( ON );

LoadFileLocations();
AstralCursor( NULL );
}
Esempio n. 18
0
void LoadComboWithDirectories(
/************************************************************************/
HWND hWnd,
WORD idComboBox,
BOOL bHide)
{
#ifdef WIN32

#else
HWND hControl;
int i, count;
STRING szString, szDirName;
LPSTR lpDir, lp;
int retc, iMaxSubDirs;
struct find_t dir;

hControl = GetDlgItem( hWnd, idComboBox );

if ( bHide )
//	ShowControl( hWnd, idComboBox, idComboBox, NO, YES /*Delay*/ );
	SetWindowPos( hControl, 0, /* Same z order */
		0, 0, /* Same location */
		0, 0, /* Same size */
		SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
		SWP_NOREDRAW );

CURRENTDIR( szString, MAX_STR_LEN );
lpDir = &szString[3]; // Skip over the drive, colon, and slash
lp = lpDir;
iMaxSubDirs = 32;

SendDlgItemMessage( hWnd, idComboBox, LB_RESETCONTENT, 0, 0L );
AddSpaces( szDirName, iMaxSubDirs-- ); // Add spaces to defeat the sort
lstrcat( szDirName, "\\" );
CombineStringID( szDirName, IDC_PATHICON_ROOT );
SendDlgItemMessage( hWnd, idComboBox, LB_ADDSTRING, 0, (long)(LPSTR)szDirName );
count = 0;

while ( *lp )
	{
	if ( *lp != '\\' )
		{
		lp++;
		continue;
		}
	*lp++ = '\0'; // Overwrite the slash and skip past it
	AddSpaces( szDirName, iMaxSubDirs-- ); // Add spaces to defeat the sort
	lstrcat( szDirName, lpDir );
	CombineStringID( szDirName, IDC_PATHICON_OPEN );
	SendDlgItemMessage( hWnd, idComboBox, LB_ADDSTRING, 0,
		(long)Lowercase(szDirName) );
	count++;
	lpDir = lp;
	}

if ( lp > lpDir )
	{
	AddSpaces( szDirName, iMaxSubDirs-- ); // Add spaces to defeat the sort
	lstrcat( szDirName, lpDir );
	CombineStringID( szDirName, IDC_PATHICON_ACTIVE );
	SendDlgItemMessage( hWnd, idComboBox, LB_ADDSTRING, 0,
		(long)Lowercase(szDirName) );
	count++;
	}

retc = _dos_findfirst( "*.*", _A_SUBDIR, &dir );
for ( i=0; ; i++ )
	{
	if ( retc )
		break;
	if ( dir.attrib & _A_SUBDIR && dir.name[0] != '.' )
		{ // If this is a subdirectory
		lstrcpy( szDirName, dir.name );
		CombineStringID( szDirName, IDC_PATHICON_CLOSED );
		SendDlgItemMessage( hWnd, idComboBox, LB_ADDSTRING, 0,
			(long)Lowercase(szDirName) );
		}
	retc = _dos_findnext( &dir );
	}

//SendDlgItemMessage( hWnd, idComboBox, LB_SETCURSEL, count, 0L);
SendDlgItemMessage( hWnd, idComboBox, LB_SETCURSEL, -1, 0L);

if ( bHide )
	{
//	ShowControl( hWnd, idComboBox, idComboBox, YES, NO /*Delay*/ );
	SetWindowPos( hControl, 0, /* Same z order */
		0, 0, /* Same location */
		0, 0, /* Same size */
		SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER );
//		SWP_NOREDRAW );
	}
#endif  // WIN32
}
Esempio n. 19
0
BOOL CMiscPrefPage::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	HWND   	hActiveWnd = GetActiveDoc();
	HWND	hDlg = GetSafeHwnd();
	int 	id = GET_WM_COMMAND_ID(wParam, lParam);
	UINT 	codeNotify = GET_WM_COMMAND_CMD(wParam, lParam);

	switch (id)
	{
		case IDC_PREF_POUCH:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
	    		break;
			if ( codeNotify != EN_CHANGE )
	    		break;
			::GetDlgItemText( hDlg, id, Control.PouchPath,
				sizeof(Control.PouchPath));
			FixPath( Lowercase( Control.PouchPath ) );
			SetModified(TRUE);
		break;

		case IDC_PREF_TABLET:
//		case IDC_PREF_TABLETUNUSED:
//		case IDC_PREF_TABLETOPACITY:
//		case IDC_PREF_TABLETSIZE:
//		case IDC_PREF_TABLETBOTH:
			if ( !(id = HandleCombo( hDlg, id, codeNotify )) )
				break;
			Control.UseTablet = id-IDC_PREF_TABLETUNUSED;
			SetModified(TRUE);
		break;

		case IDC_PREF_STARTMACRO:
		   	GetExtNameN( hDlg, id, IDC_FILENAME, Names.StartMacro,
		    	IDN_MACRO, codeNotify, IDS_NONE, NO );
			SetModified(TRUE);
		break;

		case IDC_PREF_MASKTINT:
//		case IDC_PREF_MASKTINT1:
//		case IDC_PREF_MASKTINT2:
//		case IDC_PREF_MASKTINT3:
//		case IDC_PREF_MASKTINT4:
//		case IDC_PREF_MASKTINT5:
//		case IDC_PREF_MASKTINT6:
			if ( !(id = HandleCombo( hDlg, id, codeNotify )) )
				break;
			Control.MaskTint = id - IDC_PREF_MASKTINT1;
			SetModified(TRUE);
		break;

		case IDC_PREF_TOOLSETTINGS:
			Control.IndependentSettings = !Control.IndependentSettings;
			::CheckDlgButton(hDlg, id, Control.IndependentSettings);
			SetModified(TRUE);
		break;

		case IDC_CMS_ENABLED:
			Control.CMSEnabled = CMSOpen( !Control.CMSEnabled );
			::CheckDlgButton(hDlg, id, Control.CMSEnabled);
			SetModified(TRUE);
		break;

		case IDC_PREF_PASTEATREALSIZE:
			Mask.PasteAtRealSize = !Mask.PasteAtRealSize;
			::CheckDlgButton( hDlg, IDC_PREF_PASTEATREALSIZE, Mask.PasteAtRealSize);
			SetModified(TRUE);
		break;

		case IDC_PREF_USEGRAYSCALEICONS:
			Control.UseGrayScaleIcons = !Control.UseGrayScaleIcons;
			::CheckDlgButton( hDlg, IDC_PREF_USEGRAYSCALEICONS, Control.UseGrayScaleIcons);
			SetModified(TRUE);
		break;

		case IDC_PREF_DISABLEAUTOSCROLL:
			Control.DisableAutoScroll = !Control.DisableAutoScroll;
			::CheckDlgButton( hDlg, IDC_PREF_DISABLEAUTOSCROLL, Control.DisableAutoScroll);
			SetModified(TRUE);
		break;

		case IDC_PREF_DISABLEDITHER:
			Vignette.DisableDither = !Vignette.DisableDither;
			::CheckDlgButton( hDlg, IDC_PREF_DISABLEDITHER, Vignette.DisableDither);
			SetModified(TRUE);
		break;

		case IDC_PREF_FILETYPE:
    		if( Control.Retail )
    		{
	    		if (! (id = TableHandleCombo(hDlg, FileType_Table,
					    		sizeof(FileType_Table)/sizeof(ITEMID),
					    		id, codeNotify)))
            		break;
    		}
    		else
    		{
	    		if (! (id = TableHandleCombo(hDlg, FileType_TableOEM,
					    		sizeof(FileType_TableOEM)/sizeof(ITEMID),
					    		id, codeNotify)))
            		break;
    		}
			Control.DefaultFileType = AppFileType(id);
			SetModified(TRUE);
		break;

	   	default:
			return (CPPPropertyPage::OnCommand(wParam, lParam));   	
		break;
   	}
	return(TRUE);
}
Esempio n. 20
0
BOOL WINPROC EXPORT DlgOpenProc(
/************************************************************************/
HWND 	hDlg,
UINT 	msg,
WPARAM 	wParam,
LPARAM 	lParam)
{
BOOL Bool;
ITEMID id;
WORD wMsg, wIndex;
int i, ii, l, fp, hi, lo;
FNAME szDriveNDir, szFileName, szExtension;
HMENU hMenu;
STRING szString;
char cChar;
BOOL bModifySaveName;
static BOOL bDisableCancel;

switch (msg)
    {
    case WM_INITDIALOG:
	SET_CLASS_HBRBACKGROUND(hDlg, ( HBRUSH )GetStockObject(LTGRAY_BRUSH));
	CenterPopup( hDlg );
	if ( !DlgDirList(hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr) )
		{
		lstrcpy( szFileSpec, lstrchr( szFileSpec, '*' ) );
		DlgDirList(hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr);
		}
	SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving);
	CheckComboItem( hDlg, IDC_FILETYPES, IDC_ART, IDC_BMP,
		IDC_ART + (idFileType-IDN_ART) );
	SendDlgItemMessage(hDlg, IDC_FNAME, EM_LIMITTEXT, MAX_FNAME_LEN-1, 0L);

	LoadComboWithDrives( hDlg, IDC_DRIVES );
	LoadComboWithDirectories( hDlg, IDC_DIRS, NO );
	CheckDlgButton( hDlg, IDC_SAVEPATH, Save.OKtoSavePath );
	CheckDlgButton( hDlg, IDC_SAVECOMPRESS, Save.Compressed );
	for (i = IDC_ART; bImageOpen && i <= IDC_BMP; ++i)
		{
		ii = i-IDC_ART;
		if (lstrlen(Readers[ii].szDLL))
			{
			lstrcpy(szString, Control.ProgHome);
			lstrcat(szString, Readers[ii].szDLL);
			if (!FileExists(szString))
				{
				if ( GetPrivateProfileString( "Micrografx", "Libraries", "",
					szString, sizeof(STRING), "MGX.INI" ) > 2 )
						FixPath( szString );
				lstrcat(szString, Readers[ii].szDLL);
				if (!FileExists(szString))
					{
					ControlEnable( hDlg, i, NO);
					continue;
					}
				}
			}
		if (fSaving)
			ControlEnable( hDlg, i, lpImage &&
				Readers[ii].bSave[FrameDepth(ImgGetBaseEditFrame(lpImage))] );
		else
			ControlEnable( hDlg, i, Readers[ii].bOpen );
		}
	if ( bImageOpen && lpImage )
		{
		idDataType = lpImage->DataType;
		for (i = IDC_SAVECT; i <= IDC_SAVE24BITCOLOR; ++i)
			ControlEnable( hDlg, i,
			Readers[idFileType-IDN_ART].bTypes[i-IDC_SAVECT]);
		CheckComboItem( hDlg, IDC_DATATYPES, IDC_SAVECT,
			IDC_SAVE24BITCOLOR, idDataType );
		ControlEnable( hDlg, IDC_SAVECOMPRESS,
			Readers[idFileType-IDN_ART].bCompressed );
		}

	SetFocus( GetDlgItem( hDlg, IDC_FNAME ) );
	SendDlgItemMessage(hDlg, IDC_FNAME, EM_SETSEL,
		NULL, MAKELONG(0, 0x7fff));
	bNavigated = NO;
	bDisableCancel = NO;
	return( FALSE );

    case WM_PALETTECHANGED:
	break;

    case WM_MENUSELECT:
	lo = LOWORD(lParam);
	hi = HIWORD(lParam);
	if (hi == 0)
		break;
	if (lo == -1)
		break;
	if (lo & MF_SYSMENU)
		break;
	if (lo & MF_POPUP)
		{
		hMenu = (HMENU)wParam;
		while (GetSubMenu(hMenu, 0))
			hMenu = GetSubMenu(hMenu, 0);
		id = GetMenuItemID(hMenu, 0);
		if (id <= 0)
			break;
		wParam = id - 1;
		}
	HintLine( wParam );
	break;

    case WM_SETCURSOR:
	return( SetupCursor( wParam, lParam, idOpen ) );

    case WM_CLOSE:
	AstralDlgEnd( hDlg, FALSE|2 );
	break;

    case WM_MEASUREITEM:
    case WM_DRAWITEM:
	id = ((LPDRAWITEMSTRUCT)lParam)->CtlID;
	Bool = ( id == IDC_DRIVES || id == IDC_DIRS );
	return( OwnerDraw( hDlg, msg, lParam, Bool ) );
//	break;

    case WM_CTLCOLOR:
	return( (BOOL)SetControlColors( (HDC)wParam, hDlg, (HWND)LOWORD(lParam),
		HIWORD(lParam) ) );

    case WM_COMMAND:
	if (wParam != IDCANCEL)
		bDisableCancel = NO;
	switch(wParam)
	    {
	    case IDC_FILETYPES:
//	    case IDC_ART:
//	    case IDC_TIFF:
//	    case IDC_BMP:
		if ( !(wParam = HandleCombo( hDlg, wParam, lParam )) )
			break;
		idFileType = IDN_ART + (wParam-IDC_ART);
		if (bNavigated)
			{
			LookupExtension( idFileType, szFileSpec );
			}
		else	GetFileLocation( idFileType, szFileSpec );
		for (i = IDC_SAVECT; i <= IDC_SAVE24BITCOLOR; ++i)
			ControlEnable( hDlg, i,
			Readers[idFileType-IDN_ART].bTypes[i-IDC_SAVECT]);
		ControlEnable( hDlg, IDC_SAVECOMPRESS,
			Readers[idFileType-IDN_ART].bCompressed );
		SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, NO );
		SendMessage( hDlg, WM_COMMAND, IDOK, 0L );
		break;

	    case IDC_DATATYPES:
//	    case IDC_SAVECT:
//	    case IDC_SAVELA:
//	    case IDC_SAVESP: // scatterprint
//	    case IDC_SAVE8BITCOLOR:
//	    case IDC_SAVE24BITCOLOR:
		if ( !(wParam = HandleCombo( hDlg, wParam, lParam )) )
			break;
		idDataType = wParam;
		break;

	    case IDC_SAVEPATH:
		Save.OKtoSavePath = (BOOL)SendDlgItemMessage (hDlg, IDC_SAVEPATH,
		  BM_GETCHECK, 0, 0L);
//		Save.OKtoSavePath = !Save.OKtoSavePath;
//		CheckDlgButton( hDlg, IDC_SAVEPATH, Save.OKtoSavePath );
		break;

	    case IDC_SAVECOMPRESS:
		Save.Compressed = (BOOL)SendDlgItemMessage (hDlg, IDC_SAVECOMPRESS,
		  BM_GETCHECK, 0, 0L);
//		Save.Compressed = !Save.Compressed;
//		CheckDlgButton( hDlg, IDC_SAVECOMPRESS, Save.Compressed );
		break;

	    case IDC_DRIVES:
		wMsg = HIWORD(lParam);
		if ( wMsg != CBN_SELCHANGE )
			break;
		wIndex = SendDlgItemMessage( hDlg, wParam, CB_GETCURSEL, 0, 0L);
		SendDlgItemMessage( hDlg, wParam, CB_GETLBTEXT, wIndex,
			(long)(LPSTR)szDriveNDir );
		id = ExtractStringID( szDriveNDir );
		if (CHDRIVE( *szDriveNDir - 'a' ))
			{
			LoadComboWithDrives(hDlg, IDC_DRIVES);
			break;
			}
		if (!CURRENTDIR(szString, sizeof(szString)))
			{
			GetDlgItemText(hDlg, IDC_FPATH, szString,
				 sizeof(szString));
			CHDRIVE(*szString - 'a');
			LoadComboWithDrives(hDlg, IDC_DRIVES);
			}
//12/15		SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, NO);
		DlgDirList( hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr );
		LoadComboWithDirectories( hDlg, IDC_DIRS, YES );
		SetDlgItemText( hDlg, IDC_DISKSPACE,
			DriveSize( *szDriveNDir - 'a', szString ) );
		SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving );
		bNavigated = YES;
		break;

	    case IDC_DIRS:
		wMsg = HIWORD(lParam);
		if ( wMsg == LBN_DBLCLK )
			{
			SendMessage(hDlg, WM_COMMAND, IDOK, 1L);
			break;
			}
		if ( wMsg != LBN_SELCHANGE )
			break;
		wIndex = SendDlgItemMessage( hDlg, wParam, LB_GETCURSEL, 0, 0L);
		// Figure out how to build the path name based on the selection
		SendDlgItemMessage( hDlg, wParam, LB_GETTEXT, wIndex,
			(long)(LPSTR)szDriveNDir );
		id = ExtractStringID( szDriveNDir );
		if ( id == IDC_PATHICON_OPEN )
			i = 0; // Must start building the path from the root
		else
		if ( id == IDC_PATHICON_ACTIVE )
			i = 9999; // Don't build any path - we're there
		else	i = wIndex; // OK to build a relative path
		szFileName[0] = '\0';
		for ( ; i<=wIndex; i++ )
			{
			SendDlgItemMessage( hDlg, wParam, LB_GETTEXT, i,
				(long)(LPSTR)szDriveNDir );
			id = ExtractStringID( szDriveNDir );
			if ( id == IDC_PATHICON_CLOSED && i != wIndex )
				continue;
			lstrcat( szFileName, SkipSpaces(szDriveNDir) );
			if ( id != IDC_PATHICON_ROOT )
				lstrcat( szFileName, "\\" );
			}
		lstrcat( szFileName, szFileSpec );
		SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO );
		bNavigated = YES;
		break;

	    case IDC_FLIST:
		wMsg = HIWORD(lParam);
		if ( wMsg == LBN_DBLCLK )
			{
			SendMessage(hDlg, WM_COMMAND, IDOK, 1L);
			break;
			}
		if ( wMsg != LBN_SELCHANGE )
			break;
		/* If a directory is selected... */
		if (DlgDirSelectEx(hDlg, szFileName, sizeof(szFileName), wParam))
			lstrcat(szFileName, szFileSpec);
		// 1-2-92 - TMR - always use SetFileName for all FNAME sets
// 		SetDlgItemText(hDlg, IDC_FNAME, szFileName);
		SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO );
		SendDlgItemMessage(hDlg, IDC_FNAME, EM_SETSEL,
			NULL, MAKELONG(0, 0x7fff));
//		SendDlgItemMessage(hDlg, IDC_FNAME, CB_SETEDITSEL,
//			NULL, MAKELONG(0, 0x7fff));
		break;

	    case IDC_FNAME:
		/* If the name is changed, disable OK if its length goes 0 */
		if (HIWORD(lParam) != EN_CHANGE)
//		if (HIWORD(lParam) != CBN_EDITCHANGE)
			break;
		ControlEnable( hDlg, IDOK,
			(BOOL)SendDlgItemMessage( hDlg, wParam,
			WM_GETTEXTLENGTH, 0, 0L));
		
		// 1-2-92 - TMR - make sure Edit Box has focus to make sure
		// that szSaveName only gets overwritten from user input
		// 1-3-92 - TMR - move this after ControlEnable
		if (GetFocus() != GetDlgItem(hDlg, IDC_FNAME))
			break;
		if (fSaving)
			{
			GetDlgItemText(hDlg, IDC_FNAME, szSaveName,
				MAX_FNAME_LEN);
			fUntitled = NO;
			}
		break;

	    case IDC_FPATH:
		wMsg = HIWORD(lParam);
		if ( wMsg == BN_DOUBLECLICKED )
			{
			SendMessage(hDlg, WM_COMMAND, IDOK, 1L);
			break;
			}
		if ( wMsg != BN_CLICKED )
			break;
 		GetDlgItemText(hDlg, wParam, szFileName, sizeof(szFileName));
		if ( !szFileName[0] )
			break;
		FixPath( szFileName );
		lstrcat( szFileName, szFileSpec );
		SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO );
		bNavigated = YES;
		break;

	    case IDOK:
		GetDlgItemText(hDlg, IDC_FNAME, szFileName,sizeof(szFileName));
		bModifySaveName = fSaving && StringsEqual(szFileName,
			szSaveName);
		/* Strip off the drive and directory to make */
		/* a DlgDirlist() call to switch over to them */
		/* Loop backwards over the file name */
		l = lstrlen(szFileName);
		while( --l >= 0 )
		   {
		   cChar = szFileName[l];
		   /* If we find a wildcard, the next DlgDirList() takes */
		   /* care of drive and directory switching; so get out */
		   if ( cChar == '?' || cChar == '*' )
			break;
		   /* If we find a drive or directory, handle it and get out */
		   if ( cChar == '\\' || cChar == ':' )
			{
			lstrcpy(szDriveNDir, szFileName);
			l++;
			szDriveNDir[l] = '\0';
			lstrcat(szDriveNDir, szFileSpec);
			// 1-3-92 - TMR - Handle directory change error
			if (DlgDirList(hDlg, szDriveNDir,
					 IDC_FLIST, IDC_FPATH, wFileAttr))
				lstrcpy( szFileName, &szFileName[l] );
			else
				{
				szDriveNDir[l] = '\0';
				Message(IDS_EDIRECTORYCHANGE,
					 Lowercase(szDriveNDir));
				szFileName[0] = '\0';
				}
			break;
			}
		   }

		// 1-3-92 - TMR add extension if none present
		/* Check to see if the file has an extension... */
		if ( !lstrchr( szFileName, '.' ) ) // if no extension...
		    if ( LookupExtension( idFileType, szExtension ) )
			{
			if (lstrlen(szFileName))
			    lstrcat( szFileName, extension(szExtension) );
			else
			    lstrcat( szFileName, szExtension);
			}
		if (bModifySaveName)
			lstrcpy(szSaveName, szFileName);

		/* Try to display a new list box */
		if ( !szFileName[0] )
			lstrcat(szFileName, szFileSpec);
		if (DlgDirList(hDlg, szFileName, IDC_FLIST, IDC_FPATH,
		    wFileAttr))
			{ /* A wildcard was found and a new list displayed */
			lstrcpy(szFileSpec, szFileName);
			SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName,
				fSaving );
			LoadComboWithDrives( hDlg, IDC_DRIVES );
			LoadComboWithDirectories( hDlg, IDC_DIRS, YES );
			
			break;
			}

		// If there is still a path or wildcards in the name, the
		// file specification must be invalid
		if (lstrchr(szFileName, '\\') || lstrchr(szFileName, ':') ||
		    lstrchr(szFileName, '?') || lstrchr(szFileName, '*'))
			{
			lstrcpy(szString, szFileName);
			stripfile(szString);
			Message(IDS_EDIRECTORYCHANGE, Lowercase(szString));
			lstrcpy(szFileSpec, filename(szFileName));
			lstrcpy(szFileName, szFileSpec); // is this needed?
			SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName,
				fSaving );
			break;
			}

		/* No wildcards, and the drive and dir have been changed */
		LoadComboWithDrives( hDlg, IDC_DRIVES );
		LoadComboWithDirectories( hDlg, IDC_DIRS, YES );

		/* Check to see if the file has 8 characters or less... */
		if ( fSaving )
			RemoveWhiteSpace( szFileName );
		FixFileName( szFileName );

		/* Check to see if the file has an extension... */
		if ( !lstrchr( szFileName, '.' ) ) // if no extension...
			if ( LookupExtension( idFileType, szExtension ) )
				lstrcat( szFileName, extension(szExtension) );

		// Build the fully qualified path name
		GetDlgItemText( hDlg, IDC_FPATH, szString, sizeof(szString) );
		FixPath( szString );
		lstrcat( szString, szFileName );

		/* Check to see if the file exists... */
		if ( (fp = _lopen( szString, OF_READ ) ) < 0 )
			{ /* The file does not exist */
			if ( !fSaving )
				{
				Message(IDS_EOPEN, Lowercase(szString));
				break;
				}
			}
		else	{
			_lclose( fp );
			if ( fSaving )
				{
				if ( !AstralAffirm( IDS_OVERWRITEIMAGE,
					Lowercase(szString) ) )
					break;
				}
			}

		lstrcpy( szFileSpec, szString );
		AstralDlgEnd(hDlg, TRUE|2);
		break;

	    case IDC_CANCEL:
	    case IDCANCEL:
		if ( bDisableCancel && !LOWORD(lParam) )
			break;
		GetDlgItemText(hDlg, IDC_FPATH, szFileSpec,sizeof(szFileSpec));
		AstralDlgEnd(hDlg, FALSE|2);
		break;

	    default:
		return( FALSE );
	    }
	break;

    default:
	return( FALSE );
    }

return( TRUE );
}
Esempio n. 21
0
 bool CommandLine::HasSwitch(const std::string& switch_string) const
 {
     std::string lowercased_switch(switch_string);
     Lowercase(&lowercased_switch);
     return switches_.find(lowercased_switch)!=switches_.end();
 }