The R Project SVN R

Rev

Rev 63077 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
51883 ripley 1
 
2
[Code]
3
 
4
var
5
  NoAdminPage: TOutputMsgWizardPage;
6
  SelectOptionsPage: TInputOptionWizardPage;
7
  MDISDIPage: TInputOptionWizardPage;
8
  HelpStylePage: TInputOptionWizardPage;
9
  INIFilename: String;
10
 
11
function IsAdmin: boolean;
12
begin
13
  Result := IsAdminLoggedOn or IsPowerUserLoggedOn;
14
end;
15
 
16
function NonAdmin: boolean;
17
begin
18
  Result := not IsAdmin;
19
end;
20
 
21
procedure InitializeWizard;
22
var
23
  option : String;
24
  index : Integer;
25
begin
26
  NoAdminPage := CreateOutputMsgPage(wpWelcome, SetupMessage(msgInformationTitle), 
27
    CustomMessage('adminprivilegesrequired'), CustomMessage('adminexplanation'));
28
 
29
  SelectOptionsPage := CreateInputOptionPage(wpSelectComponents,
30
    CustomMessage('startupt'), CustomMessage('startupq'),
31
    CustomMessage('startupi'), True, False);
32
  SelectOptionsPage.Add(CustomMessage('startup0'));
33
  SelectOptionsPage.Add(CustomMessage('startup1'));
34
  SelectOptionsPage.SelectedValueIndex := 1;
35
 
36
  MDISDIPage := CreateInputOptionPage(SelectOptionsPage.ID,
37
    CustomMessage('MDIt'), CustomMessage('MDIq'),
38
    CustomMessage('MDIi'), True, False);
39
  MDISDIPage.Add(CustomMessage('MDI0'));
40
  MDISDIPage.Add(CustomMessage('MDI1'));
41
 
42
  HelpStylePage := CreateInputOptionPage(MDISDIPage.ID,
43
    CustomMessage('HelpStylet'), CustomMessage('HelpStyleq'),
44
    CustomMessage('HelpStylei'), True, False);
45
  HelpStylePage.Add(CustomMessage('HelpStyle0'));
46
  HelpStylePage.Add(CustomMessage('HelpStyle1'));
47
 
48
  INIFilename := ExpandConstant('{param:LOADINF}');
49
  if INIFilename <> '' then INIFilename := ExpandFilename(INIFilename);
50
 
51
  { From highest to lowest, priority is:
52
    LOADINF value
53
    PreviousData value
54
    Default from build }
55
 
56
  option := GetPreviousData('MDISDI', '');
57
  if INIFilename <> '' then
58
    option := GetIniString('R', 'MDISDI', option, INIFilename);
59
  case option of
60
    'MDI': index := 0;
61
    'SDI': index := 1;
62
  else
63
    index := @MDISDI@;
64
  end;  
65
  MDISDIPage.SelectedValueIndex := index;
66
 
67
  option := GetPreviousData('HelpStyle', '');
68
  if INIFilename <> '' then
69
    option := GetIniString('R', 'HelpStyle', option, INIFilename);  
70
  case option of
71
    'plain': index := 0;
72
    'CHM':   index := 1;
73
    'HTML':  index := 1;
74
  else
75
    index := @HelpStyle@;
76
  end;
77
  HelpStylePage.SelectedValueIndex := index;
78
 
79
  { Get the save name now, because the current dir might change }
80
  INIFilename := ExpandConstant('{param:SAVEINF}');
81
  if INIFilename <> '' then INIFilename := ExpandFilename(INIFilename);    
82
end;
83
 
84
procedure RegisterPreviousData(PreviousDataKey: Integer);
85
var
86
  MDISDI: String;
87
  HelpStyle: String;
88
begin
89
 
90
  { Store the settings so we can restore them next time }
91
  case MDISDIPage.SelectedValueIndex of
92
    0: MDISDI := 'MDI';
93
    1: MDISDI := 'SDI';
94
  end;
95
  SetPreviousData(PreviousDataKey, 'MDISDI', MDISDI);
96
  if INIFilename <> '' then
97
    SetIniString('R', 'MDISDI', MDISDI, INIFilename);
98
 
99
  case HelpStylePage.SelectedValueIndex of
100
    0: HelpStyle := 'plain';
101
    1: HelpStyle := 'HTML';
102
  end;
103
  SetPreviousData(PreviousDataKey, 'HelpStyle', HelpStyle);  
104
  if INIFilename <> '' then
105
    SetIniString('R', 'HelpStyle', HelpStyle, INIFilename);
106
 
107
end;
108
 
62763 murdoch 109
function SetCommentMarker(var lines: TArrayOfString; option: String; active: boolean) : boolean;
51883 ripley 110
var
111
  i : integer;
62763 murdoch 112
  old : string;
51883 ripley 113
begin
62763 murdoch 114
  Result := false;
51883 ripley 115
  for i := 0 to pred(GetArrayLength(lines)) do
116
    if pos(option, lines[i]) > 0 then 
117
    begin
62763 murdoch 118
      old := lines[i];
51883 ripley 119
      if active then
120
        lines[i][1] := ' '
121
      else
122
        lines[i][1] := '#';
62763 murdoch 123
      if old <> lines[i] then
124
        Result := true;  
51883 ripley 125
      exit;
126
    end;
127
end;
128
 
129
procedure EditOptions();
130
var
131
  lines : TArrayOfString;
132
  filename : String;
62763 murdoch 133
  changed : boolean;
51883 ripley 134
begin
62763 murdoch 135
  changed := false;
51883 ripley 136
  filename := ExpandConstant(CurrentFilename);
137
  LoadStringsFromFile(filename, lines);
138
 
63077 murdoch 139
  if SetCommentMarker(lines, 'MDI = yes', MDISDIPage.SelectedValueIndex = 0) then changed := true;
140
  if SetCommentMarker(lines, 'MDI = no', MDISDIPage.SelectedValueIndex = 1) then changed := true;
51883 ripley 141
 
63077 murdoch 142
  if SetCommentMarker(lines, 'options(help_type="text"', HelpStylePage.SelectedValueIndex = 0) then changed := true;
143
  if SetCommentMarker(lines, 'options(help_type="html"', HelpStylePage.SelectedValueIndex = 1) then changed := true;
51883 ripley 144
 
62763 murdoch 145
  if changed then
146
    SaveStringsToFile(filename, lines, False);
51883 ripley 147
end;
148
 
149
function ShouldSkipPage(PageID: Integer): boolean;
150
begin
151
  if PageID = NoAdminPage.ID then Result := IsAdmin
68631 murdoch 152
  else if (PageID = MDISDIPage.ID) or (PageID = HelpStylePage.ID) then 
51883 ripley 153
    Result := SelectOptionsPage.SelectedValueIndex = 1
154
  else Result := false;
155
end;
156
 
157
function UserPF(Param:String): String;
158
begin
159
  Result := ExpandConstant('{pf}');
160
  if (not IsAdmin) then 
161
  begin
162
    try
163
      Result := ExpandConstant('{userdocs}');
164
    except
165
    // Do nothing, user doesn't have a My Documents folder
166
    end;
167
  end;
168
end;