summaryrefslogtreecommitdiff
path: root/plugins/Watrack/kolframe/frm_designer.inc
blob: f12c01f05d62f329cf89cb6c66d10ca767eccf57 (plain)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
{Frame designer}
const
  // trackbar
  opt_tbleft  :pAnsiChar='frame/designer/trackbar/left';
  opt_tbtop   :pAnsiChar='frame/designer/trackbar/top';
  opt_tbwidth :pAnsiChar='frame/designer/trackbar/width';
  opt_tbheight:pAnsiChar='frame/designer/trackbar/height';
  // text block
  opt_tleft   :pAnsiChar='frame/designer/text/left';
  opt_ttop    :pAnsiChar='frame/designer/text/top';
  opt_twidth  :pAnsiChar='frame/designer/text/width';
  opt_theight :pAnsiChar='frame/designer/text/height';
  // buttons (with number)
  opt_bleft   :pAnsiChar='frame/designer/buttons/left';
  opt_btop    :pAnsiChar='frame/designer/buttons/top';

procedure TWATFrame.DesignerSaveSettings;
var
  i:integer;
  D:PWATFrameData;
  lleft,ltop:array [0..63] of AnsiChar;
  pleft,ptop:PAnsiChar;
begin
  D:=CustomData;
  if D.TrackBar<>nil then
  begin
    DBWriteWord(0,PluginShort,opt_tbleft  ,D.Trackbar.Left);
    DBWriteWord(0,PluginShort,opt_tbtop   ,D.Trackbar.Top);
    DBWriteWord(0,PluginShort,opt_tbwidth ,D.Trackbar.Width);
    DBWriteWord(0,PluginShort,opt_tbheight,D.Trackbar.Height);
  end;

  if D.TextBlock<>nil then
  begin
    DBWriteWord(0,PluginShort,opt_tleft  ,D.TextBlock.Left);
    DBWriteWord(0,PluginShort,opt_ttop   ,D.TextBlock.Top);
    DBWriteWord(0,PluginShort,opt_twidth ,D.TextBlock.Width);
    DBWriteWord(0,PluginShort,opt_theight,D.TextBlock.Height);
  end;

  if (D.ShowControls and scButtons)<>0 then
  begin
    if D.btnarray[0]<>nil then
    begin
      pleft:=StrCopyE(lleft,opt_bleft);
      ptop :=StrCopyE(ltop ,opt_btop);
      for i:=0 to HIGH(D.btnarray) do
      begin
        IntToStr(pleft,i); DBWriteWord(0,PluginShort,lleft,D.btnarray[i].Left);
        IntToStr(ptop ,i); DBWriteWord(0,PluginShort,ltop ,D.btnarray[i].Top);
      end;
    end;
  end;
end;

procedure TWATFrame.DesignerLoadSettings;
var
  i:integer;
  D:PWATFrameData;
  lleft,ltop:array [0..63] of AnsiChar;
  pleft,ptop:PAnsiChar;
  for_check:integer;
begin
  D:=CustomData;

  if (D.TrackBar<>nil) and
    ((D.ShowControls and scTrackbar)<>0) and
    ((D.Loaded and scTrackbar)=0) then
  begin
    D.Loaded:=D.Loaded or scTrackbar;
    for_check:=DBReadWord(0,PluginShort,opt_tbwidth);
    if for_check<>0 then
    begin
      D.Trackbar.SetPosition(
        DBReadWord(0,PluginShort,opt_tbleft),
        DBReadWord(0,PluginShort,opt_tbtop));
      D.Trackbar.SetSize(
        for_check,
        {18}DBReadWord(0,PluginShort,opt_tbheight));
    end;
  end;

  if (D.TextBlock<>nil) and
    ((D.ShowControls and scText)<>0) and
    ((D.Loaded and scText)=0) then
  begin
    D.Loaded:=D.Loaded or scText;
    for_check:=DBReadWord(0,PluginShort,opt_twidth);
    if for_check<>0 then
    begin
      D.TextBlock.SetPosition(
        DBReadWord(0,PluginShort,opt_tleft),
        DBReadWord(0,PluginShort,opt_ttop));
      D.TextBlock.SetSize(
        for_check,
        DBReadWord(0,PluginShort,opt_theight));
    end;
  end;

  if ((D.ShowControls and scButtons)<>0) and
     ((D.Loaded and scButtons)=0) then
  begin
    if D.btnarray[0]<>nil then
    begin
      D.Loaded:=D.Loaded or scButtons;
      pleft:=StrCopyE(lleft,opt_bleft);
      pleft^:='0'; (pleft+1)^:=#0;
      for_check:=SmallInt(DBReadWord(0,PluginShort,lleft,word(-1)));
      if for_check>=0 then
      begin
        ptop :=StrCopyE(ltop,opt_btop);
        for i:=0 to HIGH(D.btnarray) do
        begin
          IntToStr(pleft,i);
          IntToStr(ptop ,i);
          D.btnarray[i].SetPosition(
            DBReadWord(0,PluginShort,lleft,word(-1)),
            DBReadWord(0,PluginShort,ltop ,word(-1)));
        end;
      end;
    end;
  end;
end;

procedure TWATFrame.CreateDesigner(Sender:PControl;var Mouse:TMouseEventData);
var
  D:PWATFrameData;
begin
  D:=CustomData;
  if not D.ManualPlacement then exit;

  if D.Designer=nil then
    D.Designer:=NewDesigner(@self);

  if not D.Designer.Active then
  begin
    // Trackbar
    if D.Trackbar<>nil then
    begin
      D.Trackbar.Anchor(false,false,false,false);
      D.Designer.Connect('Trackbar',D.Trackbar);
    end;
    // TextBlock
    if D.TextBlock<>nil then
    begin
      D.TextBlock.Anchor(false,false,false,false);
      D.Designer.Connect('Panel',D.TextBlock);
    end;
    // Icons
    if (D.ShowControls and scButtons)<>0 then MakeButtonsDesigner;

    D.Designer.Active:=true;
  end
  else
  begin
    D.Designer.Active:=False;

    DesignerSaveSettings;
    if D.Trackbar <>nil then D.Designer.Disconnect(D.Trackbar);
    if D.TextBlock<>nil then D.Designer.Disconnect(D.TextBlock);
    if (D.ShowControls and scButtons)<>0 then FreeButtonsDesigner;
    Sender.Update;
  end;
end;