"Thomas, Timothy B" wrote:
> 
> I would also be interested in seeing this code, maybe we could help get the
> bugs worked out if we had the code.

  What the heck.  Here is what I have so far...

  I call it 'gb' (GUI Guilder) - easy to type.

  There is the main program (gb) and three supporting files:

  but_prop.pl (Button Property Window)
  lab_prop.pl (Label Property Window)
  bor_prop.pl (Border Property Window)

  ...and an optional config file (gb.cf) which lets me load 
  previous GUI designs quickly from the File menu.

  The Edit->Delete does nothing.

  To start things off, I type "perl gb" in a DOS window (I 
  developed this on a w95 box).

  When the config window comes up click on File->New

  You should get a "Design Window".  Click on the "Butt" button in the
  config window.  You'll get a property window.  Enter some text and
click
  ok.  You should get a button in the design window which follows your 
  mouse around.  Click where you want the button placed.  Now... if you
  look at the code I'm scanning for a mouse click every few whatevers so
  it does not always pick up the mouse click - you may need to click a 
  few times.

  The border button is suppose to create a border or whatever it is
called.
  Click where you want the upper left corner, move the mouse to the
bottom
  right corner and click again.

  I was playing around with a "select" button to select an object for 
  manipulation but I didn't finish it.  A single or double mouse click
  over the object would be better, but once again the way I do mouse 
  events is not the best.

  The latest build 4?? broke some of the calls found down in
"Build_GUI_File"
  so the numbers associated with each widget don't come out right.  If
you 
  go back to the previous build 3??, it should work correctly.

  Once again - I wrote this as a means for building quick and simple
GUIs and
  as a way to learn about the capabilities of Win32::GUI.  I never
finished 
  the code and I haven't looked at it for a few weeks.

  With all that said - enjoy.  ;)

  -David Hiltz
#!perl
#----------------------------------------------------
# gb.pl - Gui Builder.  ..at least the start of one.
#----------------------------------------------------

use Win32::GUI;

require "lab_prop.pl";
require "but_prop.pl";
require "bor_prop.pl";

$DEBUG = 1;

$top = 10;
$bottom = 20;

$bi = 10;

$CW{left}   = 100;
$CW{top}    = 100;  
$CW{width}  = 700;
$CW{height} = 130;

$DW{top}    = $CW{top} + $CW{height};
$DW{width}  = 300;
$DW{left}   = $CW{left} + ($CW{width} / 2) - ($DW{width} / 2);
$DW{height} = 300;

$PROP_WIN_X_OFFSET = 100;
$PROP_WIN_Y_OFFSET = 90;

$first_resize = 1;  # $CWin_Resize is called before the Window is ready.

# There is a unusable border around the real window.  Corrdinate 0,0
# really starts 4 over and 23 + 19 down (See diagram below).
$WIN_OFFSET_X = 4;
$WIN_OFFSET_Y = 23;
$WIN_OFFSET_Y_MENU = 19;
#
#  +-----------------+
#  |             23 {|
#  +-----------------+
#  |File Edit } 19   |
#  +-----------------+
#  | 0,0             |
#  |^                |
#  |4                |


# Loading Prefences from gb.cf file.
$PREFS = &Read_Prefs;

&Setup_Menu;

$PopupMenu = Win32::GUI::MakeMenu (
        "POP with POD"   => "POPUP_POD",
        "  >&Item1"      => {-name=>"Item1",-default=>1},
        "  >&Item2"      => "Item2",
        "  >&Item3"      => "Item3",
);

$CWin = new Win32::GUI::Window(
        -left   => $CW{left},
        -top    => $CW{top},
        -width  => $CW{width},
        -height => $CW{height},
        -name   => "MWin",
        -text   => "gb - GUI Builder (v0)",
        -menu   => $Menu,
);

$CWin->Show();



# Draws a line under menu.
#$CWin->AddToolbar(
#       -name=>"SeperatorBar"
#       );

&Setup_Toolbar;

$CWin->AddLabel(
      -text => "0000, 0000",
      -name => "Status_XY_Lab",
      );

$CWin->AddLabel(
      -text => " " x 150,
      -name => "WinInfo_Lab",
);


&Calculate_Status_XY_Position;


$w = $CWin->AddButton(
      -text => $text = "Hide",
      -name => "${text}But",
      -left => $bi,
      -top  => $BUTTON_Y,
     ); $bi += $w->Width() + 6;


$w = $CWin->AddButton(
      -text => $text = "Bigger",
      -name => "${text}But",
      -left => $bi,
      -top  => $BUTTON_Y,
     ); $bi += $w->Width() + 6;

$w = $CWin->AddButton(
      -text => $text = "Smaller",
      -name => "${text}But",
      -left => $bi,
      -top  => $BUTTON_Y,
     ); $bi += $w->Width() + 6;

$w = $CWin->AddButton(
      -text => $text = "Longer",
      -name => "${text}But",
      -left => $bi,
      -top  => $BUTTON_Y,
     ); $bi += $w->Width() + 6;

$w = $CWin->AddButton(
      -text => $text = "LongerX10",
      -name => "${text}But",
      -left => $bi,
      -top  => $BUTTON_Y,
     ); $bi += $w->Width() + 6;

$w = $CWin->AddButton(
      -text => $text = "Shorter",
      -name => "${text}But",
      -left => $bi,
      -top  => $BUTTON_Y,
     ); $bi += $w->Width() + 6;

$w = $CWin->AddButton(
        -text => $text = "<",
        -name => "OBJ_MoveLeftBut",
        -left => $bi,
        -top  => $BUTTON_Y,
       ); $bi += $w->Width() + 6;

$w = $CWin->AddButton(
        -text => $text = ">",
        -name => "OBJ_MoveRightBut",
        -left => $bi,
        -top  => $BUTTON_Y,
       ); $bi += $w->Width() + 6;

$w = $CWin->AddButton(
        -text => $text = "^",
        -name => "OBJ_MoveUpBut",
        -left => $bi,
        -top  => $BUTTON_Y,
       ); $bi += $w->Width() + 6;

$w = $CWin->AddButton(
        -text => $text = "v",
        -name => "OBJ_MoveDownBut",
        -left => $bi,
        -top  => $BUTTON_Y,
       ); $bi += $w->Width() + 6;

$w = $CWin->AddButton(
        -text => $text = "Select",
        -name => "OBJ_SelectBut",
        -left => $bi,
        -top  => $BUTTON_Y,
       ); $bi += $w->Width() + 6;


Win32::GUI::Dialog();


#----------------------------------------------------------------
sub Read_Prefs {
   local($pref_file) = "gb.cf";
   $PREFS = "";

   if (-e "$pref_file") {
      print "Reading Preferences File ($pref_file)...\n" if ($DEBUG);

      open(PREF_FILE,"$pref_file") || die "Error opening $pref_file: $!\n";

      while (<PREF_FILE>) {
         if ($_ =~ /recent_open\s*=\s*(.*)/) {
            push(@{$PREFS->{recent_files}},$1);
         }
      }
      close PREF_FILE;
   }

   return($PREFS);
}


#----------------------------------------------------------------
sub Calculate_Status_XY_Position {

   ($w_left,$w_top,$w_right,$w_bottom) = $CWin->GetWindowRect();

   # 23 - 19 are unused border amounts. 5 is just a margin.
   $STATUS_Y = $CWin->Height - 23 - 19 - $CWin->Status_XY_Lab->Height - 5;
   $STATUS_X = 10;

   $CWin->Status_XY_Lab->Move($STATUS_X,$STATUS_Y);

   $BUTTON_Y = $STATUS_Y - $CWin->Status_XY_Lab->Height - 10; 

   # 10 - 5 for margin used on Status line and 5 more for spacing between
   # buttons and status line.
   $CWin->WinInfo_Lab->Move($STATUS_X + $CWin->Status_XY_Lab->Width + 10,
                            $STATUS_Y);

}

#----------------------------------------------------------------
sub WinInfoBut_Click {
   &Update_WinInfo;
}


#--------------------------------------------------------------
sub Update_WinInfo {
   ($w_left,$w_top,$w_right,$w_bottom) = $CWin->GetWindowRect();

   $x_rel = $w_right - $CWin->Width;
   $y_rel = $w_bottom - $CWin->Height;

   $CWin->WinInfo_Lab->Text(" sh=".$CWin->ScaleHeight().
                           " sw=".$CWin->ScaleWidth() .
                           " wh=".$CWin->Height()     .
                           " ww=".$CWin->Width()      .
                           " wl=".$w_left            .
                           " wt=".$w_top             .
                           " wr=".$w_right           .
                           " wb=".$w_bottom          .
                           " rx=".$x_rel             .
                           " ry=".$y_rel);
}


#--------------------------------------------------------------
sub Get_OBJ_xy {

   ($w_left,$w_top,$w_right,$w_bottom) = $DWin->GetWindowRect();
   ($o_left,$o_top,$o_right,$o_bottom) = Win32::GUI::GetWindowRect($OBJ);

   my $x = $o_left - $w_left - $WIN_OFFSET_X;
   my $y = $o_top - $w_top - $WIN_OFFSET_Y;

   #$x++; $y++;  # For Dialog Boxes only.

   return($x,$y);
}

   
#---------------------------------------------------------------
sub OBJ_MoveLeftBut_Click {
   
   my ($x,$y) = &Get_OBJ_xy();

   print "x = $x and y = $y\n";

   Win32::GUI::Move($OBJ,--$x,$y);
}

#---------------------------------------------------------------
sub OBJ_MoveRightBut_Click {
   
   my ($x,$y) = &Get_OBJ_xy();

   Win32::GUI::Move($OBJ,++$x,$y);
}

#---------------------------------------------------------------
sub OBJ_MoveUpBut_Click {
   
   my ($x,$y) = &Get_OBJ_xy();

   Win32::GUI::Move($OBJ,$x,--$y);
}
#---------------------------------------------------------------
sub OBJ_MoveDownBut_Click {
   
   my ($x,$y) = &Get_OBJ_xy();

   Win32::GUI::Move($OBJ,$x,++$y);
}

#---------------------------------------------------------------
sub BiggerBut_Click {
   ($o_left,$o_top,$o_right,$o_bottom) = Win32::GUI::GetWindowRect($OBJ);

   Win32:GUI::Resize($OBJ,$o_right - $o_left + 1,$o_bottom - $o_top + 1);
}

#---------------------------------------------------------------
sub LongerBut_Click {
   ($o_left,$o_top,$o_right,$o_bottom) = Win32::GUI::GetWindowRect($OBJ);

   Win32::GUI::Resize($OBJ,$o_right - $o_left + 1,$o_bottom - $o_top);
}
#---------------------------------------------------------------
sub LongerX10But_Click {
   ($o_left,$o_top,$o_right,$o_bottom) = Win32::GUI::GetWindowRect($OBJ);

   Win32::GUI::Resize($OBJ,$o_right - $o_left + 10,$o_bottom - $o_top);
}

#---------------------------------------------------------------
sub ShorterBut_Click {
   ($o_left,$o_top,$o_right,$o_bottom) = Win32::GUI::GetWindowRect($OBJ);

   Win32::GUI::Resize($OBJ,$o_right - $o_left - 1,$o_bottom - $o_top);
}

#---------------------------------------------------------------
sub SmallerBut_Click {
   ($o_left,$o_top,$o_right,$o_bottom) = Win32::GUI::GetWindowRect($OBJ);

   Win32:GUI::Resize($OBJ,$o_right - $o_left - 1,$o_bottom - $o_top - 1);
}

#---------------------------------------------------------------
sub OBJ_SelectBut_Click {

   if ($select) {
      $DWin->Object_Select->Kill();
      $select = 0;

      if (0) {      
       #-- Draw a small dot to show where we are.
       $DC = $DWin->GetDC;

       # Color and thickness of rectangle border
       $P = new Win32::GUI::Pen(   
            -color => [150,0,0], 
            -width => 1,
       );

       $DC->SelectObject($P);
       $DC->Rectangle($xpos,$ypos,$xpos+2,$ypos+2);
      }

      ($x,$y) = Win32::GUI::GetCursorPos();

      $OBJ = Win32::GUI::WindowFromPoint($x,$y);

      Win32::GUI::Disable($OBJ);
      sleep 1;
      Win32::GUI::Enable($OBJ);

      if (Win32::GUI::IsWindow($OBJ)) {
         print "  -- GOT IT --\n" if ($DEBUG);
         ($o_left,$o_top,$o_right,$o_bottom) = Win32::GUI::GetWindowRect($OBJ);
      }
   }
   else {
      $select = 1;
      $DWin->AddTimer("Object_Select",20);
   }
}

#----------------------------------------------------------------
sub Object_Select_Timer {

   # Query Window message looking for mouse clicks - Better way is
   # to have windows tell us when a mouse click event has occured - 
   # maybe in the next version. ;)
   ($rcode,$mi,$wparm,$iparm,$time,$x,$y) = 
   Win32::GUI::GetMessage($DWin,162,513);
   #print "$mi - $wparm $iparm\n";
   if ($rcode != -1 && ($mi == 513 || $mi == 162)) {
      &OBJ_SelectBut_Click;
   }

   ($x,$y) = Win32::GUI::GetCursorPos();

   ($w_left,$w_top,$w_right,$w_bottom) = $DWin->GetWindowRect();

   $xpos = $x - ($w_right - $DWin->Width) - $WIN_OFFSET_X;
      
   $ypos = $y - ($w_bottom - $DWin->Height) - $WIN_OFFSET_Y;
}

#---------------------------------------------------------------
sub Object_Size {

   if ($sizing) {
      $DWin->Object_Size->Kill();
      $sizing = 0;
      $SIZE = 0;
   }
   else {
      $DWin->AddTimer("Object_Size",20);
      $sizing = 1;
   }
}

#----------------------------------------------------------------
sub Object_Size_Timer {

   # Query Window message looking for mouse clicks - Better way is
   # to have windows tell us when a mouse click event has occured - 
   # maybe in the next version. ;)
   ($rcode,$mi,$wparm,$iparm,$time,$x,$y) = 
   Win32::GUI::GetMessage($DWin,162,513);
   #print "$mi - $wparm $iparm\n";
   if ($rcode != -1 && ($mi == 513 || $mi == 162)) {
      &Object_Size;
   }

   ($x,$y) = Win32::GUI::GetCursorPos();

   ($w_left,$w_top,$w_right,$w_bottom) = $DWin->GetWindowRect();

   $xpos = $x - ($w_right - $DWin->Width) - $WIN_OFFSET_X;
   
   $ypos = $y - ($w_bottom - $DWin->Height) - $WIN_OFFSET_Y;

   $CWin->Status_XY_Lab->Text($xpos.", ".$ypos);
   
   $OBJ->Resize($xpos,$ypos);
}

#---------------------------------------------------------------
# Called to move or stop moving an object.  Reference to object
# is passed.
#---------------------------------------------------------------
sub Object_Move {
   
   if ($moving) {
      $DWin->Object_Move->Kill();
      $moving = 0;
      if ($SIZE) {
         &Object_Size;
      }
   }
   else {
      $DWin->AddTimer("Object_Move",20);
      $moving = 1;
   }
}

#----------------------------------------------------------------
# Called when an object is selected for moving.  Object will float
# Around on the screen following the pointer until some event
# happends (keypress, click).
#----------------------------------------------------------------
sub Object_Move_Timer {

   # Query Window message looking for mouse clicks - Better way is
   # to have windows tell us when a mouse click event has occured - 
   # maybe in the next version. ;)
   ($rcode,$mi,$wparm,$iparm,$time,$x,$y) = 
   Win32::GUI::GetMessage($DWin,162,513);
   #print "$mi - $wparm $iparm\n";
   if ($rcode != -1 && ($mi == 513 || $mi == 162)) {
      &Object_Move;
   }

   ($x,$y) = Win32::GUI::GetCursorPos();

   ($w_left,$w_top,$w_right,$w_bottom) = $DWin->GetWindowRect();

   $xpos = $x - ($w_right - $DWin->Width) - $WIN_OFFSET_X;
   
   $ypos = $y - ($w_bottom - $DWin->Height) - $WIN_OFFSET_Y;

   $CWin->Status_XY_Lab->Text($xpos.", ".$ypos);
   
   $OBJ->Move($xpos,$ypos);
}

#----------------------------------------------------------
sub File_New_Click {

   $DWin = new Win32::GUI::Window(
           -left   => $DW{left},
           -top    => $DW{top},
           -width  => $DW{width},
           -height => $DW{height},
           -name   => "DWin",
           -text   => "gb - Design Window",
   );

   $DWin->Show();
}

#----------------------------------------------------------
sub File_Open_Click {

    # Open File Dialog Box
    # show files with *.ui extension starting in C:\ directory
    $file_spec = "*.ui"; #\0" . " " x 256;
    $dir = cwd;

    $OPENED_FILE = GUI::GetOpenFileName(
                   -owner => $CWin,
                   -directory => "$dir",
                   -title => "GUI Designer - Open File", 
                   -file => $file_spec,
    );

     
    if (-e "$OPENED_FILE") {
       &Read_UI_File("$OPENED_FILE");
    }
    else {
       &winerr("Unable to find file: $OPENED_FILE");
    }
}


#----------------------------------------------------------
sub File_SaveAs_Click {

    # Open File Dialog Box
    # show files with *.ui extension starting in C:\ directory
    $file_spec = "*.ui\0" . " " x 256;
    $dir = cwd;

    $file = GUI::GetOpenFileName(
        -owner => $CWin,
        -directory => "$dir",
        -title => "GUI Designer - File Save As", 
        -file => $file_spec,
    );

    &Build_GUI_File("$file");
}


#------------------------------------------------------------
sub File_Save_Click {

    if (length($OPENED_FILE) >= 1) {
       &Build_GUI_File("$OPENED_FILE");
    }
    else {
       &File_SaveAs_Click;
    }
}


#------------------------------------------------------------
sub File_Exit_Click {
   &MWin_Terminate();
}


#------------------------------------------------------------
sub Help_About_Click {

   $about =  "gb (Win32::GUI Builder)\n\n";
   $about .= "David Hiltz\n\n";
   $about .= "Version 0.0\n";

   Win32::GUI::MessageBox(0,$about,"Info",64);
}


#-----------------------------------------------------------
sub MWin_Resize {

   if (!$first_resize) {
      &Calculate_Status_XY_Position;

      # Can add the other buttons if we decide to have a row of 
      # them on the bottom of the screen.
      $CWin->WinInfoBut->Move($bi,$BUTTON_Y);

      &Update_WinInfo;
   }
   $first_resize = 0;
}


#------------------------------------------------------
sub Setup_Menu {
   local($file,$code);
   local($file_ct) = 0;
   local($recent_files_text) = "";

   if (defined(@{$PREFS->{recent_files}})) {
      foreach $file (@{$PREFS->{recent_files}}) {
          #print "recent --- $file\n";
          $file_ct++;
          $recent_files_text .= "\"    > $file\"  => \"RecentFile_$file_ct\",\n";
          $sub_code=<<end_code;
sub RecentFile_${file_ct}_Click {
    \$OPENED_FILE = "$file";
    &Read_UI_File("$file");
}
end_code

          eval $sub_code;
      }
      $recent_files_text .= "\"   > -\"   => 0,";
   }


$code=<<end_code;
\$Menu = Win32::GUI::MakeMenu(
        "&File"              => "&File",
        "    > &New"         => "File_New",
        "    > &Open"        => "File_Open",
        "    > &Save"        => "File_Save",
        "    > Save &As.."   => "File_SaveAs",
        "    > -"            => 0,
        $recent_files_text
        "    > E&xit"        => "File_Exit",
        "&Edit"              => "&Edit",
        "    > &Delete"      => "Edit_Delete",
        "&Help"              => "&Help",
        "    > &About gb"    => "Help_About"
        );
end_code

#print "$code";

eval $code;
}


#----------------------------------------------------
sub Setup_Toolbar {

   $small_font = new Win32::GUI::Font(
          -name   => "Arial",
          -height => 12,
          -weight => 200,
   );

   $CWin->AddToolbar(
          -name   => "ToolBar",
          -style  => 1022,   # Don't know what this does?
          -width  => $CW{width},
          -height => 45,
          -font   => $small_font,
   );

   # Worry about this later.
   $CWin->ToolBar->SetBitmapSize(16,16);
   #$BM1 = new Win32::GUI::Bitmap("TB_button.bmp");
   #$CWin->ToolBar->AddBitmap($BM1,5);

   # Add text to bottom of button and makes button taller.
   $CWin->ToolBar->AddString("Butt");
   $CWin->ToolBar->AddString("Label");
   $CWin->ToolBar->AddString("Text");
   $CWin->ToolBar->AddString("Radio");
   $CWin->ToolBar->AddString("Check");
   $CWin->ToolBar->AddString("BordR");

   $CWin->ToolBar->AddButtons(
          6,
          0, 1, 4, 0, 0,
          1, 2, 4, 0, 1,
          2, 3, 4, 0, 2,
          3, 4, 4, 0, 3,
          4, 5, 4, 0, 4,
          5, 6, 4, 0, 5,
   );

   $CWin->ToolBar->Show();
}

#-------------------------------------------------------
sub get_objname {
   local($prefix) = @_;
   local($num,$maxnum) = 0;

   foreach $child (keys %{$DWin}) {
      if ($child =~ /^-/) {
         next;
      }
      else {
         if ($child =~ /^${prefix}_(\d+)$/) {
            $num = $1;
            if ($num > $maxnum) {
               $maxnum = $num;
            }
         }
      }
   }
   if ($maxnum == 0) {
      print "Returning objname = ${prefix}_1\n" if ($DEBUG);
      return("${prefix}_1");
   }
   else {
      $maxnum++;
      print "Returning objname = ${prefix}_$maxnum\n" if ($DEBUG);
      return("${prefix}_$maxnum");
   }
}
   
#-----------------------------------------------
sub ToolBar_ButtonClick {
   my($button) = @_;

   if ($button == 1) {  # Button
      &Button_Property_Win;
   }
   elsif ($button == 2) {  # Label
      &Label_Property_Win;
   }
   elsif ($button == 3) {  # TextField

      $objname = &get_objname("TextField");

      $OBJTYPE{"$objname"} = "Edit";

      $OBJ = $DWin->AddTextfield(
      -width => 80,         # Without these we could not
      -height => 20,        # see the textfield.
      -name => "$objname",
     ) || die "Error: ", Win32::GetLastError();

     &Object_Move;
   }
   elsif ($button == 4) {  # RadioButton
      $objname = &get_objname("RadioButton");

      $OBJTYPE{"$objname"} = "Radio";  # Wrong - Button type

      $OBJ = $DWin->AddRadioButton(
      -text => "RadioButton",
      -name => "$objname",
     ) || die "Error: ", Win32::GetLastError();

     &Object_Move;
   }
   elsif ($button == 5) {  # Checkbox
      $objname = &get_objname("CheckBox");


      $OBJTYPE{"$objname"} = "Check";  # Wrong - Button type

      $OBJ = $DWin->AddCheckbox(
      -text => "Checkbox",
      -name => "$objname",
     ) || die "Error: ", Win32::GetLastError();

     &Object_Move;
   }
   elsif ($button == 6) {  # Border - simply a type of button.
      &Border_Property_Win;

   }
}

#-----------------------------------------------------------------
sub New_Button {
   local($text,$FixVal) = @_;

   if (!defined($text)) {
      return;
   }

   $objname = &get_objname("Button");

   $OBJTYPE{"$objname"} = "Button";

   $OBJ = $DWin->AddButton(
   -text => $text = $text,
   -name => "$objname",
   ) || die "Error: ", Win32::GetLastError();

   if (defined($FixVal)) {
      $OBJ->Width($FixVal);
   }

   &Object_Move;
}


#-----------------------------------------------------------------
sub New_Label {
   local(%parms) = @_;

   if (!defined(%parms)) {
      return;
   }

   $objname = &get_objname("Label");

   $OBJTYPE{"$objname"} = "Static";

   $fg_text = "-foreground => $parms{fgcolor},";

   $OBJ = $DWin->AddLabel(
          -text   => "$parms{text}",
          -width  => length($parms{text}) * 6,
          -foreground => $parms{fgcolor},
          -background => $parms{bgcolor},
        #  -font       => new Win32::GUI::Font(%font_stuff),
          -name => "$objname",
          ) || die "Error: ", Win32::GetLastError();

   print "$fg_text\n";
   foreach $i (keys %parms) {
     print "$i = $parms{$i}\n";
   }

#   if (defined($parms{fgcolor}) || defined($parms{bgcolor})) {
#      $OBJ->Change(-background=> $parms{bgcolor},
#                   -background=> $parms{bgcolor}
#      );
#   }

   &Object_Move;
   
}

#----------------------------------------------------------------
sub New_Border {
   local($text,$Width_TF,$Height_TF) = @_;

   if (!defined($text)) {
      return;
   }
 
   $objname = &get_objname("Border");

   $OBJTYPE{"$objname"} = "Border";  # Wrong - Button Class

   $OBJ = $DWin->AddButton(
   -text => $text = $text,
   -name => "$objname",
   -style => WS_CHILD | WS_VISIBLE | 7,  # 7 indicates border type
   ) || die "Error: ", Win32::GetLastError();

   if (defined($Width_TF)) {
      $OBJ->Width($Width_TF);
   }
   if (defined($Height_TF)) {
      $OBJ->Height($Height_TF);
   }

   $SIZE = 1;
   &Object_Move;
}

#-----------------------------------------------------------------
sub MWin_Terminate {
    return -1;
}
sub DWin_Terminate {
    return -1;
}

#-----------------------------------------------------------------
sub Build_GUI_File {
   local($filename) = @_;
   local($obj);

   print "Build_GUI_File (Filename='$filename')\n" if ($DEBUG);

   ($w_left,$w_top,$w_right,$w_bottom) = $DWin->GetWindowRect();

   open(NEW,">$filename") || die "Error opening $filename): $!\n";

   print NEW<<END_INPUT;
#!perl

use Win32::GUI;

\$Win = new Win32::GUI::Window(
        -left   => $w_left,
        -top    => $w_top,
        -width  => $w_right - $w_left,
        -height => $w_bottom - $w_top,
        -name   => "Win",
        -text   => "gb - output",
);

\$Win->Show();

END_INPUT

   foreach $child (keys %{$DWin}) {
      print "  CHILD - $child\n";
      if ($child =~ /^-/) {
         next;
      }
      else {
         ($left,$top,$right,$bottom) = Win32::GUI::GetWindowRect($DWin->{$child});
         print "l=$left,r=$righ,t=$top,b=$bottom\n";

         # Can't use name because borders, checkboxes, radiobuttons are all
         # buttons.
         ($classname) = Win32::GUI::GetClassName($DWin->{$child});

         ($height) = Win32::GUI::Height($DWin->{$child});
         ($width) = Win32::GUI::Width($DWin->{$child});

         ($text) = Win32::GUI::Text($DWin->{$child});
         #($font) = Win32::GUI::Font($DWin->{$child});
 
         print "  child=$child ($text), H=$heigh, W=$width, classtype=$classname, 
type=$OBJTYPE{$child}\n";

         if ($OBJTYPE{$child} eq "Button") {
            print NEW<<END_INPUT;
\$Win->AddButton (
       -text   => "$text",
       -name   => "$child",
       -left   => $right - $w_left - $width - 4,
       -top    => $top - $w_top - 24 + 1,  # 24 is def button height
       -width  => $width,
       -height => $height,
      );

END_INPUT
         }
         elsif ($OBJTYPE{$child} eq "Edit") {
            print NEW<<END_INPUT;
\$Win->AddTextfield (
       -text   => "$text",
       -name   => "$child",
       -left   => $right - $w_left - $width - 4,
       -top    => $top - $w_top - 20 - 3, # 20 is def text field height
       -width  => $width,
       -height => $height,
      );

END_INPUT
         }
         elsif ($OBJTYPE{$child} eq "Static") {
            print NEW<<END_INPUT;
\$Win->AddLabel (
       -text   => "$text",
       -name   => "$child",
       -left   => $right - $w_left - $width - 4, 
       -top    => $top - $w_top - $height - 7,
       -width  => $width,
       -height => $height,
      );

END_INPUT
         }
         elsif ($OBJTYPE{$child} eq "Border") {
            print NEW<<END_INPUT;
\$Win->AddButton (
       -text   => "$text",
       -name   => "$child",
       -left   => $right - $w_left - $width - 4, 
       -top    => $top - $w_top - 23,
       -width  => $width,
       -height => $height,
       -style  => WS_CHILD | WS_VISIBLE | 7,  # 7 indicates border type
      );

END_INPUT
         } # if $classname
         else {
             print "** UNKNOWN OBJTYPE \n";
         }

      } # if $child

   } # for

   print NEW<<END_INPUT;
Win32::GUI::Dialog();

sub Win_Terminate {
   return -1;
}
END_INPUT
   
   close NEW;
}

#sub Button1_Click {
#   $DWin->TrackPopupMenu($PopupMenu,$xpos, $ypos);
#}

#----------------------------------------------------------
# A very basic parsing routine to read in existing UI file.
#----------------------------------------------------------
sub Read_UI_File {
    local($filename) = @_;

    print "Reading UI File...\n" if ($DEBUG);
    if ($DEBUG) {
       open(READ,">uiread.txt") or die "Error opening READ file $!\n";
    }

    open(UI,"$filename") || die "Error opening $filename: $!\n";

    while (<UI>) {
       $file .= $_;
    }
    close UI;

    $* = 1;
    # Strip out Window definition.
    if ($file =~ 
/\$(\w+)\s*=\s*new\s+Win32::GUI::(Window|DialogBox)\s*\((\s*-\w+\s*=>\s*.*,?\s*)+\)\;/)
 {
          $Winvar = $1;
          $Wincode = $&;
    }

    # Strip out what we found and process the rest.
    $file = $` . $';

    $Wincode .= "\n\$${Winvar}->Show();\n\n";

    do {
      undef $object;

      # Doesn't check for duplicate object names.
      if ($file =~ /\$${Winvar}->Add(\w+)\s*\((\s*-\w+\s*=>\s*.*,?\s*)+\)\;/) {
         $object = $&;

         $file = $` . $';  # Reduce down to what is left after match.

         $Wincode .= "$object\n";
      }
    } until (!defined($object));

    print READ $Wincode if ($DEBUG);

    eval "$Wincode";

    eval "\$DWin = \$${Winvar}";

   # Not a complete solution as checkboxes and radiobuttons are of type button.  
   foreach $child (keys %{$DWin}) {
      if ($child =~ /^-/) {
         next;
      }
      else {
         ($classname) = Win32::GUI::GetClassName($DWin->{$child});
         print "  Read $child - classname=$classname\n" if ($DEBUG);
#         %opts = $DWin->{$child};
       print "  other:", ref $DWin->{$child},"\n";
         foreach $item (keys %{$DWin->{$child}}) {
             print "      $item =", $DWin->{$child}{$item},"\n";

         }
         if (!defined($OBJTYPE{$child})) {
            $OBJTYPE{$child} = $classname;
         }
         else {
             &winerr("Object Name not uniqe: $classname");
         }
      }
   }
}

#--------------------------------------------------------
sub winerr {
   local($msg) = @_;

   Win32::GUI::MessageBox(0,$msg,"Error",64);
}

#--------------------------------------------------------
sub winmsg {
   local($msg) = @_;

   Win32::GUI::MessageBox(0,$msg,"Info",64);
}

But_prop.pl

lab_prop.pl

bor_prop.pl

recent_open = but_prop.ui
recent_open = lab_prop.ui
recent_open = nspref.ui
recent_open=v.ui
begin:vcard 
n:hiltz;david
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:[EMAIL PROTECTED]
title:whatever
x-mozilla-cpt:;0
fn:david hiltz
end:vcard

Reply via email to