Ejemplo n.º 1
0
void LayoutParser::parseLayout()
{
    static const QStringList typeValues(QString::fromLatin1("general,url,email,number,phonenumber,common").split(','));
    static const QStringList orientationValues(QString::fromLatin1("landscape,portrait").split(','));

    const QXmlStreamAttributes attributes(m_xml.attributes());
    const TagLayout::LayoutType type(enumValue("type", typeValues, TagLayout::General));
    const TagLayout::LayoutOrientation orientation(enumValue("orientation", orientationValues, TagLayout::Landscape));
    const bool uniform_font_size(boolValue(attributes.value(QLatin1String("uniform-font-size")), false));
    TagLayoutPtr new_layout(TagLayoutPtr(new TagLayout(type, orientation, uniform_font_size)));
    m_keyboard->appendLayout(new_layout);

    bool found_section(false);

    while (m_xml.readNextStartElement()) {
        const QStringRef name(m_xml.name());

        if (name == QLatin1String("section")) {
            found_section = true;
            parseSection(new_layout);
        } else {
            error(QString::fromLatin1("Expected '<section>', but got '<%1>'.").arg(name.toString()));
        }
    }

    if (not found_section) {
        error(QString::fromLatin1("Expected '<section>'."));
    }
}
Ejemplo n.º 2
0
static void add_layout(LAYOUT *base, int level, int width, int height,
                int direction, int marginx, int marginy, 
                int borderx, int border_top, int border_bottom, int flag,
                PACKINFO *pinf)
{
    LAYOUT *layout, *tmp;

    layout = new_layout();
    layout->width  = width;
    layout->height = height;
    layout->marginx = marginx;
    layout->marginy = marginy;
    layout->borderx = borderx;
    layout->border_bottom = border_bottom;
    layout->border_top = border_top;
    layout->direction = direction;
    layout->flag = flag;
    layout->pinf = pinf;

    if (base->next == NULL) {
        base->next = layout;
        return;
    }
    tmp = base->next;
    while (tmp->next)
        tmp = tmp->next;
    while (level) {
        if (tmp->child == NULL) {
            tmp->child = layout;
            layout->parent = tmp;
            return;
        }
        tmp = tmp->child;
        while (tmp->next)
            tmp = tmp->next;
        level--;
    }
    tmp->next = layout;
    layout->parent = tmp->parent;
}
Ejemplo n.º 3
0
main()
{
    static PACKINFO pinf[100];
    int i=0,level,flag=0;
    int padx, pady, count;
LAYOUT *base, *tmpxx;

    padx = 4;
    pady = 4;
/*
    flag = FILL_X | FILL_Y | GRID_X;
    flag = ALIGNY_CENTER  ;
*/

flag=   GRID_X | FILL_Y;
 i=0;

    level = 0; 
    pinf[i].level =  level;
    pinf[i].width = 50;
    pinf[i].height= 50;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_VERTICAL;
    pinf[i].flag = flag;
    
   level++;
    i++;
    pinf[i].level =  level;
    pinf[i].width = 1;
    pinf[i].height= 1;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_VERTICAL;
    pinf[i].flag = flag;

    level++;
    i++;
    pinf[i].level =  level;
    pinf[i].width = 8;
    pinf[i].height= 5;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_VERTICAL;
    pinf[i].flag = flag; 

    level--;
    i++;
    pinf[i].level =  level;
    pinf[i].width = 50;
    pinf[i].height= 20;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_VERTICAL;
    pinf[i].flag = flag;
    
    i++;
    pinf[i].level =  level;
    pinf[i].width = 1;
    pinf[i].height= 1;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_VERTICAL;
    pinf[i].flag = FILL_X;

    i++;
    pinf[i].level =  level;
    pinf[i].width = 40;
    pinf[i].height= 10;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_VERTICAL;
    pinf[i].flag = flag;
 
 
    i++;
    pinf[i].level =  level;
    pinf[i].width = 1;
    pinf[i].height= 1;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_VERTICAL;
    pinf[i].flag = flag;
 
    level++;
    i++;
    pinf[i].level =  level;
    pinf[i].width = 20;
    pinf[i].height= 16;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_HORIZONTAL;
    pinf[i].flag = FILL_Y;

   i++;
    pinf[i].level =  level;
    pinf[i].width = 38;
    pinf[i].height= 9;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_HORIZONTAL;
    pinf[i].flag = FILL_Y;
    
    count = i+1;
/*
                   pinf[i].borderx, 
                   pinf[i].border_bottom, 

*/
    base = new_layout();
    for (i=0;i<count;i++) {
        add_layout(base, 
                   pinf[i].level, 
                   pinf[i].width, 
                   pinf[i].height,
                   pinf[i].direction, 
                   pinf[i].marginx, 
                   pinf[i].marginy, 
                   5, 
                   8, 
                   2, 
                   pinf[i].flag,
                   &(pinf[i]));
    }
    calc_total_layout(base);
    transfer_results(base);
    free_layout(base);

   
{
FILE *file = fopen("blaa.ps","w");
if (file==NULL)
    return; 

   ps_header( file, 2.0);

    for (i=0;i<count;i++) {

           fprintf(file,"%d %d %d %d dr\n",
                pinf[i].x, 
                pinf[i].y, 
                pinf[i].x+pinf[i].width, 
                pinf[i].y+pinf[i].height);

}    
    ps_footer(file);
fclose(file);
}


}
Ejemplo n.º 4
0
void manage_layout(PACKINFO *pinf)
{
    LAYOUT *base, *tmp;
    int i,level,flag;
    int padx, pady;
PACKINFO *tmpxx;
FILE *file;
    padx = 6;
    pady = 10;
/*
    flag = FILL_X | FILL_Y | GRID_X;
*/
    flag = ALIGN_Y_CENTER  ;

tmpxx=pinf;

//file = fopen("blaa","w");
//if (file==NULL)
  //  return;

    base = new_layout();
    level = 0;
    while (pinf) {
        if (pinf->level < 0) {
            free_layout(base);
            return;
        }
        add_layout(base, 
                   pinf->level, 
                   pinf->width, 
                   pinf->height,
                   pinf->direction, 
                   pinf->marginx, 
                   pinf->marginy, 
                   pinf->borderx, 
                   pinf->border_top, 
                   pinf->border_bottom, 
                   pinf->flag,
                   pinf);
//fprintf(file, "%d %d %d\n",pinf->level, 
    //               pinf->width, 
      //             pinf->height);



        pinf = pinf->next;
    }
//fclose(file);

    calc_total_layout(base);
    transfer_results(base);
    free_layout(base);

#ifdef debuggg
{
FILE *file = fopen("blaa.ps","w");
if (file==NULL)
    return;

   ps_header( file, 1.0);
pinf=tmpxx;
    while (pinf) {

           fprintf(file,"%d %d %d %d dr\n",
                pinf->x, 
                pinf->y, 
                pinf->x+pinf->width, 
                pinf->y+pinf->height);
pinf=pinf->next;
}
    ps_footer(file);
fclose(file);
}
#endif
}