home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 February / Chip_2001-02_cd1.bin / sharewar / vecad / examples / bcb / editor / Funcs.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-20  |  3.1 KB  |  117 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <stdio.h>
  4. #pragma hdrstop
  5.  
  6. #include "VecApi.h"
  7. #include "Funcs.h"
  8. #include "DwgProc.h"
  9. #include "Main.h"
  10.  
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13.  
  14. HWND ghwVec;   // VeCAD window to display draw
  15. int  VecX0;    // coordinates of left top corner
  16. int  VecY0;    //       of VeCAD window
  17. int  SBarH;    // height of status bar
  18. bool TheEnd=false;
  19.  
  20. //-----------------------------------------------
  21. void UnloadVecadDll ()
  22. {
  23.   vlCleanup();
  24.   TheEnd = true;
  25. }
  26.  
  27. //-----------------------------------------------
  28. // Create VeCAD window
  29. //-----------------------------------------------
  30. void CreateVecWindow (HWND Handle)
  31. {
  32.   TheEnd = false;
  33.   // Register your copy of Vecad.dll
  34.   vlRegistration( 0 );
  35.   // Create VeCAD toolbar
  36.   int w=0, h=0, h2;
  37.   int x = 0;
  38.   int y = -1;
  39.   vlToolBarCreate( Handle, VL_TB_MAIN, x, y, -1, 1, &w, &h );
  40.   y+=h;
  41.   h2=h;
  42.   x=0;
  43.   vlToolBarCreate( Handle, VL_CB_LAYER, x, y, 210, h2, &w, &h );
  44.   x+=w;
  45.   vlToolBarCreate( Handle, VL_CB_COLOR, x, y, 90, h2, &w, &h );
  46.   x+=w;
  47.   vlToolBarCreate( Handle, VL_CB_STLINE, x, y, 200, h2, &w, &h );
  48.   x+=w;
  49.   vlToolBarCreate( Handle, VL_TB_SNAP, x, y, -1, 1, &w, &h );
  50.   y+=h;
  51.   vlToolBarCreate( Handle, VL_TB_DRAW, 0, y, 60, 500, &w, &h );
  52.   y+=h;
  53.   vlToolBarCreate( Handle, VL_TB_EDIT, 0, y, 60, -1, &w, &h );
  54.   x=w;
  55.   y=h2+h2-1;
  56.   VecX0 = x;
  57.   VecY0 = y;
  58.   // Create VeCAD StatusBar
  59.   vlStatBarCreate( Handle, &SBarH );
  60.   // Create VeCAD window, size will be set in OnSize()
  61.   ghwVec = vlWndCreate( Handle, VL_WS_CHILD|VL_WS_SCROLL|VL_WS_BORDER,
  62.                         VecX0,VecY0,400,300, DwgProc );
  63.   if (ghwVec){
  64.     ::PostMessage( Handle, WM_SIZE, 0, 0 );
  65.     vlPropPut( VD_WND_EMPTYTEXT, (int)ghwVec, "Editor" );
  66.   }
  67. }
  68.  
  69. //-----------------------------------------------
  70. // Resize VeCAD window
  71. //-----------------------------------------------
  72. void ResizeVecWindow (HWND Handle)
  73. {
  74.   if (!TheEnd){
  75.     int w, h;
  76.     vlGetWinSize( Handle, &w, &h );
  77.     if (w>0 && h>0){
  78.       // Resize drawing window
  79.       vlWndResize( ghwVec, VecX0, VecY0, w - VecX0, h - VecY0 - SBarH );
  80.       // Resize statusbar
  81.       vlStatBarResize();
  82.     }
  83.   }
  84. }
  85.  
  86. //-------------------------------------------------------------------
  87. void UpdateMainTitle ()
  88. {
  89.   char szPgName[64], szTitle[256], szFName[256];
  90.  
  91.   int iPage = vlPageIndex( NULL, 0 );
  92.   int nPage = vlPageCount();
  93.   ZeroMemory( szPgName, sizeof(szPgName) );
  94.   ZeroMemory( szFName, sizeof(szFName) );
  95.   vlPropGet( VD_PAGE_NAME, iPage, szPgName );
  96.   vlPropGet( VD_DWG_FILENAME, -1, szFName );
  97.   if (strcmp(szFName,"")==0){
  98.     strcpy( szFName, "noname" );
  99.   }
  100.   sprintf( szTitle, "Editor - [%s], page: %d/%d  %c%s%c", szFName, iPage+1, nPage, '"', szPgName, '"' );
  101.   Form1->Caption = szTitle;
  102. }
  103.  
  104. //-----------------------------------------------
  105. void FileNew ()
  106. {
  107.   vlFileNew( ghwVec, DwgProc, "" );
  108. }
  109.  
  110. //-----------------------------------------------
  111. void FileOpen ()
  112. {
  113.   vlFileOpen( ghwVec, DwgProc, "" );
  114. }
  115.  
  116.  
  117.