File: options-resource.pl

package info (click to toggle)
fuse-emulator 1.0.0.1a%2Bdfsg1-4
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 9,568 kB
  • sloc: ansic: 67,895; sh: 10,265; perl: 3,386; makefile: 787; yacc: 227; lex: 139
file content (97 lines) | stat: -rwxr-xr-x 2,990 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/perl -w

# options-resource.pl: generate options dialog boxes
# $Id: options-resource.pl 4088 2009-09-02 19:56:57Z specu $

# Copyright (c) 2001-2007 Philip Kendall, Stuart Brady, Marek Januszewski

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

# Author contact information:

# E-mail: philip-fuse@shadowmagic.org.uk

use strict;

use Fuse;
use Fuse::Dialog;

die "No data file specified" unless @ARGV;

my @dialogs = Fuse::Dialog::read( shift @ARGV );

print Fuse::GPL( 'options.rc: options dialog boxes',
		 '2001-2007 Philip Kendall, Stuart Brady' ) . << "CODE";

/* This file is autogenerated from options.dat by options-resource.pl.
   Do not edit unless you know what you\'re doing! */

#include "options_internals.h"
CODE

foreach( @dialogs ) {

    my $buffer = ""; # needed because we find out the height at the end at the end
    my $optname = uc( "OPT_$_->{name}" );
    my $y = 5;

    foreach my $widget ( @{ $_->{widgets} } ) {

	my $text = $widget->{text}; $text =~ s/\((.)\)/&$1/;
	if( $widget->{type} eq "Checkbox" ) {
	    $buffer .= sprintf "  AUTOCHECKBOX \"%s\",IDC_%s_%s,5,$y,160,12\n",
		$text, $optname, uc( $widget->{value}, );
	    $y += 12;
	} elsif( $widget->{type} eq "Entry" ) {
	    $buffer .= sprintf "  LTEXT \"%s\",IDC_%s_LABEL_%s,5,$y,90,12\n",
		$text, $optname, uc( $widget->{value} );
	    $buffer .= sprintf "  EDITTEXT IDC_%s_%s,100,$y,85,10\n",
		$optname, uc( $widget->{value} );
	    $y += 12;
	} elsif( $widget->{type} eq "Combo" ) {
	    $buffer .= sprintf "  LTEXT \"%s\",IDC_%s_LABEL_%s,5,$y,90,12\n",
		$text, $optname, uc( $widget->{value} );
	    $buffer .= sprintf "  COMBOBOX IDC_%s_%s,100,$y,85,90,"
	        . "CBS_DROPDOWNLIST | CBS_HASSTRINGS\n",
		$optname, uc( $widget->{value} );
	    $y += 12;
	} else {
	    die "Unknown type '$widget->{type}'";
	}

    }

    $y += 5;

    $buffer .= sprintf "  DEFPUSHBUTTON \"OK\",IDOK,55,$y,40,13\n", $optname;
    $buffer .= sprintf "  PUSHBUTTON \"Cancel\",IDCANCEL,100,$y,40,13\n", $optname;

    $y += 13 + 5; #height of the buttons + 5 margin
   
    print << "CODE";

IDD_$optname DIALOGEX 6,5,190,$y
  CAPTION "Fuse - $_->{title}"
  FONT 8,"Ms Shell Dlg 2",400,0,1
  STYLE WS_POPUP | WS_CAPTION | WS_BORDER | WS_SYSMENU
  EXSTYLE WS_EX_APPWINDOW
BEGIN
CODE

    print $buffer;

    print "END\n";
    printf "\n";
}