home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / pstoedit.zip / source.zip / pstoedit.2.50 / src / bc5gui / paradlg.cpp < prev    next >
C/C++ Source or Header  |  1996-12-13  |  7KB  |  306 lines

  1. /*
  2.    paradlg.cpp : This file is part of pstoedit
  3.    parameter dialog
  4.  
  5.    Copyright (C) 1996 Jens Weber, wr@lzh1.lzh.de
  6.  
  7.     This program is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU General Public License as published by
  9.     the Free Software Foundation; either version 2 of the License, or
  10.     (at your option) any later version.
  11.  
  12.     This program is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU General Public License
  18.     along with this program; if not, write to the Free Software
  19.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21. */
  22.  
  23.  
  24. #include "winp2e.h"
  25. #include "config.h"
  26.  
  27.  
  28. // TParaDlg-Konstruktor: Instanzieren von Edit-Feldern
  29. // zur Parametereingabe
  30.  
  31. TParaDlg::TParaDlg(TWindow* AParent, TResId resId, TParameter *pzeiger,
  32.                                     TMyTransferStruct& ts)
  33.                  :TDialog(AParent, resId), TWindow(AParent)
  34. {
  35.     para_zeiger = pzeiger;
  36.  
  37.   //Defaultwerte vorbereiten
  38.     sprintf(ts.NameEdit1,"%f",pzeiger->magnification);
  39.     sprintf(ts.NameEdit2,"%f",pzeiger->flatness);
  40.     sprintf(ts.NameEdit3,"%s",pzeiger->resolution_x);
  41.     sprintf(ts.NameEdit4,"%s",pzeiger->resolution_y);
  42.  
  43.     // HINWEIS: die Zuordnung ts.button n zu den CheckBoxes n
  44.     // ist nicht explizit festgelegt
  45.     if(para_zeiger->merging) ts.button1=BF_CHECKED;
  46.     else ts.button1=BF_UNCHECKED;
  47.     if(para_zeiger->drawtext) ts.button2=BF_CHECKED;
  48.     else ts.button2=BF_UNCHECKED;
  49.     if(para_zeiger->display) ts.button3=BF_CHECKED;
  50.     else ts.button3=BF_UNCHECKED;
  51.     if(para_zeiger->verbose) ts.button4=BF_CHECKED;
  52.     else ts.button4=BF_UNCHECKED;
  53.  
  54.     if(para_zeiger->backendonly) ts.button5=BF_CHECKED;
  55.     else ts.button5=BF_UNCHECKED;
  56.     // notice nomaplatin is used inversely !!
  57.     // the button says 'map to iso latin1'
  58.     if(para_zeiger->nomaplatin) ts.button6=BF_UNCHECKED;
  59.     else ts.button6=BF_CHECKED;
  60.     if(para_zeiger->noquit) ts.button7=BF_CHECKED;
  61.     else ts.button7=BF_UNCHECKED;
  62.     if(para_zeiger->enhanced) ts.button8=BF_CHECKED;
  63.     else ts.button8=BF_UNCHECKED;
  64.  
  65.     new TEdit(this, ID_NAMEEDIT1,sizeof(ts.NameEdit1) );
  66.     new TEdit(this, ID_NAMEEDIT2,sizeof(ts.NameEdit2) );
  67.     new TEdit(this, ID_NAMEEDIT3,sizeof(ts.NameEdit3) );
  68.     new TEdit(this, ID_NAMEEDIT4,sizeof(ts.NameEdit4) );
  69.  
  70.     cb1 = new TCheckBox(this, ID_CHECK1, NULL);
  71.     cb2 = new TCheckBox(this, ID_CHECK2, NULL);
  72.     cb3 = new TCheckBox(this, ID_CHECK3, NULL);
  73.     cb4 = new TCheckBox(this, ID_CHECK4, NULL);
  74.     cb5 = new TCheckBox(this, ID_CHECK5, NULL);
  75.     cb6 = new TCheckBox(this, ID_CHECK6, NULL);
  76.     cb7 = new TCheckBox(this, ID_CHECK7, NULL);
  77.     cb8 = new TCheckBox(this, ID_CHECK8, NULL);
  78.  
  79.     Combo1 = new TComboBox(this, ID_LISTBOX, 10);
  80.  
  81. #ifdef WITHTGIF
  82.     ts.ComboBoxData.AddString("tgif");
  83. #endif
  84. #ifdef WITHRPL
  85.     ts.ComboBoxData.AddString("rpl");
  86. #endif
  87. #ifdef WITHLWO
  88.     ts.ComboBoxData.AddString("lwo");
  89. #endif
  90. #ifdef WITHRIB
  91.     ts.ComboBoxData.AddString("rib");
  92. #endif
  93. #ifdef WITHMIF
  94.     ts.ComboBoxData.AddString("mif");
  95. #endif
  96. #ifdef WITHFIG
  97.     ts.ComboBoxData.AddString("fig");
  98. #endif
  99. #ifdef WITHPDF
  100.     ts.ComboBoxData.AddString("pdf");
  101. #endif
  102. #ifdef WITHGNUPLOT
  103.     ts.ComboBoxData.AddString("gnuplot");
  104. #endif
  105.     ts.ComboBoxData.AddString("ps");
  106.     ts.ComboBoxData.AddString("debug");
  107.     ts.ComboBoxData.AddString("dump");
  108. #if defined (WITHMET) && defined(__OS2__)
  109.     ts.ComboBoxData.AddString("met");
  110. #endif
  111. #ifdef WITHWMF
  112.     ts.ComboBoxData.AddString("wmf");
  113. #endif
  114. #ifdef WITHDXF
  115.     ts.ComboBoxData.AddString("dxf");
  116. #endif
  117. #ifdef WITHCGM
  118.     ts.ComboBoxData.AddString("cgm");
  119.     ts.ComboBoxData.AddString("cgmt");
  120. #endif
  121. #ifdef WITHJAVA
  122.     ts.ComboBoxData.AddString("java");
  123. #endif
  124. #ifdef WITHSAMPLE
  125.     ts.ComboBoxData.AddString("sample");
  126. #endif
  127.  
  128.     SetTransferBuffer(&ts);
  129.  
  130.     // Selektion vorgeben (aus para_zeiger->format)
  131.     ts.ComboBoxData.SelectString(para_zeiger->format);
  132. }
  133.  
  134. TParaDlg::~TParaDlg()
  135. {
  136.  
  137.     delete Combo1;
  138.  
  139. }
  140.  
  141.  
  142.  
  143. bool TParaDlg::CanClose()
  144.  
  145. {
  146.  
  147.   FillBuffers();
  148.  
  149.   Combo1->GetString(para_zeiger->format, Combo1->GetSelIndex());
  150.  
  151.     if(cb1->GetCheck())
  152.         para_zeiger->merging=TRUE;
  153.     else
  154.     para_zeiger->merging=FALSE;
  155.  
  156.  
  157.     if(cb2->GetCheck())
  158.         para_zeiger->drawtext=TRUE;
  159.     else
  160.     para_zeiger->drawtext=FALSE;
  161.  
  162.     if(cb3->GetCheck())
  163.         para_zeiger->display=TRUE;
  164.     else
  165.     para_zeiger->display=FALSE;
  166.  
  167.     if(cb4->GetCheck())
  168.         para_zeiger->verbose=TRUE;
  169.     else
  170.     para_zeiger->verbose=FALSE;
  171.  
  172.     if(cb5->GetCheck())
  173.         para_zeiger->backendonly=TRUE;
  174.     else
  175.     para_zeiger->backendonly=FALSE;
  176.  
  177.     // notice nomaplatin is used inversely !!
  178.     // the button says 'map to iso latin1'
  179.     if(cb6->GetCheck())
  180.         para_zeiger->nomaplatin=FALSE;
  181.     else
  182.     para_zeiger->nomaplatin=TRUE;
  183.  
  184.     if(cb7->GetCheck())
  185.         para_zeiger->noquit=TRUE;
  186.     else
  187.     para_zeiger->noquit=FALSE;
  188.  
  189.     if(cb8->GetCheck())
  190.         para_zeiger->enhanced=TRUE;
  191.     else
  192.     para_zeiger->enhanced=FALSE;
  193.  
  194.     if ( (Name1[0]) && (Name2[0])  )
  195.     {
  196.         if ( ValidField1() && ValidField2() && ValidField3() && ValidField4()) {
  197.             return TRUE; }
  198.   }
  199.   else
  200.     MessageBox("Please fullfill complete","Input Error",
  201.                     MB_OK | MB_ICONEXCLAMATION);
  202.   return FALSE;
  203.  
  204. }
  205.  
  206.  
  207. void TParaDlg::FillBuffers()
  208. {
  209.  
  210.      GetDlgItemText(ID_NAMEEDIT1, Name1, NAMELENGTH);
  211.      GetDlgItemText(ID_NAMEEDIT2, Name2, NAMELENGTH);
  212.      GetDlgItemText(ID_NAMEEDIT3, Name3, NAMELENGTH);
  213.      GetDlgItemText(ID_NAMEEDIT4, Name4, NAMELENGTH);
  214.  
  215. }
  216.  
  217. bool TParaDlg::ValidField1()
  218.  
  219. // Vergroesserungsfaktor
  220.  
  221. {
  222.   float d;
  223.  
  224.   if(!(sscanf(Name1,"%f",&d))) return FALSE;
  225.  
  226.   para_zeiger->magnification = d;
  227.  
  228.  
  229.   if(d==0.0)  {
  230.             MessageBox("Magnification must have a nonzero value","Input Error",
  231.                 MB_OK | MB_ICONEXCLAMATION);
  232.             return FALSE;  }
  233.  
  234.     return TRUE;
  235.  
  236. }
  237.  
  238. bool TParaDlg::ValidField2()
  239.  
  240. // Flatness
  241.  
  242. {
  243.  
  244.     float d;
  245.  
  246.   if(!(sscanf(Name2,"%f",&d))) return FALSE;
  247.  
  248.   para_zeiger->flatness = d;
  249.  
  250.  
  251.   if(d==0.0)  {
  252.             MessageBox("Flatness must have a nonzero value","Input Error",
  253.                 MB_OK | MB_ICONEXCLAMATION);
  254.       return FALSE;  }
  255.  
  256.     return TRUE;
  257.  
  258. }
  259.  
  260. bool TParaDlg::ValidField3()
  261.  
  262. // Resolution-Option (x)
  263.  
  264. {
  265.    int d;
  266.  
  267.    if(!(sscanf(Name3,"%d",&d))) {
  268.             MessageBox("x-Resolution must be an integer","Input Error",
  269.                 MB_OK | MB_ICONEXCLAMATION);
  270.          return FALSE; }
  271.  
  272.    if(d<=0)  {
  273.         MessageBox("x-Resolution must be greater zero","Input Error",
  274.                 MB_OK | MB_ICONEXCLAMATION);
  275.       return FALSE;  }
  276.  
  277.     strcpy(para_zeiger->resolution_x,Name3);
  278.  
  279.     return TRUE;
  280.  
  281. }
  282.  
  283. bool TParaDlg::ValidField4()
  284.  
  285. // Resolution-Option (y)
  286.  
  287. {
  288.    int d;
  289.  
  290.    if(!(sscanf(Name4,"%d",&d))) {
  291.             MessageBox("y-Resolution must be an integer","Input Error",
  292.                 MB_OK | MB_ICONEXCLAMATION);
  293.          return FALSE; }
  294.  
  295.    if(d<=0)  {
  296.         MessageBox("y-Resolution must be greater zero","Input Error",
  297.                 MB_OK | MB_ICONEXCLAMATION);
  298.       return FALSE;  }
  299.  
  300.     strcpy(para_zeiger->resolution_y,Name4);
  301.  
  302.     return TRUE;
  303.  
  304. }
  305.  
  306.