home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l406 / 4.ddi / ICONEDIT.FR_ / ICONEDIT.bin (.txt)
Encoding:
Visual Basic Form  |  1992-10-21  |  105.7 KB  |  2,494 lines

  1. VERSION 2.00
  2. Begin Form Editor 
  3.    Caption         =   "IconWorks Editor: 1 - [Untitled]"
  4.    ClipControls    =   0   'False
  5.    ForeColor       =   &H00FFFFFF&
  6.    Height          =   5355
  7.    Icon            =   ICONEDIT.FRX:0000
  8.    Left            =   1935
  9.    LinkMode        =   1  'Source
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   311
  12.    ScaleMode       =   3  'Pixel
  13.    ScaleWidth      =   411
  14.    Top             =   1215
  15.    Width           =   6285
  16.    Begin PictureBox Pic_ToolPalette 
  17.       AutoSize        =   -1  'True
  18.       BackColor       =   &H00808080&
  19.       BorderStyle     =   0  'None
  20.       DrawMode        =   6  'Invert
  21.       DrawWidth       =   2
  22.       Height          =   3840
  23.       Left            =   0
  24.       Picture         =   ICONEDIT.FRX:0302
  25.       ScaleHeight     =   256
  26.       ScaleMode       =   3  'Pixel
  27.       ScaleWidth      =   32
  28.       TabIndex        =   0
  29.       TabStop         =   0   'False
  30.       Top             =   0
  31.       Visible         =   0   'False
  32.       Width           =   480
  33.    End
  34.    Begin VScrollBar Scrl_Zoom 
  35.       Height          =   3870
  36.       HelpContextID   =   1903
  37.       LargeChange     =   32
  38.       Left            =   480
  39.       Max             =   258
  40.       Min             =   34
  41.       SmallChange     =   32
  42.       TabIndex        =   4
  43.       Tag             =   "9040"
  44.       Top             =   -15
  45.       Value           =   34
  46.       Visible         =   0   'False
  47.       Width           =   270
  48.    End
  49.    Begin PictureBox Pic_Edit 
  50.       BackColor       =   &H000000FF&
  51.       Height          =   3870
  52.       Left            =   735
  53.       ScaleHeight     =   256
  54.       ScaleMode       =   3  'Pixel
  55.       ScaleWidth      =   256
  56.       TabIndex        =   2
  57.       Tag             =   "9000"
  58.       Top             =   -15
  59.       Visible         =   0   'False
  60.       Width           =   3870
  61.       Begin PictureBox Pic_Image 
  62.          AutoRedraw      =   -1  'True
  63.          BackColor       =   &H00000000&
  64.          BorderStyle     =   0  'None
  65.          ForeColor       =   &H00000000&
  66.          Height          =   480
  67.          Left            =   1380
  68.          ScaleHeight     =   32
  69.          ScaleMode       =   3  'Pixel
  70.          ScaleWidth      =   32
  71.          TabIndex        =   5
  72.          TabStop         =   0   'False
  73.          Top             =   945
  74.          Visible         =   0   'False
  75.          Width           =   480
  76.       End
  77.       Begin PictureBox Pic_Mask 
  78.          AutoRedraw      =   -1  'True
  79.          BackColor       =   &H00FFFFFF&
  80.          BorderStyle     =   0  'None
  81.          ForeColor       =   &H00000000&
  82.          Height          =   480
  83.          Left            =   1965
  84.          ScaleHeight     =   32
  85.          ScaleMode       =   3  'Pixel
  86.          ScaleWidth      =   32
  87.          TabIndex        =   6
  88.          TabStop         =   0   'False
  89.          Top             =   945
  90.          Visible         =   0   'False
  91.          Width           =   480
  92.       End
  93.       Begin PictureBox Pic_Grid 
  94.          AutoRedraw      =   -1  'True
  95.          BackColor       =   &H00FFFFFF&
  96.          BorderStyle     =   0  'None
  97.          ForeColor       =   &H00000000&
  98.          Height          =   480
  99.          Left            =   1380
  100.          ScaleHeight     =   32
  101.          ScaleMode       =   3  'Pixel
  102.          ScaleWidth      =   32
  103.          TabIndex        =   19
  104.          Top             =   1515
  105.          Visible         =   0   'False
  106.          Width           =   480
  107.       End
  108.       Begin PictureBox Pic_Work 
  109.          AutoRedraw      =   -1  'True
  110.          AutoSize        =   -1  'True
  111.          BackColor       =   &H00000000&
  112.          BorderStyle     =   0  'None
  113.          FillStyle       =   0  'Solid
  114.          ForeColor       =   &H00000000&
  115.          Height          =   480
  116.          Left            =   1965
  117.          ScaleHeight     =   32
  118.          ScaleMode       =   3  'Pixel
  119.          ScaleWidth      =   32
  120.          TabIndex        =   14
  121.          TabStop         =   0   'False
  122.          Top             =   1515
  123.          Visible         =   0   'False
  124.          Width           =   480
  125.       End
  126.       Begin PictureBox Pic_TempImage 
  127.          AutoRedraw      =   -1  'True
  128.          BackColor       =   &H00000000&
  129.          BorderStyle     =   0  'None
  130.          ForeColor       =   &H00000000&
  131.          Height          =   480
  132.          Left            =   1380
  133.          ScaleHeight     =   32
  134.          ScaleMode       =   3  'Pixel
  135.          ScaleWidth      =   32
  136.          TabIndex        =   15
  137.          Top             =   2085
  138.          Visible         =   0   'False
  139.          Width           =   480
  140.       End
  141.       Begin PictureBox Pic_TempMask 
  142.          AutoRedraw      =   -1  'True
  143.          BackColor       =   &H00FFFFFF&
  144.          BorderStyle     =   0  'None
  145.          Height          =   480
  146.          Left            =   1965
  147.          ScaleHeight     =   32
  148.          ScaleMode       =   3  'Pixel
  149.          ScaleWidth      =   32
  150.          TabIndex        =   16
  151.          Top             =   2085
  152.          Visible         =   0   'False
  153.          Width           =   480
  154.       End
  155.       Begin PictureBox Pic_EditTemp 
  156.          AutoRedraw      =   -1  'True
  157.          BackColor       =   &H00FFFFFF&
  158.          Height          =   480
  159.          Left            =   1680
  160.          ScaleHeight     =   30
  161.          ScaleMode       =   3  'Pixel
  162.          ScaleWidth      =   30
  163.          TabIndex        =   20
  164.          Top             =   2745
  165.          Visible         =   0   'False
  166.          Width           =   480
  167.       End
  168.    End
  169.    Begin PictureBox Pic_StatusArea 
  170.       BackColor       =   &H00C0C0C0&
  171.       FontBold        =   -1  'True
  172.       FontItalic      =   0   'False
  173.       FontName        =   "Courier"
  174.       FontSize        =   9.75
  175.       FontStrikethru  =   0   'False
  176.       FontTransparent =   0   'False
  177.       FontUnderline   =   0   'False
  178.       ForeColor       =   &H00C0C0C0&
  179.       Height          =   4680
  180.       HelpContextID   =   1904
  181.       Left            =   4590
  182.       ScaleHeight     =   310
  183.       ScaleMode       =   3  'Pixel
  184.       ScaleWidth      =   104
  185.       TabIndex        =   7
  186.       TabStop         =   0   'False
  187.       Tag             =   "9010"
  188.       Top             =   -15
  189.       Visible         =   0   'False
  190.       Width           =   1590
  191.       Begin PictureBox Pic_Icons 
  192.          AutoRedraw      =   -1  'True
  193.          BackColor       =   &H00FFFFFF&
  194.          BorderStyle     =   0  'None
  195.          DragIcon        =   ICONEDIT.FRX:137C
  196.          DrawMode        =   4  'Not Copy Pen
  197.          FillStyle       =   0  'Solid
  198.          ForeColor       =   &H00000000&
  199.          Height          =   480
  200.          Index           =   0
  201.          Left            =   210
  202.          Picture         =   ICONEDIT.FRX:167E
  203.          ScaleHeight     =   32
  204.          ScaleMode       =   3  'Pixel
  205.          ScaleWidth      =   32
  206.          TabIndex        =   8
  207.          TabStop         =   0   'False
  208.          Tag             =   "9130"
  209.          Top             =   180
  210.          Width           =   480
  211.       End
  212.       Begin PictureBox Pic_Icons 
  213.          AutoRedraw      =   -1  'True
  214.          BackColor       =   &H00FFFFFF&
  215.          BorderStyle     =   0  'None
  216.          DragIcon        =   ICONEDIT.FRX:1980
  217.          FillStyle       =   0  'Solid
  218.          ForeColor       =   &H00000000&
  219.          Height          =   480
  220.          Index           =   1
  221.          Left            =   885
  222.          Picture         =   ICONEDIT.FRX:1C82
  223.          ScaleHeight     =   32
  224.          ScaleMode       =   3  'Pixel
  225.          ScaleWidth      =   32
  226.          TabIndex        =   9
  227.          TabStop         =   0   'False
  228.          Tag             =   "9130"
  229.          Top             =   180
  230.          Width           =   480
  231.       End
  232.       Begin PictureBox Pic_Icons 
  233.          AutoRedraw      =   -1  'True
  234.          BackColor       =   &H00FFFFFF&
  235.          BorderStyle     =   0  'None
  236.          DragIcon        =   ICONEDIT.FRX:1F84
  237.          FillStyle       =   0  'Solid
  238.          ForeColor       =   &H00000000&
  239.          Height          =   480
  240.          Index           =   2
  241.          Left            =   210
  242.          Picture         =   ICONEDIT.FRX:2286
  243.          ScaleHeight     =   32
  244.          ScaleMode       =   3  'Pixel
  245.          ScaleWidth      =   32
  246.          TabIndex        =   10
  247.          TabStop         =   0   'False
  248.          Tag             =   "9130"
  249.          Top             =   840
  250.          Width           =   480
  251.       End
  252.       Begin PictureBox Pic_Icons 
  253.          AutoRedraw      =   -1  'True
  254.          BackColor       =   &H00FFFFFF&
  255.          BorderStyle     =   0  'None
  256.          DragIcon        =   ICONEDIT.FRX:2588
  257.          FillStyle       =   0  'Solid
  258.          ForeColor       =   &H00000000&
  259.          Height          =   480
  260.          Index           =   3
  261.          Left            =   885
  262.          Picture         =   ICONEDIT.FRX:288A
  263.          ScaleHeight     =   32
  264.          ScaleMode       =   3  'Pixel
  265.          ScaleWidth      =   32
  266.          TabIndex        =   11
  267.          TabStop         =   0   'False
  268.          Tag             =   "9130"
  269.          Top             =   840
  270.          Width           =   480
  271.       End
  272.       Begin PictureBox Pic_Icons 
  273.          AutoRedraw      =   -1  'True
  274.          BackColor       =   &H00FFFFFF&
  275.          BorderStyle     =   0  'None
  276.          DragIcon        =   ICONEDIT.FRX:2B8C
  277.          FillStyle       =   0  'Solid
  278.          ForeColor       =   &H00000000&
  279.          Height          =   480
  280.          Index           =   4
  281.          Left            =   210
  282.          Picture         =   ICONEDIT.FRX:2E8E
  283.          ScaleHeight     =   32
  284.          ScaleMode       =   3  'Pixel
  285.          ScaleWidth      =   32
  286.          TabIndex        =   12
  287.          TabStop         =   0   'False
  288.          Tag             =   "9130"
  289.          Top             =   1500
  290.          Width           =   480
  291.       End
  292.       Begin PictureBox Pic_Icons 
  293.          AutoRedraw      =   -1  'True
  294.          BackColor       =   &H00FFFFFF&
  295.          BorderStyle     =   0  'None
  296.          DragIcon        =   ICONEDIT.FRX:3190
  297.          FillStyle       =   0  'Solid
  298.          ForeColor       =   &H00000000&
  299.          Height          =   480
  300.          Index           =   5
  301.          Left            =   885
  302.          Picture         =   ICONEDIT.FRX:3492
  303.          ScaleHeight     =   32
  304.          ScaleMode       =   3  'Pixel
  305.          ScaleWidth      =   32
  306.          TabIndex        =   13
  307.          TabStop         =   0   'False
  308.          Tag             =   "9130"
  309.          Top             =   1500
  310.          Width           =   480
  311.       End
  312.       Begin PictureBox Pic_Undo 
  313.          BackColor       =   &H00FFFFFF&
  314.          BorderStyle     =   0  'None
  315.          DragIcon        =   ICONEDIT.FRX:3794
  316.          ForeColor       =   &H00FFFFFF&
  317.          Height          =   480
  318.          HelpContextID   =   1902
  319.          Left            =   1035
  320.          Picture         =   ICONEDIT.FRX:3A96
  321.          ScaleHeight     =   32
  322.          ScaleMode       =   3  'Pixel
  323.          ScaleWidth      =   32
  324.          TabIndex        =   3
  325.          TabStop         =   0   'False
  326.          Tag             =   "9150"
  327.          Top             =   2505
  328.          Width           =   480
  329.       End
  330.       Begin OptionButton Opt_Mouse 
  331.          BackColor       =   &H00C0C0C0&
  332.          Height          =   360
  333.          Index           =   0
  334.          Left            =   690
  335.          TabIndex        =   17
  336.          Tag             =   "9160"
  337.          Top             =   3600
  338.          Value           =   -1  'True
  339.          Width           =   195
  340.       End
  341.       Begin OptionButton Opt_Mouse 
  342.          BackColor       =   &H00C0C0C0&
  343.          Height          =   360
  344.          HelpContextID   =   1901
  345.          Index           =   1
  346.          Left            =   690
  347.          TabIndex        =   1
  348.          Tag             =   "9160"
  349.          Top             =   4200
  350.          Width           =   195
  351.       End
  352.    End
  353.    Begin PictureBox Pic_ColorPalette 
  354.       BackColor       =   &H00FFFFFF&
  355.       ForeColor       =   &H00000000&
  356.       Height          =   810
  357.       HelpContextID   =   1905
  358.       Left            =   0
  359.       ScaleHeight     =   52
  360.       ScaleMode       =   3  'Pixel
  361.       ScaleWidth      =   305
  362.       TabIndex        =   18
  363.       TabStop         =   0   'False
  364.       Tag             =   "9030"
  365.       Top             =   3840
  366.       Visible         =   0   'False
  367.       Width           =   4605
  368.    End
  369.    Begin Menu Menu_File 
  370.       Caption         =   "&File"
  371.       HelpContextID   =   1100
  372.       Begin Menu Menu_FileSelection 
  373.          Caption         =   "&New"
  374.          HelpContextID   =   1101
  375.          Index           =   0
  376.       End
  377.       Begin Menu Menu_FileSelection 
  378.          Caption         =   "&Open..."
  379.          HelpContextID   =   1102
  380.          Index           =   1
  381.       End
  382.       Begin Menu Menu_FileSelection 
  383.          Caption         =   "&Save"
  384.          HelpContextID   =   1103
  385.          Index           =   2
  386.          Shortcut        =   +{F12}
  387.       End
  388.       Begin Menu Menu_FileSelection 
  389.          Caption         =   "Save &As..."
  390.          HelpContextID   =   1104
  391.          Index           =   3
  392.          Shortcut        =   {F12}
  393.       End
  394.       Begin Menu Menu_FileSelection 
  395.          Caption         =   "-"
  396.          Index           =   4
  397.       End
  398.       Begin Menu Menu_FileSelection 
  399.          Caption         =   "E&xit"
  400.          HelpContextID   =   1105
  401.          Index           =   5
  402.       End
  403.    End
  404.    Begin Menu Menu_Edit 
  405.       Caption         =   "&Edit"
  406.       HelpContextID   =   1200
  407.       Begin Menu Menu_EditSelection 
  408.          Caption         =   "&Undo"
  409.          HelpContextID   =   1201
  410.          Index           =   0
  411.          Shortcut        =   %{BKSP}
  412.       End
  413.       Begin Menu Menu_EditSelection 
  414.          Caption         =   "-"
  415.          Index           =   1
  416.       End
  417.       Begin Menu Menu_EditSelection 
  418.          Caption         =   "Cu&t"
  419.          HelpContextID   =   1202
  420.          Index           =   2
  421.          Shortcut        =   +{DEL}
  422.       End
  423.       Begin Menu Menu_EditSelection 
  424.          Caption         =   "&Copy"
  425.          HelpContextID   =   1203
  426.          Index           =   3
  427.          Shortcut        =   ^{INSERT}
  428.       End
  429.       Begin Menu Menu_EditSelection 
  430.          Caption         =   "&Paste"
  431.          HelpContextID   =   1204
  432.          Index           =   4
  433.          Shortcut        =   +{INSERT}
  434.       End
  435.       Begin Menu Menu_EditSelection 
  436.          Caption         =   "Paste &Opaque"
  437.          HelpContextID   =   1205
  438.          Index           =   5
  439.          Shortcut        =   ^O
  440.       End
  441.       Begin Menu Menu_EditSelection 
  442.          Caption         =   "&Delete"
  443.          HelpContextID   =   1206
  444.          Index           =   6
  445.          Shortcut        =   {DEL}
  446.       End
  447.       Begin Menu Menu_EditSelection 
  448.          Caption         =   "&Select All"
  449.          HelpContextID   =   1207
  450.          Index           =   7
  451.          Shortcut        =   ^A
  452.       End
  453.       Begin Menu Menu_EditSelection 
  454.          Caption         =   "-"
  455.          Index           =   8
  456.       End
  457.       Begin Menu Menu_EditSelection 
  458.          Caption         =   "Flip &Horizontal"
  459.          HelpContextID   =   1208
  460.          Index           =   9
  461.          Shortcut        =   ^H
  462.       End
  463.       Begin Menu Menu_EditSelection 
  464.          Caption         =   "Flip &Vertical"
  465.          HelpContextID   =   1209
  466.          Index           =   10
  467.          Shortcut        =   ^V
  468.       End
  469.       Begin Menu Menu_EditSelection 
  470.          Caption         =   "-"
  471.          Index           =   11
  472.       End
  473.       Begin Menu Menu_EditSelection 
  474.          Caption         =   "Rotate 90  &Right"
  475.          HelpContextID   =   1210
  476.          Index           =   12
  477.          Shortcut        =   ^R
  478.       End
  479.       Begin Menu Menu_EditSelection 
  480.          Caption         =   "Rotate 90  &Left"
  481.          HelpContextID   =   1211
  482.          Index           =   13
  483.          Shortcut        =   ^L
  484.       End
  485.       Begin Menu Menu_EditSelection 
  486.          Caption         =   "-"
  487.          Index           =   14
  488.       End
  489.       Begin Menu Menu_EditSelection 
  490.          Caption         =   "&Invert"
  491.          HelpContextID   =   1212
  492.          Index           =   15
  493.          Shortcut        =   ^I
  494.       End
  495.    End
  496.    Begin Menu Menu_View 
  497.       Caption         =   "&View"
  498.       HelpContextID   =   1300
  499.       Begin Menu Menu_ViewSelection 
  500.          Caption         =   "&Status Area"
  501.          Checked         =   -1  'True
  502.          HelpContextID   =   1301
  503.          Index           =   0
  504.          Shortcut        =   ^S
  505.       End
  506.       Begin Menu Menu_ViewSelection 
  507.          Caption         =   "&Tool Palette"
  508.          Checked         =   -1  'True
  509.          HelpContextID   =   1302
  510.          Index           =   1
  511.          Shortcut        =   ^T
  512.       End
  513.       Begin Menu Menu_ViewSelection 
  514.          Caption         =   "&Color Palette"
  515.          Checked         =   -1  'True
  516.          HelpContextID   =   1303
  517.          Index           =   2
  518.          Shortcut        =   ^C
  519.       End
  520.       Begin Menu Menu_ViewSelection 
  521.          Caption         =   "&Zooming Scroll bar"
  522.          Checked         =   -1  'True
  523.          HelpContextID   =   1304
  524.          Index           =   3
  525.          Shortcut        =   ^Z
  526.       End
  527.       Begin Menu Menu_ViewSelection 
  528.          Caption         =   "Show &All"
  529.          HelpContextID   =   1305
  530.          Index           =   4
  531.       End
  532.       Begin Menu Menu_ViewSelection 
  533.          Caption         =   "-"
  534.          Index           =   5
  535.       End
  536.       Begin Menu Menu_ViewSelection 
  537.          Caption         =   "&Grid"
  538.          HelpContextID   =   1306
  539.          Index           =   6
  540.          Shortcut        =   ^G
  541.       End
  542.       Begin Menu Menu_ViewSelection 
  543.          Caption         =   "&Line Grid"
  544.          HelpContextID   =   1307
  545.          Index           =   7
  546.       End
  547.       Begin Menu Menu_ViewSelection 
  548.          Caption         =   "&Dotted Grid"
  549.          HelpContextID   =   1308
  550.          Index           =   8
  551.       End
  552.       Begin Menu Menu_ViewSelection 
  553.          Caption         =   "-"
  554.          Index           =   9
  555.       End
  556.       Begin Menu Menu_ViewSelection 
  557.          Caption         =   "Zoom &In"
  558.          HelpContextID   =   1309
  559.          Index           =   10
  560.          Shortcut        =   ^{F11}
  561.       End
  562.       Begin Menu Menu_ViewSelection 
  563.          Caption         =   "Zoom &Out"
  564.          HelpContextID   =   1310
  565.          Index           =   11
  566.          Shortcut        =   ^{F12}
  567.       End
  568.       Begin Menu Menu_ViewSelection 
  569.          Caption         =   "-"
  570.          Index           =   12
  571.       End
  572.       Begin Menu Menu_ViewSelection 
  573.          Caption         =   "&Focus to Editor on Drag&&Drop"
  574.          Checked         =   -1  'True
  575.          HelpContextID   =   1311
  576.          Index           =   13
  577.       End
  578.       Begin Menu Menu_ViewSelection 
  579.          Caption         =   "Display &Border on selected Icon"
  580.          Checked         =   -1  'True
  581.          HelpContextID   =   1312
  582.          Index           =   14
  583.       End
  584.       Begin Menu Menu_ViewSelection 
  585.          Caption         =   "&Pop-up Tools menu on Form Click"
  586.          Checked         =   -1  'True
  587.          HelpContextID   =   1313
  588.          Index           =   15
  589.       End
  590.    End
  591.    Begin Menu Menu_Tools 
  592.       Caption         =   "&Tools"
  593.       HelpContextID   =   1400
  594.       Begin Menu Menu_ToolsSelection 
  595.          Caption         =   "&Select"
  596.          HelpContextID   =   1401
  597.          Index           =   0
  598.       End
  599.       Begin Menu Menu_ToolsSelection 
  600.          Caption         =   "&Paint"
  601.          HelpContextID   =   1402
  602.          Index           =   1
  603.       End
  604.       Begin Menu Menu_ToolsSelection 
  605.          Caption         =   "&Fill"
  606.          HelpContextID   =   1403
  607.          Index           =   2
  608.       End
  609.       Begin Menu Menu_ToolsSelection 
  610.          Caption         =   "&Line"
  611.          HelpContextID   =   1404
  612.          Index           =   3
  613.       End
  614.       Begin Menu Menu_ToolsSelection 
  615.          Caption         =   "&Square"
  616.          HelpContextID   =   1405
  617.          Index           =   4
  618.       End
  619.       Begin Menu Menu_ToolsSelection 
  620.          Caption         =   "Filled S&quare"
  621.          HelpContextID   =   1406
  622.          Index           =   5
  623.       End
  624.       Begin Menu Menu_ToolsSelection 
  625.          Caption         =   "&Circle"
  626.          HelpContextID   =   1407
  627.          Index           =   6
  628.       End
  629.       Begin Menu Menu_ToolsSelection 
  630.          Caption         =   "Filled C&ircle"
  631.          HelpContextID   =   1408
  632.          Index           =   7
  633.       End
  634.    End
  635.    Begin Menu Menu_Icons 
  636.       Caption         =   "&Icons"
  637.       HelpContextID   =   1500
  638.       Begin Menu Menu_IconsSelection 
  639.          Caption         =   "&1 - [Untitled]"
  640.          Index           =   0
  641.       End
  642.       Begin Menu Menu_IconsSelection 
  643.          Caption         =   "&2 - [Untitled]"
  644.          Index           =   1
  645.       End
  646.       Begin Menu Menu_IconsSelection 
  647.          Caption         =   "&3 - [Untitled]"
  648.          Index           =   2
  649.       End
  650.       Begin Menu Menu_IconsSelection 
  651.          Caption         =   "&4 - [Untitled]"
  652.          Index           =   3
  653.       End
  654.       Begin Menu Menu_IconsSelection 
  655.          Caption         =   "&5 - [Untitled]"
  656.          Index           =   4
  657.       End
  658.       Begin Menu Menu_IconsSelection 
  659.          Caption         =   "&6 - [Untitled]"
  660.          Index           =   5
  661.       End
  662.    End
  663.    Begin Menu Menu_Color 
  664.       Caption         =   "&Color"
  665.       HelpContextID   =   1600
  666.       Begin Menu Menu_ColorSelection 
  667.          Caption         =   "&Colors..."
  668.          HelpContextID   =   1601
  669.          Index           =   0
  670.       End
  671.       Begin Menu Menu_ColorSelection 
  672.          Caption         =   "&Default Color Palette"
  673.          Checked         =   -1  'True
  674.          HelpContextID   =   1602
  675.          Index           =   1
  676.       End
  677.       Begin Menu Menu_ColorSelection 
  678.          Caption         =   "S&olid Colors Only"
  679.          HelpContextID   =   1603
  680.          Index           =   2
  681.       End
  682.       Begin Menu Menu_ColorSelection 
  683.          Caption         =   "I&NI File Color Palette"
  684.          HelpContextID   =   1604
  685.          Index           =   3
  686.       End
  687.       Begin Menu Menu_ColorSelection 
  688.          Caption         =   "-"
  689.          Index           =   4
  690.       End
  691.       Begin Menu Menu_ColorSelection 
  692.          Caption         =   "&Save Color Palette to INI file"
  693.          HelpContextID   =   1605
  694.          Index           =   5
  695.       End
  696.       Begin Menu Menu_ColorSelection 
  697.          Caption         =   "-"
  698.          Index           =   6
  699.       End
  700.       Begin Menu Menu_ColorSelection 
  701.          Caption         =   "&Left/Right Colors"
  702.          Checked         =   -1  'True
  703.          HelpContextID   =   1606
  704.          Index           =   7
  705.       End
  706.       Begin Menu Menu_ColorSelection 
  707.          Caption         =   "Screen/&Inverse Colors"
  708.          HelpContextID   =   1607
  709.          Index           =   8
  710.       End
  711.    End
  712.    Begin Menu Menu_Brush 
  713.       Caption         =   "&Brush"
  714.       HelpContextID   =   1700
  715.       Begin Menu Menu_BrushSelection 
  716.          Caption         =   "&Small (1 x 1)"
  717.          Checked         =   -1  'True
  718.          HelpContextID   =   1701
  719.          Index           =   1
  720.       End
  721.       Begin Menu Menu_BrushSelection 
  722.          Caption         =   "&Medium (3 x 3)"
  723.          HelpContextID   =   1702
  724.          Index           =   3
  725.       End
  726.       Begin Menu Menu_BrushSelection 
  727.          Caption         =   "&Large (5 x 5)"
  728.          HelpContextID   =   1703
  729.          Index           =   5
  730.       End
  731.    End
  732.    Begin Menu Menu_Help 
  733.       Caption         =   "&Help"
  734.       Begin Menu Menu_HelpSelection 
  735.          Caption         =   "&Index"
  736.          Index           =   1
  737.       End
  738.       Begin Menu Menu_HelpSelection 
  739.          Caption         =   "&Keyboard"
  740.          Index           =   2
  741.       End
  742.       Begin Menu Menu_HelpSelection 
  743.          Caption         =   "&Commands"
  744.          Index           =   3
  745.       End
  746.       Begin Menu Menu_HelpSelection 
  747.          Caption         =   "&Using Help"
  748.          Index           =   4
  749.       End
  750.       Begin Menu Menu_HelpSelection 
  751.          Caption         =   "-"
  752.          Index           =   5
  753.       End
  754.       Begin Menu Menu_HelpSelection 
  755.          Caption         =   "&About..."
  756.          Index           =   6
  757.       End
  758.    End
  759. DefInt A-Z
  760. ' When the View.Grid option is selected or deselected, this routine
  761. ' performs the neccessary checking, unchecking of the Grid menu item
  762. ' and Enables or disables the Grid type menu items appropriately,
  763. ' and creates the Grid if selected.
  764. Sub Activate_Grid ()
  765.     Menu_ViewSelection(MID_GRID).Checked = Not Menu_ViewSelection(MID_GRID).Checked
  766.     Menu_ViewSelection(MID_LINE_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  767.     Menu_ViewSelection(MID_DOTTED_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  768.     If Menu_ViewSelection(MID_GRID).Checked Then Create_Grid
  769.     Magnify_Icon 0, 0, 31, 31
  770. End Sub
  771. Sub Adjust_Color_Palette ()
  772.     ' Determine if Editor is large enough for ColorPalette
  773.     If (ScaleHeight < (Pic_ColorPalette.Height + 34)) And Menu_ViewSelection(MID_COLOR_PALETTE).Checked Then
  774.         Menu_ViewSelection(MID_COLOR_PALETTE).Checked = False
  775.         Menu_ViewSelection(MID_COLOR_PALETTE).Enabled = False
  776.     Else
  777.         Menu_ViewSelection(MID_COLOR_PALETTE).Enabled = True
  778.         ' Check if the ColorPalette is selected to be displayed.
  779.         If Menu_ViewSelection(MID_COLOR_PALETTE).Checked Then
  780.             NewTop = ScaleHeight - Pic_ColorPalette.Height
  781.             NewWidth = ScaleWidth
  782.             ' Check if the StatusArea is currently displayed, since the StatusArea
  783.             ' affects the width of the ColorPalette.
  784.             If Menu_ViewSelection(MID_STATUS_BAR).Checked Then NewWidth = NewWidth - Pic_StatusArea.Width + 1
  785.             ' Reposition and Resize the ColorPalette.
  786.             Pic_ColorPalette.Move Pic_ColorPalette.Left, NewTop, NewWidth
  787.         End If
  788.     End If
  789. End Sub
  790. ' When the Editor is Resized, the the Zoom Scrollbar must be resized,
  791. ' repositioned.  This routine performs the neccessary repositioning
  792. ' for the Zoom Scrollbar.
  793. Sub Adjust_ScrollBar ()
  794.     If Menu_ViewSelection(MID_TOOL_PALETTE).Checked Then NewLeft = Pic_ToolPalette.Width Else NewLeft = -1
  795.     NewHeight = ScaleHeight + 2 + Menu_ViewSelection(MID_COLOR_PALETTE).Checked * Pic_ColorPalette.Height
  796.     NewMax = ScaleWidth - (NewLeft - Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked * Scrl_Zoom.Width) + 3 + (Menu_ViewSelection(MID_STATUS_BAR).Checked * Pic_StatusArea.Width)
  797.     ' Set the new Max value to the smaller of the NewHeight and the NewMax value.
  798.     If NewMax > NewHeight Then NewMax = NewHeight
  799.     ' We must adjust the New Max value obtained above so it is a multiple of 32.
  800.     While (NewMax - 2) Mod 32
  801.         NewMax = NewMax - 1
  802.     Wend
  803.     Scrl_Zoom.Move NewLeft, Scrl_Zoom.Top, Scrl_Zoom.Width, NewHeight
  804.     Scrl_Zoom.Max = NewMax
  805.     ' Determine if current size of the Editing area is larger than the new maximum size.
  806.     If Pic_Edit.Height > Scrl_Zoom.Max Then
  807.         Scrl_Zoom.Value = Scrl_Zoom.Max
  808.     Else
  809.         Scrl_Zoom_Change
  810.     End If
  811. End Sub
  812. ' When the Editor is Resized, the the StatusArea must be resized, and hidden if necessary
  813. Sub Adjust_Status_Bar ()
  814.     ' Determine if Editor is large enough for StatusArea
  815.     If ((ScaleHeight < (Pic_Icons(5).Top + Pic_Icons(5).Height + HIGHLIGHT)) Or (ScaleWidth < 2 * Pic_StatusArea.Width)) And Menu_ViewSelection(MID_STATUS_BAR).Checked Then
  816.         Menu_ViewSelection(MID_STATUS_BAR).Checked = False
  817.         Menu_ViewSelection(MID_STATUS_BAR).Enabled = False
  818.     Else
  819.         Menu_ViewSelection(MID_STATUS_BAR).Enabled = True
  820.         If Menu_ViewSelection(MID_STATUS_BAR).Checked Then
  821.             OldHeight = Pic_StatusArea.Height
  822.             Pic_StatusArea.Move ScaleWidth - Pic_StatusArea.Width + 1, Pic_StatusArea.Top, Pic_StatusArea.Width, ScaleHeight + 2
  823.             NewTop = Pic_StatusArea.ScaleHeight - 4.25 * Opt_Mouse(0).Height
  824.             Opt_Mouse(0).Top = NewTop + 1.25 * Opt_Mouse(0).Height
  825.             Opt_Mouse(1).Top = NewTop + 3 * Opt_Mouse(0).Height
  826.             Visibility = NewTop >= (Pic_Icons(5).Top + Pic_Icons(5).Height + 2 * HIGHLIGHT + 4)
  827.             Opt_Mouse(0).Visible = Visibility
  828.             Opt_Mouse(1).Visible = Visibility
  829.             ' Determine if there is room to display the Undo Icon
  830.             If Opt_Mouse(0).Visible Then
  831.                 Pic_Undo.Visible = NewTop >= (Pic_Undo.Top + Pic_Undo.Height)
  832.             Else
  833.                 Pic_Undo.Visible = (Pic_Undo.Top + Pic_Undo.Height) <= Pic_StatusArea.ScaleHeight
  834.             End If
  835.             ' We only want to force it to repaint if its size has changed
  836.             If OldHeight <> Pic_StatusArea.Height Then Pic_StatusArea.Refresh
  837.         End If
  838.     End If
  839. End Sub
  840. ' When the Editor is Resized, the the ToolPalette may need to be hidden.
  841. Sub Adjust_Tool_Palette ()
  842.     If ((ScaleHeight < (Pic_ToolPalette.Height + Pic_ColorPalette.Height)) And Menu_ViewSelection(MID_COLOR_PALETTE).Checked) Or ((ScaleHeight < Pic_ToolPalette.Height) And (Not Menu_ViewSelection(MID_COLOR_PALETTE).Checked)) Then
  843.         Menu_ViewSelection(MID_TOOL_PALETTE).Checked = False
  844.         Menu_ViewSelection(MID_TOOL_PALETTE).Enabled = False
  845.     Else
  846.         Menu_ViewSelection(MID_TOOL_PALETTE).Enabled = True
  847.     End If
  848. End Sub
  849. ' To make magnified pixels appear more like single pixels when working
  850. ' with the various tools, this routine is used to adjust the actual pixel
  851. ' clicked to the Center or to the Edge of the selected magnified pixel.
  852. Sub Adjust_X_and_Y (X As Single, Y As Single, NewX, NewY, Adjustment)
  853.     Select Case Adjustment
  854.         Case TO_CENTER
  855.             NewX = (X \ PixelSize) * PixelSize + (PixelSize \ 2)
  856.             NewY = (Y \ PixelSize) * PixelSize + (PixelSize \ 2)
  857.         Case TO_EDGE
  858.             Xpix = X \ PixelSize
  859.             Ypix = Y \ PixelSize
  860.             If (X Mod PixelSize) >= (PixelSize / 2) Then Xpix = Xpix + 1
  861.             If (Y Mod PixelSize) >= (PixelSize / 2) Then Ypix = Ypix + 1
  862.             NewX = Xpix * PixelSize
  863.             NewY = Ypix * PixelSize
  864.     End Select
  865. End Sub
  866. ' This routine is called when ever the selection is to be comitted to the Icon.
  867. Sub Commit_Selection (ResetFlags)
  868.     ' Erase the Rectangle highlighting the selection
  869.     If Selecting Then Draw_Selection_Rectangle
  870.     Scale_Region True, X1, Y1, X2, Y2, True
  871.     If Menu_ViewSelection(MID_GRID).Checked Then Display_Grid (Pic_Edit.hDC), X1, Y1, X2, Y2
  872.     W = X2 - X1
  873.     H = Y2 - Y1
  874.     If Opaque Then
  875.         ' An exact copy of Mask and Image of the Selection are copied
  876.         R = BitBlt(Pic_Image.hDC, X1, Y1, W, H, Pic_TempImage.hDC, X1SelectFrom, Y1SelectFrom, SRCCOPY)
  877.         R = BitBlt(Pic_Mask.hDC, X1, Y1, W, H, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, SRCCOPY)
  878.     Else
  879.         ' Only the Foreground colors are copied.
  880.         R = BitBlt(Pic_Image.hDC, X1, Y1, W, H, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, SRCAND)
  881.         R = BitBlt(Pic_Image.hDC, X1, Y1, W, H, Pic_TempImage.hDC, X1SelectFrom, Y1SelectFrom, SRCINVERT)
  882.         R = BitBlt(Pic_Mask.hDC, X1, Y1, W, H, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, SRCAND)
  883.     End If
  884.     If ResetFlags Then
  885.         Selecting = False
  886.         MovingSelection = False
  887.     End If
  888.     ' Replace the Icons current Mask and Image bitmaps with the new ones.
  889.     Update_Icon Pic_Icons(CurrentIcon)
  890. End Sub
  891. ' This routine is called either in response to an Edit.Cut or Edit.Copy
  892. Sub Copy_Selection_To_ClipBoard (X1, Y1, X2, Y2)
  893.     Scale_Region True, X1, Y1, X2, Y2, True
  894.     Pic_Work.Picture = LoadPicture()
  895.     Pic_Work.Move Pic_Work.Left, Pic_Work.Top, X2 - X1, Y2 - Y1
  896.     R = BitBlt(Pic_Work.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_Icons(CurrentIcon).hDC, X1, Y1, SRCCOPY)
  897.     Clipboard.Clear
  898.     Clipboard.SetData Pic_Work.Image
  899. End Sub
  900. ' The Grid is drawn on a separate Picture control with a White BackGround and
  901. ' Black Foreground, and is only drawn once.  When a piece of the
  902. ' grid is to be redisplayed, the part of the Grid that corresponds
  903. ' to the area of the Icon that needs to be updated is BitBlt'd
  904. ' from the Picture of the Grid over the top of the Displayed Icon,
  905. ' Using the SCRAND raster operation.
  906. Sub Create_Grid ()
  907.     Pic_Grid.Move 0, 0, Scrl_Zoom.Value, Scrl_Zoom.Value
  908.     Pic_Grid.Cls
  909.     If Menu_ViewSelection(MID_LINE_GRID).Checked Then
  910.         For I = 1 To 31
  911.             Pic_Grid.Line (0, I * PixelSize)-(Pic_Grid.ScaleWidth, I * PixelSize)
  912.             Pic_Grid.Line (I * PixelSize, 0)-(I * PixelSize, Pic_Grid.ScaleHeight)
  913.         Next I
  914.     Else
  915.         For Y = 0 To 31
  916.             For X = 0 To 31
  917.                 Pic_Grid.PSet ((X * PixelSize) + (PixelSize \ 2), (Y * PixelSize) + (PixelSize \ 2))
  918.             Next X
  919.         Next Y
  920.     End If
  921. End Sub
  922. ' This routine is called in response to an Edit.Cut, Copy, or
  923. ' Delete menu selection.
  924. Sub Cut_Copy_Or_Delete_Selection (Index)
  925.     If Index = MID_DELETE Then
  926.         Scale_Region True, X1, Y1, X2, Y2, True
  927.     Else
  928.         Copy_Selection_To_ClipBoard X1, Y1, X2, Y2
  929.     End If
  930.     If Index <> MID_COPY Then
  931.         Delete_Selection_From_Icon
  932.         Selecting = False
  933.         Magnify_Icon X1, Y1, X2, Y2
  934.     End If
  935. End Sub
  936. ' This routine is called either in response to an Edit.Cut or Edit.Delete
  937. Sub Delete_Selection_From_Icon ()
  938.     Scale_Region True, X1, Y1, X2, Y2, True
  939.     Pic_Image.Line (X1, Y1)-(X2 - 1, Y2 - 1), BLACK, BF
  940.     Pic_Mask.Line (X1, Y1)-(X2 - 1, Y2 - 1), WHITE, BF
  941.     Update_Icon Pic_Icons(CurrentIcon)
  942. End Sub
  943. ' This routine is called to display the mouse coordinates.  The
  944. ' coordinates are that of the magnified pixels, not the screen
  945. ' coordinates, thus, regardless of the magnification of the Icon,
  946. ' the coordinates will all range from 0-31.
  947. Sub Display_Mouse_Coordinates (Xpix, Ypix)
  948.     If (Xpix >= 0) And (Xpix <= 31) Then
  949.         Pic_StatusArea.CurrentX = Pic_StatusArea.ScaleWidth * .25
  950.         Pic_StatusArea.Print Space$(Abs(Xpix < 10)) + Format$(Xpix);
  951.     End If
  952.     If (Ypix >= 0) And (Ypix <= 31) Then
  953.         Pic_StatusArea.CurrentX = Pic_StatusArea.ScaleWidth * .75
  954.         Pic_StatusArea.Print Space$(Abs(Ypix < 10)) + Format$(Ypix);
  955.     End If
  956. End Sub
  957. ' The routine is called to display
  958. ' the Line or Box for the above tools when requested.
  959. Sub Draw_Line_Or_Box ()
  960.     If CurrentTool = TID_LINE Then
  961.         Pic_Edit.Line (X1Region, Y1Region)-(X2Region, Y2Region)
  962.     Else
  963.         Pic_Edit.Line (X1Region, Y1Region)-(X2Region, Y2Region), , B
  964.     End If
  965. End Sub
  966. ' Since Windows INItialization files only allow the writing string information,
  967. ' the Color Palette color values are stored in 3 strings, 1 for each row of the
  968. ' color palette.  This routine is called to extract these color values from
  969. ' the strings and assign them to the Long Integer Color array.
  970. Sub Extract_Colors_From_String (ColorString As String, FirstColor, RefreshPalette)
  971.     N = 1
  972.     For C = FirstColor To FirstColor + 15
  973.         I = InStr(N, ColorString, " ")
  974.         If I = 0 Then I = Len(ColorString) + 1
  975.         Colors(C) = Val(Mid$(ColorString, N, I - N))
  976.         N = I + 1
  977.     Next C
  978.     If RefreshPalette Then
  979.         Display_Color_Palette Pic_ColorPalette
  980.         If ColorPaletteLoaded Then Display_Color_Palette ColorPalette.Pic_ColorPalette
  981.     End If
  982. End Sub
  983. ' This routine performs a Surface Flood fill of the selected area
  984. ' within the Icon when the Fill tool is in use.  The Mask color
  985. ' of all pixels that are different is then compare to the Mask
  986. ' color of the original starting Pixel.  If the Mask colors are the
  987. ' same the Pixel should be changed, otherwise it is unchanged.
  988. Sub Fill_Tool_MouseUp (X As Single, Y As Single, X2, Y2)
  989. Dim MaskColor As Long, NewPixelColor As Long
  990.     If (Abs(X) >= 0) And (Abs(X) <= Pic_Edit.ScaleWidth) And (Abs(Y) >= 0) And (Abs(Y) <= Pic_Edit.ScaleHeight) Then
  991.         Screen.MousePointer = HOURGLASS
  992.         Xpixel = X \ PixelSize
  993.         Ypixel = Y \ PixelSize
  994.         MaskColor = Pic_Mask.Point(Xpixel, Ypixel)
  995.         Pic_Work.FillColor = Pic_Edit.ForeColor
  996.         Pic_Work.Picture = Pic_Icons(CurrentIcon).Image
  997.         R = ExtFloodFill(Pic_Work.hDC, Xpixel, Ypixel, Pic_Icons(CurrentIcon).Point(Xpixel, Ypixel), FLOODFILLSURFACE)
  998.         For Ypix = 0 To 31
  999.             For Xpix = 0 To 31
  1000.                 NewPixelColor = Pic_Work.Point(Xpix, Ypix)
  1001.                 If (Pic_Icons(CurrentIcon).Point(Xpix, Ypix) <> NewPixelColor) And (Pic_Mask.Point(Xpix, Ypix) = MaskColor) Then
  1002.                     '
  1003.                     ' Pixel was changed by the FloodFill and its Mask matched that of the
  1004.                     ' starting Pixel, so we make the change on the Icons Image and Mask
  1005.                     '
  1006.                     If Opt_Mouse(SCREEN_COLORS).Value Then NewPixelColor = Pic_Image.ForeColor
  1007.                     Pic_Image.PSet (Xpix, Ypix), NewPixelColor
  1008.                     Pic_Mask.PSet (Xpix, Ypix)
  1009.                 End If
  1010.             Next Xpix
  1011.         Next Ypix
  1012.         Screen.MousePointer = DEFAULT
  1013.         X2 = 31
  1014.         Y2 = 31
  1015.     End If
  1016. End Sub
  1017. ' This routine Flips (Mirrors) the current Selection either
  1018. ' Horizontally or Vertically.   The Windows API StretchBlt()
  1019. ' routine is used to perform the Flip operation.
  1020. Sub Flip_Selection (Index)
  1021.     W = X2SelectFrom - X1SelectFrom
  1022.     H = Y2SelectFrom - Y1SelectFrom
  1023.     If Index = MID_FLIP_HORIZONTAL Then
  1024.         DestX = X2SelectFrom - 1
  1025.         DestY = Y1SelectFrom
  1026.         DestWidth = -W
  1027.         DestHeight = H
  1028.     Else
  1029.         DestX = X1SelectFrom
  1030.         DestY = Y2SelectFrom - 1
  1031.         DestWidth = W
  1032.         DestHeight = -H
  1033.     End If
  1034.     R = StretchBlt(Pic_TempImage.hDC, DestX, DestY, DestWidth, DestHeight, Pic_TempImage.hDC, X1SelectFrom, Y1SelectFrom, W, H, SRCCOPY)
  1035.     R = StretchBlt(Pic_TempMask.hDC, DestX, DestY, DestWidth, DestHeight, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, W, H, SRCCOPY)
  1036.     R = StretchBlt(Pic_Work.hDC, DestX, DestY, DestWidth, DestHeight, Pic_Work.hDC, X1SelectFrom, Y1SelectFrom, W, H, SRCCOPY)
  1037.     Scale_Region True, X1, Y1, X2, Y2, False
  1038.     If Not MovingSelection Then Commit_Selection False
  1039.     Magnify_Icon X1, Y1, X2, Y2
  1040. End Sub
  1041. Sub Form_Load ()
  1042.     ' Determine color mode and set Icons Image bitmap size accordingly
  1043.     ' This value, ImageSize, is used within the routines Update_Icon and
  1044.     ' Extract_Image_And_Mask within ICONWRKS.BAS
  1045.     '
  1046.     If GetDeviceCaps(hDC, BITSPIXEL) = 8 Then
  1047.         ImageSize = 1024 'bytes
  1048.     Else
  1049.         ImageSize = 512  'bytes
  1050.     End If
  1051.     ' Depending on the Video mode and video driver being used for Windows,
  1052.     ' the controls on a form might not be the same dimensions when loaded
  1053.     ' under differenct resolutions.  Since the Editor is based on a
  1054.     ' 32x32 pixel Icon, the Picture controls that are used to manipulate
  1055.     ' the icons must be set at runtime to 32x32.
  1056.     '
  1057.     ' Position and size Icon within StatusArea
  1058.     '
  1059.     Edge = (Pic_StatusArea.ScaleWidth - 64) \ 3
  1060.     For Y = 0 To 2
  1061.         For X = 0 To 1
  1062.             Pic_Icons(X + Y * 2).Move Edge + X * (32 + Edge), Edge + Y * (32 + Edge), 32, 32
  1063.         Next X
  1064.     Next Y
  1065.     Pic_Mask.Move 0, 0, 32, 32
  1066.     Pic_Image.Move 0, 0, 32, 32
  1067.     Pic_TempMask.Move 0, 0, 32, 32
  1068.     Pic_TempImage.Move 0, 0, 32, 32
  1069.     Pic_Work.Move 0, 0, 32, 32
  1070.     Pic_Grid.Move 0, 0, 32, 32
  1071.     Pic_ToolPalette.Move 0, 0, 32, 256
  1072.     Pic_Undo.Move Pic_StatusArea.ScaleWidth - 34, (Editor.Pic_Icons(5).Top + Editor.Pic_Icons(5).Height + 2.5 * HIGHLIGHT), 32, 32
  1073.     Get_INI_File_Settings
  1074.     ' Adjust size of Editor appropriately for the Video mode.
  1075.     '
  1076.     If Screen.Height = EGA_HEIGHT Then
  1077.         '
  1078.         ' EGA mode
  1079.         '
  1080.         
  1081.         NewWidth = Width
  1082.         NewHeight = Screen.Height
  1083.         NewTop = 0
  1084.     Else
  1085.         ' VGA or Better
  1086.         '
  1087.         NewWidth = Screen.Width * .75
  1088.         NewHeight = Screen.Height * .75
  1089.         NewTop = (Screen.Height - NewHeight) \ 2
  1090.     End If
  1091.     Move (Screen.Width - NewWidth) \ 2, NewTop, NewWidth, NewHeight
  1092.     ' Icon is initially displayed at full maginification
  1093.     '
  1094.     Scrl_Zoom.Value = Scrl_Zoom.Max
  1095.     ' Create Monochrome Hdc and Bitmap to be used when replace the
  1096.     ' Icons Monochrome Mask.
  1097.     '
  1098.     MonoHdc = CreateCompatibleDC(hDC)
  1099.     MonoHbm = CreateCompatibleBitmap(MonoHdc, 32, 32)
  1100.     OldObject = SelectObject(MonoHdc, MonoHbm)
  1101.     ' The BackColor of the Editing area picture control, Pic_Edit,
  1102.     ' is set to Red at design time just so the picture controls contained
  1103.     ' within it are visible at design time.
  1104.     '
  1105.     Pic_Edit.BackColor = WHITE
  1106.     ' Select initial tool and brushsize
  1107.     '
  1108.     CurrentTool = TID_PAINT
  1109.     BrushSize = 1
  1110.     ' Initialize Default Mouse Colors
  1111.     '
  1112.     MouseColors(0) = BLACK  'Left
  1113.     MouseColors(1) = RED    'Right
  1114.     MouseColors(2) = WHITE  'Screen
  1115.     MouseColors(3) = BLACK  'Inverse
  1116.     ' Add Accelerators that are not available from the Menu Design window
  1117.     ' to the appropriate menu items.
  1118.     '
  1119.     Menu_FileSelection(MID_EXIT).Caption = "E&xit" + A_TAB + "Alt+F4"
  1120.     'Menu_EditSelection(MID_UNDO).Caption = "&Undo" + A_TAB + "Alt+Bksp"
  1121.     'Menu_EditSelection(MID_CUT).Caption = "Cu&t" + A_TAB + "Shift+Del"
  1122.     'Menu_EditSelection(MID_COPY).Caption = "&Copy" + A_TAB + "Ctrl+Ins"
  1123.     'Menu_EditSelection(MID_PASTE).Caption = "&Paste" + A_TAB + "Shift+Ins"
  1124.     'Menu_EditSelection(MID_PASTE_OPAQUE).Caption = "Paste &Opaque" + A_TAB + "Ctrl+Shift+Ins"
  1125.     'Menu_EditSelection(MID_DELETE).Caption = "&Delete" + A_TAB + "Del"
  1126.     ' Initialize all 6 Icons filename to UNTITLED, so a File.Save opertion
  1127.     ' will react just like a File.Save As, the first time.
  1128.     '
  1129.     For I = 0 To 5
  1130.       IconInfo(I).FileName = UNTITLED
  1131.     Next I
  1132.     EditorLoaded = True
  1133. End Sub
  1134. ' Just for an added convience when selecting tools, Clicking anywhere
  1135. ' on the Editor that is not covered by another control, will display
  1136. ' the Tools menu as a pupup menu at that location.
  1137. Sub Form_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  1138.     ' Menu is displayed on if the left button is used.
  1139.     '
  1140.     If (Button = RIGHT_BUTTON) And Menu_ViewSelection(MID_POPUP_MENU).Checked Then
  1141.         '
  1142.         ' The X and Y coordintes passed to the TrackPopupMenu() API routine
  1143.         ' are Screen coordinates in pixels, not Form coordinates, so, the
  1144.         ' X and Y coordinates of the Mouse must be adjusted, taking into
  1145.         ' account the position of the form.  And for a little more added
  1146.         ' convience, another adjustment is made so when the menu pops up,
  1147.         ' the mouse poiner is directly over the currently selected tool.
  1148.         '
  1149.         InPixels = ScaleWidth
  1150.         ScaleMode = TWIPS
  1151.         TwipsToPixels = ScaleWidth \ InPixels
  1152.         Borders = (Width - ScaleWidth)
  1153.         TitleBarAndMenu = (Height - ScaleHeight - Borders)
  1154.         IX = X + (Left \ TwipsToPixels)
  1155.         IY = Y + (Top + TitleBarAndMenu - CurrentTool * (TitleBarAndMenu \ 2)) \ TwipsToPixels
  1156.         ScaleMode = pixels
  1157.         Menu_ToolsSelection(CurrentTool).Checked = True
  1158.         R = TrackPopupMenu(GetSubMenu(GetMenu(hwnd), 3), 0, IX, IY, 0, hwnd, 0)
  1159.     End If
  1160. End Sub
  1161. ' Resizing of the Editor can, depending on the new size, force any
  1162. ' of the palettes to be hidden, so all major controls must be
  1163. ' resized, repositioned and possibly hidden in reponse to resizing
  1164. ' the Editor.
  1165. Sub Form_Resize ()
  1166. Static LastWindowState
  1167.     ' Nothing is done if the Editor is minimized.
  1168.     '
  1169.     If WindowState = MINIMIZED Then
  1170.         '
  1171.         ' Hide ColorPalette since it should not be visible while the
  1172.         ' Editor is Minimized.
  1173.         '
  1174.         If ColorPaletteLoaded Then ColorPalette.Hide
  1175.     ElseIf ScaleHeight >= 34 Then
  1176.         '
  1177.         ' Hide the Editing area while resizing other controls
  1178.         ' to prevent uneccessary repaints.
  1179.         '
  1180.         Pic_Edit.Visible = False
  1181.         ' Adjust all major controls
  1182.         '
  1183.         Adjust_Status_Bar
  1184.         Adjust_Tool_Palette
  1185.         Adjust_Color_Palette
  1186.         Adjust_ScrollBar
  1187.         ' Hide or Show the major controls, based on their corresponding View
  1188.         ' menu item Checked value, which was set within the above *Adjust*
  1189.         ' routines.
  1190.         '
  1191.         Pic_ColorPalette.Visible = Menu_ViewSelection(MID_COLOR_PALETTE).Checked
  1192.         Pic_ToolPalette.Visible = Menu_ViewSelection(MID_TOOL_PALETTE).Checked
  1193.         Pic_StatusArea.Visible = Menu_ViewSelection(MID_STATUS_BAR).Checked
  1194.         Scrl_Zoom.Visible = Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked
  1195.         
  1196.         If (LastWindowState = MINIMIZED) And ColorPaletteLoaded Then ColorPalette.Show
  1197.     End If
  1198.     LastWindowState = WindowState
  1199. End Sub
  1200. ' Editor is being terminated
  1201. Sub Form_Unload (Cancel As Integer)
  1202.     ' Check fo any icons that have been modified since they
  1203.     ' were last saved.
  1204.     '
  1205.     Text = ""
  1206.     For I = 0 To 5
  1207.         If IconInfo(I).Changed Then Text = Text + "Icon #" + Right$(Menu_IconsSelection(I).Caption, Len(Menu_IconsSelection(I).Caption) - 1) + CRLF
  1208.     Next I
  1209.     If Text <> "" Then
  1210.         '
  1211.         ' One or more icons were changed, so prompt user.
  1212.         '
  1213.         Text = Text + CRLF + "The icons listed have not been saved since their last modification.  Quit anyway?"
  1214.         Cancel = MsgBox(Text, 36, "ICONS HAVE CHANGED") = MBNO
  1215.     End If
  1216.     If Not Cancel Then
  1217.         '
  1218.         ' User wants to terminate Editor, so clean up.
  1219.         '
  1220.         EditorLoaded = False
  1221.         Unload ColorPalette
  1222.         R = DeleteDC(MonoHdc)
  1223.         R = DeleteObject(MonoHbm)
  1224.         R = WinHelp(hwnd, dummy$, HELP_QUIT, 0)
  1225.         Save_Settings_To_INI_File
  1226.         '
  1227.         ' If Editor was started up first (Null command line or anything other than
  1228.         ' "v" or "V") then we treat it as the main Form.  So, if the Viewer is loaded,
  1229.         ' we should as the user if the Viewer should also be terminated.
  1230.         '
  1231.         If (MainForm = ICONWORKS_EDITOR) And ViewerLoaded Then
  1232.             '
  1233.             ' Editor was started first and the Viewer is loaded so ask the user
  1234.             ' if the Viewer should also be terminated.
  1235.             '
  1236.             Text = "Terminate Viewer also?"
  1237.             If MsgBox(Text, 36, "IconWorks") = MBYES Then Unload Viewer
  1238.             MainForm = ICONWORKS_VIEWER
  1239.         End If
  1240.     End If
  1241. End Sub
  1242. ' In response to a MouseDown event in the Edit area, the first thing
  1243. ' that must be done is deterine what color to use when drawing the object.
  1244. Sub Get_Current_Colors (Button As Integer)
  1245.     ' Determine which of the 4 currently selected colors to use, and
  1246.     ' assign to the Edit area's foreground color.
  1247.     Index = Opt_Mouse(SCREEN_COLORS).Value * (-2) + Button - 1
  1248.     Pic_Edit.ForeColor = MouseColors(Index)
  1249.     ' If using the Paint tool, we must use the Neaest Solid color to the selected color.
  1250.     If CurrentTool = TID_PAINT Then Pic_Edit.ForeColor = GetNearestColor(hDC, Pic_Edit.ForeColor)
  1251.     If Opt_Mouse(MOUSE_COLORS).Value Then
  1252.         Pic_Image.ForeColor = Pic_Edit.ForeColor
  1253.     Else
  1254.         Pic_Image.ForeColor = (Button = RIGHT_BUTTON) And WHITE
  1255.     End If
  1256.     Pic_Mask.ForeColor = Opt_Mouse(SCREEN_COLORS).Value And WHITE
  1257.     Pic_Image.FillColor = Pic_Image.ForeColor
  1258.     Pic_Mask.FillColor = Pic_Mask.ForeColor
  1259.     Pic_Edit.FillColor = Pic_Edit.ForeColor
  1260. End Sub
  1261. ' This routine is called to read the color value strings from
  1262. ' the IconWrks.INI file, and then have The values extracted
  1263. Sub Get_INI_File_Colors ()
  1264.     ColorString = Space$(144)
  1265.     R = GetPrivateProfileString(APP_NAME, KEY_COLOR + "1", DEFAULT_COLORS_ROW1, ColorString, Len(ColorString), INI_FILENAME)
  1266.     Extract_Colors_From_String ColorString, 0, False
  1267.     R = GetPrivateProfileString(APP_NAME, KEY_COLOR + "2", DEFAULT_COLORS_ROW2, ColorString, Len(ColorString), INI_FILENAME)
  1268.     Extract_Colors_From_String ColorString, 16, False
  1269.     R = GetPrivateProfileString(APP_NAME, KEY_COLOR + "3", DEFAULT_COLORS_ROW3, ColorString, Len(ColorString), INI_FILENAME)
  1270.     Extract_Colors_From_String ColorString, 32, True
  1271. End Sub
  1272. ' This routine is called only once, which is at load time to obtain
  1273. ' all settings saved to the IconWrks.INI file.
  1274. Sub Get_INI_File_Settings ()
  1275.     Menu_ViewSelection(MID_STATUS_BAR).Checked = -GetPrivateProfileInt(APP_NAME, KEY_STATUS_BAR, 1, INI_FILENAME)
  1276.     Menu_ViewSelection(MID_TOOL_PALETTE).Checked = -GetPrivateProfileInt(APP_NAME, KEY_TOOL_PALETTE, 1, INI_FILENAME)
  1277.     Menu_ViewSelection(MID_COLOR_PALETTE).Checked = -GetPrivateProfileInt(APP_NAME, KEY_COLOR_PALETTE, 1, INI_FILENAME)
  1278.     Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked = -GetPrivateProfileInt(APP_NAME, KEY_ZOOM_SCROLLBAR, 1, INI_FILENAME)
  1279.     Menu_ViewSelection(MID_GRID).Checked = -GetPrivateProfileInt(APP_NAME, KEY_GRID, 0, INI_FILENAME)
  1280.     Menu_ViewSelection(MID_LINE_GRID).Checked = -GetPrivateProfileInt(APP_NAME, KEY_LINE_GRID, 1, INI_FILENAME)
  1281.     Menu_ViewSelection(MID_DOTTED_GRID).Checked = -GetPrivateProfileInt(APP_NAME, KEY_DOTTED_GRID, 0, INI_FILENAME)
  1282.     Menu_ViewSelection(MID_FOCUS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_FOCUS, 1, INI_FILENAME)
  1283.     Menu_ViewSelection(MID_BORDER).Checked = -GetPrivateProfileInt(APP_NAME, KEY_BORDER, 1, INI_FILENAME)
  1284.     Menu_ViewSelection(MID_POPUP_MENU).Checked = -GetPrivateProfileInt(APP_NAME, KEY_POPUP, 1, INI_FILENAME)
  1285.     ' Get all Checked Color Menu item values
  1286.     Menu_ColorSelection(MID_DEFAULT_COLORS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_DEFAULT, 1, INI_FILENAME)
  1287.     Menu_ColorSelection(MID_SOLID_COLORS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_SOLID, 0, INI_FILENAME)
  1288.     Menu_ColorSelection(MID_INI_COLORS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_INI, 0, INI_FILENAME)
  1289.     ' Enable or Disable the Grid type menu items based on the Check value
  1290.     Menu_ViewSelection(MID_LINE_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  1291.     Menu_ViewSelection(MID_DOTTED_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  1292.     ' Set initial color palette
  1293.     If Menu_ColorSelection(MID_DEFAULT_COLORS).Checked Then Index = MID_DEFAULT_COLORS
  1294.     If Menu_ColorSelection(MID_SOLID_COLORS).Checked Then Index = MID_SOLID_COLORS
  1295.     If Menu_ColorSelection(MID_INI_COLORS).Checked Then Index = MID_INI_COLORS
  1296.     Menu_ColorSelection_Click Index
  1297. End Sub
  1298. ' In response to an Edit.Invert menu item selection, this routine
  1299. ' Inverts the Colors of the selection region.  Using a DrawMode
  1300. ' of INVERSE, a filled box is drawn over the selected region, which
  1301. ' inverts the colors.
  1302. Sub Invert_Selection ()
  1303.     Pic_TempImage.DrawMode = INVERSE
  1304.     Pic_Work.DrawMode = INVERSE
  1305.     ' Invert Selected Region.  Do not need to Invert Mask.
  1306.     Pic_TempImage.Line (X1SelectFrom, Y1SelectFrom)-(X2SelectFrom, Y2SelectFrom), , BF
  1307.     Pic_Work.Line (X1SelectFrom, Y1SelectFrom)-(X2SelectFrom, Y2SelectFrom), , BF
  1308.     Pic_TempImage.DrawMode = COPY_PEN
  1309.     Pic_Work.DrawMode = COPY_PEN
  1310.     If MovingSelection Then Draw_Selection_Rectangle Else Commit_Selection False
  1311.     Magnify_Icon X1SelectFrom, Y1SelectFrom, (X2SelectFrom), (Y2SelectFrom)
  1312. End Sub
  1313. ' Once an object, Line, Square, Filled Square, Circle, or Filled Circle
  1314. ' has been size to what the user wants, this routine is called from the
  1315. ' MouseUp event for the Editing area (Pic_Edit) to display the actual
  1316. ' object.
  1317. Sub Line_To_Filled_Circle_MouseUp (X1, Y1, X2, Y2)
  1318.     Pic_Image.DrawWidth = BrushSize
  1319.     Pic_Mask.DrawWidth = BrushSize
  1320.     If CurrentTool = TID_FILLED_SQUARE Or CurrentTool = TID_FILLED_CIRCLE Then
  1321.         Pic_Image.FillStyle = Solid
  1322.         Pic_Mask.FillStyle = Solid
  1323.     End If
  1324.     ' Scale the dimensions of the object from the Editing area down
  1325.     ' to that of the Icon, 32x32.
  1326.     Scale_Region True, X1, Y1, X2, Y2, False
  1327.     Select Case CurrentTool
  1328.         Case TID_LINE
  1329.             Pic_Image.Line (X1, Y1)-(X2, Y2)
  1330.             '
  1331.             ' Draw end-point only if BrushSize is one Pixel
  1332.             If BrushSize = 1 Then Pic_Image.PSet (X2, Y2)
  1333.             Pic_Mask.Line (X1, Y1)-(X2, Y2)
  1334.             If BrushSize = 1 Then Pic_Mask.PSet (X2, Y2)
  1335.         Case TID_SQUARE, TID_FILLED_SQUARE
  1336.             Pic_Image.Line (X1, Y1)-(X2, Y2), , B
  1337.             Pic_Mask.Line (X1, Y1)-(X2, Y2), , B
  1338.         Case TID_CIRCLE, TID_FILLED_CIRCLE
  1339.             If Valid_Circle(X1, Y1, X2, Y2) Then
  1340.                 Pic_Image.Circle (XCenter, YCenter), Radius, , , , Aspect
  1341.                 Pic_Mask.Circle (XCenter, YCenter), Radius, , , , Aspect
  1342.                 Radius = 0
  1343.             End If
  1344.     End Select
  1345.     If X1 > X2 Then Swap_Values X1, X2
  1346.     If Y1 > Y2 Then Swap_Values Y1, Y2
  1347.     Pic_Image.DrawWidth = 1
  1348.     Pic_Mask.DrawWidth = 1
  1349.     Pic_Image.FillStyle = TRANSPARENT
  1350.     Pic_Mask.FillStyle = TRANSPARENT
  1351.     ' Only the area modified is redisplayed, which is the rectangle
  1352.     ' defined by the values of X1, Y1, X2, Y2.  If the Brushsize is
  1353.     ' greater than 1 pixel, then the actual area modified is slightly
  1354.     ' larger than the this rectangle, so the values X1, Y1, X2, Y2
  1355.     ' must be adjusted to include the thickness of the Brushsize so
  1356.     ' the entire area modified is redisplayed.
  1357.     '
  1358.     If (BrushSize > 1) And (CurrentTool >= TID_LINE) Then
  1359.         Adjustment = BrushSize \ 2
  1360.         X1 = X1 - Adjustment - 1
  1361.         Y1 = Y1 - Adjustment - 1
  1362.         X2 = X2 + Adjustment + 1
  1363.         Y2 = Y2 + Adjustment + 1
  1364.     End If
  1365. End Sub
  1366. ' For the Line, Square, Filled Square, Circle, and Filled Circle Tools,
  1367. ' an Inverted resizeable version of the object is displayed in response
  1368. ' to a MouseMove.  The object is anchored at the point set by the MouseDown
  1369. ' event within the Editing area.  This routine is called to erase the
  1370. ' old object and display the new object during a MouseMove event.
  1371. Sub Line_To_Filled_Circle_Tool_Move (Shift As Integer, X As Single, Y As Single)
  1372. Static LastCircleGood
  1373.     ' Erase Old object
  1374.     '
  1375.     Draw_Line_Or_Box
  1376.     If (CurrentTool >= TID_CIRCLE) And LastCircleGood Then Pic_Edit.Circle (XCenter, YCenter), Radius, , , , Aspect
  1377.     Adjust_X_and_Y X, Y, X2Region, Y2Region, TO_CENTER
  1378.     ' Holding the Shift key down forces a perfect Square or Circle.
  1379.     ' For a line, it forces either a Horizontal, Vertical or 45 degree
  1380.     ' line to be displayed.
  1381.     '
  1382.     If Shift And SHIFT_MASK Then Make_Region_Square
  1383.     If CurrentTool >= TID_CIRCLE Then
  1384.         '
  1385.         ' When sizing a circle, a rectangle with the circle displayed
  1386.         ' within the circle is drawn.  This is done to give a better
  1387.         ' feeling that the mouse is attached to the object when sizing.
  1388.         ' The rectanle is not drawn one the mouse is released.
  1389.         '
  1390.         LastCircleGood = Valid_Circle(X1Region, Y1Region, X2Region, Y2Region)
  1391.         If LastCircleGood Then Pic_Edit.Circle (XCenter, YCenter), Radius, , , , Aspect
  1392.     End If
  1393.     ' Draw New Object
  1394.     '
  1395.     Draw_Line_Or_Box
  1396. End Sub
  1397. ' To make creating a perfect Square, Circle, or a Diagonal, Vertical,
  1398. ' or Horizontal line, the routine is called whenever the Shift key
  1399. ' is depressed in conjuction to dragging the Mouse within the Editing
  1400. ' area.  This routine adjusts the actual mouse coordinates so that
  1401. ' the displayed object is Square, or in the case of a line, Diagonal,
  1402. ' Vertical, or Horizontal.
  1403. Sub Make_Region_Square ()
  1404.     Xside = Abs(X2Region - X1Region)
  1405.     Yside = Abs(Y2Region - Y1Region)
  1406.     If Xside > Yside Then RectSide = Xside Else RectSide = Yside
  1407.     X2Region = X1Region + RectSide * Sgn(X2Region - X1Region)
  1408.     Y2Region = Y1Region + RectSide * Sgn(Y2Region - Y1Region)
  1409. End Sub
  1410. ' Changes size of brush to either 1x1, 3x3, or 5x5, and
  1411. ' Checks the corresponding Bush menu item
  1412. Sub Menu_BrushSelection_Click (Index As Integer)
  1413.     Menu_BrushSelection(BrushSize).Checked = False
  1414.     Menu_BrushSelection(Index).Checked = True
  1415.     BrushSize = Index
  1416. End Sub
  1417. ' Processes all Color Menu selections.
  1418. Sub Menu_ColorSelection_Click (Index As Integer)
  1419.     Select Case Index
  1420.         Case MID_COLORS
  1421.             '
  1422.             ' Invoke Custom ColorPalette form
  1423.             '
  1424.             ColorIndex = 0
  1425.             ColorPalette.Show
  1426.         Case MID_DEFAULT_COLORS
  1427.             '
  1428.             ' Default color palette is the same colors as the VB colorpalette
  1429.             '
  1430.             Extract_Colors_From_String DEFAULT_COLORS_ROW1, 0, False
  1431.             Extract_Colors_From_String DEFAULT_COLORS_ROW2, 16, False
  1432.             Extract_Colors_From_String DEFAULT_COLORS_ROW3, 32, True
  1433.         
  1434.         Case MID_SOLID_COLORS
  1435.             '
  1436.             ' Solid colors are the 16 colors returned from QBColors()
  1437.             '
  1438.             Menu_ColorSelection(MID_SOLID_COLORS).Checked = True
  1439.             Show_Solid_Colors_Only
  1440.         Case MID_INI_COLORS
  1441.             '
  1442.             ' If there are Colors saved to the INI file, they will
  1443.             ' be displayed, otherwise, the Default colors will be displayed
  1444.             '
  1445.             Menu_ColorSelection(MID_INI_COLORS).Checked = True
  1446.             Get_INI_File_Colors
  1447.         Case MID_SAVE_COLORS
  1448.             Save_Colors_To_INI_File
  1449.         Case MID_LEFT_RIGHT, MID_SCREEN_INVERSE
  1450.             '
  1451.             ' Same functionality as clicking either of the Mouse Option buttons
  1452.             '
  1453.             Opt_Mouse(Index - MID_LEFT_RIGHT).Value = True
  1454.     End Select
  1455.     ' If the selection was 1 of the 3 colorpalette selections, Check
  1456.     ' the current selection, and Uncheck the previous selection.
  1457.     '
  1458.     If (Index >= MID_DEFAULT_COLORS) And (Index <= MID_INI_COLORS) Then
  1459.         Menu_ColorSelection(MID_DEFAULT_COLORS).Checked = (Index = MID_DEFAULT_COLORS)
  1460.         Menu_ColorSelection(MID_SOLID_COLORS).Checked = (Index = MID_SOLID_COLORS)
  1461.         Menu_ColorSelection(MID_INI_COLORS).Checked = (Index = MID_INI_COLORS)
  1462.     End If
  1463. End Sub
  1464. ' Prepares the Edit menus Sub menu items, by Enabling or Disabling
  1465. ' the menu items depending on whether there is a current selection
  1466. ' or if the current selection is being moved, and the current format
  1467. ' of the system ClipBoard.
  1468. Sub Menu_Edit_Click ()
  1469.     Menu_EditSelection(MID_CUT).Enabled = Selecting And Not MovingSelection
  1470.     Menu_EditSelection(MID_COPY).Enabled = Selecting And Not MovingSelection
  1471.     Menu_EditSelection(MID_PASTE).Enabled = Clipboard.GetFormat(CF_BITMAP)
  1472.     Menu_EditSelection(MID_PASTE_OPAQUE).Enabled = Clipboard.GetFormat(CF_BITMAP)
  1473.     Menu_EditSelection(MID_DELETE).Enabled = Selecting And Not MovingSelection
  1474.     Menu_EditSelection(MID_FLIP_HORIZONTAL).Enabled = Selecting
  1475.     Menu_EditSelection(MID_FLIP_VERTICAL).Enabled = Selecting
  1476.     Menu_EditSelection(MID_ROTATE_LEFT).Enabled = Selecting And (Not MovingSelection) And ((X2Region - X1Region) = (Y2Region - Y1Region))
  1477.     Menu_EditSelection(MID_ROTATE_RIGHT).Enabled = Selecting And (Not MovingSelection) And ((X2Region - X1Region) = (Y2Region - Y1Region))
  1478.     Menu_EditSelection(MID_INVERT).Enabled = Selecting
  1479. End Sub
  1480. ' Processes all Edit Menu selections.
  1481. Sub Menu_EditSelection_Click (Index As Integer)
  1482.     Select Case Index
  1483.         Case MID_UNDO
  1484.             UnDo_Edits
  1485.         Case MID_CUT, MID_COPY, MID_DELETE
  1486.             Cut_Copy_Or_Delete_Selection Index
  1487.             
  1488.         Case MID_PASTE, MID_PASTE_OPAQUE
  1489.             Paste_ClipBoard_Contents Index
  1490.         Case MID_SELECT_All
  1491.             Select_Entire_Icon
  1492.         Case MID_FLIP_HORIZONTAL, MID_FLIP_VERTICAL
  1493.             Flip_Selection Index
  1494.         Case MID_ROTATE_RIGHT, MID_ROTATE_LEFT
  1495.             Rotate_Selection Index
  1496.         Case MID_INVERT
  1497.             Invert_Selection
  1498.     End Select
  1499. End Sub
  1500. ' Processes all File Menu selections.
  1501. Sub Menu_FileSelection_Click (Index As Integer)
  1502.     Select Case Index
  1503.         Case MID_NEW
  1504.             Prepare_For_New_Icon
  1505.       
  1506.         Case MID_OPEN
  1507.             Viewer.Show MODELESS
  1508.         Case MID_SAVE, MID_SAVE_AS
  1509.             Save_Icon Index
  1510.         Case MID_EXIT
  1511.             Unload Editor
  1512.     End Select
  1513. End Sub
  1514. ' Processes all Help Menu selections.
  1515. Sub Menu_HelpSelection_Click (Index As Integer)
  1516.     If Index = MID_ABOUT Then
  1517.         AboutBox.Show MODAL
  1518.     Else
  1519.         Get_Help Index
  1520.     End If
  1521. End Sub
  1522. ' Processes all Icons Menu selections.  Same as clicking
  1523. ' one of the Icons within the StatusArea.
  1524. Sub Menu_IconsSelection_Click (Index As Integer)
  1525.     Pic_Icons_MouseDown Index, LEFT_BUTTON, 0, 0, 0
  1526. End Sub
  1527. ' Prepares for the Tools sub menu to be shown, by Checking
  1528. ' the currently selected tool.
  1529. Sub Menu_Tools_Click ()
  1530.     Menu_ToolsSelection(CurrentTool).Checked = True
  1531. End Sub
  1532. ' Processes all Tools Menu selections.  Same as clicking any
  1533. ' tool within the ToolPalette
  1534. Sub Menu_ToolsSelection_Click (Index As Integer)
  1535.     Pic_ToolPalette_MouseDown LEFT_BUTTON, 0, 0, Index * 32
  1536. End Sub
  1537. ' Processes all View Menu selections.
  1538. Sub Menu_ViewSelection_Click (Index As Integer)
  1539.     Select Case Index
  1540.         Case MID_STATUS_BAR, MID_TOOL_PALETTE, MID_COLOR_PALETTE, MID_ZOOM_SCROLLBAR, MID_FOCUS, MID_BORDER, MID_POPUP_MENU
  1541.             Menu_ViewSelection(Index).Checked = Not Menu_ViewSelection(Index).Checked
  1542.             If Index = MID_BORDER Then
  1543.                 HighLight_Current_Icon
  1544.             ElseIf Index < MID_FOCUS Then
  1545.                 '
  1546.                 ' Must process a From_Resize to make the Above selection
  1547.                 ' take affect since all hiding and showing of palettes is
  1548.                 ' done within the Form_Resize event.
  1549.                 '
  1550.                 Form_Resize
  1551.             End If
  1552.         Case MID_SHOW_ALL
  1553.             For I = 0 To 3
  1554.                 Menu_ViewSelection(I).Checked = True
  1555.             Next I
  1556.             Form_Resize
  1557.         Case MID_GRID
  1558.             Activate_Grid
  1559.         Case MID_LINE_GRID, MID_DOTTED_GRID
  1560.             Select_Grid_Type Index
  1561.         Case MID_ZOOM_IN
  1562.             Scrl_Zoom.Value = Scrl_Zoom.Value + 32
  1563.         Case MID_ZOOM_OUT
  1564.             Scrl_Zoom.Value = Scrl_Zoom.Value - 32
  1565.       
  1566.     End Select
  1567.     If ((Index = MID_STATUS_BAR) Or (Index = MID_SHOW_ALL)) And Menu_ViewSelection(MID_STATUS_BAR).Checked Then Display_Color_Palette Pic_ColorPalette
  1568. End Sub
  1569. ' One of the Mouse Button Options Buttons was selected, so update
  1570. ' the corresponding Color menu items Checked value.
  1571. Sub Opt_Mouse_Click (Index As Integer)
  1572.     Menu_ColorSelection(MID_LEFT_RIGHT).Checked = Not (-Index)
  1573.     Menu_ColorSelection(MID_SCREEN_INVERSE).Checked = -Index
  1574. End Sub
  1575. ' The paint tools is the only tool that paints directly to the
  1576. ' Editing area during the MouseMove event.  This routine draws
  1577. ' the pixels to the Icons Image and Mask, and to the Editing area,
  1578. ' so, there is no need to redisplay teh modified area of the Icon
  1579. ' in response to a MouseUp event.  However, the StatusArea Icon
  1580. ' will not display the modificatioin until a MouseUp event.
  1581. Sub Paint_Tool_Move (Xpix, Ypix)
  1582.                 
  1583.     ' Adjust Mouse position so it is centered within the Pixel being
  1584.     ' drawn.
  1585.     '
  1586.     Adjustment = BrushSize \ 2
  1587.     X1 = Xpix - Adjustment
  1588.     Y1 = Ypix - Adjustment
  1589.     X2 = Xpix + Adjustment
  1590.     Y2 = Ypix + Adjustment
  1591.     ' Draw pixel on Icons Image and Mask
  1592.     '
  1593.     Pic_Image.Line (X1, Y1)-(X2, Y2), , BF
  1594.     Pic_Mask.Line (X1, Y1)-(X2, Y2), , BF
  1595.     ' Draw pixel on Editing area
  1596.     '
  1597.     X2 = X2 + 1
  1598.     Y2 = Y2 + 1
  1599.     Pic_Edit.Line (X1 * PixelSize, Y1 * PixelSize)-(X2 * PixelSize - 1, Y2 * PixelSize - 1), , BF
  1600.     ' Redisplay Grid in modified area if Grid is selected.
  1601.     '
  1602.     If Menu_ViewSelection(MID_GRID).Checked Then Display_Grid (Pic_Edit.hDC), X1, Y1, X2, Y2
  1603. End Sub
  1604. ' In response to an Edit.Paste or Edit.Paste Opaque, this routine is called
  1605. ' to perform the acutal paste operation.  There are two forms of the Paste:
  1606. '   Paste Shift+Ins:  Creates a Mask from the bitmap in the clipboard
  1607. '                     based on the current Screen Color selected.  All
  1608. '                     Pixels in the Bitmap that match the Screen Color
  1609. '                     become transparent.
  1610. '   Paste Opaque Ctrl+Shift+Ins:  No mask is created from the bitmap and
  1611. '                     It is pasted as is with no Screen Color attributes.
  1612. Sub Paste_ClipBoard_Contents (Index)
  1613.             
  1614.     ' Get Bitmap from System Clipboard
  1615.     '
  1616.     Pic_Work.Picture = Clipboard.GetData(CF_BITMAP)
  1617.     ' Determine if Bitmap is too large to paste.  Must be 32x32 pixels or
  1618.     ' smaller.
  1619.     '
  1620.     If Pic_Work.Width <= 32 And Pic_Work.Height <= 32 Then
  1621.         '
  1622.         ' Change tool selection to SelectTool, which will allow us to
  1623.         ' move the Bitmap being pasted to anywhere within the Icon.
  1624.         '
  1625.         Pic_ToolPalette_MouseDown LEFT_BUTTON, 0, 0, TID_SELECT * 32
  1626.         
  1627.         Pic_TempImage.Picture = Pic_Work.Image
  1628.         Opaque = MID_PASTE - Index
  1629.         If Opaque Then
  1630.             ' An Opaque paste, so the Bitmap is pasted as is.  So we simply create
  1631.             ' a solid Black mask.
  1632.             '
  1633.             Pic_TempMask.Line (0, 0)-(Pic_TempMask.ScaleWidth, Pic_TempMask.ScaleHeight), BLACK, BF
  1634.         Else
  1635.             ' A normal paste, so a Mask must be created from the Bitmap being pasted,
  1636.             ' based on the currently selected Screen color.  The Mask is created, by
  1637.             ' BitBlt'ing the the 16-color bitmap to a mono Hdc.  All pixels in the color
  1638.             ' bitmap which are the screen color will be white in the monochrome bitmap,
  1639.             ' all others will be black.  That is why the Backcolor of the Picture control
  1640.             ' containing the bitmap is first set to the currently selected Screen color.
  1641.             ' This Monochrome bitmap is then BitBlt'd back to a 16-Color Picture control
  1642.             ' so we can easily manipulate it.
  1643.             '
  1644.             Pic_Work.BackColor = MouseColors(2)
  1645.             R = BitBlt(MonoHdc, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_Work.hDC, 0, 0, SRCCOPY)
  1646.             R = BitBlt(Pic_TempMask.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, MonoHdc, 0, 0, SRCCOPY)
  1647.                     
  1648.             ' Once the Mask is created, all the pixels in the Image bitmap which are of
  1649.             ' currently selected screen color must be changed to Black.  To do this we
  1650.             ' Logically AND the Mask created above with the Image bitmap.  This has the
  1651.             ' affect of turning all pixels which are not the screen color to Black, leaving
  1652.             ' screen color pixels unaffected.  We then XOR the image with this result, which
  1653.             ' gives us the desired result of all screen color pixels of the origianl
  1654.             ' bitmap going to Black, all other pixels are unaffected.
  1655.             '
  1656.             R = BitBlt(Pic_TempImage.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_TempMask.hDC, 0, 0, SRCAND)
  1657.             R = BitBlt(Pic_TempImage.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_Work.hDC, 0, 0, SRCINVERT)
  1658.         End If
  1659.         If (Pic_Work.Width = 32) And (Pic_Work.Height = 32) Then
  1660.             ' Bitmap Pasted is too large to allow it to be moved, so we
  1661.             ' commit the Bitmap to the Icon with out allowing it to be
  1662.             ' moved, and then redisplay the Icon.
  1663.             '
  1664.             Scale_Region False, 0, 0, 32, 32, False
  1665.             Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, False
  1666.             Commit_Selection True
  1667.             Magnify_Icon 0, 0, 31, 31
  1668.         Else
  1669.             ' The Bitmap pasted can be moved, so go into Move mode by setting
  1670.             ' the appropriate flags.
  1671.             '
  1672.             Selecting = True
  1673.             Moveable = True
  1674.             MovingSelection = True
  1675.             ' Set the Selection Region to the size of the Bitmap pasted, in
  1676.             ' both the scale of the Icon and the Magnified Icon.
  1677.             '
  1678.             Scale_Region False, 0, 0, (Pic_Work.Width), (Pic_Work.Height), False
  1679.             Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, True
  1680.             Scale_Region True, LastX1, LastY1, LastX2, LastY2, True
  1681.             ' Redisplay Icon.  Passing a values of 0,0,0,0 simply force the Magnify_Icon
  1682.             ' routine to magnify the pasted Bitmap over the top of the magnified Icon.
  1683.             '
  1684.             Magnify_Icon 0, 0, 0, 0
  1685.         End If
  1686.     Else
  1687.         ' Bitmap was too large to paste, so prompt the user.
  1688.         '
  1689.         Pic_Work.Picture = LoadPicture()
  1690.         MsgBox "ClipBoard image is too large:  " + Format$(Pic_Work.Width) + " x " + Format$(Pic_Work.Height) + CRLF + "Image not pasted", 16, "Error"
  1691.     End If
  1692. End Sub
  1693. ' ColorPalette operations are performed on the MouseUp event,
  1694. ' and DoubleClicking the ColorPalette invokes the Custom
  1695. ' color ColorPalette Form so a flag must be set to inform the
  1696. ' MouseUp event to invoke the Custom ColorPalette form.
  1697. Sub Pic_ColorPalette_DblClick ()
  1698.     DoubleClicked = True
  1699. End Sub
  1700. ' Checks if Mouse Coordinates are within the ColorPalette, since the mouse
  1701. ' could have been dragged outside of the ColorPalette between the MouseDown
  1702. ' and MouseUp events, in which case the ColorPalette would still get the
  1703. ' MouseUp event with coordinates outside the actual ColorPalette which would
  1704. ' generate and error when accessing the Color Array.
  1705. Sub Pic_ColorPalette_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  1706.     If (X >= 0) And (X <= 16) And (Y >= 0) And (Y <= 3) Then Update_Mouse_Colors Button, X, Y
  1707. End Sub
  1708. Sub Pic_ColorPalette_Paint ()
  1709.     Display_Color_Palette Pic_ColorPalette
  1710. End Sub
  1711. ' If the Icon dropped is from the Viewer, it is loaded into the
  1712. ' currently selected Icon, otherwise nothing is done.
  1713. Sub Pic_Edit_DragDrop (Ctl As Control, X As Single, Y As Single)
  1714.     If Ctl.Parent.Tag <> Editor.Tag Then Load_An_Icon
  1715. End Sub
  1716. ' If the Icon being dragged is from the Viewer and it has just entered
  1717. ' or left the Edit area, invert the Edit area.
  1718. Sub Pic_Edit_DragOver (Ctl As Control, X As Single, Y As Single, State As Integer)
  1719.     If (Ctl.Parent.Tag <> Editor.Tag) And (State <> OVER) Then Invert_Control Pic_Edit
  1720. End Sub
  1721. ' A MouseDown event in the Editing area signals the beginning of a new
  1722. ' Tool operation if a tool operation is not already in progress.  All
  1723. ' preparation for the Tool operation is performed here, within the
  1724. ' MouseDown event.
  1725. Sub Pic_Edit_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  1726.     ' Propare for Tool operation only if there is not an operation already in
  1727.     ' progress, and only one mouse button is down, Left or Right.
  1728.     '
  1729.     If (ToolInProcess = 0) And ((Button = LEFT_BUTTON) Or (Button = RIGHT_BUTTON)) Then
  1730.         '
  1731.         ' Save Button value that started Tool Operation.
  1732.         '
  1733.         ToolInProcess = Button
  1734.         Get_Current_Colors Button
  1735.         Pic_Edit.DrawStyle = Solid
  1736.         If CurrentTool = TID_PAINT Then
  1737.             '
  1738.             ' Begin a Paint tool operation.
  1739.             '
  1740.             Pic_Edit.DrawMode = COPY_PEN
  1741.             
  1742.             ' So a pixel is drawn in repsonse to just a Click within the editing
  1743.             ' area, the MouseMove event must be called since all the actual
  1744.             ' drawing to the Editing area for the Paint Tool is done within the
  1745.             ' MouseMove event.
  1746.             '
  1747.             Pic_Edit_MouseMove Button, 0, X, Y
  1748.         ElseIf CurrentTool <> TID_FILL Then
  1749.             '
  1750.             ' Prepare for all other tools other than Fill and Paint tools.
  1751.             '
  1752.             Pic_Edit.DrawMode = INVERSE
  1753.             If CurrentTool = TID_SELECT Then Adjustment = TO_EDGE Else Adjustment = TO_CENTER
  1754.             ' Determine if a Selection is in process, the Selection can be moved,
  1755.             ' and whether the MousePointer is within the current selection.
  1756.             '
  1757.             If Selecting And Moveable And ((X >= X1Region) And (X <= X2Region) And (Y >= Y1Region) And (Y <= Y2Region)) Then
  1758.                 '
  1759.                 ' The selection is moveable and the MousePointer is within the
  1760.                 ' selection.  So prepare for a move.
  1761.                 '
  1762.                 Adjust_X_and_Y X, Y, XMoveSelection, YMoveSelection, Adjustment
  1763.                 If Button = RIGHT_BUTTON Then Opaque = True Else Opaque = False
  1764.                 If Not MovingSelection Then
  1765.                     '
  1766.                     ' The selection has not yet been moved from its original
  1767.                     ' position, so prepare to move selection.
  1768.                     '
  1769.                     ' If the Shift key is down, then the a copy of the Selection
  1770.                     ' will be moved, otherwise the selection will be move from
  1771.                     ' its current location so its previous location must be deleted.
  1772.                     '
  1773.                     If (Shift And SHIFT_MASK) = 0 Then Delete_Selection_From_Icon
  1774.                     Draw_Selection_Rectangle
  1775.                     MovingSelection = True
  1776.                     Draw_Selection_Rectangle
  1777.                 ElseIf (Shift And SHIFT_MASK) Then
  1778.                     '
  1779.                     ' The selection has already been moved from its original
  1780.                     ' location and is being moved again.  If the Shift key is
  1781.                     ' down, make a copy of the selection at its current location
  1782.                     ' and continue the move.
  1783.                     '
  1784.                     Commit_Selection False
  1785.                     Draw_Selection_Rectangle
  1786.                 End If
  1787.             Else
  1788.                 '
  1789.                 ' No selection is in progress, or a selection is in progress
  1790.                 ' but the MousePointer is not within the current selection,
  1791.                 ' or a tool other than the Select tool is in use.
  1792.                 '
  1793.                 ' If a Selection is in progress, commit the Selection at its
  1794.                 ' current location.
  1795.                 '
  1796.                 If Selecting Then Commit_Selection True
  1797.                 ' Prepare for new Tool operation
  1798.                 '
  1799.                 Opaque = True
  1800.                 Adjust_X_and_Y X, Y, X1Region, Y1Region, Adjustment
  1801.                 X2Region = X1Region
  1802.                 Y2Region = Y1Region
  1803.             End If
  1804.         End If
  1805.     End If
  1806. End Sub
  1807. ' For all tools except for the Paint tool and Fill tool, the MouseMove
  1808. ' event is used to size the object to be drawn.  The actual object is
  1809. ' drawn within the MouseUp event based on the coodinates obtained here
  1810. ' in the MouseMove event.  The Paint tool, however, does all of its
  1811. ' actual drawing to the Editing area within the MouseMove event.  The
  1812. ' Fill tool does nothing until the MouseUp event.
  1813. Sub Pic_Edit_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
  1814.     ' Calculate pixel mouse is currently over.
  1815.     '
  1816.     Xpix = X \ PixelSize
  1817.     Ypix = Y \ PixelSize
  1818.     ' The Mouse coordinates are always displayed within the StatusArea
  1819.     '
  1820.     Display_Mouse_Coordinates Xpix, Ypix
  1821.     ' Depending on the Current tool, and in the case of the Select tool,
  1822.     ' the state of the Selection, the MousePointer may change.
  1823.     '
  1824.     Set_MousePointer X, Y
  1825.     ' We only want to process the MouseMove event if the Button causing
  1826.     ' the MouseMove event is the same that started the operation.
  1827.     ' The value of the Button that started the operation is stored in
  1828.     ' the global variable ToolInProcess which is set in the MouseDown event.
  1829.     '
  1830.     If (Button = ToolInProcess) And (ToolInProcess <> 0) Then
  1831.         Select Case CurrentTool
  1832.             Case TID_SELECT
  1833.                 Select_Tool_Move Shift, X, Y
  1834.             Case TID_PAINT
  1835.                 Paint_Tool_Move Xpix, Ypix
  1836.             Case TID_LINE To TID_FILLED_CIRCLE
  1837.                 Line_To_Filled_Circle_Tool_Move Shift, X, Y
  1838.         End Select
  1839.     End If
  1840. End Sub
  1841. ' For all tools except for the Paint tool, the actual object drawn
  1842. ' is not drawn until the Mouse Button is released, which is within
  1843. ' the the edit areas MouseUp event.
  1844. Sub Pic_Edit_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  1845.     ' There is no operation that occurs with both mouse buttons down,
  1846.     ' so check to make sure that the MouseUp event is due to the release
  1847.     ' of the same button that started the drawing operation.  The global
  1848.     ' variable ToolInProcess holds the value of the Button.
  1849.     '
  1850.     If Button = ToolInProcess Then
  1851.         Pic_Edit.DrawMode = COPY_PEN
  1852.       
  1853.         Select Case CurrentTool
  1854.             Case TID_SELECT
  1855.                 Select_Tool_MouseUp X1, Y1, X2, Y2
  1856.             Case TID_FILL
  1857.                 Fill_Tool_MouseUp X, Y, X2, Y2
  1858.             Case TID_LINE To TID_FILLED_CIRCLE
  1859.                 Line_To_Filled_Circle_MouseUp X1, Y1, X2, Y2
  1860.         End Select
  1861.         ' The Icon needs to be updated to show the affect of the
  1862.         ' Tool operation for all tools except for the Select tool if
  1863.         ' just making a selection, since all that occurs is a Rectangle
  1864.         ' showing the selection is drawn.
  1865.         '
  1866.         If Not ((CurrentTool = TID_SELECT) And (Not MovingSelection)) Then
  1867.             Update_Icon Pic_Icons(CurrentIcon)
  1868.             '
  1869.             ' Redisplay the Icon for all tools except for the Paint tool.
  1870.             ' The paint tool draws directly on the Edit area within the
  1871.             ' MouseMove event.
  1872.             '
  1873.             If SeletedTool <> TID_PAINT Then Magnify_Icon X1, Y1, X2, Y2
  1874.         End If
  1875.         ToolInProcess = False
  1876.         ' Set enabled state of Edit Menu items.
  1877.         '
  1878.         Menu_Edit_Click
  1879.     End If
  1880. End Sub
  1881. Sub Pic_Edit_Paint ()
  1882.     ' Repaint Edit area
  1883.     Magnify_Icon 0, 0, 31, 31
  1884. End Sub
  1885. ' If the Icon dropped is from the Viewer, it is loaded into the
  1886. ' StatusArea Icon on which is was dropped and that icon is made
  1887. ' the current Icon, otherwise nothing is done.
  1888. Sub Pic_Icons_DragDrop (Index As Integer, Ctl As Control, X As Single, Y As Single)
  1889.     If Ctl.Parent.Tag <> Editor.Tag Then
  1890.         CurrentIcon = Index
  1891.         Load_An_Icon
  1892.     End If
  1893. End Sub
  1894. ' If the Icon being dragged is from the Viewer and it has just entered
  1895. ' or left one of the StatusArea Icons, invert the StatusArea icon.
  1896. Sub Pic_Icons_DragOver (Index As Integer, Ctl As Control, X As Single, Y As Single, State As Integer)
  1897.     If (Ctl.Parent.Tag <> Editor.Tag) And (State <> OVER) Then
  1898.         Invert_Control Pic_Icons(Index)
  1899.         Pic_Icons(Index).Refresh
  1900.     End If
  1901. End Sub
  1902. ' Clicking on any of the icons within the StatusArea, makes that
  1903. ' Icon the current Icon.  If the the Icon is already the current
  1904. ' Icon, and selection currently in progress is canceled, and
  1905. ' the Icon can be dragged to test what it looks like begin dragged.
  1906. ' It cannot be dropped on anything.
  1907. Sub Pic_Icons_MouseDown (Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
  1908.     ' Determine if new Icon is being selected
  1909.     '
  1910.     If (Button = LEFT_BUTTON) And (Index <> CurrentIcon) Then
  1911.         '
  1912.         ' New Icon has been selected, so prepare for new Icon
  1913.         '
  1914.         Menu_IconsSelection(CurrentIcon).Checked = False
  1915.         Menu_IconsSelection(Index).Checked = True
  1916.         If Selecting Then Commit_Selection True
  1917.         CurrentIcon = Index
  1918.         Select_New_Icon
  1919.     ElseIf (Button = LEFT_BUTTON) And (Index = CurrentIcon) Then
  1920.         '
  1921.         ' The current Icon was selected.
  1922.         '
  1923.         If Selecting Then
  1924.             '
  1925.             ' A selection was in progress so cancel it.
  1926.             '
  1927.             Draw_Selection_Rectangle
  1928.             Selecting = False
  1929.             MovingSelection = False
  1930.             Scale_Region True, X1, Y1, X2, Y2, True
  1931.             Magnify_Icon X1, Y1, X2, Y2
  1932.         End If
  1933.         
  1934.         ' Set the DragIcon of the selected Icon, and begin dragging
  1935.         '
  1936.         Pic_Icons(Index).DragIcon = Pic_Icons(Index).Picture
  1937.         Pic_Icons(Index).Drag
  1938.     End If
  1939. End Sub
  1940. ' Although the StatusArea appears as though it contains many controls
  1941. ' it actually contains only 7 picture controls and 2 Option buttons.
  1942. ' The rest of the information displayed within the StatusArea is painted
  1943. ' directly onto the StatusArea.  This is done to limit the actual number
  1944. ' of controls on the Editor.  The more controls, the more System resources
  1945. ' it uses and the longer it takes to load.  It may be easier to display
  1946. ' certain data using controls, but in some cases, its benificial to not
  1947. ' use controls but display the information yourself.  The easiest controls
  1948. ' to eliminate are Labels since they usually just display text and do
  1949. ' not change throughout the life of the program, and the .Print method
  1950. ' can be used to display the text instead of a label.
  1951. Sub Pic_StatusArea_Paint ()
  1952.     ' Calculate center of StatusArea
  1953.     '
  1954.     Middle = Pic_StatusArea.ScaleWidth \ 2
  1955.     ' Set font attributes for X & Y Mouse coodinate display
  1956.     '
  1957.     Pic_StatusArea.FontName = "MS Sans Serif"
  1958.     Pic_StatusArea.FontSize = 8.25
  1959.     Pic_StatusArea.ForeColor = BLACK
  1960.     ' Display X & Y mouse coordinate labels, "X=" and Y="
  1961.     '
  1962.     Pic_StatusArea.CurrentY = Pic_Icons(5).Top + Pic_Icons(5).Height + HIGHLIGHT + 1
  1963.     Pic_StatusArea.CurrentX = (Middle - Pic_StatusArea.TextWidth("XXXX")) \ 2
  1964.     Pic_StatusArea.Print "X=";
  1965.     Pic_StatusArea.CurrentX = Middle + (Middle - Pic_StatusArea.TextWidth("XXXX")) \ 2
  1966.     Pic_StatusArea.Print "Y=";
  1967.     ' If the Undo Icon is visible, display its label, "Undo to:"
  1968.     '
  1969.     If Pic_Undo.Visible Then
  1970.         Text = "Undo to:"
  1971.         Pic_StatusArea.CurrentX = (Pic_Undo.Left - Pic_StatusArea.TextWidth(Text)) \ 2
  1972.         Pic_StatusArea.CurrentY = Pic_Undo.Top + ((Pic_Undo.Height - Pic_StatusArea.TextHeight(Text)) \ 2)
  1973.         Pic_StatusArea.Print "Undo to:"
  1974.     End If
  1975.     ' If the Mouse Option buttons are visible, then display the the
  1976.     ' option button Color labels and the colors themselves.  The labels are
  1977.     ' all based on the positions of the two Option buttons, so it they
  1978.     ' are moved at design time, the labels will still be displayed
  1979.     ' correctly.
  1980.     '
  1981.     If Opt_Mouse(0).Visible Then
  1982.         '
  1983.         ' Display Mouse Butons header label within a White box with a Black
  1984.         ' outline.
  1985.         '
  1986.         Text = "Mouse Buttons"
  1987.         Y1 = Opt_Mouse(0).Top - 1.25 * Opt_Mouse(0).Height
  1988.         Pic_StatusArea.Line (0, Y1)-(Pic_StatusArea.ScaleWidth, Y1 + Pic_StatusArea.TextHeight(Text)), WHITE, BF
  1989.         Pic_StatusArea.Line (0, Y1)-(Pic_StatusArea.ScaleWidth - 1, Y1 + Pic_StatusArea.TextHeight(Text)), BLACK, B
  1990.         Pic_StatusArea.CurrentX = (Pic_StatusArea.ScaleWidth - Pic_StatusArea.TextWidth(Text)) \ 2
  1991.         Pic_StatusArea.CurrentY = Y1
  1992.         Pic_StatusArea.FontTransparent = True
  1993.         Pic_StatusArea.Print Text
  1994.         Pic_StatusArea.FontBold = False
  1995.         ' Display the Mouse Button color labels, centered on either
  1996.         ' side of the Option buttons.
  1997.         '
  1998.         For I = 0 To 3
  1999.             Select Case I
  2000.                 Case 0
  2001.                     Text = "Left"
  2002.                 Case 1
  2003.                     Text = "Right"
  2004.                     Shift = Middle
  2005.                 Case 2
  2006.                     Text = "Screen"
  2007.                     Shift = 0
  2008.                 Case 3
  2009.                     Text = "Inverse"
  2010.                     Shift = Middle
  2011.             End Select
  2012.             Pic_StatusArea.CurrentX = Shift + (Middle - Pic_StatusArea.TextWidth(Text)) \ 2
  2013.             Pic_StatusArea.CurrentY = Opt_Mouse(I \ 2).Top - Pic_StatusArea.TextHeight(Text) - 1
  2014.             Pic_StatusArea.Print Text
  2015.         Next I
  2016.         ' Display the 4 color squares showing currently selected colors
  2017.         ' These could be picture controls.
  2018.         '
  2019.         Display_Mouse_Colors
  2020.     End If
  2021.     ' Set StatusArea font attributes back to that of the Mouse coordinates.
  2022.     '
  2023.     Pic_StatusArea.ForeColor = RED
  2024.     Pic_StatusArea.FontName = "Courier"
  2025.     Pic_StatusArea.FontBold = True
  2026.     Pic_StatusArea.FontTransparent = False
  2027.     HighLight_Current_Icon
  2028. End Sub
  2029. ' Performs a "Select All" opertation, just as though the Edit.Select all
  2030. ' menu item was selected.
  2031. Sub Pic_ToolPalette_DblClick ()
  2032.     If CurrentTool = TID_SELECT Then Menu_EditSelection_Click MID_SELECT_All
  2033. End Sub
  2034. ' Prepare for a new tool.  The actual Tool selection is done within
  2035. ' the MouseMove event.
  2036. Sub Pic_ToolPalette_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  2037.     ' Commit and Selection currently being moved.
  2038.     '
  2039.     If Selecting Then Commit_Selection True
  2040.     ' Commit all edits to Undo Icon
  2041.     '
  2042.     Update_Icon Pic_Undo
  2043.     ' Remove Check from current tool in Tools menu
  2044.     '
  2045.     Menu_ToolsSelection(CurrentTool).Checked = False
  2046.     ' Since the actual selection is done within the MouseMove event, and
  2047.     ' a MouseMove event does not occur until the mouse is moved within
  2048.     ' the ToolPalette, we need to call the MouseMove event, to ensure
  2049.     ' the selected tool is in fact selected, since just clicking on
  2050.     ' the ToolPalette does not generate a MouseMove event.
  2051.     '
  2052.     Pic_ToolPalette_MouseMove Button, Shift, X, Y
  2053. End Sub
  2054. ' Moving the mouse within the ToolPalette after a MouseDown event, will select
  2055. ' the tool the mouse is currently over, so you can slide up and down the palette,
  2056. ' and the tool selection will follow the mouse.
  2057. Sub Pic_ToolPalette_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
  2058.     ' Calculate selected tool.  Each tool Icon is 32 pixels high, so this
  2059.     ' is done easily by Integer dividing the Y coordinate by 32.
  2060.     '
  2061.     NewTool = Y \ 32
  2062.     ' Check to make sure the Mouse is within the Y limits of the ToolPalette
  2063.     ' and not over the currently selected tool.
  2064.     '
  2065.     If (Button <> 0) And (NewTool >= TID_SELECT) And (NewTool <= TID_FILLED_CIRCLE) And (NewTool <> CurrentTool) Then
  2066.         '
  2067.         ' UnHighlight current tool
  2068.         '
  2069.         Pic_ToolPalette.Line (0, CurrentTool * 32 + 1)-(31, CurrentTool * 32 + 31), , BF
  2070.         ' Hightlight new tool
  2071.         '
  2072.         Pic_ToolPalette.Line (0, NewTool * 32 + 1)-(31, NewTool * 32 + 31), , BF
  2073.         CurrentTool = NewTool
  2074.     End If
  2075. End Sub
  2076. Sub Pic_ToolPalette_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  2077.     ' Set Enabled state of all Edit menu options.
  2078.     '
  2079.     Menu_Edit_Click
  2080. End Sub
  2081. ' The ToolPalette takes care of painting itself since it contains
  2082. ' a single bitmap displaying the Tools.  However, the currently
  2083. ' selected Tool needs to be Hightlighted during the Paint event.
  2084. Sub Pic_ToolPalette_Paint ()
  2085.     ' Clear ToolPalette to background bitmap of Tools
  2086.     '
  2087.     Pic_ToolPalette.Cls
  2088.     ' HightLight current tool.  The Drawmode of the ToolPalette is
  2089.     ' set to INVERSE, so we simply draw a filled box over the current
  2090.     ' tool.  This inverts the tool.
  2091.     '
  2092.     Pic_ToolPalette.Line (0, CurrentTool * 32 + 1)-(31, CurrentTool * 32 + 31), , BF
  2093. End Sub
  2094. ' Clicking the Undo Icon in the StatusArea is the same thing as
  2095. ' selecting the Edit.Undo menu item.
  2096. Sub Pic_Undo_Click ()
  2097.     Menu_EditSelection_Click MID_UNDO
  2098. End Sub
  2099. ' In response to a File.New menu opertation, this routine is called,
  2100. ' to prepare creating a new Icon from scratch.
  2101. Sub Prepare_For_New_Icon ()
  2102.     ' Determine if current Icon has changed since it was saved last and
  2103.     ' and prompt user if it has been changed and not saved.
  2104.     '
  2105.     If Ok_To_Discard_Changes() Then
  2106.         '
  2107.         ' It is ok to prepare for new Icon.
  2108.         
  2109.         ' Terminate any Selection in progress and simulate a Select all,
  2110.         ' then perform an Edit.Delete operation to clear the Icon.
  2111.         '
  2112.         Selecting = False
  2113.         MovingSelection = False
  2114.         Scale_Region False, 0, 0, 32, 32, False
  2115.         Menu_EditSelection_Click MID_DELETE
  2116.         ' Intialize the IconInfo record to default values
  2117.         '
  2118.         IconInfo(CurrentIcon).FileName = UNTITLED
  2119.         IconInfo(CurrentIcon).Changed = False
  2120.         ' Reset both the Icon menu and the Editors Titlebar
  2121.         '
  2122.         Menu_IconsSelection(CurrentIcon).Caption = "&" + Format$(CurrentIcon + 1) + " - " + UNTITLED
  2123.         Caption = "IconWorks Editor: " + Format$(CurrentIcon + 1) + " - " + UNTITLED
  2124.     End If
  2125. End Sub
  2126. ' Once a Selection has been made, or an Edit.Select All or Edit.Paste
  2127. ' operation has been made, this routine is called to prepare for a
  2128. ' potential movement of the Selection.  A copy of the actual Icons
  2129. ' Mask and Image are made, and this is the Source from which the
  2130. ' Selection is display whenever the Selection is in fact moved.
  2131. Sub Prepare_For_Possible_Move ()
  2132.               
  2133.     Pic_Work.Picture = Pic_Icons(CurrentIcon).Image
  2134.     Pic_TempImage.Picture = Pic_Image.Image
  2135.     Pic_TempMask.Picture = Pic_Mask.Image
  2136. End Sub
  2137. ' When a selection has been made and the selection is Square, it may
  2138. ' be rotated Left or Right by 90 degrees.  Cannot Rotate a selection
  2139. ' that is being moved.  This routine performs the rotation in repsonse
  2140. ' to an Edit.Rotate Left/Right menu operation.
  2141. Sub Rotate_Selection (Index)
  2142.     ' Rotation is not instant, so set Cursor to HourGlass
  2143.     '
  2144.     Screen.MousePointer = HOURGLASS
  2145.     ' Caculate size of Region
  2146.     '
  2147.     NumPixels = X2SelectFrom - X1SelectFrom - 1
  2148.     ' Perform rotation.  The rotation is performed by reading one pixel at
  2149.     ' a time from the source and copying it to is new location in rotated
  2150.     ' either Left or Right 90 degrees.  The Point Method reads the Pixel
  2151.     ' and the Pset method is used to write the pixel.  Both the Icons
  2152.     ' Mask and Image must be rotated.
  2153.     '
  2154.     For Y = 0 To NumPixels
  2155.         For X = 0 To NumPixels
  2156.             If Index = MID_ROTATE_RIGHT Then
  2157.                 '
  2158.                 ' Rotate Right
  2159.                 '
  2160.                 Pic_Image.PSet (X2SelectFrom - Y - 1, Y1SelectFrom + X), Pic_TempImage.Point(X1SelectFrom + X, Y1SelectFrom + Y)
  2161.                 Pic_Mask.PSet (X2SelectFrom - Y - 1, Y1SelectFrom + X), Pic_TempMask.Point(X1SelectFrom + X, Y1SelectFrom + Y)
  2162.             Else
  2163.                 ' Rotate Left
  2164.                 '
  2165.                 Pic_Image.PSet (X1SelectFrom + Y, Y2SelectFrom - X - 1), Pic_TempImage.Point(X1SelectFrom + X, Y1SelectFrom + Y)
  2166.                 Pic_Mask.PSet (X1SelectFrom + Y, Y2SelectFrom - X - 1), Pic_TempMask.Point(X1SelectFrom + X, Y1SelectFrom + Y)
  2167.             End If
  2168.         Next X
  2169.     Next Y
  2170.     ' Replace Icons Mask and Image with new Mask and Images.
  2171.     '
  2172.     Update_Icon Pic_Icons(CurrentIcon)
  2173.     Prepare_For_Possible_Move
  2174.     ' Redisplay selected region to show rotation.
  2175.     '
  2176.     Magnify_Icon X1SelectFrom, Y1SelectFrom, (X2SelectFrom), (Y2SelectFrom)
  2177.     ' Restore Cursor
  2178.     '
  2179.     Screen.MousePointer = DEFAULT
  2180. End Sub
  2181. ' In response to a Color.Save colors to INI file menu operatioin, this
  2182. ' routine is called to write the color values to IconWrks.INI.
  2183. ' WritePrivateProfileString() will create the INI file if it does not
  2184. ' exist, and will create the KeyName if it does not exist in the INI FILE.
  2185. ' The Color values are packed into a single string, one row of colors at
  2186. ' a time, and then written to the INI file.  The colors are formated
  2187. ' into 8-byte fields separated by one space.  After this routine,
  2188. ' IconWrks.INI will contain 3 key entries of:
  2189. '   Colors Row1=16777215 14737632 ...
  2190. '   Colors Row2=12632256 04210752 ...
  2191. '   Colors Row3=08421504 00000000 ...
  2192. Sub Save_Colors_To_INI_File ()
  2193.     For I = 0 To 2
  2194.         ColorString = ""
  2195.         For C = 0 To 15
  2196.             ColorString = ColorString + Format$(Colors(I * 16 + C), "00000000 ")
  2197.         Next C
  2198.         X = WritePrivateProfileString(APP_NAME, KEY_COLOR + Format$(I + 1), ColorString, INI_FILENAME)
  2199.     Next I
  2200. End Sub
  2201. ' In Response to a File.Save or File.Save As menu operation, this routine
  2202. ' is called to either immediately save the Icon or invoke the SaveFileDlg
  2203. ' to get a Filename to save the Icon to.  A File.Save As operation always
  2204. ' invokes the Dialog, but a File.Save will only invoke the Dialog if the
  2205. ' current icon does not yet have a name, denoted by a name of UNTITLED.
  2206. Sub Save_Icon (Index)
  2207.     If (Index = MID_SAVE_AS) Or (IconInfo(CurrentIcon).FileName = UNTITLED) Then
  2208.         SaveFileDlg.Show MODAL
  2209.     Else
  2210.         Write_Icon_To_File (IconInfo(CurrentIcon).FullPath), IconInfo(CurrentIcon).FileName
  2211.     End If
  2212. End Sub
  2213. ' When the Editor is terminated, this routine is called to save all
  2214. ' configurable items of the Editor to the IconWrks.INI file.  Size
  2215. ' and Location of the Editor are not saved.
  2216. ' WritePrivateProfileString() will create the INI file and/or any
  2217. ' KeyName that does not exist.
  2218. Sub Save_Settings_To_INI_File ()
  2219.     R = WritePrivateProfileString(APP_NAME, KEY_GRID, Format$(Abs(Menu_ViewSelection(MID_GRID).Checked)), INI_FILENAME)
  2220.     R = WritePrivateProfileString(APP_NAME, KEY_LINE_GRID, Format$(Abs(Menu_ViewSelection(MID_LINE_GRID).Checked)), INI_FILENAME)
  2221.     R = WritePrivateProfileString(APP_NAME, KEY_DOTTED_GRID, Format$(Abs(Menu_ViewSelection(MID_DOTTED_GRID).Checked)), INI_FILENAME)
  2222.     R = WritePrivateProfileString(APP_NAME, KEY_STATUS_BAR, Format$(Abs(Menu_ViewSelection(MID_STATUS_BAR).Checked)), INI_FILENAME)
  2223.     R = WritePrivateProfileString(APP_NAME, KEY_TOOL_PALETTE, Format$(Abs(Menu_ViewSelection(MID_TOOL_PALETTE).Checked)), INI_FILENAME)
  2224.     R = WritePrivateProfileString(APP_NAME, KEY_COLOR_PALETTE, Format$(Abs(Menu_ViewSelection(MID_COLOR_PALETTE).Checked)), INI_FILENAME)
  2225.     R = WritePrivateProfileString(APP_NAME, KEY_ZOOM_SCROLLBAR, Format$(Abs(Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked)), INI_FILENAME)
  2226.     R = WritePrivateProfileString(APP_NAME, KEY_FOCUS, Format$(Abs(Menu_ViewSelection(MID_FOCUS).Checked)), INI_FILENAME)
  2227.     R = WritePrivateProfileString(APP_NAME, KEY_BORDER, Format$(Abs(Menu_ViewSelection(MID_BORDER).Checked)), INI_FILENAME)
  2228.     R = WritePrivateProfileString(APP_NAME, KEY_POPUP, Format$(Abs(Menu_ViewSelection(MID_POPUP_MENU).Checked)), INI_FILENAME)
  2229.     R = WritePrivateProfileString(APP_NAME, KEY_DEFAULT, Format$(Abs(Menu_ColorSelection(MID_DEFAULT_COLORS).Checked)), INI_FILENAME)
  2230.     R = WritePrivateProfileString(APP_NAME, KEY_SOLID, Format$(Abs(Menu_ColorSelection(MID_SOLID_COLORS).Checked)), INI_FILENAME)
  2231.     R = WritePrivateProfileString(APP_NAME, KEY_INI, Format$(Abs(Menu_ColorSelection(MID_INI_COLORS).Checked)), INI_FILENAME)
  2232. End Sub
  2233. ' Scrolling the Zoom scrollbar Zooms in or Zooms out on the
  2234. ' selected Icon, and maintains it centered within the available
  2235. ' editing space.
  2236. Sub Scrl_Zoom_Change ()
  2237.     ' Check if new value is multiple of 32 pixels.  Magnified Icon must
  2238.     ' always be increased or decreased my muliples of 32 pixels so the
  2239.     ' Win API routine StretchBlt() can be used to magnify the Icon, and
  2240.     ' the result will be an exact enlargement of the original.
  2241.     '
  2242.     If (Scrl_Zoom.Value - 2) Mod Pic_Icons(0).Width Then
  2243.         '
  2244.         ' Scrollbar value is not a multiple of 32, so adjust it so it is.
  2245.         '
  2246.         Scrl_Zoom.Value = Scrl_Zoom.Value - ((Scrl_Zoom.Value - 2) Mod Pic_Icons(0).Width)
  2247.     Else
  2248.         ' Scrollbar value is a multiple of 32 pixels.
  2249.         '
  2250.         ' Hide Edit area while resizing and repainting.  It prevents a
  2251.         ' rather annoying visual affect.
  2252.         '
  2253.         Pic_Edit.Visible = False
  2254.         ' Calculate the new size and position values for the Editing area
  2255.         ' and then reposition and resize both the Editing area and the
  2256.         ' temporary Editing area which is used when magnifying the Icon.
  2257.         '
  2258.         MaxLeft = Scrl_Zoom.Left - (Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked * Scrl_Zoom.Width)
  2259.         NewLeft = MaxLeft + (ScaleWidth + Menu_ViewSelection(MID_STATUS_BAR).Checked * Pic_StatusArea.Width - MaxLeft - Scrl_Zoom.Value) \ 2
  2260.         NewTop = (ScaleHeight + Menu_ViewSelection(MID_COLOR_PALETTE).Checked * Pic_ColorPalette.Height - Scrl_Zoom.Value) \ 2
  2261.         Pic_Edit.Move NewLeft, NewTop, Scrl_Zoom.Value, Scrl_Zoom.Value
  2262.         Pic_EditTemp.Move 0, 0, Scrl_Zoom.Value, Scrl_Zoom.Value
  2263.         ' To allow a selection to be maintained if the Zoom scrollbar is scrolled
  2264.         ' while a selection is in progress, the current selection must be scaled
  2265.         ' down to the scale of the actual Icon, the new PixelSize for the Editing
  2266.         ' area must be calculated, and then the selection is Scaled back to the
  2267.         ' new scale of the Editing area.
  2268.         '
  2269.         If Selecting Then Scale_Region True, X1Region, Y1Region, X2Region, Y2Region, False
  2270.         PixelSize = Pic_Edit.ScaleWidth \ 32
  2271.         If Selecting Then Scale_Region False, X1Region, Y1Region, X2Region, Y2Region, False
  2272.         ' Recreate grid if selected and redisplay the Editing area.
  2273.         '
  2274.         If Menu_ViewSelection(MID_GRID).Checked Then Create_Grid
  2275.         Pic_Edit.Visible = True
  2276.         ' Set enable state of Zoom in/out View menu items based on new value
  2277.         ' of the Zoom Scrollbar.
  2278.         '
  2279.         Menu_ViewSelection(MID_ZOOM_IN).Enabled = Scrl_Zoom.Value < Scrl_Zoom.Max
  2280.         Menu_ViewSelection(MID_ZOOM_OUT).Enabled = Scrl_Zoom.Value > Scrl_Zoom.Min
  2281.     End If
  2282. End Sub
  2283. ' In response to Double Clicking the Select tool, or an Edit.Select All
  2284. ' menu operation, this routine is called to perform a selection on the
  2285. ' entire Icon, which is the same as if the Entire icon was selected using
  2286. ' the mouse.
  2287. Sub Select_Entire_Icon ()
  2288.     ' Make the select to the selected tool.  This is neccessary since
  2289.     ' this routine could have been called due to a menu selection, and
  2290.     ' the current tool may not be the Select Tool.
  2291.     '
  2292.     Pic_ToolPalette_MouseDown LEFT_BUTTON, 0, 0, TID_SELECT * 32
  2293.     ' Make all preparations for a selection just as if it was done
  2294.     ' using the mouse.
  2295.     '
  2296.     Prepare_For_Possible_Move
  2297.     Selecting = True
  2298.     Moveable = False
  2299.     Opaque = True
  2300.     Scale_Region False, 0, 0, 32, 32, False
  2301.     Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, False
  2302.     Draw_Selection_Rectangle
  2303. End Sub
  2304. ' There are two type of grids to choose from when the Grid selection
  2305. ' is active. Line and Dotted grid.  This routine is called in response
  2306. ' to a View.Line Grid or View.Dotted Grid menu operation, to set and
  2307. ' display the selected grid type.  The actual Grid is created in the
  2308. ' Create_Grid procedure.
  2309. Sub Select_Grid_Type (Index)
  2310.     ' Check if selected Grid is already the currently selected grid type,
  2311.     ' since there is no need to redisplay it.
  2312.     '
  2313.     If Not Menu_ViewSelection(Index).Checked Then
  2314.         '
  2315.         ' Toggle Checks on Grid type menu items.
  2316.         '
  2317.         Menu_ViewSelection(MID_LINE_GRID).Checked = Not Menu_ViewSelection(MID_LINE_GRID).Checked
  2318.         Menu_ViewSelection(MID_DOTTED_GRID).Checked = Not Menu_ViewSelection(MID_DOTTED_GRID).Checked
  2319.         ' Create the new Grid and redisplay Icon with new Grid.
  2320.         '
  2321.         Create_Grid
  2322.         Magnify_Icon 0, 0, 31, 31
  2323.     End If
  2324. End Sub
  2325. Sub Select_Tool_MouseUp (X1, Y1, X2, Y2)
  2326.             
  2327.     ' Erase old Selection rectangle
  2328.     '
  2329.     Draw_Selection_Rectangle
  2330.     ' Adjust selection rectangle so it is completely within the
  2331.     ' editing area.
  2332.     '
  2333.     If X1Region > X2Region Then Swap_Values X1Region, X2Region
  2334.     If Y1Region > Y2Region Then Swap_Values Y1Region, Y2Region
  2335.     If X1Region < 0 Then X1Region = 0
  2336.     If Y1Region < 0 Then Y1Region = 0
  2337.     MaxSize = PixelSize * 32
  2338.     If X2Region > MaxSize Then X2Region = MaxSize
  2339.     If Y2Region > MaxSize Then Y2Region = MaxSize
  2340.     If MovingSelection Then
  2341.         '
  2342.         ' The selection is being moved, so all that needs to be done is
  2343.         ' to update the values containing the last location of the
  2344.         ' selection, which are used when the selection is moved.
  2345.         '
  2346.         X1 = LastX1
  2347.         Y1 = LastY1
  2348.         X2 = LastX2
  2349.         Y2 = LastY2
  2350.     ElseIf (X1Region <> X2Region) And (Y1Region <> Y2Region) Then
  2351.         '
  2352.         ' A new selection has been made
  2353.         '
  2354.         Prepare_For_Possible_Move
  2355.         Selecting = True
  2356.         Opaque = True
  2357.         ' Determine if selection can be moved.  The selection cannot be moved
  2358.         ' if it consists of the entire icon.
  2359.         '
  2360.         Moveable = ((X2Region - X1Region) < Pic_Edit.ScaleWidth) Or ((Y2Region - Y1Region) < Pic_Edit.ScaleWidth)
  2361.         Draw_Selection_Rectangle
  2362.         Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, True
  2363.     End If
  2364.     Scale_Region True, LastX1, LastY1, LastX2, LastY2, True
  2365. End Sub
  2366. ' A move event using the Select tool, can do one of three things,
  2367. ' size the selection rectangle to make the selection, move the
  2368. ' current selection, or copy the current selection to another
  2369. ' location.  This routine either draws the selection rectangle
  2370. ' as the selection is being made or moves/copies the current
  2371. ' selection.
  2372. Sub Select_Tool_Move (Shift As Integer, X As Single, Y As Single)
  2373.     ' Erase old selection rectangle
  2374.     '
  2375.     Draw_Selection_Rectangle
  2376.     If MovingSelection Then
  2377.         '
  2378.         ' Calculate new location of Selection rectangle.
  2379.         '
  2380.         XLastMove = XMoveSelection
  2381.         YLastMove = YMoveSelection
  2382.         Adjust_X_and_Y X, Y, XMoveSelection, YMoveSelection, TO_EDGE
  2383.         X1Region = X1Region + (XMoveSelection - XLastMove)
  2384.         X2Region = X2Region + (XMoveSelection - XLastMove)
  2385.         Y1Region = Y1Region + (YMoveSelection - YLastMove)
  2386.         Y2Region = Y2Region + (YMoveSelection - YLastMove)
  2387.         ' Prevent Selection from being moved of the left or right
  2388.         ' of the editing area
  2389.         '
  2390.         If (X1Region < 0) Or (X2Region > (32 * PixelSize)) Then
  2391.             X1Region = X1Region - (XMoveSelection - XLastMove)
  2392.             X2Region = X2Region - (XMoveSelection - XLastMove)
  2393.         End If
  2394.         
  2395.         ' Prevent Selection from being moved of the top or bottom
  2396.         ' of the editing area
  2397.         '
  2398.         If (Y1Region < 0) Or Y2Region > (32 * PixelSize) Then
  2399.             Y1Region = Y1Region - (YMoveSelection - YLastMove)
  2400.             Y2Region = Y2Region - (YMoveSelection - YLastMove)
  2401.         End If
  2402.     Else
  2403.         ' A selection is being made, so adjust the mouse coordinates
  2404.         ' to the Edge of the pixels so the rectangle is completely
  2405.         ' around the selction.
  2406.         '
  2407.         Adjust_X_and_Y X, Y, X2Region, Y2Region, TO_EDGE
  2408.         ' Make the Selection perfectly square if the Shift key is down
  2409.         '
  2410.         If Shift And SHIFT_MASK Then Make_Region_Square
  2411.     End If
  2412.     ' Draw the new selection recangle
  2413.     '
  2414.     Draw_Selection_Rectangle
  2415. End Sub
  2416. ' When the MousePointer is within the Editing area, the MousePointer
  2417. ' is changed depending on the Tool being used.  This routine is called
  2418. ' from the MouseMove event for the Editing area (Pic_Edit) to change
  2419. ' the MousePointer.
  2420. Sub Set_MousePointer (X As Single, Y As Single)
  2421.     If Selecting And Moveable And (X >= X1Region) And (X <= X2Region) And (Y >= Y1Region) And (Y <= Y2Region) Then
  2422.         '
  2423.         ' A selection is in progress and the selection is moveable,
  2424.         ' and the MousePointer is within the the selection, so the
  2425.         ' MousePointer is changed to a SIZE pointer to indacte
  2426.         ' that the Selection can be moved.
  2427.         '
  2428.         Pic_Edit.MousePointer = SIZE
  2429.     ElseIf (CurrentTool = TID_PAINT) Or (CurrentTool = TID_FILL) Then
  2430.         Pic_Edit.MousePointer = UP_ARROW
  2431.     Else
  2432.         Pic_Edit.MousePointer = CROSSHAIR
  2433.     End If
  2434. End Sub
  2435. ' Since some of the tools can only use Solid colors and not Dithered
  2436. ' colors, it is useful to have the option of displayin only the solid
  2437. ' colors within the ColorPalette.  This routine changes the Color
  2438. ' array to contain only Solid color values then redisplays the
  2439. ' ColorPalette.  There are still 3 rows of colors, but each color
  2440. ' cell in the same column are set to the same solid color.
  2441. Sub Show_Solid_Colors_Only ()
  2442.     ' Set Color array to all solid colors returned from QBColors()
  2443.     '
  2444.     For I = 0 To 15
  2445.         Colors(I) = QBColor(I)
  2446.         Colors(I + 16) = QBColor(I)
  2447.         Colors(I + 32) = QBColor(I)
  2448.     Next
  2449.     ' Redisplay ColorPalettes.
  2450.     '
  2451.     Display_Color_Palette Pic_ColorPalette
  2452.     If ColorPaletteLoaded Then Display_Color_Palette ColorPalette.Pic_ColorPalette
  2453. End Sub
  2454. ' This routine is called in response to an Edit.Undo menu operation.
  2455. ' The Icon displayed in the Undo Icon within the StatusArea is
  2456. ' Copied to the Selected Icon.
  2457. Sub UnDo_Edits ()
  2458.     ' Terminate any Select or Move opteration
  2459.     '
  2460.     Selecting = False
  2461.     MovingSelection = False
  2462.     ' Get Image and Mask of Icon displayed in Undo Icon in StatusArea
  2463.     '
  2464.     Extract_Image_And_Mask Pic_Undo
  2465.     ' Copy Undo Icons Mask and Image to selected icon
  2466.     '
  2467.     Update_Icon Pic_Icons(CurrentIcon)
  2468.     ' Redisplay entire icon
  2469.     '
  2470.     Magnify_Icon 0, 0, 31, 31
  2471. End Sub
  2472. ' When using either the Circle or Filled Circle tool, this routine is called
  2473. ' to verify that the resulting circle from the current Mouse coordinates is
  2474. ' a valid circle, since in some cases the result would be a vertical or
  2475. ' horizontal line which would generate and "Division by Zero" if not checked
  2476. ' for.  If the Circle is valid, this routine calculates and sets the Global
  2477. ' values of XCenter, YCenter, and Raduis for new Circle.
  2478. Function Valid_Circle (X1, Y1, X2, Y2)
  2479.           
  2480.     Xleg = Abs(X2 - X1)
  2481.     If Xleg <> 0 Then
  2482.         Yleg = Abs(Y2 - Y1)
  2483.         Aspect = Abs(Yleg / Xleg)
  2484.         If Xleg > Yleg Then Radius = Xleg / 2 Else Radius = Yleg / 2
  2485.         XCenter = X1 + (X2 - X1) / 2
  2486.         YCenter = Y1 + (Y2 - Y1) / 2
  2487.     End If
  2488.     ' Return value of XLeg at Function value, since if XLeg is non-zero,
  2489.     ' (True) it is a valid circle, and if XLeg is zero (False) it is
  2490.     ' an Invalid circle.
  2491.     '
  2492.     Valid_Circle = Xleg
  2493. End Function
  2494.