int32 SQRButton::Create( const WndCreateParam& param ) { WndCreateParam newParam = param; newParam.uStyle |= WS_CHILD | WS_IGNOREWHEEL; int32 re = SQRWnd::Create( newParam ); float nWidth = GetWndWidth(); float nHeight = GetWndHeight(); CFRect rt( 0, 0, nWidth, nHeight ); uint32 dwColor; dwColor = CColor::RandDark(); m_MouseOverImage.AddImage( GetGraphic(), 0, "", &rt, CFPos(0.0f, 0.0f), dwColor ); dwColor = CColor::RandDark(); m_ClickDownImage.AddImage( GetGraphic(), 0, "", &rt, CFPos(0.0f, 0.0f), dwColor ); m_ClickDownColor = 0xffffffff; m_MouseOverColor = 0xffffffff; m_MouseOverBcColor = 0; m_ClickDownBcColor = 0; m_uFlashCircle = 0; m_uFlashStartTime = 0; m_uFlashEndTime = 0; return re; }
int32 SQRCheckButton::Create( const WndCreateParam& param ) { int32 re = SQRButton::Create( param ); float nWidth = GetWndWidth(); float nHeight = GetWndWidth(); CFRect rt( 0.0f, 0.0f, nWidth, nHeight ); m_UncheckMouseOverImage.AddImage( GetGraphic(), 0, "", &rt, CFPos(0.0f, 0.0f), 0xff567890 ); m_UncheckClickDownImage.AddImage( GetGraphic(), 0, "", &rt, CFPos(0.0f, 0.0f), 0xff5678ff ); m_UncheckEnableImage. AddImage( GetGraphic(), 0, "", &rt, CFPos(0.0f, 0.0f), 0xff456789 ); m_UncheckDisableImage. AddImage( GetGraphic(), 0, "", &rt, CFPos(0.0f, 0.0f), 0xff555555 ); m_UncheckEnableColor = 0xffffffff; m_UncheckDisableColor = 0xffffffff; m_UncheckMouseOverColor = 0xffffffff; m_UncheckClickDownColor = 0xffffffff; m_UncheckMouseOverBcColor = 0; m_UncheckClickDownBcColor = 0; m_UncheckEnableBcColor = 0; m_UncheckDisableBcColor = 0; m_bCheck = false; return re; }
void SQRButton::SetBackImageColor(uint32 uColor) { float nWidth = GetWndOrgWidth(); float nHeight = GetWndOrgHeight(); CFRect rt( 0, 0, nWidth, nHeight ); m_hWnd->m_Enable.ClearImage(); m_hWnd->m_Disable.ClearImage(); m_hWnd->m_Enable.AddImage( GetGraphic(), 0, "", &rt, CFPos(0.0f, 0.0f), uColor ); m_hWnd->m_Disable.AddImage(GetGraphic(), 0, "", &rt, CFPos(0.0f, 0.0f), uColor ); }
void SQRButton::CreatWndTex() { // ÏÔʾ֮ǰÉêÇë×ÊÔ´ if ( m_FlushDlg == NULL ) { m_FlushDlg = GetFlushDialog(); if ( m_FlushDlg == NULL ) return; } m_MouseOverImage.CreatTex( GetGraphic(), m_FlushDlg ); m_ClickDownImage.CreatTex( GetGraphic(), m_FlushDlg ); SQRWnd::CreatWndTex(); }
void CBigMap::InitMapData( const TCHAR* szMapFile) { ClearUp(); m_SceneName = szMapFile; //读取区域名字和文件名对应关系 if(!LoadConfig(m_SceneName)) return; //创建m_MapTextureClose //创建m_MapTextureOpen CPkgFile::EnableAsyncRead(false); string FileName = ""; format(FileName,"%s/BigMap/open.dds",m_SceneName.c_str()); if(m_bOpen) GetGraphic()->CreateTexture(PATH_ALIAS_RES.c_str(), FileName.c_str(),&m_MapTextureOpen); else { m_MapTextureOpen = NULL; return; } FileName.clear(); format(FileName,"%s/BigMap/close.dds",m_SceneName.c_str()); if(m_bClose) GetGraphic()->CreateTexture(PATH_ALIAS_RES.c_str(), FileName.c_str(),&m_MapTextureClose); else { m_MapTextureClose = NULL; return; } SafeRelease(m_pAlphaTexture); m_pAlphaTexture = GetGraphic()->CreateRenderTarget(); m_pAlphaTexture->SetWidth(uint32(GetWndWidth())); m_pAlphaTexture->SetHeight(uint32(GetWndHeight())); m_pAlphaTexture->SetUseDepthBuffer(false); m_pAlphaTexture->SetFormat(TFMT_A8R8G8B8); m_pAlphaTexture->Create(); m_BackTexUV[2] = CVector2f( 0.0f , float(m_pAlphaTexture->GetHeight())); m_BackTexUV[0] = CVector2f( 0.0f , 0.0f ); m_BackTexUV[3] = CVector2f( float(m_pAlphaTexture->GetWidth()) , float(m_pAlphaTexture->GetHeight()) ); m_BackTexUV[1] = CVector2f( float(m_pAlphaTexture->GetWidth()) , 0.0f); m_fRTWidth = float(m_pAlphaTexture->GetWidth()); m_fRTHeight = float(m_pAlphaTexture->GetHeight()); if(m_pAlphaTexture==NULL) return; //string testdir = szMapFile; //testdir+= "yhl.dds"; //m_pAlphaTexture->SaveToFile(testdir); }
void SQRCheckButton::CreatWndTex() { // 显示之前申请资源 if ( m_FlushDlg == NULL ) { m_FlushDlg = GetFlushDialog(); if ( m_FlushDlg == NULL ) return; } m_UncheckMouseOverImage.CreatTex( GetGraphic(), m_FlushDlg ); m_UncheckClickDownImage.CreatTex( GetGraphic(), m_FlushDlg ); m_UncheckEnableImage.CreatTex( GetGraphic(), m_FlushDlg ); m_UncheckDisableImage.CreatTex( GetGraphic(), m_FlushDlg ); SQRButton::CreatWndTex(); }
void CBigMap::UpdateVisibleRegion() { if(m_pAlphaTexture==NULL) return; m_pAlphaTexture->Begin(true); { m_pAlphaTexture->SetClearColor( CColor(0,0,0,0) ); m_pAlphaTexture->Clear(); GetGraphic()->SwapBegin(); AlphaTexsRenderToTexture(); GetGraphic()->SwapEnd(); } m_pAlphaTexture->End(); }
bool Picture::contains (PointObj& po, Graphic* gs) { if (!IsEmpty()) { Iterator i; FullGraphic gstemp; Transformer ttemp; BoxObj b; getBox(b, gs); if (b.Contains(po)) { gstemp.SetTransformer(&ttemp); for (First(i); !Done(i); Next(i)) { Graphic* gr = GetGraphic(i); concatGraphic(gr, gr, gs, &gstemp); if (containsGraphic(gr, po, &gstemp)) { gstemp.SetTransformer(nil); return true; } } gstemp.SetTransformer(nil); /* to avoid deleting ttemp explicitly*/ } } return false; }
bool Picture::intersects (BoxObj& userb, Graphic* gs) { if (!IsEmpty()) { Iterator i; FullGraphic gstemp; Transformer ttemp; BoxObj b; getBox(b, gs); if (b.Intersects(userb)) { gstemp.SetTransformer(&ttemp); for (First(i); !Done(i); Next(i)) { Graphic* gr = GetGraphic(i); concatGraphic(gr, gr, gs, &gstemp); if (intersectsGraphic(gr, userb, &gstemp)) { gstemp.SetTransformer(nil); return true; } } gstemp.SetTransformer(nil); /* to avoid deleting ttemp explicitly*/ } } return false; }
Line* LinkView::GetLine () { Iterator i; Graphic* gr = GetGraphic(); gr->First(i); return (Line*) gr->GetGraphic(i); }
boolean ClosedSplineView::VertexChanged () { SFH_ClosedBSpline* gview = (SFH_ClosedBSpline*) GetGraphic(); SFH_ClosedBSpline* gsubj = (SFH_ClosedBSpline*) GetClosedSplineComp()->GetGraphic(); return *gview != *gsubj; }
bool MultiLineView::VertexChanged () { SF_MultiLine* gview = (SF_MultiLine*) GetGraphic(); SF_MultiLine* gsubj = (SF_MultiLine*) GetMultiLineComp()->GetGraphic(); return *gview != *gsubj; }
void LineView::Update () { Graphic* line = GetGraphic(); IncurDamage(line); *line = *GetLineComp()->GetGraphic(); IncurDamage(line); EraseHandles(); }
void RectView::Update () { Graphic* rect = GetGraphic(); IncurDamage(rect); *rect = *GetRectComp()->GetGraphic(); IncurDamage(rect); EraseHandles(); }
void StencilView::Update () { Graphic* stencil = GetGraphic(); IncurDamage(stencil); *stencil = *GetStencilComp()->GetGraphic(); IncurDamage(stencil); EraseHandles(); }
void EllipseView::Update () { Graphic* ellipse = GetGraphic(); IncurDamage(ellipse); *ellipse = *GetEllipseComp()->GetGraphic(); IncurDamage(ellipse); EraseHandles(); }
void Picture::getExtent ( float& l, float& b, float& cx, float& cy, float& tol, Graphic* gs ) { Extent e; float right, top, dummy1, dummy2; if (extentCached()) { getCachedExtent(e._left, e._bottom, e._cx, e._cy, e._tol); } else { if (IsEmpty()) { l = b = cx = cy = tol = 0.0; return; } else { Iterator i; FullGraphic gstemp; Transformer ttemp; Extent te; gstemp.SetTransformer(&ttemp); First(i); Graphic* gr = GetGraphic(i); concatGSGraphic(gr, gr, gs, &gstemp); concatTransformerGraphic(gr, nil, gr->GetTransformer(), &ttemp); getExtentGraphic(gr, e._left,e._bottom,e._cx,e._cy,e._tol,&gstemp); for (Next(i); !Done(i); Next(i)) { gr = GetGraphic(i); concatGSGraphic(gr, gr, gs, &gstemp); concatTransformerGraphic(gr,nil, gr->GetTransformer(), &ttemp); getExtentGraphic( gr, te._left, te._bottom, te._cx, te._cy, te._tol, &gstemp ); e.Merge(te); } cacheExtent(e._left, e._bottom, e._cx, e._cy, e._tol); gstemp.SetTransformer(nil); // to avoid deleting ttemp explicitly } } right = 2*e._cx - e._left; top = 2*e._cy - e._bottom; transformRect(e._left, e._bottom, right, top, l, b, dummy1, dummy2, gs); transform(e._cx, e._cy, cx, cy, gs); tol = e._tol; }
void ArrowSplineView::Update () { ArrowOpenBSpline* amline = (ArrowOpenBSpline*) GetGraphic(); ArrowOpenBSpline* subj = GetArrowSplineComp()->GetArrowOpenBSpline(); IncurDamage(amline); *amline = *subj; IncurDamage(amline); EraseHandles(); }
void LineView::GetEndpoints (Coord& x0, Coord& y0, Coord& x1, Coord& y1) { Line* line = (Line*) GetGraphic(); Transformer t; line->GetOriginal(x0, y0, x1, y1); line->TotalTransformation(t); t.Transform(x0, y0); t.Transform(x1, y1); }
void BitmapView::Update () { Graphic* bcomp = GetBitmapComp()->GetBitmapGraphic(); Graphic* bview = (BitmapGraphic*) GetGraphic(); IncurDamage(bview); *bview = *bcomp; IncurDamage(bview); EraseHandles(); }
void ArrowLineView::Update () { ArrowLine* line = (ArrowLine*) GetGraphic(); ArrowLine* subj = GetArrowLineComp()->GetArrowLine(); IncurDamage(line); *line = *subj; IncurDamage(line); EraseHandles(); }
Graphic* Picture::Copy () { Iterator i; Picture* newPicture = new Picture(this); for (First(i); !Done(i); Next(i)) { newPicture->Append(GetGraphic(i)->Copy()); } return newPicture; }
Manipulator* TextOvView::CreateManipulator ( Viewer* v, Event& e, Transformer* rel, Tool* tool ) { Manipulator* m = nil; Editor* ed = v->GetEditor(); int tabWidth = Math::round(.5*ivinch); if (tool->IsA(GRAPHIC_COMP_TOOL)) { FontVar* fontVar = (FontVar*) ed->GetState("FontVar"); ColorVar* colVar = (ColorVar*) ed->GetState("ColorVar"); PSFont* font = (fontVar == nil) ? psstdfont : fontVar->GetFont(); PSColor* fg = (colVar == nil) ? psblack : colVar->GetFgColor(); int lineHt = font->GetLineHt(); Painter* painter = new Painter; painter->FillBg(false); painter->SetFont(font); painter->SetColors(fg, nil); Orientation o = v->GetOrientation(); if (o!=Rotated) painter->SetTransformer(rel); else { rel = new Transformer(rel); rel->Rotate(90.0); painter->SetTransformer(rel); Unref(rel); } m = new TextManip(v, painter, lineHt, tabWidth, tool); } else if (tool->IsA(RESHAPE_TOOL)) { TextGraphic* textgr = (TextGraphic*) GetGraphic(); Painter* painter = new Painter; int lineHt = textgr->GetLineHeight(); Coord xpos, ypos; rel = new Transformer; const char* text = textgr->GetOriginal(); int size = strlen(text); textgr->TotalTransformation(*rel); rel->Transform(0, 0, xpos, ypos); painter->FillBg(false); painter->SetFont(textgr->GetFont()); painter->SetColors(textgr->GetFgColor(), nil); painter->SetTransformer(rel); Unref(rel); m = new TextManip( v, text, size, xpos, ypos, painter, lineHt, tabWidth, tool ); } else { m = OverlayView::CreateManipulator(v, e, rel, tool); } return m; }
void EllipseView::Interpret (Command* cmd) { if (cmd->IsA(ALIGNTOGRID_CMD)) { float cx, cy; GetGraphic()->GetCenter(cx, cy); ((AlignToGridCmd*) cmd)->Align(this, cx, cy); } else { GraphicView::Interpret(cmd); } }
void TextView::Update () { TextGraphic* gview = (TextGraphic*) GetGraphic(); TextGraphic* gsubj = (TextGraphic*) GetTextComp()->GetGraphic(); IncurDamage(gview); * (Graphic*) gview = * (Graphic*) gsubj; gview->SetLineHeight(gsubj->GetLineHeight()); IncurDamage(gview); EraseHandles(); }
void Picture::Bequeath () { Iterator i; for (First(i); !Done(i); Next(i)) { Graphic* gr = GetGraphic(i); concatGraphic(gr, gr, this, gr); } FullGraphic null; *((Graphic*) this) = null; }
void RectView::GetCorners (Coord* x, Coord* y) { SF_Rect* rect = (SF_Rect*) GetGraphic(); Coord tx[4], ty[4]; Transformer t; rect->GetOriginal(tx[0], ty[0], tx[2], ty[2]); rect->GetOriginal(tx[3], ty[1], tx[1], ty[3]); rect->TotalTransformation(t); t.TransformList((Coord*) tx, (Coord*) ty, 4, x, y); }
Graphic* Picture::LastGraphicContaining (PointObj& pt) { Iterator i; for (Last(i); !Done(i); Prev(i)) { Graphic* subgr = GetGraphic(i); if (subgr->Contains(pt)) { return subgr; } } return nil; }
Graphic* Picture::LastGraphicIntersecting (BoxObj& b) { Iterator i; for (Last(i); !Done(i); Prev(i)) { Graphic* subgr = GetGraphic(i); if (subgr->Intersects(b)) { return subgr; } } return nil; }
ViewerView::~ViewerView () { Graphic* g = GetGraphic(); Iterator i; g->First(i); while (!g->Done(i)) { g->Remove(i); } _vg->First(i); _vg->Remove(i); delete _vg; }