home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************/
- /* */
- /* TurboCAD for Windows */
- /* Copyright (c) 1993 - 2001 */
- /* International Microcomputer Software, Inc. */
- /* (IMSI) */
- /* All rights reserved. */
- /* */
- /******************************************************************/
-
- // AutoRect.cpp : Implementation of CAutoRect
- #include "stdafx.h"
- #include "RRectA.h"
- #include "AutoRect.h"
- #include "RectPage.h" // Property page class
- #include "Imsigx.h" // TurboCAD interfaces
- #include <math.h>
-
-
- /////////////////////////////////////////////////////////////////////////////
- // Standard variants
- COleVariant t(-1L, VT_BOOL);
- COleVariant f(0L, VT_BOOL);
- COleVariant z(0.0);
- COleVariant missing((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
- const double PI = 3.14159265;
-
- /////////////////////////////////////////////////////////////////////////////
- // CAutoRect
-
- const IID IID_IGraphic =
- {0x6A481109,0xE531,0x11CF,{0xA1,0x15,0x00,0xA0,0x24,0x15,0x8D,0xAF}};
- static const IID IID_ISmartObjectServer =
- {0x6A481303,0xE531,0x11CF,{0xA1,0x15,0x00,0xA0,0x24,0x15,0x8D,0xAF}};
-
-
- STDMETHODIMP CAutoRect::get_ClassID(BSTR *pVal)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
-
- HRESULT hRes = E_FAIL;
- LPOLESTR olestr = NULL;
- try
- {
- if(SUCCEEDED( ::StringFromCLSID(CLSID_AutoRect, &olestr)))
- {
-
- *pVal = ::SysAllocString(olestr);
- hRes = S_OK;
- }
- }
- catch (...)
- {
-
- }
-
- if (olestr != NULL)
- CoTaskMemFree(olestr);
-
- return hRes;
- }
-
-
- STDMETHODIMP CAutoRect::get_Description(BSTR *pVal)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
-
- HRESULT hRes = E_FAIL;
- // Get the description from the resource
- CString strResult;
- if (strResult.LoadString(IDS_AUTORECT_DESCRIPTION))
- {
- hRes = S_OK;
- *pVal = strResult.AllocSysString();
- }
- return hRes;
-
-
- }
-
- const long VT_INTEGER_ENUM = VT_I2 + 100;
- const long VT_LONG_ENUM = VT_I4 + 100;
- const long VT_STRING_ENUM = VT_BSTR + 100;
-
- const long GF_COSMETIC = 128;
-
- enum StockPages {
- PP_STOCK_PEN = 1,
- PP_STOCK_BRUSH = 2,
- PP_STOCK_TEXT = 4,
- PP_STOCK_INSERT = 8,
- PP_STOCK_VIEWPORT = 16,
- PP_STOCK_AUTO = 32
- };
-
- // our Rounded rectangle object has only one property called Roundess
- const long nProperties = 1;
- // define one property
- enum PropertyIDs
- {
- idRoundness = 1,
- };
-
-
-
- STDMETHODIMP CAutoRect::GetPropertyInfo(VARIANT *Names, VARIANT *Types, VARIANT *IDs, VARIANT *Defaults, long* ret)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- HRESULT hRes = E_FAIL;
-
- ASSERT(Names->vt == (VT_ARRAY|VT_BSTR));
- ASSERT(Types->vt == (VT_ARRAY|VT_I4));
- ASSERT(IDs->vt == (VT_ARRAY|VT_I4));
- ASSERT(Defaults->vt == (VT_ARRAY|VT_VARIANT));
-
- SAFEARRAYBOUND bound = { nProperties, 0 };
- try
- {
- if (FAILED(::SafeArrayRedim(Names->parray, &bound)))
- {
- *ret = 0;
- return hRes;
- }
- if (FAILED(::SafeArrayRedim(Types->parray, &bound)))
- {
- *ret = 0;
- return hRes;
- }
- if (FAILED(::SafeArrayRedim(IDs->parray, &bound)))
- {
- *ret = 0;
- return hRes;
- }
- if (FAILED(::SafeArrayRedim(Defaults->parray, &bound)))
- {
- *ret = 0;
- return hRes;
- }
-
- BSTR* rgNames;
- long* rgTypes;
- long* rgIDs;
- VARIANT* rgDefaults;
- *ret = 0;
- if (SUCCEEDED(::SafeArrayAccessData(Names->parray, (void**)&rgNames)))
- {
- if (SUCCEEDED(::SafeArrayAccessData(Types->parray, (void**)&rgTypes)))
- {
- if (SUCCEEDED(::SafeArrayAccessData(IDs->parray, (void**)&rgIDs)))
- {
- if (SUCCEEDED(::SafeArrayAccessData(Defaults->parray, (void**)&rgDefaults)))
- {
- // rgNames[0] = ::SysAllocString(OLESTR("Roundness"));
- CString strStr;
- strStr.LoadString(IDS_PROPERTYROUNDESS);
- rgNames[0] = ::SysAllocString(strStr.AllocSysString());
-
- rgTypes[0] = VT_R8;
- rgIDs[0] = idRoundness;
- rgDefaults[0].vt = VT_R8;
- rgDefaults[0].dblVal = 50.0;
-
- hRes = ::SafeArrayUnaccessData(Defaults->parray);
- CHECK_HRESULT(hRes)
-
- *ret = nProperties;
- }
- hRes = ::SafeArrayUnaccessData(IDs->parray);
- CHECK_HRESULT(hRes)
- }
- hRes = ::SafeArrayUnaccessData(Types->parray);
- CHECK_HRESULT(hRes)
- }
- hRes = ::SafeArrayUnaccessData(Names->parray);
- CHECK_HRESULT(hRes)
- }
- }
- catch (...)
- {
- TRACE_EXCEPTION("CAutoRect::GetPropertyInfo")
- }
-
- return hRes;
-
- }
-
- STDMETHODIMP CAutoRect::GetPageInfo(IDispatch *AGraphic, long *StockPages, VARIANT *Names,long* ret)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- HRESULT hRes = E_FAIL;
-
- ASSERT(StockPages != NULL);
- ASSERT(Names->vt == (VT_ARRAY|VT_BSTR));
-
- // Request pen page and auto page
- *StockPages = PP_STOCK_PEN | PP_STOCK_AUTO;
-
- SAFEARRAYBOUND bound = { 1, 0 };
- if (FAILED(::SafeArrayRedim(Names->parray, &bound)))
- {
- *ret = 0;
- return hRes;
- }
-
- CString strCaption;
- strCaption.LoadString(IDS_AUTORECT_CAPTION);
- BSTR bstrCaption = strCaption.AllocSysString();
-
- long lIndex = 0;
- if (FAILED(SafeArrayPutElement(Names->parray, &lIndex, (void*)bstrCaption)))
- {
- ::SysFreeString(bstrCaption);
- *ret = 0;
- return hRes;
- }
- *ret = 1;
- hRes = S_OK;
- return hRes;
-
- }
-
- STDMETHODIMP CAutoRect::GetWizardInfo(VARIANT *Names,long* ret)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- HRESULT hRes = S_OK;
- // No wizards, nothing to do
-
- *ret = 0;
- return hRes;
-
- }
-
- STDMETHODIMP CAutoRect::GetEnumNames(long PropID, VARIANT *Names, VARIANT *Values,long* ret)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- HRESULT hRes = S_OK;
-
- // TODO: Add your implementation code here
- // Should never be called!
- *ret = 0;
- return hRes;
- }
-
- STDMETHODIMP CAutoRect::PageControls(IDispatch *ThisRegenMethod, IDispatch *AGraphic, long PageNumber, boolean SaveProperties, VARIANT_BOOL* ret)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- HRESULT hRes = E_FAIL;
-
- IGraphic* pIGraphic = NULL;
- if (FAILED(AGraphic->QueryInterface(IID_IGraphic, (void**)&pIGraphic)))
- {
- *ret = FALSE;
- return hRes;
- }
-
- *ret = FALSE;
- Properties* pProps = NULL;
- Property* pProp = NULL;
- COleVariant varIndex, varValue;
- try
- {
- if (SUCCEEDED(pIGraphic->get_Properties(&pProps)))
- {
- if (SaveProperties)
- {
- if (m_pRectPage != NULL)
- {
- // Note: the following can fail (for non-rounded rect graphics)
- CString strStr;
- strStr.LoadString(IDS_PROPERTYROUNDESS);
- varIndex = LPCTSTR(strStr);
- if (SUCCEEDED(pProps->get_Item(&varIndex, &pProp)))
- {
- varValue = (const long)m_pRectPage->m_roundness;
- hRes = pProp->put_Value(0, &varValue);
- CHECK_HRESULT(hRes)
-
- pProp->Release();
- varValue.Clear();
- }
- *ret = TRUE;
- }
- }
- else
- {
- ASSERT(m_pRectPage == NULL);
- m_pRectPage = new CRectPage();
-
- // Note: the following can fail (for indeterminate values)
- CString strStr;
- strStr.LoadString(IDS_PROPERTYROUNDESS);
- varIndex = LPCTSTR(strStr);
- if (SUCCEEDED(pProps->get_Item(&varIndex, &pProp)))
- {
- if (SUCCEEDED(pProp->get_Value(0, &varValue)) &&
- varValue.vt == VT_R8)
- m_pRectPage->m_roundness = varValue.dblVal;
- pProp->Release();
- varValue.Clear();
- }
- hRes = S_OK;
- *ret = TRUE;
- }
- pProps->Release();
- }
-
- pIGraphic->Release();
- }
- catch (...)
- {
- TRACE_EXCEPTION("CAutoRect::PageControls")
- }
-
- return hRes;
-
-
-
- }
-
- STDMETHODIMP CAutoRect::PageDone(IDispatch *ThisRegenMethod, VARIANT *PageNumber)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
-
- delete m_pRectPage;
- m_pRectPage = NULL;
- HRESULT hRes = S_OK;
- return hRes;
-
- }
-
- STDMETHODIMP CAutoRect::PropertyPages(IDispatch *ThisRegenMethod, VARIANT *PageNumber, VARIANT_BOOL* ret)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- HRESULT hRes = E_FAIL;
-
- if (m_pRectPage == NULL)
- {
- *ret = FALSE;
- return hRes;
- }
- // Run the dialog and get the results
- int nResult = m_pRectPage->DoModal();
- *ret = TRUE;
- hRes = S_OK;
-
- return hRes;
- }
-
- STDMETHODIMP CAutoRect::Wizard(IDispatch *ThisRegenMethod, VARIANT *WizardNumber, VARIANT_BOOL* ret)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- HRESULT hRes = E_FAIL;
-
- // No wizards, so just return FALSE.
- *ret = FALSE;
- return hRes;
- }
-
- STDMETHODIMP CAutoRect::OnGeometryChanged(IDispatch *AGraphic, long GeomID, VARIANT *ParamOld, VARIANT *ParamNew)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- HRESULT hRes = S_OK;
- // OK to change our geometry, so just return TRUE.
- return hRes;
- }
-
- STDMETHODIMP CAutoRect::OnGeometryChanging(IDispatch *AGraphic, long GeomID, VARIANT *ParamOld, VARIANT *ParamNew, VARIANT_BOOL* ret)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
-
- // TODO: Add your implementation code here
- HRESULT hRes = S_OK;
- *ret = TRUE;
- return hRes;
- }
-
-
- double GetRoundness(IGraphic* pIGraphic)
- {
- double roundness = 50.0;
- Properties* pProps = NULL;
- Property* pProp = NULL;
- COleVariant varIndex, varValue;
- if (SUCCEEDED(pIGraphic->get_Properties(&pProps)))
- {
- CString strStr;
- strStr.LoadString(IDS_PROPERTYROUNDESS);
- varIndex = LPCTSTR(strStr);
- if (SUCCEEDED(pProps->get_Item(&varIndex, &pProp)))
- {
- if (SUCCEEDED(pProp->get_Value(0, &varValue)) &&
- varValue.vt == VT_R8)
- {
- roundness = varValue.dblVal;
- }
- pProp->Release();
- }
- pProps->Release();
- }
- return roundness;
- }
-
- void SetRoundness(IGraphic* pIGraphic, double roundness)
- {
- Properties* pProps = NULL;
- Property* pProp = NULL;
- COleVariant varIndex;
- if (SUCCEEDED(pIGraphic->get_Properties(&pProps)))
- {
- CString strStr;
- strStr.LoadString(IDS_PROPERTYROUNDESS);
- varIndex = LPCTSTR(strStr);
- if (SUCCEEDED(pProps->get_Item(&varIndex, &pProp)))
- {
- COleVariant varValue;
- varValue.vt = VT_R8;
- varValue.dblVal = roundness;
- pProp->put_Value(0, &varValue);
- pProp->Release();
- }
- pProps->Release();
- }
- }
-
-
-
- BOOL GetVertexXYZ(IGraphic* pIGraphic, const long lVertex, double& x, double& y, double& z)
- {
- IVertex* pIVertex = NULL;
- Vertices* pVerts = NULL;
- BOOL bSuccess = FALSE;
- if (SUCCEEDED(pIGraphic->get_Vertices(&pVerts)))
- {
- COleVariant varIndex = lVertex;
- if (SUCCEEDED(pVerts->get_Item(&varIndex, &pIVertex)))
- {
- if (SUCCEEDED(pIVertex->get_X(&x)) &&
- SUCCEEDED(pIVertex->get_Y(&y)) &&
- SUCCEEDED(pIVertex->get_Z(&z)))
- bSuccess = TRUE;
- pIVertex->Release();
- }
- pVerts->Release();
- }
- return bSuccess;
- }
-
- void AddLineChild(Graphics* pGraphics, double x0, double y0, double x1, double y1)
- {
- HRESULT hRes = E_FAIL;
- IGraphic* pChild = NULL;
- COleVariant x, y;
- Vertices* pVerts = NULL;
- IVertex* pIVertex = NULL;
-
- try
- {
- hRes = pGraphics->Add(&missing /*GraphicType*/,
- &missing /*RegenMethod*/,
- &t /*Inherit*/,
- &missing /*Style*/,
- &missing /*Before*/,
- &missing /*After*/,
- &pChild);
- CHECK_HRESULT(hRes)
-
- hRes = pChild->put_Cosmetic(TRUE);
- CHECK_HRESULT(hRes)
-
-
- hRes = pChild->get_Vertices(&pVerts);
- CHECK_HRESULT(hRes)
-
- x = x0;
- y = y0;
- hRes = pVerts->Add(&x, &y, &z,
- &f /*penDown*/,
- &t /*selectable*/,
- &t /*snappable*/,
- &t /*editable*/,
- &t /*linkable*/,
- &f /*calculated*/,
- &missing /*before*/,
- &missing /*after*/,
- &pIVertex);
- CHECK_HRESULT(hRes)
-
- pIVertex->Release();
- x = x1;
- y = y1;
- hRes = pVerts->Add(&x, &y, &z,
- &t /*penDown*/,
- &t /*selectable*/,
- &t /*snappable*/,
- &t /*editable*/,
- &t /*linkable*/,
- &f /*calculated*/,
- &missing /*before*/,
- &missing /*after*/,
- &pIVertex);
- CHECK_HRESULT(hRes)
-
-
-
- }
-
- catch (...)
- {
- TRACE_EXCEPTION("AddLineChild")
- }
-
- if (pIVertex != NULL)
- pIVertex->Release();
-
- if(pVerts != NULL)
- pVerts->Release();
-
- if (pChild != NULL)
- pChild->Release();
- }
-
- void AddArcChild(Graphics* pGraphics, double xc, double yc, double r, double start, double end)
- {
- HRESULT hRes = E_FAIL;
- IGraphic* pChild = NULL;
- COleVariant type((long)imsiArc);
- try
- {
-
- hRes = pGraphics->Add(&type /*GraphicType*/,
- &missing /*RegenMethod*/,
- &t /*Inherit*/,
- &missing /*Style*/,
- &missing /*Before*/,
- &missing /*After*/,
- &pChild);
- CHECK_HRESULT(hRes)
-
-
- hRes = pChild->put_Cosmetic(TRUE);
- CHECK_HRESULT(hRes)
-
-
- COleVariant x(xc);
- COleVariant y(yc);
- COleVariant rad(r);
- COleVariant sa(start);
- COleVariant ea(end);
-
- hRes = pChild->ArcSet(&x, &y, &z, &rad, &missing, &sa, &ea, &missing);
- CHECK_HRESULT(hRes)
-
- }
-
- catch (...)
- {
- TRACE_EXCEPTION("AddArcChild")
- }
-
- if(pChild != NULL)
- pChild->Release();
- }
-
-
-
-
- STDMETHODIMP CAutoRect::OnNewGraphic(IDispatch *CopyGraphic, boolean Copy, VARIANT_BOOL* ret)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- HRESULT hRes = E_FAIL;
-
- // TODO: Add your implementation code here
-
- // Return FALSE on failure.
- // For copies, usually do nothing.
- if (Copy)
- {
- *ret = TRUE;
- hRes = S_OK;
- return hRes;
-
- }
- // Add vertices, etc. for new graphic here.
-
- // TODO: Do nothing here.
- *ret = TRUE;
- try
- {
- IGraphic* pIGraphic = NULL;
- hRes = CopyGraphic->QueryInterface(IID_IGraphic, (void**)&pIGraphic);
- CHECK_HRESULT(hRes)
-
-
- Vertices* pVerts = NULL;
- IVertex* pIVertex = NULL;
- if (SUCCEEDED(pIGraphic->get_Vertices(&pVerts)))
- {
- COleVariant x;
- COleVariant y;
-
- // First 2 vertices are lower left and upper right corners.
- const double corners[2*2] = { -1.0, -0.5, 1.0, 0.5 };
- for (int i = 0; i < 2*2; )
- {
- x = corners[i++];
- y = corners[i++];
-
- if (SUCCEEDED(pVerts->Add(&x, &y, &z,
- &f /*penDown*/,
- &t /*selectable*/,
- &f /*snappable*/,
- &f /*editable*/,
- &f /*linkable*/,
- &f /*calculated*/,
- &missing /*before*/,
- &missing /*after*/,
- &pIVertex)))
- pIVertex->Release();
- }
-
- // Third vertex is rounding handle (calculated)
- double r = 0.5 * GetRoundness(pIGraphic) / 100.0;
- double offset = 0.1 * r;
- x = 1.0 - r;
- y = 0.5 + offset;
- if (SUCCEEDED(pVerts->Add(&x, &y, &z,
- &f /*penDown*/,
- &f /*selectable*/,
- &f /*snappable*/,
- &f /*editable*/,
- &f /*linkable*/,
- &f /*calculated*/,
- &missing /*before*/,
- &missing /*after*/,
- &pIVertex)))
- pIVertex->Release();
-
- // Fourth vertex is rounding handle (editable)
- if (SUCCEEDED(pVerts->Add(&x, &y, &z,
- &f /*penDown*/,
- &t /*selectable*/,
- &f /*snappable*/,
- &t /*editable*/,
- &f /*linkable*/,
- &f /*calculated*/,
- &missing /*before*/,
- &missing /*after*/,
- &pIVertex)))
- pIVertex->Release();
-
- pIGraphic->Release();
- }
- }
- catch (...)
- {
- TRACE_EXCEPTION("CAutoRect::OnNewGraphic")
- *ret = FALSE;
- }
-
- return hRes;
- }
-
- STDMETHODIMP CAutoRect::OnCopyGraphic(IDispatch *CopyGraphic, IDispatch *SourceGraphic, VARIANT_BOOL* ret)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- HRESULT hRes = S_OK;
- // TODO: Add your implementation code here
- *ret = TRUE;
- return hRes;
- }
-
- STDMETHODIMP CAutoRect::OnPropertyChanged(IDispatch *AGraphic, long PropID, VARIANT *ValueOld, VARIANT *ValueNew)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
-
- // TODO: Add your implementation code here
- HRESULT hRes = S_OK;
-
- return hRes;
- }
-
- STDMETHODIMP CAutoRect::OnPropertyChanging(IDispatch *AGraphic, long PropID, VARIANT *ValueOld, VARIANT *ValueNew, VARIANT_BOOL* ret)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- HRESULT hRes = S_OK;
-
- // OK to change all of our properties, so just return TRUE.
- *ret = TRUE;
- return hRes;
- }
-
- STDMETHODIMP CAutoRect::OnPropertyGet(IDispatch *AGraphic, long PropID)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- HRESULT hRes = S_OK;
-
- // No special recalculating of properties needed.
- return hRes;
- }
-
- STDMETHODIMP CAutoRect::Draw(IDispatch *AGraphic, IDispatch *AView, VARIANT *AMatrix, VARIANT_BOOL* ret)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- HRESULT hRes = E_FAIL;
-
- // We don't handle special drawing, so just return FALSE.
- ret = FALSE;
- return hRes;
- }
-
- STDMETHODIMP CAutoRect::Regen(IDispatch *AGraphic)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- HRESULT hRes = E_FAIL;
-
- try
- {
- IGraphic* pIGraphic = NULL;
- hRes = AGraphic->QueryInterface(IID_IGraphic, (void**)&pIGraphic);
- CHECK_HRESULT(hRes)
-
- long lockCount = 0;
- if (SUCCEEDED(pIGraphic->RegenLock(&lockCount)))
- {
- if (lockCount == 0)
- {
- Graphics* pGraphics = NULL;
- IGraphic* pChild = NULL;
- IVertex* pIVertex = NULL;
- if (SUCCEEDED(pIGraphic->get_Graphics(&pGraphics)))
- {
- COleVariant flags = (const long)GF_COSMETIC;
- pGraphics->Clear(&flags);
-
- // Calculate height, width and radius of corners
-
- double px[4] = { 0.0 };
- double py[4] = { 0.0 };
- double pz[4] = { 0.0 };
- for (int i = 0; i < 4; ++i)
- GetVertexXYZ(pIGraphic, i, px[i], py[i], pz[i]);
-
- BOOL bHandleMoved = !(fabs(px[2] - px[3]) < 0.000001 &&
- fabs(py[2] - py[3]) < 0.000001);
-
- double w = fabs(px[1] - px[0]);
- double h = fabs(py[1] - py[0]);
- double r = (w < h) ? (w/2.0) : (h/2.0);
-
- double roundness;
- if (bHandleMoved)
- {
- if (r == 0.0)
- roundness = 0.0;
- else
- {
- roundness = fabs(px[2] - px[3]) * 100.0 / r;
- if (roundness > 100.0)
- roundness = 100.0;
- }
- SetRoundness(pIGraphic, roundness);
- }
- else
- {
- roundness = GetRoundness(pIGraphic);
- }
- r = r * roundness / 100.0;
-
- // Add child graphics
- // Make sure p[0] < p[1]
- double swap;
- if (px[0] > px[1])
- {
- swap = px[0];
- px[0] = px[1];
- px[1] = swap;
- }
- if (py[0] > py[1])
- {
- swap = py[0];
- py[0] = py[1];
- py[1] = swap;
- }
-
- if (r == 0.0)
- {
- // No rounded corners
- // All children are cosmetic
- if (SUCCEEDED(pGraphics->Add(
- &missing /*GraphicType*/,
- &missing /*RegenMethod*/,
- &t /*Inherit*/,
- &missing /*Style*/,
- &missing /*Before*/,
- &missing /*After*/,
- &pChild)))
- {
- pChild->put_Cosmetic(TRUE);
-
- COleVariant x, y;
- Vertices* pVerts = NULL;
- IVertex* pIVertex = NULL;
- if (SUCCEEDED(pChild->get_Vertices(&pVerts)))
- {
- for (int i = 0; i < 4; ++i)
- {
- x = px[(i == 0 || i == 1) ? 0 : 1];
- y = py[(i == 0 || i == 3) ? 0 : 1];
- if (SUCCEEDED(pVerts->Add(&x, &y, &z,
- (i == 0) ? &f : &t /*penDown*/,
- &t /*selectable*/,
- &t /*snappable*/,
- &t /*editable*/,
- &t /*linkable*/,
- &f /*calculated*/,
- &missing /*before*/,
- &missing /*after*/,
- &pIVertex)))
- pIVertex->Release();
- }
- if (SUCCEEDED(pVerts->AddClose(
- &t /*penDown*/,
- &t /*selectable*/,
- &t /*snappable*/,
- &t /*editable*/,
- &t /*linkable*/,
- &f /*calculated*/,
- &pIVertex)))
- pIVertex->Release();
-
- pVerts->Release();
- }
- pChild->Release();
- }
- }
- else
- {
- // Rounded corners
- // We'll make 4 line children and 4 arc children
- AddLineChild(pGraphics, px[0] + r, py[0], px[1] - r, py[0]);
- AddArcChild (pGraphics, px[1] - r, py[0] + r, r, 1.5 * PI, 0.0);
- AddLineChild(pGraphics, px[1], py[0] + r, px[1], py[1] - r);
- AddArcChild (pGraphics, px[1] - r, py[1] - r, r, 0.0, 0.5 * PI);
- AddLineChild(pGraphics, px[1] - r, py[1], px[0] + r, py[1]);
- AddArcChild (pGraphics, px[0] + r, py[1] - r, r, 0.5 * PI, PI);
- AddLineChild(pGraphics, px[0], py[1] - r, px[0], py[0] + r);
- AddArcChild (pGraphics, px[0] + r, py[0] + r, r, PI, 1.5 * PI);
- }
- pGraphics->Release();
- }
- }
- pIGraphic->RegenUnlock(&missing);
- }
- pIGraphic->Release();
- }
- catch (...)
- {
- TRACE_EXCEPTION("CAutoRect::Regen")
-
- }
- return hRes;
- }
-
- STDMETHODIMP CAutoRect::Initialize(IDispatch *ThisRegenMethod, VARIANT_BOOL* ret)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- HRESULT hRes = S_OK;
- // TODO: Add your implementation code here
- m_pRectPage = NULL;
- *ret = TRUE;
- return hRes;
- }
-
-
-
-