⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cppsrc1.cpp

📁 BORLAND公司C语言对话框开发程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:
 if (flags == 0) outf << "bfNormal";
 else {
    short plus = 0;
    if ((flags & 1) != 0) {
        plus = 1; outf << "bfDefault"; }
    if ((flags & 2) != 0) {
        if (plus) outf << "|";
        plus = 1;
        outf << "bfLeftJust";}
    if ((flags & 4) != 0) {
        if (plus) outf << "|";
        plus = 1;
        outf << "bfBroadcast"; }
    if ((flags & 8) != 0)  {
        if (plus) outf << "|";
        outf << "bfGrabFocus"; }
    }
}

void ButtonWriteObj::writeCode()
{
 start(this);
 if (strcmp("POptionButton", Obj) == 0)  //special POptionButton
    outf << ", " << Param[0] << ", " << Param[1] << ");\n";
 else {                                 // normal TButton
    outf << ", " << quoted(ButtonText) << ", ";
    if (*CommandName != '\0')
       outf << CommandName;
    else outf << CommandValue;
    outf << ", ";
    flagsOut(Flags);
    outf << ");\n";
    }
 finish(this);
}

void LabelWriteObj::writeCode()
{
 outf << "  " << DlgName << "->insert(new " << Obj;
 doTRect(this);
 outf << ", " << quoted(LabelText) << ", " << LinkName << "));\n\n";
}

void HistoryWriteObj::writeCode()
{
 outf << "  " << DlgName << "->insert(new " << Obj;
 doTRect(this);
 outf << ", (TInputLine*)" << HistoryLink << ", " << HistoryID << "));\n\n";
}

void InputLongWriteObj::writeCode()
{
  start(this);
  outf << ", " << (LongStrLeng+1) << ", " << LLim << ", " << ULim <<  ", "
       << ILOptions << ", " << quoted(LongLabelText) << ");\n";
  finish(this);
}

void InputLineWriteObj::writeCode()
{
  outf << VarName << " = new " << Obj;
  doTRect(this);
  outf << ", " << (StringLeng+1) << ");\n";    //Note: add 1
  finish(this);
}
void InputLineWriteObj::writeFields()
{
  outf << "  char " << FieldName << "[" << (StringLeng+1)  //Note: add 1 !
       << "];   //" << Obj << endl;
}

void doAtText(char *s)  // an '@' reference string
{
 while (*s) {
   char c = *s++;
   switch (c) {
     case 0x3 :
     case '@': break;
     case '\\' :
       if (*s == 'n') s++;
       else outf << c;
       break;
     default : outf << c;
     }
  }
}

void doText(char *s)
{    //split up a long string into several lines. String cannot exceed 254
 if (!*s) {
   outf << 0;
   return;
   }
 if (strlen(s) > 254) s[254] = '\0';   //truncate if too big
 outf << '\"';
 short count = 47;
 while (*s)  {
    if (s[0] == '\\' && s[1] == 'n' && s[2]) {
       outf << s[0] << s[1] << "\"\n     \"";
       count = 5;
       s++;    //extra increment to pass 'n'
       }
    else {
       outf << *s;
       count++;
       }
    s++;
    if (count > 75 && *s) {
       outf << "\"\n     \"";
       count = 5;
       }
    }
 outf << '\"';
}

void StaticTextWriteObj::writeCode()
{
  start(this);
  outf << ", ";
  if(Text[0] == '@' || Text[0] == 3 && Text[1] == '@') 
    doAtText(Text);
  else
    doText(Text);
  outf << ");\n";
  finish(this);
}

void ColoredTextWriteObj::writeCode()
{
  start(this);
  outf << ", ";
  if(Text[0] == '@' || Text[0] == 3 && Text[1] == '@')
    doAtText(Text);
  else
    doText(Text);
  outf << ", 0x" << hex << Attrib << dec << ");\n";
  finish(this);
}

void ScrollBarWriteObj::writeCode()
{
  start(this);
  outf << ");\n";
  finish(this);
}

void ScrollBarWriteObj::writeVars()
{
 if (strcmp(VarName, "control1") != 0) //control1 is used by TMemo
   aVar(this);
 else needcontrol1 = True;
}

void ListBoxWriteObj::writeCode()
{
  start(this);
  outf << ", " << Columns << ", ";
  if (*ScrollBar != '\0')
    outf << "(TScrollBar*)" << ScrollBar << ");\n";
  else outf << "0);\n";
  finish(this);
}

void MemoWriteObj::writeCode()
{
  start(this);
  outf << ", " ;
  if (*HScroll != '\0')
    outf << "(TScrollBar*)" << HScroll << ", ";
  else outf << "0, ";
  if (*VScroll != '\0')
    outf << "(TScrollBar*)" << VScroll << ", 0, ";
  else outf << "0, 0, ";
  outf << BufSize << ");\n";
  finish(this);
}
void MemoWriteObj::writeFields()
{
  outf << "  ushort " << FieldName << ";   //" << Obj << " text length\n";
  outf << "  char " << TextFieldName << "[" << BufSize << "];   //"
       << Obj << " text\n";
}

void ClusterWriteObj::writeCode()
{
  start(this);
  for (int i=0; i < Items; i++)
    outf << ",\n  new TSItem(\"" << (char *)LabelColl->at(i) << "\"";
  outf << ", 0";
  for (i = 0; i <= Items; i++)
    outf << ")";
  outf << ";\n";
  finish(this);
}

void doVars(void *p, void*)
{ViewObj *P = (ViewObj*)p;
 P->writeVars();
}

void chkFirst(int& first)  //called by doFields
{
 if ( first ) {
    outf << "struct " << Dialog->FieldName << "  {\n";
    first = False;
    }
}

void doFields(void *p, void* first)
{     // fieldnames for the data transfer struct
 ViewObj *P = (ViewObj*)p;
 if ( *(P->FieldName) != '\0') {
    chkFirst( *(int*)first );
    P->writeFields();
    }
 else if (strcmp("POptionButton", P->Obj) == 0) { //special POptionButton
    chkFirst( *(int*)first );
    outf << "  OptionRec " << P->Param[2] <<  ";   //POptionButton\n";
    }
}

void writeSource()
{//code to build the data transfer struct
 int first = True;

 if (Dialog->FieldName[0])  {  //no fieldname, no datarecord
   if (present[ListB]) outf <<
	"#if !defined(__TListBoxRec)\n"
	"#define __TListBoxRec\n"
	"struct TListBoxRec\n"
	"{\n"
	"    TCollection* collection;\n"
	"    short focused;\n"
	"};\n"
	"#endif\n\n";

   ScriptColl->forEach(doFields, &first);
   if (!first) outf << "  };\n\n";  //if !first, there is at least one field
   }

 //define variables whose names are not "control"
 ScriptColl->forEach(doVars, 0);
 outf << endl;

 //the code for the dialog and its controls
 Dialog->writeCode();
}

//-------------------------------------------------------------------
// The following exit procedure is required in order to view error
// messages before Turbo Vision wipes out the screen
//-------------------------------------------------------------------
int exit_flag = 1;

void exitfunc(void)
{
  if( exit_flag )
  {
     cout << "\nStrike Enter key to continue" << endl;
     char c;
     cin.get(c);
  }
}

#pragma exit exitfunc  100

int main(int argc, char** argv)
// argv[1] is script file
// argv[2] is .src name
// argv[3] is error filename

{
 if (argc < 3) {
   cout << "Usage:  custom1 <script filename> <source filename> [error filename]";
   exit(1);
   }
 if (argc >= 4) {
   freopen(argv[3], "w", stdout);  //redirect output to error file
   exit_flag = 0;   // won't need hold up on exit
   }

 checkMemory();

 readScriptFile(argv[1]);  //argv(1) is temporary script file

 outf.open(argv[2], ios::out);
 if (!outf.good())
   cout << "Can't open source file" << endl;

 writeSource();
 outf.close();
 cout << "completed" << endl;
 return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -