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

📄 ex-dialogs.ulp

📁 老外的PCB设计软件,是免费的.可以上网更新.
💻 ULP
📖 第 1 页 / 共 2 页
字号:
#usage "<b>Example: Dialogs</b>\n"
       "<p>"
       "<author>Author: support@cadsoft.de</author>"

// THIS PROGRAM IS PROVIDED AS IS AND WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED

// Revision 1 : Path for bitmap corrected   30.03.2005 support@cadsoft.de

string cmd = "";
int Value = 42;
int Wert = 7;
int Val = 0;
string st = "";
int Result = 0;
string msg = "";

string Colors[] = { "red"
                    , "green", "blue", "pink"
                    , "yellow", "cyan", "magenta"
                    , "brown", "white", "black"
                    , "gray", "orange"
                    };

int Selected = 2; // initially selects "blue"

string Text = "example text";

int Lines = 0;

// Checkboxes in Dialog
int mirror = 0;
int rotate = 1;
int flip   = 0;
int black  = 1;
int swap   = 1;
int solid  = 0;
int scaled = 0;
int align = 0;

//use dlgRadioButton only in dlgGroup!

Result = dlgDialog("EAGLE Version 4 / ULP Demonstration") {
  dlgHBoxLayout {
     dlgStretch(0);
     dlgGroup("Use RadioButton only in dlgGroup!") {
        dlgStretch(0);
        dlgGridLayout {
           dlgCell(1, 1)  dlgRadioButton("&Top", align);
           dlgCell(2, 0)  dlgRadioButton("&Left ", align);
           dlgCell(2, 1)  dlgRadioButton("&Center", align);
           dlgCell(2, 2)  dlgRadioButton("&Right ", align);
           dlgCell(3, 1)  dlgRadioButton("&Bottom", align);
           //                         30 pixels fixed distance
           dlgCell(1, 6) { dlgSpacing(30); dlgCheckBox("R&otate", rotate); };
           dlgCell(2, 6) { dlgSpacing(30); dlgCheckBox("&Mirror", mirror); };
           dlgCell(3, 6) { dlgSpacing(30); dlgCheckBox("&Flip", flip); };
           }
        }
     dlgStretch(0);
     dlgVBoxLayout {
        dlgHBoxLayout {
           dlgSpacing(20);
           dlgStretch(0);
           dlgPushButton("+OK") dlgAccept();
           dlgStretch(1);
           }
        dlgHBoxLayout {
           dlgSpacing(20);
           dlgStretch(0);
           dlgPushButton("-ESC") dlgReject();
           dlgStretch(1);
           }
        }
     dlgStretch(1);
     }
   dlgStretch(1);
  };
if (Result == 0) exit (0);

// a complex menu
// default is VBoxLayout

Text += "\nextend example text with Text+=...";
align = 0;
Result = dlgDialog("Version 4 - ULP test"){
   dlgStretch(0);                             // no dynamic distance on top
   dlgHBoxLayout {
      dlgStretch(0);                          // no dynamic distance on left border
      dlgLabel("<img src=eagle.bmp>");        // display a BMP file
      dlgStretch(0);                          // no dynamic distance to next object
      dlgGroup("ULP-Test Edit") {             // start a group
         dlgHBoxLayout dlgSpacing(600);       // make 600 pixel spacing
         dlgHBoxLayout {                      // horizontal direction in horizontal direction
            dlgVBoxLayout dlgSpacing(300);    // a vertical Box 300 pixels high
            dlgTextEdit(Text);                // editor window 600 x 300 pixels
            }
         }
      dlgStretch(1);                          // dynamic distance to the right border
      }
   dlgHBoxLayout {
      dlgStretch(0);                          // no dynamic distance allowed
      dlgGroup("ULP-Test Radio") {            // start a frame for a group
         dlgHBoxLayout dlgSpacing(100);       // a horizontle box min. 100 pixels wide
                            // Minimum is 80 pixels (by Windows/Microsoft)
                            // is the displayed Text in Combobox larger than 80 pixels
                            // then the Box width is automatically extended

         dlgLabel("&Color");                  // the & character marks the ALT-Key
         dlgComboBox(Colors, Selected);
         dlgRadioButton("&Center", align);
         dlgRadioButton("&Bottom", align);
         }
      dlgSpacing(20);
      dlgStretch(0);
      dlgVBoxLayout {
         dlgStretch(1);
         dlgCheckBox("&Mirror", mirror);
         dlgStretch(0);
         dlgCheckBox("&Rotate", rotate);
         dlgStretch(1);
         }
      dlgSpacing(10);
      dlgStretch(0);
      dlgLabel("Enter a &Number between 0 and 99");
      dlgSpacing(5);
      dlgStretch(0);
      dlgHBoxLayout {
         dlgIntEdit(Value, 0, 99);
         }
      dlgSpacing(10);
      dlgStretch(0);
      dlgGroup("Reset") {
         dlgStretch(0);
         dlgLabel("change values, press reset and look");
         dlgStretch(1);
         dlgPushButton("Reset")  dlgReset();
         dlgStretch(1);
         }
      dlgStretch(1);
      }
   dlgStretch(0);
   dlgSpacing(10);
   dlgHBoxLayout {
      dlgStretch(0);
      dlgSpacing(550);
      dlgPushButton("+OK") dlgAccept();
      dlgStretch(0);
      dlgSpacing(25);
      dlgPushButton("-Cancel") dlgReject();
      dlgStretch(1);
      }
   dlgStretch(1);
   };
if (Result == 0) exit (0);

// Dialog window with Button

align = 0;
Text = "\n\nCELL example\ndefine cells\n";

Result = dlgDialog(" EAGLE Version 4 / GRID/CELL Demonstration"){
  dlgGridLayout {                           // Grid & Cell
    dlgCell(0, 0) dlgLabel("Cell 0,0");
    dlgCell(0, 1) dlgLabel("Cell 0,1");
    dlgCell(0, 2) dlgLabel("Cell 0,2");
    dlgCell(0, 3) dlgLabel("Cell 0,3");
    dlgCell(0, 4) dlgLabel("Cell 0,4");
    dlgCell(0, 5) dlgLabel("Cell 0,5");
    dlgCell(0, 6) dlgLabel("Cell 0,6");
    dlgCell(0, 7) dlgLabel("Cell 0,7");
    dlgCell(0, 8) dlgLabel("Cell 0,8");
    dlgCell(0, 9) dlgLabel("Cell 0,9");
    dlgCell(0, 10) dlgLabel("Cell 0,10");
    dlgCell(0, 11) dlgLabel("Cell 0,11");

    dlgCell(1, 0) dlgLabel("Cell 1,0");
    dlgCell(2, 0) dlgLabel("Cell 2,0");
    dlgCell(3, 0) dlgLabel("Cell 3,0");
    dlgCell(4, 0) dlgLabel("Cell 4,0");
    dlgCell(5, 0) dlgLabel("Cell 5,0");
    dlgCell(6, 0) dlgLabel("Cell 6,0");
    dlgCell(7, 0) dlgLabel("Cell 7,0");
    dlgCell(8, 0) dlgLabel("Cell 8,0");
    dlgCell(9, 0) dlgLabel("Cell 9,0");
    dlgCell(10, 0) dlgLabel("Cell 10,0");
    dlgCell(11, 0) dlgLabel("Cell 11,0");

    dlgCell(1, 2, 4, 6) dlgTextEdit(Text);
    dlgCell(1, 8) dlgComboBox(Colors, Selected);
    dlgCell(2, 8) dlgCheckBox("&Mirror", mirror);
    dlgCell(3, 8) dlgCheckBox("&Rotate", rotate);

    dlgCell(4, 8, 4, 8) dlgGroup("Gruop") {
      dlgGridLayout {
         dlgCell(6, 8)  dlgRadioButton("&Top", align);
         dlgCell(7, 8)  dlgRadioButton("&Center", align);
         dlgCell(8, 8)  dlgRadioButton("&Bottom", align);
         }
      }

    dlgCell(6, 4) dlgPushButton("+OK") dlgAccept();
    dlgCell(7, 4) dlgPushButton("-CANCEL\n\nStop ULP\nand\nExit") dlgReject();
    dlgCell(7, 2) dlgPushButton("Reset")  dlgReset();
    dlgCell(1, 1) dlgLabel("<img src=eagle.bmp>");
    dlgCell(1, 8) dlgLabel("<img src=eagle.bmp>");
    dlgCell(9, 1) dlgLabel("<img src=eagle.bmp>");
    dlgCell(9, 8) dlgLabel("<img src=eagle.bmp>");

    }
  dlgLabel("a small example for Grid & Cell");
 };
if (Result == 0) exit (0);

Result = dlgDialog("Checkbox Demonstration"){
  dlgGroup("Orientation and Print") {
    dlgCheckBox("&Mirror", mirror);
    dlgCheckBox("&Rotate", rotate);
    dlgCheckBox("&Flip", flip);
    dlgCheckBox("&Black", black);
    dlgCheckBox("&Solid", solid);
    dlgCheckBox("S&caled", scaled);
    }
  dlgVBoxLayout {
    dlgHBoxLayout {
      dlgStretch(1);
      dlgPushButton("+OK") dlgAccept();
      dlgStretch(0);
      }
    dlgHBoxLayout {
      dlgStretch(1);
      dlgPushButton("-Cancel") dlgReject();
      dlgStretch(0);
      }
    }
  };
if (Result == 0) exit (0);


// Comboboxes
Result = dlgDialog("Combobox"){
  dlgComboBox(Colors, Selected);
  dlgVBoxLayout {
    dlgHBoxLayout {
      dlgStretch(1);
      dlgPushButton("+OK") dlgAccept();
      dlgStretch(0);
      }
    dlgHBoxLayout {
      dlgStretch(1);
      dlgPushButton("-Cancel") dlgReject();
      dlgStretch(0);
      }
    }
  };
if (Result == 0) exit (0);

// GridLayout - define cell by cell content

Result = dlgDialog("Grid Layout"){
  dlgGridLayout {
    dlgCell(0, 0) dlgLabel("Row 0/Col 0");
    dlgCell(1, 0) dlgLabel("Row 1/Col 0");
    dlgCell(0, 4) dlgLabel("Row 0/Col 4");
    dlgCell(5, 5) dlgLabel("Row 5/Col 5");
    dlgCell(10, 20) dlgPushButton("+OK") dlgAccept();
    dlgCell(10, 24) dlgPushButton("-Cancel") dlgReject();
    }
  };
if (Result == 0) exit (0);

// input a Integer-Value
Result = dlgDialog("IntEdit"){
  dlgHBoxLayout {
    dlgLabel("Enter a &Number between 0 and 99");
    dlgIntEdit(Value, 0, 99);
    }
  dlgVBoxLayout {
    dlgHBoxLayout {
      dlgStretch(1);
      dlgPushButton("+OK") dlgAccept();
      dlgStretch(0);
      }
    dlgHBoxLayout {
      dlgStretch(1);
      dlgPushButton("-Cancel") dlgReject();
      dlgStretch(0);
      }
    }
  };
if (Result == 0) exit (0);

// List box selection field
Result = dlgDialog("List Box") {
   dlgListBox(Colors, Selected)
   dlgAccept();
   };
dlgMessageBox("selected Color " + Colors[Selected]);
if (Result == 0) exit (0);


//Multi column list view selection field
string Colours[] = { "red\tThe color RED", "green\tThe color GREEN", "blue\tThe color BLUE" };

Selected = 1;
Result = dlgDialog("ListView") {
  dlgListView("Name\tDescription", Colours, Selected) dlgAccept();
  dlgPushButton("+OK") dlgAccept();
  };
dlgMessageBox("last selected\n" + Colours[Selected]);
if (Result == 0) exit (0);


// Predefined Button OK
Result = dlgDialog("Hello") {
  dlgLabel("Hello world");
  dlgPushButton("+OK") dlgAccept();
              // look at the '+' character
  };

// Radio Button
// can be used only in a dglGroup
align = 0;

Result = dlgDialog("RadioButton") {
    dlgGroup("Alignment") {
      dlgRadioButton("&Top", align);

⌨️ 快捷键说明

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