home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / Cell Control / DATA1.CAB / VCDEMO_Files / VCDemoView.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-11  |  7.7 KB  |  333 lines

  1. // VCDemoView.cpp : implementation of the CVCDemoView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "VCDemo.h"
  6.  
  7. #include "VCDemoDoc.h"
  8. #include "VCDemoView.h"
  9.  
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CVCDemoView
  18.  
  19. IMPLEMENT_DYNCREATE(CVCDemoView, CView)
  20.  
  21. BEGIN_MESSAGE_MAP(CVCDemoView, CView)
  22.     //{{AFX_MSG_MAP(CVCDemoView)
  23.     ON_COMMAND(ID_DEMO_USERFUNC, OnDemoUserfunc)
  24.     ON_COMMAND(ID_DEMO_CELLTYPE, OnDemoCelltype)
  25.     ON_COMMAND(ID_DEMO_CHART, OnDemoChart)
  26.     ON_COMMAND(ID_DEMO_FACE, OnDemoFace)
  27.     ON_COMMAND(ID_DEMO_FORMULA, OnDemoFormula)
  28.     ON_COMMAND(ID_DEMO_SHOWONLY, OnDemoShowonly)
  29.     ON_COMMAND(ID_DEMO_SIZE, OnDemoSize)
  30.     ON_COMMAND(ID_DEMO_SORT, OnDemoSort)
  31.     ON_COMMAND(ID_DEMO_BK, OnDemoBk)
  32.     ON_COMMAND(ID_DEMO_CELLSTYLE, OnDemoCellstyle)
  33.     ON_COMMAND(ID_DEMO_COPY, OnDemoCopy)
  34.     ON_COMMAND(ID_DEMO_DRAG, OnDemoDrag)
  35.     ON_COMMAND(ID_DEMO_INPUT, OnDemoInput)
  36.     ON_COMMAND(ID_DEMO_PAGES, OnDemoPages)
  37.     ON_COMMAND(ID_DEMO_PRINT, OnDemoPrint)
  38.     ON_COMMAND(ID_DEMO_DROPGRID, OnDemoDropgrid)
  39.     ON_COMMAND(ID_DEMO_SAVELOAD, OnDemoSaveload)
  40.     ON_COMMAND(ID_DEMO_DBASE, OnDemoDbase)
  41.     ON_COMMAND(ID_DEMO_UNDO, OnDemoUndo)
  42.     ON_COMMAND(ID_DEMO_UNSCROLL, OnDemoUnscroll)
  43.     //}}AFX_MSG_MAP
  44.     // Standard printing commands
  45.     ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  46.     ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
  47.     ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  48. END_MESSAGE_MAP()
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CVCDemoView construction/destruction
  52.  
  53. CVCDemoView::CVCDemoView()
  54. {
  55.     // TODO: add construction code here
  56.  
  57. }
  58.  
  59. CVCDemoView::~CVCDemoView()
  60. {
  61. }
  62.  
  63. BOOL CVCDemoView::PreCreateWindow(CREATESTRUCT& cs)
  64. {
  65.     // TODO: Modify the Window class or styles here by modifying
  66.     //  the CREATESTRUCT cs
  67.  
  68.     return CView::PreCreateWindow(cs);
  69. }
  70.  
  71. /////////////////////////////////////////////////////////////////////////////
  72. // CVCDemoView drawing
  73.  
  74. void CVCDemoView::OnDraw(CDC* dc)
  75. {
  76.     CVCDemoDoc* pDoc = GetDocument();
  77.     ASSERT_VALID(pDoc);
  78.  
  79.     // TODO: add draw code for native data here
  80.         RECT    rect,rect2;
  81.         int        i,x,y;
  82.         int        step = 40;
  83.         
  84.         GetClientRect(&rect);
  85.         CopyRect(&rect2,&rect);
  86.  
  87.         x= rect.right/(step*2);         
  88.         y= rect.bottom/(step*2);         
  89.  
  90.         CBrush *brush;
  91.         for(i=0;i<step;i++){
  92.             CRgn  rgn;
  93.             brush = new CBrush(RGB( 0, 0, (i+1)*255/step) );
  94.  
  95.             rect2.top = rect.top+(i-15)*y;
  96.             rect2.bottom = rect.bottom-(i-15)*y;
  97.             rect2.left = rect.left+(i-15)*x;
  98.             rect2.right = rect.right-(i-15)*x;
  99.             if( i == 0 )dc->FillRect(&rect,brush);
  100.  
  101.             if( rect2.right > rect2.left && rect2.bottom > rect2.top && 
  102.                 rgn.CreateEllipticRgnIndirect( &rect2 ) )
  103.                 dc->FillRgn(&rgn,brush);
  104.             delete brush;
  105.         }
  106.  
  107.         CFont *font, *oldfont;
  108.         CString string = "CELL Control make you success!";
  109.         CSize size;
  110.         int point = 50;
  111.  
  112.         //found better font size
  113.         while(TRUE){
  114.             font = new CFont;
  115.             font->CreateFont(point,0,0,0,700,0,0,0,0,0,0,0,0,"Times New Roman");
  116.             oldfont = dc->SelectObject(font);
  117.             if( point <= 1 )break;
  118.             size = dc->GetTextExtent(string);
  119.             if(size.cx > rect.right*0.6 ){
  120.                 double ratio = size.cx/(rect.right*0.6);
  121.                 point = int(point/ratio-1);
  122.                 if( point <= 0 )point = 1;
  123.                 dc->SelectObject( oldfont );
  124.                 delete font;
  125.             }
  126.             else
  127.                 break;
  128.         }
  129.  
  130.         dc->SetBkMode(TRANSPARENT);
  131.         dc->SetTextColor(RGB(0,0,0));
  132.         dc->DrawText(string,&rect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
  133.         dc->SetTextColor(RGB(230,230,230));
  134.         rect.top -=6;
  135.         rect.left -=6;
  136.         dc->DrawText(string,&rect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
  137.         dc->SetTextColor(RGB(255,140,80));
  138.         rect.top +=3;
  139.         rect.left +=3;
  140.         dc->DrawText(string,&rect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
  141.  
  142.         dc->SelectObject( oldfont );
  143.         delete font;
  144. }
  145.  
  146. /////////////////////////////////////////////////////////////////////////////
  147. // CVCDemoView printing
  148.  
  149. BOOL CVCDemoView::OnPreparePrinting(CPrintInfo* pInfo)
  150. {
  151.     // default preparation
  152.     return DoPreparePrinting(pInfo);
  153. }
  154.  
  155. void CVCDemoView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  156. {
  157.     // TODO: add extra initialization before printing
  158. }
  159.  
  160. void CVCDemoView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  161. {
  162.     // TODO: add cleanup after printing
  163. }
  164.  
  165. /////////////////////////////////////////////////////////////////////////////
  166. // CVCDemoView diagnostics
  167.  
  168. #ifdef _DEBUG
  169. void CVCDemoView::AssertValid() const
  170. {
  171.     CView::AssertValid();
  172. }
  173.  
  174. void CVCDemoView::Dump(CDumpContext& dc) const
  175. {
  176.     CView::Dump(dc);
  177. }
  178.  
  179. CVCDemoDoc* CVCDemoView::GetDocument() // non-debug version is inline
  180. {
  181.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVCDemoDoc)));
  182.     return (CVCDemoDoc*)m_pDocument;
  183. }
  184. #endif //_DEBUG
  185.  
  186. /////////////////////////////////////////////////////////////////////////////
  187. // CVCDemoView message handlers
  188. #include "userfuncdlg.h"
  189.  
  190. void CVCDemoView::OnDemoUserfunc() 
  191. {
  192.     // TODO: Add your command handler code here
  193.     CUserFuncDlg dlg;
  194.     dlg.DoModal();
  195. }
  196. #include "celltypedlg.h"
  197. void CVCDemoView::OnDemoCelltype() 
  198. {
  199.     // TODO: Add your command handler code here
  200.     CCellTypeDlg dlg;
  201.     dlg.DoModal();
  202. }
  203. #include "chartdlg.h"
  204. void CVCDemoView::OnDemoChart() 
  205. {
  206.     // TODO: Add your command handler code here
  207.     CChartDlg dlg;
  208.     dlg.DoModal();
  209. }
  210. #include "FaceDlg.h"
  211. void CVCDemoView::OnDemoFace() 
  212. {
  213.     // TODO: Add your command handler code here
  214.     CFaceDlg dlg;
  215.     dlg.DoModal();
  216. }
  217. #include "formuladlg.h"
  218. void CVCDemoView::OnDemoFormula() 
  219. {
  220.     // TODO: Add your command handler code here
  221.     CFormulaDlg dlg;
  222.     dlg.DoModal();
  223. }
  224. #include "virtualdlg.h"
  225. void CVCDemoView::OnDemoShowonly() 
  226. {
  227.     // TODO: Add your command handler code here
  228.     CVirtualDlg dlg;
  229.     dlg.DoModal();
  230. }
  231. #include "SizeDlg.h"
  232. void CVCDemoView::OnDemoSize() 
  233. {
  234.     // TODO: Add your command handler code here
  235.     CSizeDlg dlg;
  236.     dlg.DoModal();
  237. }
  238. #include "SortDlg.h"
  239. void CVCDemoView::OnDemoSort() 
  240. {
  241.     // TODO: Add your command handler code here
  242.     CSortDlg dlg;
  243.     dlg.DoModal();
  244. }
  245. #include "BkDlg.h"
  246. void CVCDemoView::OnDemoBk() 
  247. {
  248.     // TODO: Add your command handler code here
  249.     CBKDlg dlg;
  250.     dlg.DoModal();
  251. }
  252. #include "CellStyleDlg.h"
  253. void CVCDemoView::OnDemoCellstyle() 
  254. {
  255.     // TODO: Add your command handler code here
  256.     CCellStyleDlg dlg;
  257.     dlg.DoModal();
  258. }
  259. #include "CopyDlg.h"
  260. void CVCDemoView::OnDemoCopy() 
  261. {
  262.     // TODO: Add your command handler code here
  263.     CCopyDlg dlg;
  264.     dlg.DoModal();
  265. }
  266. #include "DragDlg.h"
  267. void CVCDemoView::OnDemoDrag() 
  268. {
  269.     // TODO: Add your command handler code here
  270.     CDragDlg dlg;
  271.     dlg.DoModal();
  272. }
  273. #include "InputDlg.h"
  274. void CVCDemoView::OnDemoInput() 
  275. {
  276.     // TODO: Add your command handler code here
  277.     CInputDlg dlg;
  278.     dlg.DoModal();
  279. }
  280. #include "PagesDlg.h"
  281. void CVCDemoView::OnDemoPages() 
  282. {
  283.     // TODO: Add your command handler code here
  284.     CPagesDlg dlg;
  285.     dlg.DoModal();
  286. }
  287. #include "PrintDemodlg.h"
  288. void CVCDemoView::OnDemoPrint() 
  289. {
  290.     // TODO: Add your command handler code here
  291.     CPrintDemoDlg dlg;
  292.     dlg.DoModal();
  293. }
  294. #include "Dropwindlg.h"
  295. void CVCDemoView::OnDemoDropgrid() 
  296. {
  297.     // TODO: Add your command handler code here
  298.     CDropwinDlg dlg;
  299.     dlg.DoModal();
  300. }
  301.  
  302. #include "Demofiledlg.h"
  303. void CVCDemoView::OnDemoSaveload() 
  304. {
  305.     // TODO: Add your command handler code here
  306.     CDemoFileDlg dlg;
  307.     dlg.DoModal();
  308. }
  309.  
  310. #include "dbasedlg.h"
  311. void CVCDemoView::OnDemoDbase() 
  312. {
  313.     // TODO: Add your command handler code here
  314.     CDbaseDlg dlg;
  315.     dlg.DoModal();
  316. }
  317.  
  318. #include "undodlg.h"
  319. void CVCDemoView::OnDemoUndo() 
  320. {
  321.     // TODO: Add your command handler code here
  322.     CUndoDlg dlg;
  323.     dlg.DoModal();
  324. }
  325.  
  326. #include"unscrolldlg.h"
  327. void CVCDemoView::OnDemoUnscroll() 
  328. {
  329.     // TODO: Add your command handler code here
  330.     CUnScrollDlg dlg;
  331.     dlg.DoModal();
  332. }
  333.