summaryrefslogtreecommitdiff
path: root/plugins/Actman30/iac_settings.pas
blob: 3997fbe73d29609623b29767938e89308d4583cb (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
165
166
167
168
169
170
171
172
173
174
175
unit iac_settings;

interface

implementation

uses
  windows, messages, commctrl,
  global,iac_global, dlgshare, lowlevelc,
  m_api, mirutils, dbsettings, common, wrapper;

{$include i_cnst_settings.inc}
{$resource iac_settings.res}


//----- Support functions -----


//----- Dialog realization -----

procedure FillServiceModeList(wnd:HWND);
begin
  SendMessage(wnd,CB_RESETCONTENT,0,0);
  InsertString(wnd,0 ,'value');
  InsertString(wnd,1 ,'name');
  InsertString(wnd,2 ,'value (name)');
  InsertString(wnd,3 ,'name ''value''');
  SendMessage(wnd,CB_SETCURSEL,0,0);
end;

procedure ClearFields(Dialog:HWND);
begin
  CheckDlgButton(Dialog,IDC_CNT_FILTER,BST_UNCHECKED);
  SetDlgItemTextW(Dialog,IDC_EDIT_FORMAT,'');

  CheckDlgButton(Dialog,IDC_FR_FLAG,BST_UNCHECKED);
  CheckDlgButton(Dialog,IDC_VL_FLAG,BST_UNCHECKED);
end;

function DlgProc(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall;
var
  fCLformat:pWideChar;
  lp:TLPARAM;
  stat:integer;
begin
  result:=0;

  case hMessage of
    WM_INITDIALOG: begin
      TranslateDialogDefault(Dialog);

      OptSetButtonIcon(GetDlgItem(Dialog,IDC_CNT_APPLY),ACI_APPLY);

      OptSetButtonIcon(GetDlgItem(Dialog,IDC_SRV_APPLY),ACI_APPLY);
      FillServiceModeList(GetDlgItem(Dialog,IDC_SERVICELIST));
    end;

    WM_ACT_SETVALUE: begin
      ClearFields(Dialog);
    end;

    WM_ACT_RESET: begin
      ClearFields(Dialog);
      // Contact list settings
      CheckDlgButton (Dialog,IDC_CNT_FILTER,DBReadByte(0,DBBranch,'CLfilter',BST_UNCHECKED));
      fCLformat:=DBReadUnicode(0,DBBranch,'CLformat');
      SetDlgItemTextW(Dialog,IDC_EDIT_FORMAT,fCLformat);
      mFreeMem(fCLformat);

      // Servicelist mode settings
      CB_SelectData(Dialog,IDC_SERVICELIST,DBReadByte(0,DBBranch,'SrvListMode'));
    end;

    WM_SHOWWINDOW: begin
      // Show window by ShowWindow function
      if (lParam=0) and (wParam=1) then
      begin
        lp:=LV_GetLParam(MacroListWindow);
        if (lp and ACF_FIRSTRUN)<>0 then
          stat:=BST_CHECKED
        else
          stat:=BST_UNCHECKED;
        CheckDlgButton(Dialog,IDC_FR_FLAG,stat);

        if (lp and ACF_VOLATILE)<>0 then
          stat:=BST_CHECKED
        else
          stat:=BST_UNCHECKED;
        CheckDlgButton(Dialog,IDC_VL_FLAG,stat);
      end;
    end;

    WM_COMMAND: begin
      case wParam shr 16 of
        BN_CLICKED: begin
          case loword(wParam) of
            IDC_SRV_APPLY: begin
              DBWriteByte(0,DBBranch,'SrvListMode',
                  CB_GetData(GetDlgItem(Dialog,IDC_SERVICELIST)));
            end;

            IDC_CNT_APPLY: begin
              fCLformat:=GetDlgText(Dialog,IDC_EDIT_FORMAT);
              DBWriteUnicode(0,DBBranch,'CLformat',fCLformat);
              mFreeMem(fCLformat);
            end;

            IDC_CNT_FILTER: begin
              DBWriteByte(0,DBBranch,'CLfilter',IsDlgButtonChecked(Dialog,IDC_CNT_FILTER));
            end;

            IDC_FR_FLAG: begin
              lp:=LV_GetLParam(MacroListWindow);
              if IsDlgButtonChecked(Dialog,IDC_FR_FLAG)=BST_UNCHECKED then
                lp:=lp and not ACF_FIRSTRUN
              else
                lp:=lp or ACF_FIRSTRUN;
              LV_SetLParam(MacroListWindow,lp);

              SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0);
            end;

            IDC_VL_FLAG: begin
              lp:=LV_GetLParam(MacroListWindow);
              if IsDlgButtonChecked(Dialog,IDC_VL_FLAG)=BST_UNCHECKED then
                lp:=lp and not ACF_VOLATILE
              else
                lp:=lp or ACF_VOLATILE;
              LV_SetLParam(MacroListWindow,lp);

              SendMessage(GetParent(GetParent(Dialog)),PSM_CHANGED,0,0);
            end;
          end;
        end;
      end;
    end;

    WM_HELP: begin
      result:=1;
    end;

  end;
end;

//----- Export/interface functions -----

var
  vc:tActModule;

function CreateAction:tBaseAction;
begin
  result:=nil;
end;

function CreateDialog(parent:HWND):HWND;
begin
  result:=CreateDialogW(hInstance,'IDD_SETTINGS',parent,@DlgProc);
end;

procedure Init;
begin
  vc.Next    :=ModuleLink;

  vc.Name    :='Settings';
  vc.Dialog  :=@CreateDialog;
  vc.Create  :=@CreateAction;
  vc.Icon    :='IDI_SETTINGS';
  vc.Hash    :=1;

  ModuleLink :=@vc;
end;

begin
  Init;
end.