Exemplo n.º 1
0
LoadFont (DviWidget dw, int position, int size)
{
	XFontStruct	*font;

	font = QueryFont (dw, position, size);
	dw->dvi.font_number = position;
	dw->dvi.font_size = size;
	dw->dvi.font = font;
	XSetFont (XtDisplay (dw), dw->dvi.normal_GC, font->fid);
	return;
}
Resource* CreateTextWidget( XMLIterator i, XMLCreatorEnv *env )
{
    XMLCreatorEnv ch_env;
    XMLAttributes attributes;
    XMLStyle      branch_style;
    CascadeStyles( i, env, attributes, branch_style, ch_env );

    std::string font = get_attribute( attributes, "font" );

    int bodyAsLink = 0;
    try_attribute_i( attributes, "body_as_link", &bodyAsLink );
    Text text;
    if ( bodyAsLink )
        text = QueryText( make_string( (*i)._value ));
    else
        text = MakeText(to_chars( (*i)._value ));


    Widget *ptr;
    XMLIterator ch_i = i;
    int line_spacing = 0;
    std::string alignment;

    bool adv_text = try_attribute_i( attributes, "spacing", &line_spacing );
    adv_text |= try_attribute( attributes, "align", &alignment );

    // create DualText
    if ( !!ch_i.StepInto() )
    {
        int shift = 2;
        try_attribute_i( attributes, "shift", &shift );

        std::wstring left, right;
        for ( ; !!ch_i; ++ch_i )
        {
            if ( (*ch_i)._name == "left" )
                left = to_chars( (*ch_i)._value );
            else
                if ( (*ch_i)._name == "right" )
                    right = to_chars( (*ch_i)._value );
        }
        
        int bodyAsLink = 0;
        try_attribute_i( attributes, "body_as_link", &bodyAsLink );
        Text leftT, rightT;
        if ( bodyAsLink )
        {
            leftT  = QueryText( make_string( left ));
            rightT = QueryText( make_string( right ));
        }
        else
        {
            leftT  = MakeText(left);
            rightT = MakeText(right);
        }

        DualTextWidget *p_dual;
        ptr = p_dual = new DualTextWidget( 100, QueryFont(font), leftT, rightT, shift );

        std::string dotcode;
        if ( try_attribute( attributes, "dot", &dotcode ) )
            p_dual->SetDotCode( ( dotcode.size()>0 ? dotcode[0] : ' ' ) );    
    }
    else
    if ( adv_text )
    {
        int align = 0;
        if ( alignment == "left"   ) { align = 0; } else
        if ( alignment == "right"  ) { align = 1; } else
        if ( alignment == "center" ) { align = 2; }

        if ( (*i)._name == "activetext" )
        {
            ptr = new ActiveText( QueryFont(font), text, line_spacing, align );
        }
        else
        {
            ptr = new AdvTextWidget( QueryFont(font), text, line_spacing, align );
        }
    }   
    else
    {
         TextWidget *ptrTW = new TextWidget( QueryFont(font), text );
         ptr = ptrTW;
         ptrTW->SetText( text );
    }

    InsertChildWidget( ptr, attributes, env);
    return new AnyResource<Widget*>( ptr );
}
Exemplo n.º 3
0
static MRESULT EXPENTRY AttachStatProc(HWND hwnd, ULONG message, MPARAM mp1,
                                       MPARAM mp2)
{
   extern WINDOWPOSITIONS windowpositions;
   extern WINDOWCOLORS windowcolors;
   extern WINDOWFONTS windowfonts;
   extern HWND frame;
   extern HWND hwndhelp;
   PCHECKATPAR pCheckPar=NULL;
   PFIELDINFO pFieldInfo, pFirstFieldInfo;
   FIELDINFOINSERT FieldInfoInsert;
   CNRINFO CnrInfo;
   PATTACHRECORD pRecord, pFirstRecord;
   RECORDINSERT RecordInsert;
   HWND hwndCnr;
   PFILELIST pTemp;

   static char pchTitleFile[50];
   static char pchTitleSize[50];
   static char pchTitleStatus[50];
   static char pchOK[50];
   static char pchNotFound[50];

   switch(message)
   {
      case WM_INITDLG:
         pCheckPar=(PCHECKATPAR) mp2;
         LoadString(IDST_ATT_TITLEFILE,   50, pchTitleFile);
         LoadString(IDST_ATT_TITLESIZE,   50, pchTitleSize);
         LoadString(IDST_ATT_TITLESTATUS, 50, pchTitleStatus);
         LoadString(IDST_ATT_OK,          50, pchOK);
         LoadString(IDST_ATT_NOTF,        50, pchNotFound);

         WinAssociateHelpInstance(hwndhelp, hwnd);

         hwndCnr=WinWindowFromID(hwnd, IDD_ATTACHSTAT+2);
         OldAttachContainerProc=WinSubclassWindow(hwndCnr,
                                                  NewAttachContainerProc);

         SetFont(hwndCnr, windowfonts.attachfont);
         SetForeground(hwndCnr, &windowcolors.attachfore);
         SetBackground(hwndCnr, &windowcolors.attachback);

         /* Felder des Containers vorbereiten */
         pFirstFieldInfo=(PFIELDINFO)SendMsg(hwndCnr,
                                                CM_ALLOCDETAILFIELDINFO,
                                                MPFROMLONG(3), NULL);

         pFieldInfo=pFirstFieldInfo;

         pFieldInfo->cb=sizeof(FIELDINFO);
         pFieldInfo->flData=CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
         pFieldInfo->flTitle=0;
         pFieldInfo->pTitleData= pchTitleFile;
         pFieldInfo->offStruct= FIELDOFFSET(ATTACHRECORD, pchFileName);
         pFieldInfo=pFieldInfo->pNextFieldInfo;

         pFieldInfo->cb=sizeof(FIELDINFO);
         pFieldInfo->flData=CFA_ULONG | CFA_HORZSEPARATOR | CFA_SEPARATOR |
                            CFA_RIGHT;
         pFieldInfo->flTitle=0;
         pFieldInfo->pTitleData= pchTitleSize;
         pFieldInfo->offStruct= FIELDOFFSET(ATTACHRECORD, ulSize);
         pFieldInfo=pFieldInfo->pNextFieldInfo;

         pFieldInfo->cb=sizeof(FIELDINFO);
         pFieldInfo->flData=CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR |
                            CFA_CENTER;
         pFieldInfo->flTitle=0;
         pFieldInfo->pTitleData= pchTitleStatus;
         pFieldInfo->offStruct= FIELDOFFSET(ATTACHRECORD, pchStatus);

         /* Felder des Containers einfuegen */
         FieldInfoInsert.cb=sizeof(FIELDINFOINSERT);
         FieldInfoInsert.pFieldInfoOrder=(PFIELDINFO) CMA_FIRST;
         FieldInfoInsert.fInvalidateFieldInfo=TRUE;
         FieldInfoInsert.cFieldInfoInsert=3;

         SendMsg(hwndCnr, CM_INSERTDETAILFIELDINFO,
                    pFirstFieldInfo, &FieldInfoInsert);

         /* Container-Attribute setzen */
         CnrInfo.cb=sizeof(CNRINFO);
         CnrInfo.pFieldInfoLast=NULL;
         CnrInfo.flWindowAttr=CV_DETAIL | CA_DETAILSVIEWTITLES;
         CnrInfo.xVertSplitbar=0;

         SendMsg(hwndCnr, CM_SETCNRINFO, &CnrInfo,
                    MPFROMLONG(CMA_FLWINDOWATTR));

         /* Elemente einfuegen */

         pFirstRecord=(PATTACHRECORD)SendMsg(hwndCnr, CM_ALLOCRECORD,
                           MPFROMLONG(sizeof(ATTACHRECORD)-sizeof(MINIRECORDCORE)),
                           MPFROMLONG(pCheckPar->ulCountRecords));
         pRecord=pFirstRecord;
         pTemp=pCheckPar->pFileList;
         while(pTemp)
         {
            pRecord->pchFileName=pTemp->pchFileName;
            pRecord->ulSize=pTemp->ulSize;
            if (pTemp->bFound)
                pRecord->pchStatus = pchOK;
            else
                pRecord->pchStatus = pchNotFound;

            pRecord=(PATTACHRECORD)pRecord->RecordCore.preccNextRecord;
            pTemp=pTemp->next;
         }

         RecordInsert.cb=sizeof(RECORDINSERT);
         RecordInsert.pRecordOrder=(PRECORDCORE) CMA_FIRST;
         RecordInsert.pRecordParent=NULL;
         RecordInsert.fInvalidateRecord=TRUE;
         RecordInsert.zOrder=CMA_TOP;
         RecordInsert.cRecordsInsert=pCheckPar->ulCountRecords;

         SendMsg(hwndCnr, CM_INSERTRECORD, pFirstRecord, &RecordInsert);

         RestoreWinPos(hwnd, &windowpositions.attachpos, FALSE, TRUE);
         break;

      case WM_DESTROY:
         QueryWinPos(hwnd, &windowpositions.attachpos);
         QueryFont(WinWindowFromID(hwnd, IDD_ATTACHSTAT+2),
                   windowfonts.attachfont);
         QueryForeground(WinWindowFromID(hwnd, IDD_ATTACHSTAT+2),
                         &windowcolors.attachfore);
         QueryBackground(WinWindowFromID(hwnd, IDD_ATTACHSTAT+2),
                         &windowcolors.attachback);
         WinAssociateHelpInstance(hwndhelp, frame);
         break;

      default:
         break;
   }
   return WinDefDlgProc(hwnd, message, mp1, mp2);
}