Advertisement
Guest User

Gio PEt

a guest
Mar 17th, 2010
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 25.52 KB | None | 0 0
  1. {SMART PASTE_Command to control the automatic creation of new classes when Copy/Pasting across Drawings.
  2. Copyright (C) 2010  Giovanni Petrolito}
  3.  
  4.  
  5. PROCEDURE Smart_Paste;
  6.  
  7.  
  8.  
  9.  
  10. VAR
  11.         ClassNames                      :DYNARRAY[] of STRING;
  12.         NewClassNames                   :DYNARRAY[] of STRING;
  13.         ExtraClassNames                 :DYNARRAY[] of STRING;
  14.        
  15.        
  16.         { Variables to Generate Undo History }      
  17.         ButtonChoice                    :ARRAY[1..100] of STRING;
  18.         ClassRecord                     :ARRAY[1..100] of STRING;
  19.         IndexRecord                     :ARRAY[1..100] of INTEGER;
  20.         Click_Count                     :INTEGER;
  21.        
  22.         { Global Variables for Assign Class and Add Class Procedures }
  23.         OldClass                        :STRING;
  24.         NewClass                        :STRING;
  25.         to_be_assigned                  :STRING;
  26.         assign_to                       :STRING;
  27.        
  28.         countClasses, NewcountClasses   :INTEGER;
  29.         diff, StartClass                :INTEGER;
  30.         index                           :INTEGER;
  31.         ClassOptions                    :INTEGER;
  32.        
  33.        
  34.         { Variables to Create Resource Lists }
  35.         ResourceName1:      String;
  36.         ResourceName2:      String;
  37.         ResourceList1:      LongInt;
  38.         ResourceList2:  LongInt;
  39.         NumItems:   LongInt;
  40.         NumItems2:  LongInt;
  41.        
  42.        
  43.         Didcancel    :BOOLEAN;
  44.         canceled     :BOOLEAN;
  45.        
  46.  
  47.  
  48.        
  49.        
  50.                
  51. { ***************************************************************************************************************** }        
  52.                 { BEGINNING OF SUB-PROCEDURES }        
  53. { ***************************************************************************************************************** }        
  54.        
  55.  
  56.  
  57.         PROCEDURE ResourceList_Existing_Classes;
  58.         Const
  59.             ObjectType=94;   {Class Definintion}
  60.             FolderIndex=3;   {BuildResourceList Def for Plug-ins Data Folder See Func. Ref}
  61.             SubFolderName='';    {Nul subfolder get all folders and subfolders}
  62.  
  63.         VAR
  64.                 x       :INTEGER;
  65.                
  66.         BEGIN
  67.             ResourceList1:=BuildResourceList(ObjectType,FolderIndex,'',NumItems);
  68.        
  69.                 For x:=1 to NumItems Do Begin
  70.                     ResourceName1:=GetNameFromResourceList(ResourceList1,x);
  71.                 end;
  72.         END;
  73.  
  74. { ***************************************************************************************************************** }      
  75.  
  76.         PROCEDURE ResourceList_Extra_Classes;  
  77.         Const
  78.             ObjectType=94;   {Class Definintion}
  79.             FolderIndex=3;   {BuildResourceList Def for Plug-ins Data Folder See Func. Ref}
  80.             SubFolderName='';    {Nul subfolder get all folders and subfolders}
  81.         VAR
  82.                 x       :INTEGER;
  83.                 y       :INTEGER;
  84.                
  85.         BEGIN
  86.             ResourceList2:=BuildResourceList(ObjectType,FolderIndex,'',NumItems2);
  87.    
  88.                 For x:=1 to NumItems Do Begin
  89.                 ResourceName1:=GetNameFromResourceList( ResourceList1,x);
  90.        
  91.                 For y:=1 to NumItems2 Do Begin
  92.                     ResourceName2:=GetNameFromResourceList(ResourceList2,y);
  93.                
  94.                     IF ResourceName2=ResourceName1 Then DeleteResourceFromList(ResourceList2,y);
  95.                 End;   
  96.             End;
  97.             NumItems2:=ResourceListSize(ResourceList2);
  98.         END;
  99.  
  100. { ***************************************************************************************************************** }
  101.  
  102.        
  103.        
  104.         PROCEDURE dialog1_Main;
  105.        
  106.         CONST
  107.             kStartStringAt = 3000;
  108.             kOK           = 1;
  109.             kCancel       = 2;
  110.             kUndo_Btn     = 4;
  111.             kPaste_Btn    = 5;
  112.             kAssign       = 6;
  113.             kGroupBox7    = 7;
  114.             kGroupBox14   = 14;
  115.             kGroupBox15   = 15;
  116.             kGroupBox25   = 25;
  117.             kGroupBox26   = 26;
  118.             kNEWclsnm     = 40;
  119.             kEXclsnm      = 41;
  120.             kStaticText63 = 63;
  121.             kStaticText64 = 64;
  122.            
  123.  
  124.             kRight        = 1;
  125.             kBottom       = 2;
  126.             kLeft         = 3;
  127.             kResize       = 0;
  128.             kShift        = 1;
  129.  
  130.             kTextOnly     = 0;
  131.             kIconOnly     = 1;
  132.             kTextIcon     = 3;
  133.             kStatic       = 1;
  134.             kRadio        = 2;
  135.             kMulti        = 3;
  136.             kCol0         = 0;
  137.             kCol1         = 1;
  138.             kRow1         = 1;
  139.         VAR
  140.             dialog1             :INTEGER;
  141.             kImageCheckNEW      :INTEGER;
  142.             kImageBlankNEW      :INTEGER;
  143.             kImageSheetNEW      :INTEGER;
  144.             kImageViewNEW       :INTEGER;
  145.    
  146.             kImageCheckEX       :INTEGER;
  147.             kImageBlankEX       :INTEGER;
  148.             kImageSheetEX       :INTEGER;
  149.             kImageViewEX        :INTEGER;
  150.    
  151.             cnt                 :INTEGER;
  152.             int                 :INTEGER;
  153.             ndx                 :INTEGER;
  154.    
  155.             numOfClass          :INTEGER;
  156.             classname           :INTEGER;
  157.    
  158.             xmlID               :LONGINT;
  159.    
  160.             boo                 :BOOLEAN;
  161.             Select_more         :BOOLEAN;
  162.             Select_one          :BOOLEAN;
  163.             str                 :STRING;
  164.            
  165.    
  166.             {$Include _DialogBuilderUtilities.txt}
  167.  
  168.  
  169.  
  170.             FUNCTION GetPlugInString(ndx :INTEGER) :STRING;
  171.                 BEGIN
  172.                 CASE ndx OF
  173.                     {Static Text}
  174.                     3001: GetPlugInString := 'OK';
  175.                     3002: GetPlugInString := 'Cancel';
  176.                     3003: GetPlugInString := 'Smart Paste © 2010 GioPEt';
  177.                     3004: GetPlugInString := 'Undo';
  178.                     3005: GetPlugInString := 'Add';
  179.                     3006: GetPlugInString := 'Assign';
  180.                     3007: GetPlugInString := '  Controls';
  181.                     3014: GetPlugInString := 'Untitled';
  182.                     3015: GetPlugInString := 'Untitled';
  183.                     3025: GetPlugInString := '';
  184.                     3026: GetPlugInString := '';
  185.                    
  186.                     3063: GetPlugInString := 'New Incoming Classes:';
  187.                     3064: GetPlugInString := 'Existing Classes:';
  188.                    
  189.                     {Help Text}
  190.                     4001: GetPlugInString := 'Closes this dialog.';
  191.                     4002: GetPlugInString := 'Cancels the operation without changes.';
  192.                     4004: GetPlugInString := 'The selected Incoming classes will be assigned to the selected Existing Class.';
  193.                     4005: GetPlugInString := 'The selected Incoming classes will be added to the current Drawing.';
  194.                     4006: GetPlugInString := 'Undo the previous action.';
  195.                     4007: GetPlugInString := '';
  196.                     4014: GetPlugInString := '';
  197.                     4015: GetPlugInString := '';
  198.                     4025: GetPlugInString := 'A group box control.';
  199.                     4026: GetPlugInString := 'A group box control.';
  200.                     4040: GetPlugInString := 'A list box control.';
  201.                     4041: GetPlugInString := 'A list box control.';
  202.                     4063: GetPlugInString := 'Static text control.';
  203.                     4064: GetPlugInString := 'Static text control.';
  204.                 END;
  205.             END;
  206.  
  207. { ***************************************************************************************************************** }
  208.  
  209.             FUNCTION GetStr(ndx :INTEGER) :STRING;
  210.                 BEGIN
  211.                     GetStr := GetPlugInString(ndx + kStartStringAt);
  212.                 END;
  213.  
  214. { ***************************************************************************************************************** }
  215.  
  216.             PROCEDURE dialog1_Setup;
  217.                 BEGIN
  218.                     dialog1 := CreateResizableLayout(GetStr( 3), TRUE, GetStr(kOK), GetStr(kCancel), FALSE, TRUE);
  219.                    
  220.                     CreatePushButton          (dialog1, kUndo_Btn,      GetStr(kUndo_Btn));
  221.                     CreatePushButton          (dialog1, kPaste_Btn,     GetStr(kPaste_Btn));
  222.                     CreatePushButton          (dialog1, kAssign,        GetStr(kAssign));
  223.                     CreateGroupBox            (dialog1, kGroupBox7,     GetStr(kGroupBox7), TRUE);
  224.                     CreateGroupBox            (dialog1, kGroupBox14,    GetStr(kGroupBox14), FALSE);
  225.                     CreateGroupBox            (dialog1, kGroupBox15,    GetStr(kGroupBox15), FALSE);
  226.                     CreateGroupBox            (dialog1, kGroupBox25,    GetStr(kGroupBox25), TRUE);
  227.                     CreateGroupBox            (dialog1, kGroupBox26,    GetStr(kGroupBox26), TRUE);
  228.                    
  229.                     CreateLB                  (dialog1, kNEWclsnm,      32, 10);
  230.                     CreateLB                  (dialog1, kEXclsnm,       32, 10);
  231.                     EnableLBSorting(dialog1, kNEWclsnm, FALSE);
  232.                     EnableLBSorting(dialog1,  kEXclsnm, FALSE);
  233.                     CreateStaticText          (dialog1, kStaticText63,  GetStr(kStaticText63), -1);
  234.                     CreateStaticText          (dialog1, kStaticText64,  GetStr(kStaticText64), -1);
  235.                    
  236.                     SetFirstLayoutItem(dialog1, kGroupBox15);
  237.                     SetFirstGroupItem (dialog1, kGroupBox15,    kGroupBox26);
  238.                     SetFirstGroupItem (dialog1, kGroupBox26,    kStaticText63);
  239.                     SetBelowItem      (dialog1, kStaticText63,  kNEWclsnm,      0, 0);
  240.                     SetRightItem      (dialog1, kGroupBox26,    kGroupBox7,     0, 0);
  241.    
  242.                     SetFirstGroupItem (dialog1, kGroupBox7,     kAssign);
  243.                     SetBelowItem (dialog1, kGroupBox7,     kPaste_Btn, 3.25, -40 );
  244.                     SetRightItem (dialog1,kPaste_Btn,     kUndo_Btn, -11.47, 10 );
  245.    
  246.                     SetRightItem      (dialog1, kGroupBox7,     kGroupBox14,    0, 0);
  247.                     SetFirstGroupItem (dialog1, kGroupBox14,    kGroupBox25);
  248.                     SetFirstGroupItem (dialog1, kGroupBox25,    kStaticText64);
  249.                     SetBelowItem      (dialog1, kStaticText64,  kEXclsnm,       0, 0);
  250.                    
  251.  
  252.                     AlignItemEdge(dialog1, kNEWclsnm,      kLeft,    2, kResize);
  253.                     AlignItemEdge(dialog1, kEXclsnm,       kRight,   2, kResize);
  254.  
  255.                     SetEdgeBinding        (dialog1, kUndo_Btn,      FALSE, FALSE, FALSE, FALSE);
  256.                     SetEdgeBinding        (dialog1, kPaste_Btn,     FALSE, FALSE, FALSE, FALSE);
  257.                     SetEdgeBinding        (dialog1, kAssign,        FALSE, FALSE, FALSE, FALSE);
  258.                     SetEdgeBinding        (dialog1, kGroupBox14,    TRUE, TRUE, TRUE, TRUE);
  259.                     SetEdgeBinding        (dialog1, kGroupBox15,    TRUE, TRUE, TRUE, TRUE);
  260.                     SetEdgeBinding        (dialog1, kGroupBox25,    TRUE, TRUE, TRUE, TRUE);
  261.                     SetEdgeBinding        (dialog1, kGroupBox26,    TRUE, TRUE, TRUE, TRUE);
  262.                     SetEdgeBinding        (dialog1, kNEWclsnm,      TRUE, TRUE, TRUE, TRUE);
  263.                     SetEdgeBinding        (dialog1, kEXclsnm,       TRUE, TRUE, TRUE, TRUE);
  264.                     SetEdgeBinding        (dialog1, kStaticText63,  FALSE, FALSE, TRUE, FALSE);
  265.                     SetEdgeBinding        (dialog1, kStaticText64,  FALSE, FALSE, TRUE, FALSE);
  266.                    
  267.                    
  268.                     SetProportionalBinding(dialog1, kNEWclsnm,      FALSE, FALSE, FALSE, FALSE);
  269.                     SetProportionalBinding(dialog1, kEXclsnm,       FALSE, FALSE, FALSE, FALSE);
  270.    
  271.                     FOR cnt := 1 TO 15 DO SetHelpString(cnt, GetStr(cnt + 1000));
  272.                 END;
  273.  
  274.             { ***************************************************************** }
  275.                         { PROCEDURES TO DEFINE BUTTONS BEHAVIOUR }
  276.             { ***************************************************************** }
  277.  
  278.             PROCEDURE Assign_Button;
  279.        
  280.             Var
  281.                     Selection, Remove, Assign   :Boolean;
  282.                        
  283.             Sel_ndx, Sel_cls            :Integer;
  284.            
  285.             temp_ndx1, temp_ndx2        :Integer;
  286.             temp_cls1, temp_cls2        :string;
  287.             list_name                   :STRING;       
  288.             list_image                  :Integer;      
  289.             list_number                 :INTEGER;
  290.            
  291.             LOC_ClassArray              :DYNARRAY[] of STRING;
  292.             LOC_ClassIndex              :DYNARRAY[] of INTEGER;
  293.            
  294.             atChoice    :Integer;
  295.             h           :handle;
  296.             x           :Integer;
  297.            
  298.            
  299.            
  300.             Procedure AssignThem(h :HANDLE);
  301.                 begin
  302.                     if GetClass(h) = LOC_ClassArray[x]  then SetClass(h, assign_to);
  303.                    
  304.                 end;
  305.            
  306.                
  307.                 BEGIN
  308.                     IF GetNumSelectedLBItems(dialog1, kEXclsnm)<>0 THEN BEGIN
  309.                            
  310.                         list_number := GetNumLBItems(dialog1, kEXclsnm);
  311.                                
  312.                         For atChoice:=0 to list_number Do Begin
  313.                             Selection := IsLBItemSelected(dialog1, kEXclsnm, atChoice);
  314.                                    
  315.                             If  Selection=True Then Begin
  316.                                 Assign := GetLBItemInfo(dialog1, kEXclsnm, atChoice, kCol0, assign_to, list_image);
  317.                                 x:=1;
  318.                             End;   
  319.                                
  320.                         End;
  321.                                
  322.                     IF GetNumLBItems(dialog1, kNEWclsnm)<>0 THEN BEGIN
  323.                            
  324.                         list_number := GetNumLBItems(dialog1, kNEWclsnm);
  325.                         Sel_cls := GetNumSelectedLBItems(dialog1, kNEWclsnm);
  326.                    
  327.                         if  Sel_cls=0 Then BEGIN
  328.                             AlrtDialog('No classes selected');
  329.                         End;
  330.                                
  331.                         if  Sel_cls>0 Then BEGIN
  332.                                    
  333.                    
  334.                             ALLOCATE LOC_ClassArray[1..Sel_cls];
  335.                             ALLOCATE LOC_ClassIndex[1..Sel_cls];
  336.                             Sel_ndx:=1;    
  337.                            
  338.                             For atChoice:=0 to list_number Do Begin
  339.                                 Selection := IsLBItemSelected(dialog1, kNEWclsnm, atChoice);
  340.                                
  341.                                 If  Selection=True Then Begin
  342.                                     Assign := GetLBItemInfo(dialog1, kNEWclsnm, atChoice, kCol0, to_be_assigned, list_image);
  343.                        
  344.                                     LOC_ClassArray[Sel_ndx] := to_be_assigned;  
  345.                                     LOC_ClassIndex[Sel_ndx] := atChoice;
  346.                    
  347.                                     Sel_ndx:=Sel_ndx+1;    
  348.                                    
  349.                                     { Send Selection to Global Variables for Undo History}
  350.                                    
  351.                                     Click_Count:=(Click_Count+1);  
  352.                                     ButtonChoice[Click_Count]:='Assign';
  353.                                     ClassRecord[Click_Count]:=to_be_assigned;
  354.                                 End;
  355.                        
  356.                             End;
  357.                        
  358.                             Sel_ndx:=(Sel_cls);
  359.                        
  360.                        
  361.                             {Sort the Array in Descending order to allow DeleteLBItem work in a
  362.                             Loop }
  363.                        
  364.                             For x:=1 to Sel_cls do BEGIN
  365.                        
  366.                                 if x<Sel_ndx Then Begin
  367.                            
  368.                            
  369.                                     temp_ndx1 := LOC_ClassIndex[Sel_ndx];
  370.                                     temp_cls1 := LOC_ClassArray[Sel_ndx];
  371.                            
  372.                                     temp_ndx2 := LOC_ClassIndex[x];
  373.                                     temp_cls2 := LOC_ClassArray[x];
  374.                                
  375.                                     LOC_ClassIndex[x] := temp_ndx1;
  376.                                     LOC_ClassArray[x] := temp_cls1;
  377.                            
  378.                                     LOC_ClassIndex[Sel_ndx] := temp_ndx2;
  379.                                     LOC_ClassArray[Sel_ndx] := temp_cls2;
  380.                                 End;   
  381.                                 Sel_ndx:=(Sel_ndx-1);
  382.                             End;    
  383.                            
  384.                                
  385.                             For x:=1 to Sel_cls Do BEGIN
  386.                                 ForEachObject(AssignThem, SEL);
  387.                                 DelClass(LOC_ClassArray[x]);
  388.                                
  389.                                 Remove:=DeleteLBItem(dialog1, kNEWclsnm, LOC_ClassIndex[x]);
  390.                                
  391.                             End;
  392.                            
  393.                            
  394.                         End;
  395.            
  396.                     END ELSE BEGIN
  397.                         AlrtDialog('No more classes need to be reassigned');
  398.                     End;   
  399.            
  400.                 END ELSE BEGIN
  401.                     AlrtDialog('SELECT ONE OF THE EXISTING CLASSES');
  402.                 End;
  403.             End;
  404.            
  405. { ***************************************************************************************************************** }                          
  406.             Procedure   Add_Button;
  407.             Var
  408.                 Selection, Remove, Assign   :Boolean;
  409.                 Add                         :Integer;
  410.            
  411.                 Sel_ndx, Sel_cls            :Integer;
  412.            
  413.                 temp_ndx1, temp_ndx2        :Integer;
  414.                 temp_cls1, temp_cls2        :string;
  415.                 list_name                   :STRING;       
  416.                 list_image                  :Integer;      
  417.                 list_number                 :INTEGER;
  418.            
  419.                 LOC_ClassArray              :DYNARRAY[] of STRING;
  420.                 LOC_ClassIndex              :DYNARRAY[] of INTEGER;
  421.                
  422.                 atChoice    :Integer;
  423.                 h           :handle;
  424.                 x           :Integer;
  425.                 beginningfile :Integer;
  426.        
  427.             BEGIN
  428.            
  429.                 IF GetNumLBItems(dialog1, kNEWclsnm)<>0 THEN BEGIN
  430.                     list_number := GetNumLBItems(dialog1, kNEWclsnm);
  431.                     Sel_cls := GetNumSelectedLBItems(dialog1, kNEWclsnm);
  432.                    
  433.                         if  Sel_cls=0 Then BEGIN
  434.                             AlrtDialog('No classes Selected');
  435.                         End;
  436.                                
  437.                     if  Sel_cls>0 Then BEGIN
  438.                         ALLOCATE LOC_ClassArray[1..Sel_cls];
  439.                         ALLOCATE LOC_ClassIndex[1..Sel_cls];
  440.                
  441.                         Sel_ndx:=1;    
  442.                         For atChoice:=0 to list_number Do Begin
  443.                             Selection := IsLBItemSelected(dialog1, kNEWclsnm, atChoice);
  444.                                
  445.                             If  Selection=True Then Begin
  446.                                 Assign := GetLBItemInfo(dialog1, kNEWclsnm, atChoice, kCol0, to_be_assigned, list_image);
  447.                        
  448.                                 LOC_ClassArray[Sel_ndx] := to_be_assigned;  
  449.                                 LOC_ClassIndex[Sel_ndx] := atChoice;
  450.                                
  451.                                 Sel_ndx:=Sel_ndx+1;
  452.                             End;
  453.                         End;
  454.                    
  455.                         Sel_ndx:=(Sel_cls);
  456.    
  457.                         {Sort the Array in Descending order to allow DeleteLBItem work in a Loop }
  458.                         For x:=1 to Sel_cls do BEGIN
  459.                        
  460.                             if x<Sel_ndx Then Begin
  461.                                                        
  462.                                 temp_ndx1 := LOC_ClassIndex[Sel_ndx];
  463.                                 temp_cls1 := LOC_ClassArray[Sel_ndx];
  464.                            
  465.                                 temp_ndx2 := LOC_ClassIndex[x];
  466.                                 temp_cls2 := LOC_ClassArray[x];
  467.                                
  468.                                 LOC_ClassIndex[x] := temp_ndx1;
  469.                                 LOC_ClassArray[x] := temp_cls1;
  470.                            
  471.                                 LOC_ClassIndex[Sel_ndx] := temp_ndx2;
  472.                                 LOC_ClassArray[Sel_ndx] := temp_cls2;
  473.                             End;   
  474.                             Sel_ndx:=(Sel_ndx-1);
  475.                         End;    
  476.                        
  477.                        
  478.                         For x:=1 to Sel_cls Do Begin
  479.                             { Send Selection to Global Variables for Undo History}
  480.                             Click_Count:=(Click_Count+1);
  481.                             ButtonChoice[Click_Count]:='Add';
  482.                             ClassRecord[Click_Count]:=LOC_ClassArray[x];
  483.                             IndexRecord[Click_Count]:=LOC_ClassIndex[x];
  484.                            
  485.                             Remove:=DeleteLBItem(dialog1, kNEWclsnm, LOC_ClassIndex[x]);
  486.                             Add:=InsertLBItem(dialog1, kEXclsnm, 0,LOC_ClassArray[x]);
  487.                         End;
  488.                     End;
  489.                
  490.                     END ELSE BEGIN
  491.                         IF GetNumLBItems(dialog1, kNEWclsnm)=0 THEN BEGIN
  492.                             AlrtDialog('No more classes can be added');
  493.                             END ELSE BEGIN
  494.                                 AlrtDialog('SELECT ONE OF THE EXISTING CLASSES');
  495.                         End;
  496.                     END;
  497.             END;
  498.                    
  499. { **************************************************************************************************************** }
  500.  
  501.         Procedure Undo_Button;
  502.         VAR
  503.             ArrangeChoice                   :ARRAY[1..100] of String;
  504.             ArrangeClass                    :ARRAY[1..100] of STRING;
  505.             ArrangeIndex                    :ARRAY[1..100] of Integer;
  506.             Add     :Integer;
  507.             Remove  :Boolean;
  508.             x,y     :Integer;
  509.            
  510.            
  511.            
  512.             temp_ch1, temp_ch2      :String;
  513.             temp_cls1, temp_cls2    :string;
  514.             temp_ndx1, temp_ndx2    :Integer;
  515.             Counter                 :Integer;
  516.        
  517.         BEGIN
  518.             If Click_Count<=0 then BEGIN
  519.             AlrtDialog('NOTHING TO UNDO!');
  520.            
  521.             END ELSE BEGIN
  522.                 {Duplicate Array for sorting}
  523.                 For x:=1 to 100 do begin
  524.                     ArrangeChoice[x]:=ButtonChoice[x];
  525.                     ArrangeClass[x]:=ClassRecord[x];
  526.                     ArrangeIndex[x]:=IndexRecord[x];
  527.                 End;
  528.            
  529.                 {Sort the Array in Descending order to Build Undo History}
  530.                 Counter:=Click_Count;  
  531.            
  532.                 For x:=1 to Click_Count do BEGIN
  533.                        
  534.                     if x<=Counter Then Begin
  535.                                                        
  536.                         temp_ch1 := ArrangeChoice[Counter];
  537.                         temp_cls1 := ArrangeClass[Counter];
  538.                         temp_ndx1 := ArrangeIndex[Counter];
  539.                            
  540.                         temp_ch2 := ArrangeChoice[x];
  541.                         temp_cls2 := ArrangeClass[x];
  542.                         temp_ndx2 := ArrangeIndex[x];
  543.                                
  544.                         ArrangeChoice[x] := temp_ch1;
  545.                         ArrangeClass[x] := temp_cls1;
  546.                         ArrangeIndex[x] := temp_ndx1;
  547.                            
  548.                         ArrangeChoice[Counter] := temp_ch2;
  549.                         ArrangeClass[Counter] := temp_cls2;
  550.                         ArrangeIndex[Counter] := temp_ndx2;
  551.                     End;   
  552.                     Counter:=(Counter-1);
  553.                                        
  554.                 End;    
  555.                     If ArrangeChoice[1]='Assign' Then BEGIN
  556.                         NameClass(ArrangeClass[1]);
  557.                         Add:=InsertLBItem(dialog1, kNewclsnm, 0,ArrangeClass[1t]);
  558.                        
  559.                         Click_Count:=(Click_Count-1);
  560.                
  561.                     End;
  562.                     If ArrangeChoice[1]='Add' Then BEGIN
  563.            
  564.                         Add:=InsertLBItem(dialog1, kNewclsnm, 0,ArrangeClass[1]);
  565.                         Remove:=DeleteLBItem(dialog1, kExclsnm, 0);
  566.                    
  567.                         Click_Count:=(Click_Count-1);
  568.                     End;   
  569.             End;
  570.         END;
  571.        
  572.        
  573. { **************************************************************************************************************** }
  574.  
  575.         { ***************************************************************** }
  576.                         { END DEFINITION OF BUTTONS BEHAVIOUR }
  577.         { ***************************************************************** }
  578.        
  579.         PROCEDURE dialog1_Handler(VAR item :LONGINT; data :LONGINT);
  580.  
  581.         Var
  582.             ColNum,TempI,I : Integer;
  583.             SheetTypeIcon : Integer;
  584.             BSB : Boolean;
  585.             BSS : String;
  586.             Selection : Boolean;
  587.  
  588.             LayerName,SelectedIconString : String;
  589.             SheetIconNumber,SelectedIconNumber : Integer;
  590.            
  591.            
  592.             atChoice    :Integer;
  593.             list_number :Integer;
  594.            
  595.             list_image  :Integer;
  596.             Assign      :Boolean;
  597.             x,y         :integer;
  598.            
  599.  
  600.         BEGIN
  601.             CASE item OF
  602.                 SetupDialogC:
  603.                     BEGIN
  604.  
  605.                         {Load images into kNEWclsnm.}
  606.                
  607.                         kImageCheckNEW := AddLBImage(dialog1, kNEWclsnm, 1, 11022);
  608.                         kImageBlankNEW := AddLBImage(dialog1, kNEWclsnm, 1, 11023);
  609.                         kImageSheetNEW := AddLBImage(dialog1, kNEWclsnm, 1, 11024);
  610.                         kImageViewNEW := AddLBImage(dialog1, kNEWclsnm, 1, 11025);
  611.                
  612.  
  613.                         {Define kNEWclsnm column 0.}
  614.                         cnt := InsertLBColumn        (dialog1, kNEWclsnm, kCol0, 'Class Name', 180);
  615.                         boo := SetLBControlType      (dialog1, kNEWclsnm, kCol0, kStatic);
  616.                         boo := SetLBItemDisplayType  (dialog1, kNEWclsnm, kCol0, kTextOnly);
  617.                
  618.                         {Initialize the rows to be used in kNEWclsnm.}
  619.                         FOR cnt := 1 TO NumItems2 DO BEGIN
  620.                             ResourceName2:=GetNameFromResourceList(ResourceList2,cnt);
  621.                             int := InsertLBItem(dialog1, kNEWclsnm, cnt, ResourceName2);
  622.                         END;
  623.  
  624.                         {Insert the data into the columns and assign them to the rows.}
  625.                         LB_SetCell(dialog1, kNEWclsnm, kCol0, kRow1, 'ClassList('')');
  626.  
  627.                         EnableLBColumnLines(dialog1, kNEWclsnm, TRUE);
  628.                
  629.                         {Load images into kEXclsnm.}
  630.                         kImageCheckEX := AddLBImage(dialog1, kEXclsnm, 1, 11022);
  631.                         kImageBlankEX := AddLBImage(dialog1, kEXclsnm, 1, 11023);
  632.                         kImageSheetEX := AddLBImage(dialog1, kEXclsnm, 1, 11024);
  633.                         kImageViewEX := AddLBImage(dialog1, kEXclsnm, 1, 11025);
  634.                
  635.                         {Define kEXclsnm column 0.}
  636.                         cnt := InsertLBColumn        (dialog1, kEXclsnm, kCol0, 'Class Name', 180);
  637.                         boo := SetLBControlType      (dialog1, kEXclsnm, kCol0, kStatic);
  638.                         boo := SetLBItemDisplayType  (dialog1, kEXclsnm, kCol0, kTextOnly);
  639.                
  640.                         {Initialize the rows to be used in kEXclsnm.}
  641.                         FOR cnt := 1 TO NumItems DO BEGIN
  642.                             ResourceName1:=GetNameFromResourceList(ResourceList1,cnt);
  643.                             int := InsertLBItem(dialog1, kEXclsnm, cnt, ResourceName1);
  644.                         END;
  645.  
  646.                         {Insert the data into the columns and assign them to the rows.}
  647.                         LB_SetCell(dialog1, kEXclsnm, kCol0, kRow1, 'ClassList('')');
  648.  
  649.                         EnableLBColumnLines(dialog1, kEXclsnm, TRUE);
  650.                
  651.                     END;
  652.        
  653.                 { ***************************************************************** }
  654.                             { CALL PROCEDURES OF BUTTONS BEHAVIOUR}
  655.                 { ***************************************************************** }
  656.                 kCancel:
  657.                     BEGIN
  658.                         canceled:=TRUE;
  659.                         Didcancel:=canceled;   
  660.                     END;
  661.            
  662.                 kUndo_Btn:
  663.                     BEGIN
  664.                         Undo_Button;           
  665.                     END;
  666.            
  667.                 kPaste_Btn:
  668.                         BEGIN
  669.                             Add_Button;
  670.                         END;
  671.            
  672.                 kAssign:
  673.                         BEGIN
  674.                             Assign_Button;
  675.                         END;
  676.  
  677.                 kOK:
  678.                     BEGIN
  679.                         IF GetNumLBItems(dialog1, kNEWclsnm)<>0 THEN Begin                     
  680.                         AlrtDialog('Please, Assign or Add the Incoming Classes!');
  681.                         dialog1_Main;
  682.                         end;
  683.                     END;
  684.            
  685.                 kNEWclsnm:
  686.                     BEGIN
  687.                     {Insert the data into the columns and assign them to the rows.}
  688.            
  689.                         For cnt:= 1 to numOfClass do
  690.                         LB_SetCell(dialog1, kNEWclsnm, 0, cnt, ClassList(cnt));
  691.                         EnableLBColumnLines(dialog1, kNEWclsnm, TRUE);
  692.                         Select_more:=EnableLBSingleLineSelection(dialog1, kNEWclsnm,FALSE);
  693.                     END;
  694.            
  695.                 kEXclsnm:
  696.                     BEGIN
  697.                     {Insert the data into the columns and assign them to the rows.}
  698.            
  699.                         For cnt:= 1 to numOfClass do
  700.                         LB_SetCell(dialog1, kEXclsnm, 0, cnt, ClassList(cnt));
  701.                         EnableLBColumnLines(dialog1, kEXclsnm, TRUE);
  702.                         Select_one:=EnableLBSingleLineSelection(dialog1, kEXclsnm,TRUE);
  703.                     END;
  704.             END;
  705.         END;
  706.  
  707.     BEGIN   {of dialog1_Main}
  708.  
  709.         kImageCheckNEW  := 0;
  710.         kImageBlankNEW  := 0;
  711.         kImageSheetNEW  := 0;
  712.         kImageViewNEW   := 0;
  713.    
  714.         kImageCheckEX := 0;
  715.         kImageBlankEX := 0;
  716.         kImageSheetEX := 0;
  717.         kImageViewEX  := 0;
  718.    
  719.    
  720.         IF ResourceIsOK THEN dialog1_Setup;
  721.         IF RunLayoutDialog(dialog1, dialog1_Handler) = 1 then BEGIN
  722.         END;
  723.     END;
  724.  
  725. { **************************************************************************************************************** }
  726.                                 { END OF ALL SUB-PROCEDURES }
  727. { **************************************************************************************************************** }
  728.  
  729. BEGIN  {of Smart_Paste}
  730.  
  731.            
  732.     ResourceList_Existing_Classes;
  733.     DoMenuTextByName('Paste in Place',0);
  734.     ResourceList_Extra_Classes;    
  735.    
  736.     IF (NumItems2=0) THEN BEGIN
  737.         Message('No New Classes Pasted');
  738.     END ELSE BEGIN
  739.        
  740.         Click_Count:=0;
  741.         dialog1_Main;
  742.         IF Didcancel THEN BEGIN
  743.             DoMenuTextByName('Undo',0);
  744.         END;
  745.     END;
  746. END;
  747.  
  748. { ***************************************************************************************************************** }
  749.  
  750. RUN(Smart_Paste);
  751.        
  752.    
  753.  
  754. {This program is free software: you can redistribute it and/or modify
  755.     it under the terms of the GNU General Public License as published by
  756.     the Free Software Foundation, either version 3 of the License, or
  757.     (at your option) any later version.
  758.  
  759.     This program is distributed in the hope that it will be useful,
  760.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  761.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  762.     GNU General Public License for more details.
  763.  
  764.     You should have received a copy of the GNU General Public License
  765.     along with this program.  If not, see <http://www.gnu.org/licenses/>.}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement