// ----------------------------------------------------------------------- //
//
//	ROUTINE:	CLTDialogueWnd::Init
//
//	PURPOSE:	Initialization
//
// ----------------------------------------------------------------------- //
BOOL CLTDialogueWnd::Init(DIALOGUEWNDCREATESTRUCT* pcs)
{
	// Sanity checks
	if(!pcs || m_bInitialized)
		return FALSE;

	// Gotta have a font
	if(!pcs->pFont)
		return FALSE;

	// Initialize the base class
	if(!CLTMaskedWnd::Init(pcs))
		return FALSE;

	// Simple vars -- Ya gotta specify a width/height since this is scaleable, bunghole. :)
	m_nWidth = pcs->nWidth;
	m_nHeight = pcs->nHeight;
	m_pFont = pcs->pFont;
	m_bFrame = pcs->bFrame;

	// Init the frame if necessary
	if(!InitFrame(pcs->szFrame))
	{
		Term();
		return FALSE;
	}

	SetAlpha(pcs->fAlpha);

	// Decision window
	DECISIONWNDCREATESTRUCT dwcs;
	dwcs.nControlID = pcs->nControlID;
	dwcs.pParentWnd = pcs->pParentWnd;
	dwcs.szBitmap = pcs->szDecisionBitmap;
	dwcs.hSurf = pcs->hDecisionSurf;
	dwcs.pcollFrames = &m_collFrames;
	dwcs.prcFrame = &m_rcFrame;
	dwcs.prcTotal = &m_rcTotal;
	dwcs.pFont = g_pInterfaceResMgr->GetMediumFont();

	dwcs.bFrame = pcs->bDecisionFrame;
	dwcs.fAlpha = pcs->fDecisionAlpha;
	dwcs.dwFlags = LTWF_SIZEABLE;
	dwcs.dwState = LTWS_CLOSED;

	if(!m_DecisionWnd.Init(&dwcs))
	{
		Term();
		return FALSE;
	}


	Reset();

	// Center us
	MoveWindow((g_pGameClientShell->GetScreenWidth()-m_nWidth)/2,m_yPos);

	// All done!
	return TRUE;
}
Esempio n. 2
0
status_t GlLineScanner::Scan(	int32 w, int32 h, float angle,
								int8 signX, int8 signY, int8 perpSignX, int8 perpSignY,
								uint32 count, uint32 anchor, int32 anchorX, int32 anchorY,
								int32 gapOffset, int32 gapX, int32 gapY)
{
	if (count < 1) return B_ERROR;

	float		perpAngle = angle + 90;
	if (perpAngle > 359) perpAngle -= 360;

	/* Initialize cells */
	status_t	err = Init(w, h, count, perpAngle, perpSignX, perpSignY);
	if (err != B_OK) return err;
	/* Offset cells to anchor */
	int32		offsetX = anchorX - mLine1->cells[anchor].x,
				offsetY = anchorY - mLine1->cells[anchor].y;
	for (uint32 k = 0; k < count; k++) {
		mLine1->cells[k].x += offsetX;
		mLine1->cells[k].y += offsetY;

		mLine2->cells[k].x = mLine1->cells[k].x;
		mLine2->cells[k].y = mLine1->cells[k].y;

		mGapLine->indexes[k] = -1;
	}
	InitFrame(w, h, mLine1->size, mLine1->cells);
	mLine1->Offset(0, 0);

	/* Perform the scanning */
	return ScanLoop(w, h, angle, signX, signY, anchorX, anchorY, gapOffset, gapX, gapY);
}
Esempio n. 3
0
/////////////////////////////////////////////////////////////////////
// makeKanBeWin
/////////////////////////////////////////////////////////////////////
void
kanBeApp::makeKanBeWin(void)
{
BFont			aFont;
font_height		h_info;
float			h, w;
char			basepath[B_FILE_NAME_LENGTH];

	ReadSetting(basepath, &aFont);
	setBasePath(basepath);

	w = aFont.StringWidth(B_UTF8_HIROSHI);	// kanji width
	aFont.GetHeight(&h_info);
	h = h_info.ascent + h_info.descent + h_info.leading;

	mWindow = new BWindow(InitFrame(w, h), "kanBe ver. 0.52", B_TITLED_WINDOW,
						B_NOT_RESIZABLE|B_NOT_CLOSABLE|B_NOT_MINIMIZABLE|B_NOT_ZOOMABLE);
	mWindow->Lock();
	mView = new FEPView(mWindow->Bounds());
	mView->SetFont(&aFont);
	mWindow->AddChild(mView);
	mWindow->Unlock();

	mWindow->Show();
}
Esempio n. 4
0
bool MyApp::OnInit()
{
#ifdef __LINUX__
setlocale (LC_ALL,"POSIX");
#endif

 register_all_file_formats();
#if GILVIEWER_USE_GDAL
    OGRRegisterAll();
#endif // GILVIEWER_USE_GDAL
	try
	{
		if ( InitFrame() )
			m_mainFrameDock->Show();
		else
			exit(0);


	}
	catch( std::exception &e )
	{
		wxString message;
		message << wxString(e.what(), *wxConvCurrent);
		wxMessageBox( message );
	}
	catch( ... )
	{
		wxMessageBox( _("Unhandled exception ...") );
	}

	return true;
}
Esempio n. 5
0
void DrawEditor::Init (OverlayComp* comp, const char* name) {
    _curr_others = _prev_others = nil;
    _num_curr_others = _num_prev_others = 0;
    _texteditor = nil;
    _autonewframe = false;
    _autonewframe_tts = nil;
    if (!comp) comp = new DrawIdrawComp;
    _terp = new ComTerpServ();
    ((OverlayUnidraw*)unidraw)->comterp(_terp);
    AddCommands(_terp);
    add_comterp("DrawServ", _terp);
    _overlay_kit->Init(comp, name);
    InitFrame();
    _last_selection = new Selection;
}
Esempio n. 6
0
void frmMainConfig::InitForm()
{
	appearanceFactory->SetIcons(this);

	InitFrame(wxT("frmMainConfig"));
	RestorePosition(50, 50, 600, 600, 300, 200);

	cfgList = new ctlListView(this, CTL_CFGVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER);

	cfgList->SetImageList(configImageList, wxIMAGE_LIST_SMALL);

	cfgList->AddColumn(_("Setting name"), 120);
	cfgList->AddColumn(_("Value"), 80);
	if (conn)
		cfgList->AddColumn(_("Current value"), 80);
	cfgList->AddColumn(_("Comment"), 400);
}
Esempio n. 7
0
status_t GlLineSlicer::HalfQuad(int32 w, int32 h, float angle,
								int8 xSign, int8 ySign,
								int32 originX, int32 originY,
								int32 changeX, int32 changeY)
{
	/* Init the lines */
	uint32					count = (w > h) ? w : h;
	ArpVALIDATE(count > 0, return B_ERROR);
	status_t				err = InitLines(count);
	if (err != B_OK) return err;
	/* Fill the coords of each cell */
	int32					x = originX, y = originY;
	GlDegreeLine			line(angle, float(x), float(y), xSign, ySign);
	for (uint32 k = 0; k < count; k++) {
		mLine->cells[k].x = x;
		mLine->cells[k].y = y;
		line.GetNext(&x, &y);
	}
	mLine->Offset(0, 0);
	InitLineVal(mLine->size, mLine->cells);
	/* Init the frame */
	InitFrame(w, h, count, mLine->cells);

	ArpASSERT(false);	// FIX:  Who calls this?  Need to figure out the steps
#if 0
	/* Find the number of steps */
	int32				ox = originX, oy = originY;
	uint32				c = 0;
	while (GL_IN_BOUNDS(ox, oy, w, h)) {
		ox += changeX;
		oy += changeY;
		c++;
	}
uint32	c2 = 0;
#endif
	/* Render each slice */
	while (FrameInBounds(w, h)) {
		FillLine(w, h, mLine->size, mLine->cells);
		mLine->Offset(changeX, changeY);
		OffsetBounds(changeX, changeY);
//c2++;
	}
//printf("c %ld real %ld\n", c, c2);
	return B_OK;
}
Esempio n. 8
0
void frmPgpassConfig::Init()
{
	appearanceFactory->SetIcons(this);

	InitFrame(wxT("frmPgpassConfig"));
	RestorePosition(150, 150, 650, 300, 300, 200);


	listEdit = new ctlListView(this, CTL_CFGVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER);
	listEdit->SetImageList(configImageList, wxIMAGE_LIST_SMALL);

	listEdit->AddColumn(_("Host"), 50);
	listEdit->AddColumn(_("Port"), 30);
	listEdit->AddColumn(_("Database"), 80);
	listEdit->AddColumn(_("Username"), 80);
	listEdit->AddColumn(_("Password"), 80);

	editMenu->Enable(MNU_DELETE, false);
	toolBar->EnableTool(MNU_DELETE, false);
}
Esempio n. 9
0
extern "C" __declspec(dllexport) int Load(void)
{
	mir_getLP(&pluginInfo);
	INITCOMMONCONTROLSEX icc;
	icc.dwSize=sizeof(icc);
	icc.dwICC=ICC_DATE_CLASSES|ICC_UPDOWN_CLASS|ICC_PROGRESS_CLASS;
	if (!InitCommonControlsEx(&icc)) return 1;

	if (InitFrame()) return 1; /* before icons */

	/* shared */
	Icon_Register(hInst, "Automatic Shutdown", iconList, SIZEOF(iconList));

	InitShutdownSvc();
	InitWatcher(); /* before InitSettingsDlg() */
	InitSettingsDlg();
	InitOptions();

	HookEvent(ME_SYSTEM_MODULESLOADED, ShutdownModulesLoaded);
	return 0;
}
Esempio n. 10
0
PERROR InitFreeSelection( FRAME *frame )
{
    struct Selection *selection = &frame->selection;
    FRAME *mask = selection->mask;

    D(bug("InitFreeSelection(%08X)\n",frame));

    if( !mask || NOTSAMESIZE( mask, frame ) ) {

        if( mask ) RemFrame( mask, globxd );

        mask = MakeFrame( frame, globxd );
        mask->pix->components = 1;
        mask->pix->colorspace = CS_UNKNOWN;

        if( InitFrame( mask, globxd ) != PERR_OK )
            return PERR_ERROR;

        frame->selection.mask = mask;
    }

    if( !selection->vertices ) {
        if( NULL == (selection->vertices = smalloc( sizeof(Point) * 1024 ))) {
            Panic( "Can't alloc vertices!!!" );
        }
        selection->nMaxVertices = 1024;
    }

    selection->ButtonDown        = FreeButtonDown;
    selection->ButtonUp          = FreeButtonUp;
    // s->ControlButtonDown = LassoRectControlButtonDown;
    selection->DrawSelection     = FreeDraw;
    selection->EraseSelection    = FreeErase;
    selection->MouseMove         = FreeMouseMove;
    selection->IsInArea          = FreeIsInArea;
    //s->Rescale           = LassoRectRescale;
    //s->Copy              = LassoRectCopy;

    return PERR_OK;
}
Esempio n. 11
0
void frmHbaConfig::Init()
{
	appearanceFactory->SetIcons(this);

	InitFrame(wxT("frmHbaConfig"));
	RestorePosition(150, 150, 650, 300, 300, 200);


	listEdit = new ctlListView(this, CTL_CFGVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER);
	listEdit->SetImageList(configImageList, wxIMAGE_LIST_SMALL);

	listEdit->AddColumn(_("Type"), 40);
	listEdit->AddColumn(_("Database"), 80);
	listEdit->AddColumn(_("User"), 80);
	listEdit->AddColumn(_("IP-Address"), 100);
	listEdit->AddColumn(_("Method"), 40);
	listEdit->AddColumn(_("Option"), 100);

	helpMenu->Enable(MNU_HINT, false);
	toolBar->EnableTool(MNU_HINT, false);

	editMenu->Enable(MNU_DELETE, false);
	toolBar->EnableTool(MNU_DELETE, false);
}
Esempio n. 12
0
/******************************************************************************
    CreateCellFrame:
    Create a Cell frame.
*******************************************************************************/
CreateCellFrame(PTERWND w,int level,LPINT pFrameNo,int y,int ScrY, LPINT pFrameHt,LPINT pScrFrameHt, 
                 int CurColHeight,int ScrCurColHeight, LPINT pFirstCellFrame, 
                 LPINT pTableRowHeight, LPINT pScrTableRowHeight,LPINT pCellX,int TableRowIndent,
                 int PageNo,int TopLeftMargin,int ColumnNo,int sect,int PrevCell, LPINT pCellFramed,
                 long FrameFirstLine, long FrameLastLine, UINT PassFlags, BOOL RowBreak,
                 LPINT pCellWidth, int TextWidth,int MaxColumns, int ColumnSpace, int PageWdth,
                 int ColumnX,int ColumnWidth, int BoxFrame, int ParaFrameId)
{
    int TblCellHeight,LeftWidth,RightWidth,TopWidth,BotWidth,SpaceTop,SpaceBot;
    int row,CellLeftMarg,CellRightMarg,CellMargin,FrameSpaceHt;
    BOOL IsFirstCellFrame=FALSE;
    UINT border;
    int ParentLeftMargin,ParentRightMargin;
    int  pad,i,x,PrevRowId=cell[PrevCell].row;
    COLORREF BorderColor[4];
    long l;

    //dm("CreateCellFrame");

    // define the argument for easy reference
    #define FrameNo (*pFrameNo)
    #define FrameHt (*pFrameHt)
    #define ScrFrameHt (*pScrFrameHt)
    #define FirstCellFrame (*pFirstCellFrame)
    #define TableRowHeight (*pTableRowHeight)
    #define ScrTableRowHeight (*pScrTableRowHeight)
    #define CellX (*pCellX)
    #define CellFramed (*pCellFramed)
    #define CellWidth (*pCellWidth)

    
    // calcualte parent cell margin
    if (level>0) {
       int ParentCell=cell[PrevCell].ParentCell;
       ParentLeftMargin=TwipsToPrtX(CellLeftMargin(w,ParentCell));
       ParentRightMargin=TwipsToPrtX(CellRightMargin(w,ParentCell));
    }
    else ParentLeftMargin=ParentRightMargin=0;

    // adjust y from any frame space before the row
    row=cell[PrevCell].row;
    FrameSpaceHt=TableRow[row].FrmSpcBef;
    if (FrameSpaceHt>0) {
       y+=FrameSpaceHt;
       ScrY+=PrtToScrY(FrameSpaceHt);
    } 

    // update table row height
    if (FirstCellFrame==-1) {
        int MinHeight;
        FirstCellFrame=FrameNo; // first frame for the row
        MinHeight=TableRow[PrevRowId].MinHeight;
        if (True(TableRow[PrevRowId].flags&ROWFLAG_SPLIT) /*&& TableAux[PrevRowId].FirstPage==PageNo */ && MinHeight>0) MinHeight=0;  // 20051201 - min-height not supported at page-bot/top to keep the row height within the page-body area
        if (MinHeight<0) MinHeight=-MinHeight;   // exact match

        if (TableRow[PrevRowId].MinPictHeight>MinHeight) MinHeight=TableRow[PrevRowId].MinPictHeight;  // height of the picture frames
        TableRowHeight=TwipsToPrtY(MinHeight);
        ScrTableRowHeight=TwipsToScrY(MinHeight);
        IsFirstCellFrame=TRUE;

    }

    // set the border and space top/bottom
    border=GetCellFrameBorder(w,PrevCell,&LeftWidth,&RightWidth,&TopWidth,&BotWidth,PageNo,BorderColor);
    if (CellAux[PrevCell].flags&CAUX_SET_TOP_SPACE) SpaceTop=TwipsToPrtY(cell[PrevCell].margin);  // use extra space
    else  {
       pad=CellTopPad(w,PrevCell);
       SpaceTop=TwipsToPrtY(TopWidth+pad);    // 20070430
    }
    pad=CellBotPad(w,PrevCell);
    SpaceBot=TwipsToPrtY(BotWidth+pad); 

    // adjust the frame height
    FrameHt+=(SpaceTop+SpaceBot);
    ScrFrameHt+=PrtToScrY(SpaceTop+SpaceBot);
    
    // keep track of max row height
    TblCellHeight=0;        // height contribute by this cell toward the row
    if (IsLastSpannedCell(w,PrevCell)) TblCellHeight=GetLastSpannedCellHeight(w,PrevCell,NULL,PageNo);  // height contrinution of this cell toward the row height
    else if ((cell[PrevCell].RowSpan==1 || IsPageLastRow(w,cell[PrevCell].row,PageNo)) 
             && !(cell[PrevCell].flags&CFLAG_ROW_SPANNED)) {
         TblCellHeight=FrameHt;
         if (cell[PrevCell].TextAngle!=0) TblCellHeight=TwipsToPrtY(MIN_VTEXT_CELL_HEIGHT);  // vertical text does not affect the row height
         
         if (cell[PrevCell].flags&CFLAG_VALIGN_BASE) TblCellHeight+=CellAux[PrevCell].SpaceBefore;  // add base alignment adjustment
    }
    if (TableRow[PrevRowId].MinHeight>=0) {
        if (TblCellHeight>TableRowHeight) TableRowHeight=TblCellHeight;
    }
    ScrTableRowHeight=PrtToScrY(TableRowHeight);

    if (RowBreak) {            // last cell of the table
        int row=cell[PrevCell].row;

        // 20070104: check for a hidden row
        for (i=FirstCellFrame;i<=FrameNo;i++) {
           int LastLine=frame[i].PageLastLine;
           int FirstLine=frame[i].PageFirstLine;
           if (frame[i].empty) continue;
           
           if (i==FrameNo) {           // the frame for the last cell not yet built
              FirstLine=FrameFirstLine;
              LastLine=FrameLastLine;
           } 
           for (l=FirstLine;l<=LastLine;l++) {
             int height=LineHt(l);
             if (height>0 && LineLen(l)==1 && LineInfo(w,l,INFO_CELL) && IsHiddenLine(w,l)) height=0;
             if (height!=0) break;
           }
           if (l<=LastLine) break;
        } 
        if (i>FrameNo) ScrTableRowHeight=TableRowHeight=0;   // all text in the row hidden - hide the row

        TableRow[row].height=TableRowHeight;  // record the updated table row height

        for (i=FirstCellFrame;i<=FrameNo;i++) {
            if (frame[i].level!=level) continue;
            
            frame[i].height=TableRowHeight;
            frame[i].ScrHeight=ScrTableRowHeight;
        }
        FirstCellFrame=-1;      // reset for the next row

    }

    // create the empty row indentation frame
    if (IsFirstCellFrame) {
        int row=cell[PrevCell].row;

        // create the empty frame to reserve any frame space
        if (TableRow[row].FrmSpcBef>0) {
            int SpcBef=TableRow[row].FrmSpcBef;
            frame[FrameNo].empty=TRUE;
            frame[FrameNo].PageNo=PageNo;             // 20070511
            frame[FrameNo].level=level;
            frame[FrameNo].sect=sect;     // section to which the frame belongs
            frame[FrameNo].x=CellX;
            frame[FrameNo].y=y+CurColHeight-SpcBef;  // relative to top margin
            frame[FrameNo].ScrY=ScrY+ScrCurColHeight-PrtToScrY(SpcBef);  // relative to top margin
            frame[FrameNo].width=TextWidth;
            frame[FrameNo].BoxFrame=BoxFrame;
            frame[FrameNo].ParaFrameId=ParaFrameId;
            if (ParaFrameId>0) frame[FrameNo].ZOrder=ParaFrame[ParaFrameId].ZOrder;
            if (!BorderShowing && level==0) frame[FrameNo].flags|=FRAME_RIGHTMOST;

            frame[FrameNo].height=SpcBef;
            frame[FrameNo].ScrHeight=PrtToScrY(SpcBef);

            FrameNo++;                      // advance to the next frame
            if (!InitFrame(w,FrameNo)) AbortTer(w,"Ran Out of Text Frame Table (CreateFrames 1)",1);

            if (FirstCellFrame>=0) FirstCellFrame=FrameNo; // first frame for the row
        }

        TableRow[PrevRowId].FirstFrame=FrameNo;  // first frame of the row

        frame[FrameNo].empty=TRUE;
        frame[FrameNo].PageNo=PageNo;             // 20070511
        frame[FrameNo].level=level;
        frame[FrameNo].sect=sect;     // section to which the frame belongs
        frame[FrameNo].y=y+CurColHeight;  // relative to top margin
        frame[FrameNo].ScrY=ScrY+ScrCurColHeight;  // relative to top margin
        frame[FrameNo].BoxFrame=BoxFrame;
        frame[FrameNo].ParaFrameId=ParaFrameId;
        if (ParaFrameId>0) frame[FrameNo].ZOrder=ParaFrame[ParaFrameId].ZOrder;
        frame[FrameNo].CellId=PrevCell;

        frame[FrameNo].width=TableRow[PrevRowId].CurIndent;   // TableRowIndent;
        frame[FrameNo].x=CellX;

        frame[FrameNo].border=0;
        frame[FrameNo].RowId=PrevRowId;
        frame[FrameNo].height=FrameHt=TableRowHeight;
        frame[FrameNo].ScrHeight=ScrFrameHt=ScrTableRowHeight;
        frame[FrameNo].flags|=FRAME_FIRST_ROW_FRAME;

        CellX=CellX+frame[FrameNo].width;

        FrameNo++;                      // advance to the next frame
        if (!InitFrame(w,FrameNo)) AbortTer(w,"Ran Out of Text Frame Table (CreateFrames 1)",1);
    }

    // create any intervening empty cell frames
    FrameEmptyCells(w,PrevRowId,&CellFramed,PrevCell,&CellX,y+CurColHeight,TableRowHeight,&FrameNo,sect,PageNo);

    // create the text frame
    CellMargin=TwipsToPrtX(cell[PrevCell].margin);
    CellLeftMarg=TwipsToPrtX(CellLeftMargin(w,PrevCell));
    CellRightMarg=TwipsToPrtX(CellRightMargin(w,PrevCell));
    CellWidth=TwipsToPrtX(cell[PrevCell].width);

    frame[FrameNo].empty=FALSE;
    frame[FrameNo].PageNo=PageNo;             // 20070511
    frame[FrameNo].level=level;
    frame[FrameNo].sect=sect;     // section to which the frame belongs
    frame[FrameNo].PageFirstLine=FrameFirstLine;
    frame[FrameNo].PageLastLine=FrameLastLine;
    frame[FrameNo].y=y+CurColHeight;  // relative to top margin
    frame[FrameNo].ScrY=ScrY+ScrCurColHeight;  // relative to top margin
    frame[FrameNo].BoxFrame=BoxFrame;
    frame[FrameNo].ParaFrameId=ParaFrameId;
    if (ParaFrameId>0) frame[FrameNo].ZOrder=ParaFrame[ParaFrameId].ZOrder;
    frame[FrameNo].shading=cell[PrevCell].shading; // shading percentage
    
    frame[FrameNo].BackColor=cell[PrevCell].BackColor; // background color
    if (cell[PrevCell].BackColor==CLR_WHITE && cell[PrevCell].ParentCell>0 && False(cell[PrevCell].flags&CFLAG_FORCE_BKND_CLR)) { // check if parent cell is non-white
       int ParentCell=cell[PrevCell].ParentCell;
       while (ParentCell>0) {
          if (cell[ParentCell].BackColor!=CLR_WHITE || True(cell[ParentCell].flags&CFLAG_FORCE_BKND_CLR)) break;
          ParentCell=cell[ParentCell].ParentCell;
       }
       if (ParentCell>0) {
         frame[FrameNo].BackColor=cell[PrevCell].BackColor; // 20060313 
         frame[FrameNo].flags|=FRAME_FORCE_BKND_CLR;        // to foce drawing of white color if any
       }
    } 

    frame[FrameNo].flags|=PassFlags;  // flags for the pass
    if (cell[PrevCell].flags&CFLAG_FORCE_BKND_CLR) frame[FrameNo].flags|=FRAME_FORCE_BKND_CLR;  // enforce background color even for default color

    frame[FrameNo].x=CellX;
    frame[FrameNo].width=CellWidth;
    frame[FrameNo].SpaceLeft=CellLeftMarg;
    if (HtmlMode && IsFirstCellFrame && border&BORDER_LEFT) frame[FrameNo].SpaceLeft+=ScrToPrtX(3);  // add width of the html table border
    frame[FrameNo].SpaceRight=CellRightMarg;

    // record the frame x space for the row
    if (IsFirstCellFrame) TableAux[PrevRowId].FrmBegX=frame[FrameNo].x;
    TableAux[PrevRowId].FrmEndX=frame[FrameNo].x+frame[FrameNo].width;;

    frame[FrameNo].border=border;
    frame[FrameNo].BorderWidth[BORDER_INDEX_LEFT]=LeftWidth;
    frame[FrameNo].BorderWidth[BORDER_INDEX_RIGHT]=RightWidth;
    frame[FrameNo].BorderWidth[BORDER_INDEX_TOP]=TopWidth;
    frame[FrameNo].BorderWidth[BORDER_INDEX_BOT]=BotWidth;

    // set border color
    for (i=0;i<4;i++) frame[FrameNo].BorderColor[i]=BorderColor[i];
    
    frame[FrameNo].RowId=PrevRowId;

    if (cell[PrevCell].flags&CFLAG_ROW_SPANNED)    // set height
        frame[FrameNo].TextHeight=frame[FrameNo].height=frame[FrameNo].ScrHeight=0;
    else {
        frame[FrameNo].TextHeight=ScrFrameHt-PrtToScrY(SpaceBot);
        frame[FrameNo].height=TableRowHeight;
        frame[FrameNo].ScrHeight=ScrTableRowHeight;
    }
    FrameHt=TableRowHeight;
    ScrFrameHt=ScrTableRowHeight;

    frame[FrameNo].SpaceTop=SpaceTop;
    frame[FrameNo].SpaceBot=SpaceBot;
    frame[FrameNo].CellId=PrevCell;


    CellFramed=PrevCell;
        
    FrameNo++;                      // advance to the next frame
    if (!InitFrame(w,FrameNo)) AbortTer(w,"Ran Out of Text Frame Table (CreateFrames 4)",1);

    // on row break create an empty frame on the right to cover any blank area
    x=frame[FrameNo-1].x+frame[FrameNo-1].width;  // right edge of the right most frame
    if (RowBreak) {
        if (true || level==0) FrameEmptyCells(w,PrevRowId,&CellFramed,0,&x,frame[FrameNo-1].y,frame[FrameNo-1].height,&FrameNo,sect,PageNo);

        TableRow[PrevRowId].LastFrame=FrameNo;

        frame[FrameNo].empty=TRUE;
        frame[FrameNo].PageNo=PageNo;             // 20070511
        frame[FrameNo].level=level;
        frame[FrameNo].y=frame[FrameNo-1].y;
        frame[FrameNo].ScrY=frame[FrameNo-1].ScrY;
        frame[FrameNo].x=x;
        frame[FrameNo].BoxFrame=BoxFrame;
        frame[FrameNo].ParaFrameId=ParaFrameId;
        if (ParaFrameId>0) frame[FrameNo].ZOrder=ParaFrame[ParaFrameId].ZOrder;

        frame[FrameNo].width=ColumnX+ColumnWidth+ColumnSpace-x;
        if (level==0) {
            if (ParaFrameId>0) { 
               int right=frame[BoxFrame].x+frame[BoxFrame].width-frame[BoxFrame].BorderWidth[BORDER_INDEX_RIGHT];
               frame[FrameNo].width=right-frame[FrameNo].x;
            } 
            else if (BorderShowing) {
               if (MaxColumns==1 || ((ColumnNo+1)==MaxColumns)) {
                  int sect=frame[FrameNo-1].sect;
                  frame[FrameNo].width=PageWdth-LeftBorderWidth-(int)(TerSect[sect].RightMargin*PrtResX)-x;
               }
               else  frame[FrameNo].flags|=FRAME_LINE_BET_COL;  // line between columns
            }
            else {
               frame[FrameNo].flags|=FRAME_RIGHTMOST;
               if ((ColumnNo+1)<MaxColumns) frame[FrameNo].flags|=FRAME_LINE_BET_COL;  // line between columns
            }
        }

        if (frame[FrameNo].width<0) frame[FrameNo].width=0;

        frame[FrameNo].height=frame[FrameNo-1].height;
        frame[FrameNo].ScrHeight=frame[FrameNo-1].ScrHeight;
        frame[FrameNo].sect=frame[FrameNo-1].sect;
        frame[FrameNo].RowId=frame[FrameNo-1].RowId;
        frame[FrameNo].CellId=frame[FrameNo-1].CellId;  // set cell id so that frame height is adjusted properly when this frame is after a spanning cell frame
        frame[FrameNo].flags|=(PassFlags|FRAME_LAST_ROW_FRAME);     // last frame for the row

        CellFramed=0;                   // initialize for the next row
        
        FrameNo++;                      // advance to the next frame
        if (!InitFrame(w,FrameNo)) AbortTer(w,"Ran Out of Text Frame Table (CreateFrames 4)",1);
    }

    // adjust FrameHt to FrameSpace before
    FrameHt+=FrameSpaceHt;
    ScrFrameHt+=PrtToScrY(FrameSpaceHt);

    // undefine the arguments;
    #undef FrameNo
    #undef FrameHt
    #undef ScrFrameHt
    #undef FirstCellFrame
    #undef TableRowHeight
    #undef ScrTableRowHeight
    #undef CellX
    #undef CellFramed
    #undef CellWidth

    return TRUE;
}
Esempio n. 13
0
bool
GIFLoad::ReadGIFImageData() 
{
	unsigned char newEntry[4096];
	
	unsigned char cs;
	fInput->Read(&cs, 1);
	if (cs == fPalette->size_in_bits) {
		if (!InitFrame(fPalette->size_in_bits))
			return false;
	} else if (cs > fPalette->size_in_bits) {
		if (debug)
			syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - Code_size should be %d, not "
				"%d, allowing it\n", fCodeSize, cs);
		if (!InitFrame(cs))
			return false;
	} else if (cs < fPalette->size_in_bits) {
		if (debug)
			syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - Code_size should be %d, not "
				"%d\n", fCodeSize, cs);
		return false;
	}
	
	if (debug)
		syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - Starting LZW\n");
	
	while ((fNewCode = NextCode()) != -1 && fNewCode != fEndCode) {
		if (fNewCode == fClearCode) {
			ResetTable();
			fNewCode = NextCode();
			fOldCode[0] = fNewCode;
			fOldCodeLength = 1;
			if (!OutputColor(fOldCode, 1)) goto bad_end;
			if (fNewCode == -1 || fNewCode == fEndCode) {
				if (debug)
					syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - Premature fEndCode "
						"or error\n");
				goto bad_end;
			}
			continue;
		}
		
		// Explicitly check for lack of clear code at start of file
		if (fOldCodeLength == 0) {
			fOldCode[0] = fNewCode;
			fOldCodeLength = 1;
			if (!OutputColor(fOldCode, 1))
				goto bad_end;
			continue;
		}
		
		if (fTable[fNewCode] != NULL) { // Does exist in table
			if (!OutputColor(fTable[fNewCode], fEntrySize[fNewCode]))
				goto bad_end;
			
			//memcpy(newEntry, fOldCode, fOldCodeLength);
			for (int x = 0; x < fOldCodeLength; x++) {
				newEntry[x] = fOldCode[x];
			}
			
			//memcpy(newEntry + fOldCodeLength, fTable[fNewCode], 1);
			newEntry[fOldCodeLength] = *fTable[fNewCode];
		} else { // Does not exist in table
			//memcpy(newEntry, fOldCode, fOldCodeLength);
			for (int x = 0; x < fOldCodeLength; x++) {
				newEntry[x] = fOldCode[x];
			}
			
			//memcpy(newEntry + fOldCodeLength, fOldCode, 1);
			newEntry[fOldCodeLength] = *fOldCode;
			
			if (!OutputColor(newEntry, fOldCodeLength + 1))
				goto bad_end;
		}
		fTable[fNextCode] = MemblockAllocate(fOldCodeLength + 1);

		//memcpy(fTable[fNextCode], newEntry, fOldCodeLength + 1);
		for (int x = 0; x < fOldCodeLength + 1; x++) {
			fTable[fNextCode][x] = newEntry[x];
		}
		
		fEntrySize[fNextCode] = fOldCodeLength + 1;
		
		//memcpy(fOldCode, fTable[fNewCode], fEntrySize[fNewCode]);
		for (int x = 0; x < fEntrySize[fNewCode]; x++) {
			fOldCode[x] = fTable[fNewCode][x];
		}
		
		fOldCodeLength = fEntrySize[fNewCode];
		fNextCode++;
		
		if (fNextCode > fMaxCode && fBits != 12) {
			fBits++;
			fMaxCode = (1 << fBits) - 1;
		}
	}

	MemblockDeleteAll();
	if (fNewCode == -1)
		return false;
	if (debug)
		syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - Done\n");
	return true;
	
bad_end:
	if (debug)
		syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - Reached a bad end\n");
	MemblockDeleteAll();
	return false;
}
Esempio n. 14
0
FRAME *DoTransparency( FRAME *frame, struct Values *v, struct PPTBase *PPTBase)
{
    FRAME *newframe = NULL;
    BOOL  hasalpha = FALSE;
    ULONG tol;

    tol = SQR(v->tolerance);

    if( frame->pix->colorspace == CS_ARGB )
        hasalpha = TRUE;

    // PDebug(MYNAME": Exec()\n");

    newframe = MakeFrame( frame );
    if(newframe) {
        newframe->pix->colorspace = CS_ARGB;
        newframe->pix->components = 4;

        if( InitFrame( newframe ) == PERR_OK ) {
            WORD row;

            InitProgress(frame,"Setting up transparency...",0,frame->pix->height);

            for( row = 0; row < frame->pix->height; row++ ) {
                RGBPixel *cp;
                ARGBPixel *dcp, *acp;
                WORD col;
                BOOL isin;

                if( Progress(frame, row) ) {
                    RemFrame(newframe);
                    newframe = NULL;
                    break;
                }

                cp = (RGBPixel *)GetPixelRow( frame, row );
                acp = (ARGBPixel *)cp;
                dcp = (ARGBPixel *)GetPixelRow( newframe, row );

                /*
                 *  Loopety loop.  If the pixel to be set is exactly
                 *  the color, then set the transparency.
                 */

                for( col = 0; col < frame->pix->width; col++ ) {
                    ULONG dist;

                    /*
                     *  Check if we're inside selbox
                     */

                    if( row >= frame->selbox.MinY && row < frame->selbox.MaxY &&
                        col >= frame->selbox.MinX && col < frame->selbox.MaxX ){
                        isin = TRUE;
                    } else {
                        isin = FALSE;
                    }

                    /*
                     *  Set the alpha channel, if we're inside the selbox
                     */
                    if( hasalpha ) {
                        dist = SQR((WORD)((WORD)acp->r - v->r))+
                               SQR((WORD)((WORD)acp->g - v->g))+
                               SQR((WORD)((WORD)acp->b - v->b));

                        if( (v->mode == MODE_ALL || dist <= tol) && isin)
                        {
                            dcp->a = (UBYTE) v->transp;
                        } else {
                            dcp->a = acp->a; /* Retain transparency */
                        }
                        dcp->r = acp->r;
                        dcp->g = acp->g;
                        dcp->b = acp->b;
                        acp++;
                        dcp++;
                    } else {
                        dist = SQR((WORD)((WORD)cp->r - v->r))+
                               SQR((WORD)((WORD)cp->g - v->g))+
                               SQR((WORD)((WORD)cp->b - v->b));

                        if( (v->mode == MODE_ALL || dist <= tol) && isin)
                        {
                            dcp->a = (UBYTE) v->transp;
                        } else {
                            dcp->a = 0; /* No transparency */
                        }
                        dcp->r = cp->r;
                        dcp->g = cp->g;
                        dcp->b = cp->b;
                        cp++;
                        dcp++;
                    }
                }

                PutPixelRow( newframe, row, dcp );
            }

            FinishProgress(frame);

        } else {
            RemFrame(newframe);
            newframe = NULL;
        }
    }

    return newframe;

}
Esempio n. 15
0
void ModelClass::SetFromXml(wxXmlNode* ModelNode, bool zeroBased)
{
    wxString tempstr,channelstr;
    wxString customModel,RGBorder;
    long degrees, StartChannel, channel;
    size_t i;

    ModelXml=ModelNode;
    TreeDegrees=0;
    StrobeRate=0;
    Nodes.clear();

    name=ModelNode->GetAttribute("name");
    DisplayAs=ModelNode->GetAttribute("DisplayAs");
    if (ModelNode->HasAttribute("StringType"))
    {
        // post 3.1.4
        StringType=ModelNode->GetAttribute("StringType");
    }
    else
    {
        // 3.1.4 and earlier
        StringType=ModelNode->GetAttribute("Order","RGB")+" Nodes";
    }
    SingleNode=HasSingleNode(StringType);
    SingleChannel=HasSingleChannel(StringType);
    RGBorder=SingleNode ? "RGB" : RGBorder=StringType.Left(3);
    rgbidx[0]=std::max(RGBorder.Find('R'),0);
    rgbidx[1]=std::max(RGBorder.Find('G'),0);
    rgbidx[2]=std::max(RGBorder.Find('B'),0);

    tempstr=ModelNode->GetAttribute("parm1");
    tempstr.ToLong(&parm1);
    tempstr=ModelNode->GetAttribute("parm2");
    tempstr.ToLong(&parm2);
    tempstr=ModelNode->GetAttribute("parm3");
    tempstr.ToLong(&parm3);
    tempstr=ModelNode->GetAttribute("StartChannel","1");
    tempstr.ToLong(&StartChannel);
    tempstr=ModelNode->GetAttribute("Dir");
    IsLtoR=tempstr != "R";
    if (ModelNode->HasAttribute("StartSide"))
    {
        tempstr=ModelNode->GetAttribute("StartSide");
        isBotToTop = (tempstr == "B");
    }
    else
    {
        isBotToTop=true;
    }

    tempstr=ModelNode->GetAttribute("Antialias","0");
    tempstr.ToLong(&Antialias);
    AliasFactor=1 << Antialias;
    MyDisplay=IsMyDisplay(ModelNode);

    tempstr=ModelNode->GetAttribute("offsetXpct","0");
    tempstr.ToDouble(&offsetXpct);
    tempstr=ModelNode->GetAttribute("offsetYpct","0");
    tempstr.ToDouble(&offsetYpct);
    tempstr=ModelNode->GetAttribute("PreviewScale","0.333");
    tempstr.ToDouble(&PreviewScale);
    tempstr=ModelNode->GetAttribute("PreviewRotation","0");
    tempstr.ToLong(&degrees);
    PreviewRotation=degrees;

    // calculate starting channel numbers for each string
    size_t NumberOfStrings= HasOneString(DisplayAs) ? 1 : parm1;
    int ChannelsPerString=parm2*3;
    if (SingleChannel)
        ChannelsPerString=1;
    else if (SingleNode)
        ChannelsPerString=3;

    if (ModelNode->HasAttribute("CustomModel"))
    {
        customModel = ModelNode->GetAttribute("CustomModel");
        int maxval=GetCustomMaxChannel(customModel);
        // fix NumberOfStrings
        if (SingleNode)
        {
            NumberOfStrings=maxval;
        }
        else
        {
            ChannelsPerString=maxval*3;
        }
    }

    tempstr=ModelNode->GetAttribute("Advanced","0");
    bool HasIndividualStartChans=tempstr == "1";
    stringStartChan.clear();
    stringStartChan.resize(NumberOfStrings);
    for (i=0; i<NumberOfStrings; i++)
    {
        tempstr=StartChanAttrName(i);
        if (!zeroBased && HasIndividualStartChans && ModelNode->HasAttribute(tempstr))
        {
            ModelNode->GetAttribute(tempstr, &channelstr);
            channelstr.ToLong(&channel);
            stringStartChan[i] = channel-1;
        }
        else
        {
            stringStartChan[i] = (zeroBased? 0 : StartChannel-1) + i*ChannelsPerString;
        }
    }

    // initialize model based on the DisplayAs value
    wxStringTokenizer tkz(DisplayAs, " ");
    wxString token = tkz.GetNextToken();
    if (token == "Tree")
    {
        InitVMatrix();
        token = tkz.GetNextToken();
        token.ToLong(&degrees);
        SetTreeCoord(degrees);
    }
    else if (DisplayAs == "Custom")
    {
        InitCustomMatrix(customModel);
        CopyBufCoord2ScreenCoord();
    }
    else if (DisplayAs == "Vert Matrix")
    {
        InitVMatrix();
        CopyBufCoord2ScreenCoord();
    }
    else if (DisplayAs == "Horiz Matrix")
    {
        InitHMatrix();
        CopyBufCoord2ScreenCoord();
    }
    else if (DisplayAs == "Single Line")
    {
        InitLine();
        SetLineCoord();
    }
    else if (DisplayAs == "Arches")
    {
        InitHMatrix(); // Old call was InitLine();
        SetArchCoord();
    }
    else if (DisplayAs == "Window Frame")
    {
        InitFrame();
        CopyBufCoord2ScreenCoord();
    }
    else if (DisplayAs == "Star")
    {
        InitStar();
        CopyBufCoord2ScreenCoord();
    }
    else if (DisplayAs == "Wreath")
    {
        InitWreath();
        CopyBufCoord2ScreenCoord();
    }

    size_t NodeCount=GetNodeCount();
    for(size_t i=0; i<NodeCount; i++)
    {
        Nodes[i]->sparkle = rand() % 10000;
    }
}
Esempio n. 16
0
/******************************************************************************
    CreateSubTableFrames:
    Create the frames for the sub table.
*******************************************************************************/
long CreateSubTableFrames(PTERWND w,long FirstLine,int ParentLevel,LPINT pFrameNo,LPINT pTableHt,
                          int ColumnX, int PageNo,int sect,int y, int ScrY,int HiddenY, int HdrMargin, 
                          int HdrHeight,int TopSect,int TopLeftMargin, int ColumnNo, LPINT pHasPictFrames, int pass,
                          int BoxFrame, int ParaFrameId)
{
    long l;
    int FrameNo=(*pFrameNo),ParentCell,CurLevel=ParentLevel+1,CurCell,ParentRow;
    int FirstFrame=0,FrameHt,CurColHeight,MaxColumnHeight,CellX,ColumnWidth;
    int ScrFrameHt,ScrCurColHeight,ScrMaxColumnHeight;
    long PrevFrameLastLine=0;
    int  TableRowIndent,CellWidth,SubTableHt;
    int ParentLeftMargin,ParentRightMargin,FirstCellFrame,TableRowHeight,ScrTableRowHeight;
    BOOL EndOfSubTable=FALSE,RowBreak,CellBreak;
    long FrameFirstLine,FrameNextLine,FrameLastLine;
    int  CurLineHt,PrevCell,CurRowId,PrevRowId;
    int  PassFlags=0,LeftWidth,RightWidth,TopWidth,BotWidth;
    BOOL CellFramed;
    COLORREF BorderColor[4];

    dm("CreateSubTableFrames");

    (*pTableHt)=0;
   
    if (cid(FirstLine)==0) return FirstLine;


    // find the cell at at the current level
    CurCell=0;
    for (l=FirstLine;l<TotalLines;l++) {
       if (TableLevel(w,l)==ParentLevel) return (l-1);  // current level not found
       if (TableLevel(w,l)==(ParentLevel+1)) {
          CurCell=cid(l);
          break;
       }
    }
    if (CurCell==0) return (TotalLines-1);     // current level not found

    ParentCell=cell[CurCell].ParentCell;
    ParentRow=cell[ParentCell].row;

    ParentLeftMargin=TwipsToPrtX(CellLeftMargin(w,ParentCell));         // 20070417
    ParentRightMargin=TwipsToPrtX(CellRightMargin(w,ParentCell));
    ColumnWidth=TwipsToPrtX(cell[ParentCell].width)-ParentLeftMargin-ParentRightMargin;
    ColumnX+=ParentLeftMargin;

    // check if parent row indentation needs to be added to ColumnX
    if (cell[ParentCell].PrevCell<=0 && cell[ParentCell].level>0) {   // get the row indentation - level 0 ColumnX is already adjusted in CreateFrames function
       int row=cell[ParentCell].row;
       ColumnX+=TableRow[row].CurIndent;
    }    


    // find the space needed at the top of the parent cell
    CurColHeight=0;         // current column height
    GetCellFrameBorder(w,ParentCell,&LeftWidth,&RightWidth,&TopWidth,&BotWidth,PageNo,BorderColor);
    TopWidth+=CellTopPad(w,ParentCell);         // 20070430
    BotWidth+=CellBotPad(w,ParentCell);
    
    if (CellAux[ParentCell].flags&CAUX_SET_TOP_SPACE) TopWidth=cell[ParentCell].margin;  // use extra space
    CurColHeight=TwipsToPrtY(TopWidth);
    ScrCurColHeight=PrtToScrY(CurColHeight);


    // divide text into columns
    FirstFrame=FrameNo;
    if (!InitFrame(w,FrameNo))  AbortTer(w,"Ran Out of Text Frame Table (CreateFrames 1)",1);

    FrameHt=0;              // adds up the line height
    ScrFrameHt=0;
    MaxColumnHeight=0;
    ScrMaxColumnHeight=0;
    CellX=ColumnX;          // x position of the previous column or cell

    PrevFrameLastLine=FirstLine-1;
    FirstCellFrame=-1;
    TableRowHeight=0;       // height of a table row
    ScrTableRowHeight=0;    // height of a table row
    CurCell=0;
    FrameFirstLine=-1;
    SubTableHt=0;           // subtable height before the line
    TableRowIndent=0;
    CellFramed=FALSE;

    for (l=FirstLine;;l++) {
       if (TableLevel(w,l)<CurLevel) EndOfSubTable=TRUE;   // out of the sub table

       if (l<TotalLines && pass==PASS_BODY && LinePage(l)!=PageNo && cid(l) && !EndOfSubTable) continue;  // this line does not belong to this page
        
        
       // set the frame line variables
       if (FrameFirstLine<0) FrameFirstLine=FrameNextLine=l;
       FrameLastLine=FrameNextLine;
       FrameNextLine=l;

       CurLineHt=0;
       if (l<TotalLines) CurLineHt=LineHt(l);

       // reset frame types and break types
       RowBreak=CellBreak=FALSE;

       // get current and previous cell ids
       PrevCell=CurCell;
       if (l<TotalLines && !EndOfSubTable) CurCell=LevelCell(w,CurLevel,l);
       else                                CurCell=0;
       
       if (EndOfSubTable && PrevCell==0 && CurCell==0) break;  // This would happen if the whole subtable falls in the following page


       CurRowId=cell[CurCell].row;
       PrevRowId=cell[PrevCell].row;

       if (CurCell!=PrevCell && PrevCell!=0)                   CellBreak=TRUE;
       if (CurRowId!=PrevRowId && PrevRowId!=0 && PrevCell!=0) RowBreak=TRUE;
       if (EndOfSubTable) CellBreak=RowBreak=TRUE;

       if (CellBreak || RowBreak) {// start next frame
          CreateCellFrame(w,CurLevel,&FrameNo,y,ScrY, &FrameHt,&ScrFrameHt, 
                 CurColHeight,ScrCurColHeight, &FirstCellFrame, 
                 &TableRowHeight, &ScrTableRowHeight,&CellX,TableRowIndent,
                 PageNo,TopLeftMargin,ColumnNo,sect,PrevCell, &CellFramed,
                 FrameFirstLine, FrameLastLine, PassFlags, RowBreak,
                 &CellWidth, ColumnWidth,1,0,ColumnWidth,ColumnX,ColumnWidth,BoxFrame,ParaFrameId);


          // logic after cell frame creation
          FrameFirstLine=FrameNextLine;      // for the next frame

          // reset frame height for cells and para frames
          if (!RowBreak) FrameHt=ScrFrameHt=0;

          // adjust operational variables
          CurColHeight+=FrameHt;
          ScrCurColHeight+=ScrFrameHt;
          FrameHt=ScrFrameHt=0;            // reset the height for the frame

          // set x position for the next frame
          CellX=CellX+CellWidth;
          if (RowBreak)   CellX=ColumnX; // x for the first cell of the next row

       }
       if (EndOfSubTable) break;  // end of sub table

       // check if a subtable needs to be created
       if (l<TotalLines && TableLevel(w,l)>CurLevel) {
          int BeginX=CellX;
          int cl,FirstCell=0;
          if (FirstLine<TotalLines) FirstCell=LevelCell(w,CurLevel,FirstLine);
          if (FirstCell>0 && cell[CurCell].PrevCell>0) {    // subtable not starting at column 0, so add the column width of the empty columns
             ParentRow=cell[FirstCell].row;
             for (cl=TableRow[ParentRow].FirstCell;cl>0 && cl!=FirstCell;cl=cell[cl].NextCell) BeginX+=TwipsToPrtX(cell[cl].width);

             // 20060810: add width of the any missing parent cells after the last cell framed on this row
             if (PrevCell>0 && PrevCell!=CurCell && cell[PrevCell].row==cell[CurCell].row) {
                for (cl=cell[PrevCell].NextCell;cl>0 && cl!=CurCell;cl=cell[cl].NextCell) BeginX+=TwipsToPrtX(cell[cl].width);
             } 
          } 

          l=CreateSubTableFrames(w,l,CurLevel,&FrameNo,&SubTableHt,BeginX,
                                 PageNo,sect,y+CurColHeight+FrameHt,
                                 ScrY+ScrCurColHeight+ScrFrameHt,HiddenY,HdrMargin,HdrHeight,TopSect,
                                 TopLeftMargin,ColumnNo,pHasPictFrames,pass,BoxFrame,ParaFrameId);
          FrameHt+=SubTableHt;
          ScrFrameHt+=PrtToScrY(SubTableHt);
          continue;
       }

       // record line y and x position, set PageHasControl flag
       if (l<TotalLines) SetFrameLineInfo(w,l,y,ScrY,&FrameHt,&ScrFrameHt,CurColHeight,
                 CellX,&TableRowIndent,PageNo,HiddenY,HdrMargin,HdrHeight,
                 TopSect,TopLeftMargin,ColumnNo,pHasPictFrames,sect,CurLineHt,FirstLine);

    }

    // pass values by reference
    (*pFrameNo)=FrameNo;
    (*pTableHt)=CurColHeight;  


    return (l-1);    // return the last line of the subtable
}
Esempio n. 17
0
bool CodeBlocksApp::OnInit()
{
#ifdef __WXMSW__
    InitCommonControls();
#endif

    wxLog::EnableLogging(true);

    SetAppName(_T("codeblocks"));

    s_Loading              = true;
    m_pBatchBuildDialog    = nullptr;
    m_BatchExitCode        = 0;
    m_Batch                = false;
    m_BatchNotify          = false;
    m_Build                = false;
    m_ReBuild              = false;
    m_Clean                = false;
    m_HasProject           = false;
    m_HasWorkSpace         = false;
    m_SafeMode             = false;
    m_BatchWindowAutoClose = true;

    wxTheClipboard->Flush();

    wxCmdLineParser& parser = *Manager::GetCmdLineParser();
    parser.SetDesc(cmdLineDesc);

    // NOTE: crash handler explicitly disabled because it causes problems
    //       with plugins loading/unloading...
    //
    // static CrashHandler crash_handler(!m_CrashHandler);

    // we'll do this once and for all at startup
    wxFileSystem::AddHandler(new wxZipFSHandler);
    wxFileSystem::AddHandler(new wxMemoryFSHandler);
    wxXmlResource::Get()->InsertHandler(new wxToolBarAddOnXmlHandler);
    wxXmlResource::Get()->InsertHandler(new wxScrollingDialogXmlHandler);
    wxInitAllImageHandlers();
    wxXmlResource::Get()->InitAllHandlers();

    Manager::Get()->GetLogManager()->Log(F(wxT("Starting ") + appglobals::AppName + wxT(" ") +
                                           appglobals::AppActualVersionVerb + wxT(" ") +
                                           appglobals::AppBuildTimestamp));

    try
    {
    #if (wxUSE_ON_FATAL_EXCEPTION == 1)
        wxHandleFatalExceptions(true);
    #endif

        InitExceptionHandler();

        delete wxMessageOutput::Set(new cbMessageOutputNull); // No output. (suppress warnings about unknown options from plugins)
        if (ParseCmdLine(nullptr) == -1) // only abort if '--help' was passed in the command line
        {
            delete wxMessageOutput::Set(new wxMessageOutputMessageBox);
            parser.Usage();
            return false;
        }

        if ( !LoadConfig() )
            return false;

        // set safe-mode appropriately
        PluginManager::SetSafeMode(m_SafeMode);

        // If not in batch mode, and no startup-script defined, initialise XRC
        if(!m_Batch && m_Script.IsEmpty() && !InitXRCStuff())
            return false;

        InitLocale();

        if (m_DDE && !m_Batch && Manager::Get()->GetConfigManager(_T("app"))->ReadBool(_T("/environment/use_ipc"), true))
        {
            // Create a new client
            DDEClient *client = new DDEClient;
            DDEConnection* connection = nullptr;
            wxLogNull ln; // own error checking implemented -> avoid debug warnings
            connection = (DDEConnection *)client->MakeConnection(_T("localhost"), F(DDE_SERVICE, wxGetUserId().wx_str()), DDE_TOPIC);

            if (connection)
            {
                // don't eval here just forward the whole command line to the other instance
                wxString cmdLine;
                for (int i = 1 ; i < argc; ++i)
                    cmdLine += wxString(argv[i]) + _T(' ');

                if ( !cmdLine.IsEmpty() )
                {
                    // escape openings and closings so it is easily possible to find the end on the rx side
                    cmdLine.Replace(_T("("), _T("\\("));
                    cmdLine.Replace(_T(")"), _T("\\)"));
                    connection->Execute(_T("[CmdLine({") + cmdLine + _T("})]"));
                }

                // On Linux, C::B has to be raised explicitly if it's wanted
                if (Manager::Get()->GetConfigManager(_T("app"))->ReadBool(_T("/environment/raise_via_ipc"), true))
                    connection->Execute(_T("[Raise]"));
                connection->Disconnect();
                delete connection;
                delete client;

                // return false to end the application
                return false;
            }
            // free memory DDE-/IPC-clients, if we are here connection could not be established and there is no need to free it
            delete client;
        }
        // Now we can start the DDE-/IPC-Server, if we did it earlier we would connect to ourselves
        if (m_DDE && !m_Batch)
        {
            g_DDEServer = new DDEServer(nullptr);
            g_DDEServer->Create(F(DDE_SERVICE, wxGetUserId().wx_str()));
        }

        m_pSingleInstance = nullptr;
        if (   Manager::Get()->GetConfigManager(_T("app"))->ReadBool(_T("/environment/single_instance"), true)
            && !parser.Found(_T("multiple-instance")) )
        {
            const wxString name = wxString::Format(_T("Code::Blocks-%s"), wxGetUserId().wx_str());

            m_pSingleInstance = new wxSingleInstanceChecker(name, ConfigManager::GetTempFolder());
            if (m_pSingleInstance->IsAnotherRunning())
            {
                /* NOTE: Due to a recent change in logging code, this visual warning got disabled.
                   So the wxLogError() has been changed to a cbMessageBox(). */
                cbMessageBox(_("Another program instance is already running.\nCode::Blocks is currently configured to only allow one running instance.\n\nYou can access this Setting under the menu item 'Environment'."),
                            _T("Code::Blocks"), wxOK | wxICON_ERROR);
                return false;
            }
        }
        // Splash screen moved to this place, otherwise it would be short visible, even if we only pass filenames via DDE/IPC
        // we also don't need it, if only a single instance is allowed
        Splash splash(!m_Batch && m_Script.IsEmpty() && m_Splash &&
                      Manager::Get()->GetConfigManager(_T("app"))->ReadBool(_T("/environment/show_splash"), true));
        InitDebugConsole();

        Manager::SetBatchBuild(m_Batch || !m_Script.IsEmpty());
        Manager::Get()->GetScriptingManager();
        MainFrame* frame = nullptr;
        frame = InitFrame();
        m_Frame = frame;

        // plugins loaded -> check command line arguments again
        delete wxMessageOutput::Set(new wxMessageOutputBest); // warn about unknown options
        if ( ParseCmdLine(m_Frame) == 0 )
        {
            if (Manager::Get()->GetConfigManager(_T("app"))->ReadBool(_T("/environment/blank_workspace"), true) == false)
                Manager::Get()->GetProjectManager()->LoadWorkspace();
        }

        if (m_SafeMode) wxLog::EnableLogging(true); // re-enable logging in safe-mode

        if (m_Batch)
        {
            Manager::SetAppStartedUp(true);

            // the compiler plugin might be waiting for this
            CodeBlocksEvent event(cbEVT_APP_STARTUP_DONE);
            Manager::Get()->ProcessEvent(event);

            Manager::Get()->RegisterEventSink(cbEVT_COMPILER_FINISHED, new cbEventFunctor<CodeBlocksApp, CodeBlocksEvent>(this, &CodeBlocksApp::OnBatchBuildDone));
            s_Loading = false;
            LoadDelayedFiles(frame);

            BatchJob();
            frame->Close();
            return true;
        }

        if (!m_Script.IsEmpty())
        {
            s_Loading = false;
            LoaderBase* loader = Manager::Get()->GetFileManager()->Load(m_Script);

            if (loader->GetData())
                Manager::Get()->GetScriptingManager()->LoadBuffer(cbC2U(loader->GetData()));

            delete loader;
            frame->Close();
            return true;
        }

        CheckVersion();

        // run startup script
        try
        {
            wxString startup = ConfigManager::LocateDataFile(_T("startup.script"), sdScriptsUser | sdScriptsGlobal);
            if (!startup.IsEmpty())
                Manager::Get()->GetScriptingManager()->LoadScript(startup);
        }
        catch (SquirrelError& exception)
        {
            Manager::Get()->GetScriptingManager()->DisplayErrors(&exception);
        }
        Manager::ProcessPendingEvents();

        // finally, show the app
        splash.Hide();
        SetTopWindow(frame);
        frame->Show();

        frame->StartupDone();

        frame->ShowTips(); // this func checks if the user wants tips, so no need to check here

        if (platform::windows)
            InitAssociations();

        s_Loading = false;

        LoadDelayedFiles(frame);
        AttachDebugger();
        Manager::Get()->GetProjectManager()->WorkspaceChanged();

        // all done
        Manager::SetAppStartedUp(true);

        CodeBlocksEvent event(cbEVT_APP_STARTUP_DONE);
        Manager::Get()->ProcessEvent(event);

        return true;
    }
    catch (cbException& exception)
    {
        exception.ShowErrorMessage();
    }
    catch (SquirrelError& exception)
    {
        Manager::Get()->GetScriptingManager()->DisplayErrors(&exception);
    }
    catch (const char* message)
    {
        wxSafeShowMessage(_T("Exception"), cbC2U(message));
    }
    catch (...)
    {
        wxSafeShowMessage(_T("Exception"), _T("Unknown exception was raised. The application will terminate immediately..."));
    }
    // if we reached here, return error
    return false;
}
Esempio n. 18
0
bool
GIFLoad::ReadGIFImageData()
{
	unsigned char newEntry[ENTRY_COUNT];
	unsigned char codeSize;
	if (fInput->Read(&codeSize, 1) < 1)
		return false;

	if (codeSize > fPalette->size_in_bits) {
		if (debug) {
			syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - "
				"Code_size should be %d, not %d, allowing it\n",
				fCodeSize, codeSize);
		}
		if (!InitFrame(codeSize))
			return false;
	} else if (codeSize < fPalette->size_in_bits) {
		if (debug) {
			syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - "
				"Code_size should be %d, not %d\n", fCodeSize, codeSize);
		}
		return false;
	} else if (!InitFrame(fPalette->size_in_bits))
		return false;

	if (debug)
		syslog(LOG_INFO, "GIFLoad::ReadGIFImageData() - Starting LZW\n");

	while ((fNewCode = NextCode()) != -1 && fNewCode != fEndCode) {
		if (fNewCode == fClearCode) {
			ResetTable();
			fNewCode = NextCode();
			fOldCode[0] = fNewCode;
			fOldCodeLength = 1;
			if (!OutputColor(fOldCode, 1))
				goto bad_end;

			if (fNewCode == -1 || fNewCode == fEndCode) {
				if (debug) {
					syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - "
						"Premature fEndCode or error reading fNewCode\n");
				}
				goto bad_end;
			}
			continue;
		}

		// explicitly check for lack of clear code at start of file
		if (fOldCodeLength == 0) {
			fOldCode[0] = fNewCode;
			fOldCodeLength = 1;
			if (!OutputColor(fOldCode, 1))
				goto bad_end;

			continue;
		}

		// error out if we're trying to access an out-of-bounds index
		if (fNextCode >= ENTRY_COUNT)
			goto bad_end;

		if (fTable[fNewCode] != NULL) {
			// exists in table

			if (!OutputColor(fTable[fNewCode], fEntrySize[fNewCode]))
				goto bad_end;

			//memcpy(newEntry, fOldCode, fOldCodeLength);
			for (unsigned int x = 0; x < fOldCodeLength; x++)
				newEntry[x] = fOldCode[x];

			//memcpy(newEntry + fOldCodeLength, fTable[fNewCode], 1);
			newEntry[fOldCodeLength] = fTable[fNewCode][0];
		} else {
			// does not exist in table

			//memcpy(newEntry, fOldCode, fOldCodeLength);
			for (unsigned int x = 0; x < fOldCodeLength; x++)
				newEntry[x] = fOldCode[x];

			//memcpy(newEntry + fOldCodeLength, fOldCode, 1);
			newEntry[fOldCodeLength] = fOldCode[0];

			if (!OutputColor(newEntry, fOldCodeLength + 1))
				goto bad_end;
		}
		fTable[fNextCode] = MemblockAllocate(fOldCodeLength + 1);
		if (fTable[fNextCode] == NULL)
			goto bad_end;

		//memcpy(fTable[fNextCode], newEntry, fOldCodeLength + 1);
		for (unsigned int x = 0; x < fOldCodeLength + 1; x++)
			fTable[fNextCode][x] = newEntry[x];

		fEntrySize[fNextCode] = fOldCodeLength + 1;

		//memcpy(fOldCode, fTable[fNewCode], fEntrySize[fNewCode]);
		for (int x = 0; x < fEntrySize[fNewCode]; x++)
			fOldCode[x] = fTable[fNewCode][x];

		fOldCodeLength = fEntrySize[fNewCode];
		fNextCode++;

		if (fNextCode > fMaxCode && fBits < LZ_MAX_BITS) {
			fBits++;
			fMaxCode = (1 << fBits) - 1;
		}
	}

	MemblockDeleteAll();
	if (fNewCode == -1)
		return false;

	if (debug)
		syslog(LOG_INFO, "GIFLoad::ReadGIFImageData() - Done\n");

	return true;

bad_end:
	if (debug)
		syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - Reached a bad end\n");

	MemblockDeleteAll();
	return false;
}