Esempio n. 1
0
// read text strings from file
//
void CTextList::ReadTexts( CStdioFile * pcb_file )
{
	int pos, err, np;
	CString in_str, key_str;
	CArray<CString> p;

	// find beginning of [texts] section
	do
	{
		err = pcb_file->ReadString( in_str );
		if( !err )
		{
			// error reading pcb file
			CString mess;
			mess.Format( "Unable to find [texts] section in file" );
			AfxMessageBox( mess );
			return;
		}
		in_str.Trim();
	}
	while( in_str != "[texts]" );

	// get all text strings
	while( 1 )
	{
		pos = pcb_file->GetPosition();
		err = pcb_file->ReadString( in_str );
		if( !err )
		{
			CString * err_str = new CString( "unexpected EOF in project file" );
			throw err_str;
		}
		in_str.Trim();
		if( in_str == "[end]" )
			break;		// start of [texts] section, exit
		else if( in_str.Left(5) == "text:" )
		{
			np = ParseKeyString( &in_str, &key_str, &p );
			CString str = p[0];
			int x = my_atoi( &p[1] );
			int y = my_atoi( &p[2] );
			int file_layer = my_atoi( &p[3] );
			int layer = m_layer_by_file_layer[file_layer];
			int angle = my_atoi( &p[4] );
			int mirror = my_atoi( &p[5] );
			int font_size = my_atoi( &p[6] );
			int stroke_width = my_atoi( &p[7] );
			BOOL m_bNegative = 0;
			if( np > 9)
				m_bNegative = my_atoi( &p[8] );
			AddText( x, y, angle, mirror, m_bNegative, layer, font_size, stroke_width, &str );
		}
	}
}
Esempio n. 2
0
File: key.c Progetto: kuailexs/jwm
/** Insert a key binding. */
void InsertBinding(KeyType key, const char *modifiers,
                   const char *stroke, const char *code,
                   const char *command)
{

    KeyNode *np;
    unsigned int mask;
    char *temp;
    KeySym sym;

    mask = ParseModifierString(modifiers);

    if(stroke && strlen(stroke) > 0) {
        int offset;

        for(offset = 0; stroke[offset]; offset++) {
            if(stroke[offset] == '#') {

                temp = CopyString(stroke);

                for(temp[offset] = '1'; temp[offset] <= '9'; temp[offset]++) {

                    sym = ParseKeyString(temp);
                    if(sym == NoSymbol) {
                        Release(temp);
                        return;
                    }

                    np = Allocate(sizeof(KeyNode));
                    np->next = bindings;
                    bindings = np;

                    np->key = key | ((temp[offset] - '1' + 1) << 8);
                    np->state = mask;
                    np->symbol = sym;
                    np->command = NULL;
                    np->code = 0;

                }

                Release(temp);

                return;
            }
        }

        sym = ParseKeyString(stroke);
        if(sym == NoSymbol) {
            return;
        }

        np = Allocate(sizeof(KeyNode));
        np->next = bindings;
        bindings = np;

        np->key = key;
        np->state = mask;
        np->symbol = sym;
        np->command = CopyString(command);
        np->code = 0;

    } else if(code && strlen(code) > 0) {

        np = Allocate(sizeof(KeyNode));
        np->next = bindings;
        bindings = np;

        np->key = key;
        np->state = mask;
        np->symbol = NoSymbol;
        np->command = CopyString(command);
        np->code = atoi(code);

    } else {

        Warning(_("neither key nor keycode specified for Key"));
        np = NULL;

    }

}