Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.1 KiB

  1. use Win32::GUI;
  2. $BS_GROUPBOX = 7;
  3. sub AutoFormCheckboxGroup
  4. {
  5. my($pWnd) = shift(@_);
  6. my($bRadio) = shift(@_);
  7. my($sName) = shift(@_);
  8. my($nLeft) = shift(@_);
  9. my($nTop) = shift(@_);
  10. my($sText) = shift(@_);
  11. my($nMaxLength) = length($sName) + 2;
  12. for (my $i = 1 ; $i < scalar(@_) ; $i += 2)
  13. {
  14. if (length($_[$i]) > $nMaxLength)
  15. {
  16. $nMaxLength = length($_[$i]);
  17. }
  18. }
  19. my($nWidth) = ($nMaxLength * $g_nHorzCharSize) + $g_nHorzSpacing * 2;
  20. my($nHeight) = (scalar(@_) / 2 + 1) * ($g_nVertSpacing + $g_nVertCharSize) + $g_nVertSpacing;
  21. FormCheckboxGroup($pWnd, $bRadio, $sName, $nLeft, $nTop, $nWidth, $nHeight, $sText, @_);
  22. }
  23. # pWnd, bRadio, sName, nLeft, nTop, nWidth, nHeight, sText, [cbx1name, cbx1text], [...]
  24. sub FormCheckboxGroup
  25. {
  26. my($pWnd) = shift(@_);
  27. my($bRadio) = shift(@_);
  28. my($sName) = shift(@_);
  29. my($nLeft) = shift(@_);
  30. my($nTop) = shift(@_);
  31. my($nWidth) = shift(@_);
  32. my($nHeight) = shift(@_);
  33. my($sText) = shift(@_);
  34. if (scalar(@_) % 2 == 1)
  35. {
  36. print(STDERR "bad windows dimensions\n");
  37. return(0);
  38. }
  39. $pWnd->AddButton(
  40. -name => $sName,
  41. -left => $nLeft,
  42. -top => $nTop,
  43. -width => $nWidth,
  44. -height => $nHeight,
  45. -text => $sText,
  46. -style => WS_VISIBLE | WS_CHILD | $BS_GROUPBOX,
  47. );
  48. for (my $i = 0 ; $i < scalar(@_) ; $i += 2)
  49. {
  50. if ($bRadio)
  51. {
  52. $W->AddRadioButton(
  53. -name => $_[$i],
  54. -left => $nLeft + $g_nHorzSpacing,
  55. -top => $nTop + ((($i / 2) + 1) * ($g_nVertSpacing + $g_nVertCharSize)),
  56. -text => $_[$i + 1]." ",
  57. );
  58. }
  59. else
  60. {
  61. $W->AddCheckbox(
  62. -name => $_[$i],
  63. -left => $nLeft + $g_nHorzSpacing,
  64. -top => $nTop + ((($i / 2) + 1) * ($g_nVertSpacing + $g_nVertCharSize)),
  65. -text => $_[$i + 1]." ",
  66. );
  67. }
  68. }
  69. if ($_[0] && $bRadio)
  70. {
  71. $pWnd->{$_[0]}->Checked(1);
  72. }
  73. }