summaryrefslogtreecommitdiff
path: root/plugins/Watrack/i_gui.inc
blob: 709584b0661684c114a05d051643f1e930660de0 (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
{some visual stuff}

function OnTTBLoaded(wParam:WPARAM;lParam:LPARAM):int;cdecl;
var
  ttb:m_api.TTBButton;
begin
  FillChar(ttb,SizeOf(ttb),0);
  ttb.cbSize :=SizeOf(ttb);
  ttb.dwFlags:=TTBBF_VISIBLE or TTBBF_SHOWTOOLTIP;

  // plugin status button
  if DisablePlugin<>dsPermanent then
    ttb.dwFlags:=ttb.dwFlags or TTBBF_PUSHED;

  ttb.hIconDn   :=IcoLib_GetIcon(IcoBtnEnable,0);
  ttb.hIconUp   :=IcoLib_GetIcon(IcoBtnDisable,0);
  ttb.wParamUp  :=1;
//  ttb.wParamDown    :=0;
  ttb.pszService:=MS_WAT_PLUGINSTATUS;
  ttb.name      :='WATrack status';
//  ttb.tooltipDn:='Disable Plugin';
//  ttb.tooltipUp:='Enable Plugin';
  ttbState:=TopToolbar_AddButton(@ttb);
  if ttbState=THANDLE(-1) then
    ttbState:=0
  else
    CallService(MS_TTB_SETBUTTONOPTIONS,(ttbState shl 16)+TTBO_TIPNAME,
        tlparam(Translate('Disable WATrack')));
  result:=0;
end;

procedure CreateMenus;
var
  mi:TCListMenuItem;
begin
  FillChar(mi, sizeof(mi), 0);
  mi.cbSize       :=sizeof(mi);
  mi.szPopupName.a:=PluginShort;

  mi.hIcon        :=IcoLib_GetIcon(IcoBtnEnable,0);
  mi.szName.a     :='Disable WATrack';
  mi.pszService   :=MS_WAT_PLUGINSTATUS;
  mi.popupPosition:=MenuDisablePos;
  hMenuDisable:=Menu_AddMainMenuItem(@mi);
end;

procedure ChangeMenuIcons(f1:cardinal);
var
  mi:tClistMenuItem;
  p:PAnsiChar;
begin
  FillChar(mi,sizeof(mi),0);
  mi.cbSize:=sizeof(mi);
  mi.flags :=CMIM_NAME+CMIM_FLAGS+CMIM_ICON+f1;
  if f1<>0 then
  begin
    mi.hIcon   :=IcoLib_GetIcon(IcoBtnDisable,0);
    mi.szName.a:='Enable WATrack';
  end
  else
  begin
    mi.hIcon   :=IcoLib_GetIcon(IcoBtnEnable,0);
    mi.szName.a:='Disable WATrack';
  end;
  CallService(MS_CLIST_MODIFYMENUITEM,hMenuDisable,lparam(@mi));

  if ServiceExists(MS_TTB_SETBUTTONSTATE)<>0 then
  begin
    if f1<>0 then
    begin
      p:='Enable WATrack';
      CallService(MS_TTB_SETBUTTONSTATE,ttbState,0)
    end
    else
    begin
      p:='Disable WATrack';
      CallService(MS_TTB_SETBUTTONSTATE,ttbState,TTBST_PUSHED);
    end;
    CallService(MS_TTB_SETBUTTONOPTIONS,(ttbState shl 16)+TTBO_TIPNAME,
        lparam(Translate(p)));
  end;
end;

function IconChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl;
var
  mi:TCListMenuItem;
  ttb:m_api.TTBButton;
begin
  result:=0;
  FillChar(mi,SizeOf(mi),0);
  mi.cbSize:=sizeof(mi);
  mi.flags :=CMIM_ICON;

  mi.hIcon:=IcoLib_GetIcon(IcoBtnEnable,0);
  CallService(MS_CLIST_MODIFYMENUITEM,hMenuDisable,tlparam(@mi));

  // toptoolbar
  if ServiceExists(MS_TTB_GETBUTTONOPTIONS)<>0 then
  begin
    CallService(MS_TTB_GETBUTTONOPTIONS,(ttbState shl 16)+TTBO_ALLDATA,tlparam(@ttb));
    ttb.hIconDn:=IcoLib_GetIcon(IcoBtnEnable,0);
    ttb.hIconUp:=IcoLib_GetIcon(IcoBtnDisable,0);
    CallService(MS_TTB_SETBUTTONOPTIONS,(ttbState shl 16)+TTBO_ALLDATA,tlparam(@ttb));
  end;

end;