home *** CD-ROM | disk | FTP | other *** search
/ Delphi Anthology / aDELPHI.iso / ActiveX / 3DText_ActiveX_v3.1-FCN / data1.cab / Example_Files / 3DText / Vc / VC3DTextDemoDlg.cpp < prev    next >
C/C++ Source or Header  |  1999-10-27  |  19KB  |  645 lines

  1. // VCGLTextDemoDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <atlconv.h>
  6. #include <Afxctl.h>
  7.  
  8. #include "NFont.h"
  9. #include "VC3DTextDemo.h"
  10. #include "VC3DTextDemoDlg.h"
  11.  
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CAboutDlg dialog used for App About
  20. using namespace N3DTEXTLib;
  21.  
  22. /////////////////////////////////////////////////////////////////////////////
  23. // some useful macro definitions
  24. #define BOOL_TO_VAR(x) ( (x) ? VARIANT_TRUE : VARIANT_FALSE)
  25. #define VAR_TO_BOOL(x) (x == VARIANT_TRUE)
  26.  
  27. class CAboutDlg : public CDialog
  28. {
  29. public:
  30.     CAboutDlg();
  31.  
  32. // Dialog Data
  33.     //{{AFX_DATA(CAboutDlg)
  34.     enum { IDD = IDD_ABOUTBOX };
  35.     //}}AFX_DATA
  36.  
  37.     // ClassWizard generated virtual function overrides
  38.     //{{AFX_VIRTUAL(CAboutDlg)
  39.     protected:
  40.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  41.     //}}AFX_VIRTUAL
  42.  
  43. // Implementation
  44. protected:
  45.     //{{AFX_MSG(CAboutDlg)
  46.     //}}AFX_MSG
  47.     DECLARE_MESSAGE_MAP()
  48. };
  49.  
  50. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  51. {
  52.     //{{AFX_DATA_INIT(CAboutDlg)
  53.     //}}AFX_DATA_INIT
  54. }
  55.  
  56. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  57. {
  58.     CDialog::DoDataExchange(pDX);
  59.     //{{AFX_DATA_MAP(CAboutDlg)
  60.     //}}AFX_DATA_MAP
  61. }
  62.  
  63. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  64.     //{{AFX_MSG_MAP(CAboutDlg)
  65.         // No message handlers
  66.     //}}AFX_MSG_MAP
  67. END_MESSAGE_MAP()
  68.  
  69. /////////////////////////////////////////////////////////////////////////////
  70. // CVCGLTextDemoDlg dialog
  71. CVCGLTextDemoDlg::CVCGLTextDemoDlg(CWnd* pParent /*=NULL*/)
  72.     : CDialog(CVCGLTextDemoDlg::IDD, pParent)
  73. {
  74.     //{{AFX_DATA_INIT(CVCGLTextDemoDlg)
  75.     m_sElevation = _T("");
  76.     m_sExtrusion = _T("");
  77.     m_sLineSpacing = _T("");
  78.     m_sRotation = _T("");
  79.     m_sText = _T("");
  80.     m_sZoom = _T("");
  81.     m_bEnableLightning = FALSE;
  82.     m_bEnableMouse = FALSE;
  83.     m_bOrtographicProjection = FALSE;
  84.     //}}AFX_DATA_INIT
  85.     // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  86.     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  87. }
  88.  
  89. //////////////////////////////////////////////////////////////////////
  90. void CVCGLTextDemoDlg::DoDataExchange(CDataExchange* pDX)
  91. {
  92.     CDialog::DoDataExchange(pDX);
  93.     //{{AFX_DATA_MAP(CVCGLTextDemoDlg)
  94.     DDX_Text(pDX, IDC_ELEVATION_EDIT, m_sElevation);
  95.     DDX_Text(pDX, IDC_EXTRUSION_EDIT, m_sExtrusion);
  96.     DDX_Text(pDX, IDC_LINE_SPACING_EDIT, m_sLineSpacing);
  97.     DDX_Text(pDX, IDC_ROTATION_EDIT, m_sRotation);
  98.     DDX_Text(pDX, IDC_TEXT_EDIT, m_sText);
  99.     DDX_Text(pDX, IDC_ZOOM_EDIT, m_sZoom);
  100.     DDX_Check(pDX, IDC_ENABLE_LIGHTNING_CHECK, m_bEnableLightning);
  101.     DDX_Check(pDX, IDC_ENABLE_MOUSE_CHECK, m_bEnableMouse);
  102.     DDX_Check(pDX, IDC_ORTOGRAPHIC_PROJECTION_CHECK, m_bOrtographicProjection);
  103.     //}}AFX_DATA_MAP
  104. }
  105.  
  106. //////////////////////////////////////////////////////////////////////
  107. BEGIN_MESSAGE_MAP(CVCGLTextDemoDlg, CDialog)
  108.     //{{AFX_MSG_MAP(CVCGLTextDemoDlg)
  109.     ON_WM_SYSCOMMAND()
  110.     ON_WM_PAINT()
  111.     ON_WM_QUERYDRAGICON()
  112.     ON_BN_CLICKED(IDC_ABOUT_BUTTON, OnAboutButton)
  113.     ON_BN_CLICKED(ID_ARIAL_FONT_BUTTON, OnArialFontButton)
  114.     ON_BN_CLICKED(ID_CURRIER_NEW_FONT_BUTTON, OnCurrierNewFontButton)
  115.     ON_BN_CLICKED(IDC_ANIMATE_ROTATEXY_BUTTON, OnAnimateRotatexyButton)
  116.     ON_BN_CLICKED(IDC_ANIMATE_ROTATEZ_BUTTON, OnAnimateRotatezButton)
  117.     ON_BN_CLICKED(IDC_ENABLE_MOUSE_CHECK, OnEnableMouseCheck)
  118.     ON_BN_CLICKED(IDC_GRADIENT_BUTTON, OnGradientButton)
  119.     ON_BN_CLICKED(ID_TEXTURE_BUTTON, OnTextureButton)
  120.     ON_BN_CLICKED(IDC_BK_FILL_EFFECT_BUTTON, OnBkFillEffectButton)
  121.     ON_BN_CLICKED(IDC_ENABLE_LIGHTNING_CHECK, OnEnableLightningCheck)
  122.     ON_BN_CLICKED(IDC_FILL_EFFECT_BUTTON, OnFillEffectButton)
  123.     ON_BN_CLICKED(IDC_MATERIAL_BUTTON, OnMaterialButton)
  124.     ON_BN_CLICKED(ID_SOLID_COLOR_BUTTON, OnSolidColorButton)
  125.     ON_BN_CLICKED(IDC_ANIMATED_TEXTURE_BUTTON, OnAnimatedTextureButton)
  126.     ON_BN_CLICKED(IDC_PATTERN_BUTTON, OnPatternButton)
  127.     ON_EN_CHANGE(IDC_ZOOM_EDIT, OnChangeZoomEdit)
  128.     ON_EN_CHANGE(IDC_TEXT_EDIT, OnChangeTextEdit)
  129.     ON_EN_CHANGE(IDC_ROTATION_EDIT, OnChangeRotationEdit)
  130.     ON_EN_CHANGE(IDC_LINE_SPACING_EDIT, OnChangeLineSpacingEdit)
  131.     ON_EN_CHANGE(IDC_ELEVATION_EDIT, OnChangeElevationEdit)
  132.     ON_EN_CHANGE(IDC_EXTRUSION_EDIT, OnChangeExtrusionEdit)
  133.     ON_BN_CLICKED(IDC_ORTOGRAPHIC_PROJECTION_CHECK, OnOrtographicProjectionCheck)
  134.     //}}AFX_MSG_MAP
  135. END_MESSAGE_MAP()
  136.  
  137. /////////////////////////////////////////////////////////////////////////////
  138. // CVCGLTextDemoDlg message handlers
  139.  
  140. BOOL CVCGLTextDemoDlg::OnInitDialog()
  141. {
  142.     USES_CONVERSION;
  143.     CDialog::OnInitDialog();
  144.  
  145.     // IDM_ABOUTBOX must be in the system command range.
  146.     ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  147.     ASSERT(IDM_ABOUTBOX < 0xF000);
  148.  
  149.     CMenu* pSysMenu = GetSystemMenu(FALSE);
  150.     if (pSysMenu != NULL)
  151.     {
  152.         CString strAboutMenu;
  153.         strAboutMenu.LoadString(IDS_ABOUTBOX);
  154.         if (!strAboutMenu.IsEmpty())
  155.         {
  156.             pSysMenu->AppendMenu(MF_SEPARATOR);
  157.             pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  158.         }
  159.     }
  160.  
  161.     // Set the icon for this dialog.  The framework does this automatically
  162.     //  when the application's main window is not a dialog
  163.     SetIcon(m_hIcon, TRUE);            // Set big icon
  164.     SetIcon(m_hIcon, FALSE);        // Set small icon
  165.     
  166.     SetButtonFonts();
  167.  
  168.     // Get the window of the text
  169.     CWnd* pTextChartWnd = GetDlgItem(IDC_NGLTEXTCTRL1);
  170.     ASSERT(pTextChartWnd);
  171.  
  172.     // Query for the IDualPieChart - it is faster than the disp interface
  173.     IDual3dText *pTextControl;
  174.     if (FAILED(pTextChartWnd->GetControlUnknown()->QueryInterface(__uuidof(pTextControl), (void**)&pTextControl)))
  175.     {
  176.         AfxMessageBox("Query interace failed");
  177.         return TRUE;
  178.     }
  179.  
  180.     // the pointer is addrefed (QueryInterface was called) - we attach it to a smart pointer and
  181.     // thus does not forget to call Release when the object is destroyed
  182.     m_pTextControl.Attach(pTextControl);
  183.  
  184.     // update interface controls
  185.     m_sRotation.Format("%.2f", m_pTextControl->Get3DView()->Rotation);
  186.     m_sElevation.Format("%.2f", m_pTextControl->Get3DView()->Elevation);
  187.     m_sZoom.Format("%.2f", m_pTextControl->Get3DView()->Zoom);
  188.     m_sText = OLE2A(m_pTextControl->Text);
  189.  
  190.     m_sExtrusion.Format("%.2f", m_pTextControl->TextExtrusion);
  191.     m_sLineSpacing.Format("%.2f", m_pTextControl->LineSpacing); 
  192.  
  193.     m_bEnableMouse = VAR_TO_BOOL(m_pTextControl->Get3DView()->EnableMouse);
  194.     m_bEnableLightning = VAR_TO_BOOL(m_pTextControl->LightModel()->EnableLightning);
  195.  
  196.     UpdateData(FALSE);
  197.     
  198.     return TRUE;  // return TRUE  unless you set the focus to a control
  199. }
  200.  
  201. //////////////////////////////////////////////////////////////////////
  202. CString CVCGLTextDemoDlg::GetImageDir()
  203. {
  204.     char path[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR];
  205.  
  206.     ::GetModuleFileName(AfxGetInstanceHandle(), path, _MAX_PATH);
  207.  
  208.     CString sPath;
  209.     _splitpath(path, drive, dir, NULL, NULL);
  210.     sPath.Format("%s%s", drive, dir);
  211.  
  212.     // move several directories up - test images are located in the Images
  213.     sPath += "..\\..\\..\\Images";
  214.  
  215.     return sPath;
  216. }
  217.  
  218. //////////////////////////////////////////////////////////////////////
  219. CString CVCGLTextDemoDlg::GetControlText(int nControlId)
  220. {
  221.     CString sText;
  222.     CWnd *pWnd;
  223.  
  224.     pWnd = GetDlgItem(nControlId);
  225.     ASSERT(pWnd);
  226.     pWnd->GetWindowText(sText);
  227.  
  228.     return sText;
  229. }
  230.  
  231. //////////////////////////////////////////////////////////////////////
  232. void CVCGLTextDemoDlg::SetControlText(int nControlId, const CString& sText)
  233. {
  234.     CWnd *pWnd;
  235.  
  236.     pWnd = GetDlgItem(nControlId);
  237.     ASSERT(pWnd);
  238.     pWnd->SetWindowText(sText);
  239. }
  240.  
  241. //////////////////////////////////////////////////////////////////////
  242. BOOL CVCGLTextDemoDlg::GetChecked(int nControlId)
  243. {
  244.     CButton *pButton;
  245.  
  246.     pButton = (CButton*)GetDlgItem(nControlId);
  247.     ASSERT(pButton);
  248.  
  249.     return pButton->GetCheck();
  250. }
  251.  
  252. //////////////////////////////////////////////////////////////////////
  253. void CVCGLTextDemoDlg::SetChecked(int nControlId, BOOL bCheck)
  254. {
  255.     CButton *pButton;
  256.  
  257.     pButton = (CButton*)GetDlgItem(nControlId);
  258.     ASSERT(pButton);
  259.  
  260.     pButton->SetCheck(bCheck);
  261. }
  262.  
  263. //////////////////////////////////////////////////////////////////////
  264. void CVCGLTextDemoDlg::InitLogFont(const CString& sFontName, BOOL bBold, BOOL bItalic, LOGFONT *pLogFont)
  265. {
  266.     ASSERT(pLogFont);
  267.  
  268.     memset(pLogFont, 0, sizeof(LOGFONT));
  269.  
  270.     // set the paramaters of the logfont structure
  271.     pLogFont->lfHeight = -12;
  272.     pLogFont->lfWidth  = 0;  
  273.     pLogFont->lfEscapement = 0;
  274.     pLogFont->lfOrientation = 0;
  275.     pLogFont->lfWeight = (bBold ? FW_BOLD : FW_NORMAL); 
  276.     pLogFont->lfItalic = bItalic;
  277.     pLogFont->lfUnderline = FALSE;
  278.     pLogFont->lfStrikeOut = FALSE;
  279.     pLogFont->lfCharSet = ANSI_CHARSET;
  280.     pLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
  281.     pLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
  282.     pLogFont->lfQuality = DEFAULT_QUALITY;
  283.     pLogFont->lfPitchAndFamily = FF_DONTCARE;
  284.     strcpy(pLogFont->lfFaceName, sFontName);
  285. }
  286.  
  287. /////////////////////////////////////////////////////////////////////
  288. void CVCGLTextDemoDlg::SetButtonFonts()
  289. {
  290.     CWnd    *pWnd;
  291.     CFont   Font;
  292.     LOGFONT LogFont;
  293.     
  294.     // set the font of the Arial button
  295.     InitLogFont("Arial", FALSE, TRUE, &LogFont);
  296.     if (!Font.CreateFontIndirect(&LogFont))
  297.         return;
  298.  
  299.     pWnd = GetDlgItem(ID_ARIAL_FONT_BUTTON);
  300.     ASSERT(pWnd);
  301.     pWnd->SetFont(&Font);
  302.     Font.Detach();
  303.  
  304.     // set the font of the Currier New button
  305.     InitLogFont("Courier New", TRUE, FALSE, &LogFont);
  306.     if (!Font.CreateFontIndirect(&LogFont))
  307.         return;
  308.  
  309.     pWnd = GetDlgItem(ID_CURRIER_NEW_FONT_BUTTON);
  310.     ASSERT(pWnd);
  311.     pWnd->SetFont(&Font);
  312.     Font.Detach();
  313. }
  314.  
  315. //////////////////////////////////////////////////////////////////////
  316. void CVCGLTextDemoDlg::OnSysCommand(UINT nID, LPARAM lParam)
  317. {
  318.     if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  319.     {
  320.         CAboutDlg dlgAbout;
  321.         dlgAbout.DoModal();
  322.     }
  323.     else
  324.     {
  325.         CDialog::OnSysCommand(nID, lParam);
  326.     }
  327. }
  328.  
  329. // If you add a minimize button to your dialog, you will need the code below
  330. //  to draw the icon.  For MFC applications using the document/view model,
  331. //  this is automatically done for you by the framework.
  332.  
  333. void CVCGLTextDemoDlg::OnPaint() 
  334. {
  335.     if (IsIconic())
  336.     {
  337.         CPaintDC dc(this); // device context for painting
  338.  
  339.         SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  340.  
  341.         // Center icon in client rectangle
  342.         int cxIcon = GetSystemMetrics(SM_CXICON);
  343.         int cyIcon = GetSystemMetrics(SM_CYICON);
  344.         CRect rect;
  345.         GetClientRect(&rect);
  346.         int x = (rect.Width() - cxIcon + 1) / 2;
  347.         int y = (rect.Height() - cyIcon + 1) / 2;
  348.  
  349.         // Draw the icon
  350.         dc.DrawIcon(x, y, m_hIcon);
  351.     }
  352.     else
  353.     {
  354.         CDialog::OnPaint();
  355.     }
  356. }
  357.  
  358. // The system calls this to obtain the cursor to display while the user drags
  359. //  the minimized window.
  360. HCURSOR CVCGLTextDemoDlg::OnQueryDragIcon()
  361. {
  362.     return (HCURSOR) m_hIcon;
  363. }
  364.  
  365. //////////////////////////////////////////////////////////////////////
  366. void CVCGLTextDemoDlg::OnAboutButton() 
  367. {
  368.     m_pTextControl->AboutBox();
  369. }
  370.  
  371. //////////////////////////////////////////////////////////////////////
  372. void CVCGLTextDemoDlg::OnArialFontButton() 
  373. {
  374.     CWaitCursor wait;
  375.     IFontDisp *pFontDisp;
  376.  
  377.     m_pTextControl->get_TextFont(&pFontDisp);
  378.     ASSERT(pFontDisp);
  379.     
  380.     CNFont font;
  381.     LOGFONT lf;
  382.  
  383.     font.SetDispatch(pFontDisp);
  384.     font.GetLogFont(lf);
  385.  
  386.     memcpy(lf.lfFaceName, "Arial", sizeof("Arial"));
  387.     lf.lfHeight = -14;
  388.     lf.lfWeight = FW_NORMAL;
  389.     lf.lfItalic = TRUE;
  390.  
  391.     font.SetLogFont(lf);
  392.     m_pTextControl->put_TextFont(font.GetFontDispatch());
  393. }
  394.  
  395. //////////////////////////////////////////////////////////////////////
  396. void CVCGLTextDemoDlg::OnCurrierNewFontButton() 
  397. {
  398.     CWaitCursor wait;
  399.     IFontDisp *pFontDisp;
  400.  
  401.     m_pTextControl->get_TextFont(&pFontDisp);
  402.     ASSERT(pFontDisp);
  403.     
  404.     CNFont font;
  405.     LOGFONT lf;
  406.  
  407.     font.SetDispatch(pFontDisp);
  408.     font.GetLogFont(lf);
  409.  
  410.     memcpy(lf.lfFaceName, "Courier New", sizeof("Courier New"));
  411.     lf.lfHeight = -14;
  412.     lf.lfWeight = FW_BOLD;
  413.     lf.lfItalic = FALSE;
  414.  
  415.     font.SetLogFont(lf);
  416.     m_pTextControl->put_TextFont(font.GetFontDispatch());    
  417. }
  418.  
  419. //////////////////////////////////////////////////////////////////////
  420. void CVCGLTextDemoDlg::OnAnimateRotatexyButton() 
  421. {
  422.     CWaitCursor wait;
  423.     IDual3DViewPtr pView = m_pTextControl->Get3DView();
  424.  
  425.     UpdateData();
  426.     float fCurrentRotation = (float)atof(m_sRotation);
  427.  
  428.     for (int i = 1; i < 30; i++)
  429.     {
  430.         fCurrentRotation += 3;
  431.         pView->Rotation = fCurrentRotation;
  432.     
  433.         m_pTextControl->Update();
  434.     }
  435.  
  436.     m_sRotation.Format("%.2f", pView->Rotation);
  437.     UpdateData(FALSE);
  438. }
  439.  
  440. //////////////////////////////////////////////////////////////////////
  441. void CVCGLTextDemoDlg::OnAnimateRotatezButton() 
  442. {
  443.     CWaitCursor wait;
  444.     IDual3DViewPtr pView = m_pTextControl->Get3DView();
  445.  
  446.     UpdateData();
  447.     float fCurrentElevation = (float)atof(m_sElevation);
  448.  
  449.     for (int i = 1; i < 30; i++)
  450.     {
  451.         fCurrentElevation += 3;
  452.         pView->Elevation = fCurrentElevation;
  453.     
  454.         m_pTextControl->Update();
  455.     }
  456.  
  457.     m_sElevation.Format("%.2f", pView->Elevation);
  458.     UpdateData(FALSE);
  459. }
  460.  
  461. //////////////////////////////////////////////////////////////////////
  462. void CVCGLTextDemoDlg::OnEnableMouseCheck() 
  463. {    
  464.     UpdateData();
  465.     m_pTextControl->Get3DView()->EnableMouse = BOOL_TO_VAR(m_bEnableMouse);
  466. }
  467.  
  468. //////////////////////////////////////////////////////////////////////
  469. void CVCGLTextDemoDlg::OnSolidColorButton() 
  470. {
  471.     IDualFillEffectPtr pTextFillEffect = m_pTextControl->FillEffect();
  472.  
  473.     pTextFillEffect->Type = fetSolidColor;
  474.     pTextFillEffect->Color = RGB(0, 255, 0);
  475. }
  476.  
  477. //////////////////////////////////////////////////////////////////////
  478. void CVCGLTextDemoDlg::OnGradientButton() 
  479. {
  480.     IDualFillEffectPtr pTextFillEffect = m_pTextControl->FillEffect();
  481.     
  482.     m_pTextControl->Redraw = VARIANT_FALSE;
  483.  
  484.     pTextFillEffect->Type = fetGradient;
  485.     pTextFillEffect->GradientStyle = gsDiagonalUp;
  486.     pTextFillEffect->GradientVariant = gvVariant4;
  487.     pTextFillEffect->GradientColor1 = RGB(0, 255, 0);
  488.     pTextFillEffect->GradientColor2 = RGB(0, 0, 0);
  489.     
  490.     m_pTextControl->Redraw = VARIANT_TRUE;
  491. }
  492.  
  493. //////////////////////////////////////////////////////////////////////
  494. void CVCGLTextDemoDlg::OnTextureButton() 
  495. {
  496.     CString sFullPath;
  497.     IDualFillEffectPtr pTextFillEffect = m_pTextControl->FillEffect();
  498.  
  499.     sFullPath = GetImageDir() + CString("\\Seaside.bmp");
  500.     m_pTextControl->Redraw = VARIANT_FALSE;
  501.     
  502.     try
  503.     {
  504.         pTextFillEffect->Type = fetImage;
  505.         pTextFillEffect->ImageMapType = mtMapType0; // Object linear texture mapping
  506.         pTextFillEffect->ImageFileName = sFullPath.AllocSysString();
  507.     }
  508.     catch (_com_error err)
  509.     {
  510.         AfxMessageBox(CString((LPCTSTR)err.Description())); 
  511.     }
  512.  
  513.     m_pTextControl->Redraw = VARIANT_TRUE;
  514. }
  515.  
  516. //////////////////////////////////////////////////////////////////////
  517. void CVCGLTextDemoDlg::OnBkFillEffectButton() 
  518. {
  519.     m_pTextControl->BackgroundFillEffect()->ShowDialog();
  520. }
  521.  
  522. //////////////////////////////////////////////////////////////////////
  523. void CVCGLTextDemoDlg::OnEnableLightningCheck() 
  524. {
  525.     UpdateData();
  526.     m_pTextControl->LightModel()->EnableLightning = BOOL_TO_VAR(m_bEnableLightning);
  527. }
  528.  
  529. //////////////////////////////////////////////////////////////////////
  530. void CVCGLTextDemoDlg::OnFillEffectButton() 
  531. {
  532.     m_pTextControl->FillEffect()->ShowDialog();    
  533. }
  534.  
  535. //////////////////////////////////////////////////////////////////////
  536. void CVCGLTextDemoDlg::OnMaterialButton() 
  537. {
  538.     m_pTextControl->Material()->ShowDialog();    
  539. }
  540.  
  541. //////////////////////////////////////////////////////////////////////
  542. void CVCGLTextDemoDlg::OnAnimatedTextureButton() 
  543. {
  544.     m_pTextControl->Redraw = VARIANT_FALSE;
  545.  
  546.     IDualFillEffectPtr pTextFillEffect = m_pTextControl->FillEffect();
  547.     CString sFullPath;
  548.     sFullPath = GetImageDir() + CString("\\animation1.avi");
  549.  
  550.     pTextFillEffect->Type = fetAnimation;
  551.     pTextFillEffect->AnimationMapType = mtMapType1;
  552.     pTextFillEffect->AnimationFileName = sFullPath.AllocSysString();
  553.     
  554.     m_pTextControl->Redraw = VARIANT_TRUE;
  555. }
  556.  
  557. //////////////////////////////////////////////////////////////////////
  558. void CVCGLTextDemoDlg::OnPatternButton() 
  559. {
  560.     m_pTextControl->Redraw = VARIANT_FALSE;
  561.  
  562.     IDualFillEffectPtr pTextFillEffect = m_pTextControl->FillEffect();
  563.  
  564.     pTextFillEffect->Type = fetPattern;
  565.     pTextFillEffect->PatternBackgroundColor = RGB(255, 255, 0); // yellow
  566.     pTextFillEffect->PatternForegroundColor = RGB(0, 0, 255); // blue
  567.     pTextFillEffect->PatternType = ptDivot;
  568.     
  569.     m_pTextControl->Redraw = VARIANT_TRUE;
  570. }
  571.  
  572. //////////////////////////////////////////////////////////////////////
  573. void CVCGLTextDemoDlg::OnChangeZoomEdit() 
  574. {
  575.     m_pTextControl->Redraw = VARIANT_FALSE;
  576.     UpdateData();
  577.  
  578.     m_pTextControl->Get3DView()->Zoom = (float)atof(m_sZoom);
  579.     m_pTextControl->Redraw = VARIANT_TRUE;
  580. }
  581.  
  582. //////////////////////////////////////////////////////////////////////
  583. void CVCGLTextDemoDlg::OnChangeTextEdit() 
  584. {
  585.     m_pTextControl->Redraw = VARIANT_FALSE;
  586.     UpdateData();
  587.  
  588.     m_pTextControl->Text = m_sText.AllocSysString();
  589.     m_pTextControl->Redraw = VARIANT_TRUE;
  590. }
  591.  
  592. //////////////////////////////////////////////////////////////////////
  593. void CVCGLTextDemoDlg::OnChangeRotationEdit() 
  594. {
  595.     m_pTextControl->Redraw = VARIANT_FALSE;
  596.     UpdateData();
  597.  
  598.     m_pTextControl->Get3DView()->Rotation = (float)atof(m_sRotation);
  599.     m_pTextControl->Redraw = VARIANT_TRUE;
  600. }
  601.  
  602. //////////////////////////////////////////////////////////////////////
  603. void CVCGLTextDemoDlg::OnChangeLineSpacingEdit() 
  604. {
  605.     m_pTextControl->Redraw = VARIANT_FALSE;
  606.     UpdateData();
  607.  
  608.     m_pTextControl->LineSpacing = (float)atof(m_sLineSpacing);
  609.     m_pTextControl->Redraw = VARIANT_TRUE;
  610. }
  611.  
  612. //////////////////////////////////////////////////////////////////////
  613. void CVCGLTextDemoDlg::OnChangeElevationEdit() 
  614. {
  615.     m_pTextControl->Redraw = VARIANT_FALSE;
  616.     UpdateData();
  617.  
  618.     m_pTextControl->Get3DView()->Elevation = (float)atof(m_sElevation);
  619.     m_pTextControl->Redraw = VARIANT_TRUE;
  620. }
  621.  
  622. //////////////////////////////////////////////////////////////////////
  623. void CVCGLTextDemoDlg::OnChangeExtrusionEdit() 
  624. {
  625.     m_pTextControl->Redraw = VARIANT_FALSE;
  626.     UpdateData();
  627.  
  628.     m_pTextControl->TextExtrusion = (float)atof(m_sExtrusion);
  629.     m_pTextControl->Redraw = VARIANT_TRUE;
  630. }
  631.  
  632. //////////////////////////////////////////////////////////////////////
  633. void CVCGLTextDemoDlg::OnOrtographicProjectionCheck() 
  634. {
  635.     UpdateData();
  636.     if (m_bOrtographicProjection)
  637.     {
  638.         m_pTextControl->Get3DView()->ProjectionType = N3DTEXTLib::ptOrtogonal;
  639.     }
  640.     else
  641.     {
  642.         m_pTextControl->Get3DView()->ProjectionType = N3DTEXTLib::ptPerspective;
  643.     }
  644. }
  645.