summaryrefslogtreecommitdiff
path: root/plugins/Watrack/kolframe/frm_dlg2.inc
blob: 29b9a71180d1101707cf30fada76227480acfe28 (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
{Frame text}
const
  MaxTxtScrollSpeed = 20;

function FrameTextDlg(Dialog:HWND; hMessage:uint; wParam:WPARAM; lParam:LPARAM):LRESULT; stdcall;
const
  DlgInited      :boolean=false;
  TemplateChanged:Boolean=false;
var
  tmp,tmp1:integer;
  tmpb:longbool;
  pcf:TCHOOSEFONT;
  lf:LOGFONTW;
begin
  result:=0;

  case hMessage of
    WM_DESTROY: begin
      // new - if Apply, old - if cancel
      if FrameCtrl<>nil then // for case when FrameCtrl was destryed already
        if PWATFrameData(FrameCtrl.CustomData).TextBlock<>nil then
        PWATFrameData(FrameCtrl.CustomData).TextBlock.FontData:=TextLF;
    end;

    WM_INITDIALOG: begin
      DlgInited:=false;
      TranslateDialogDefault(Dialog);
      with PWATFrameData(FrameCtrl.CustomData).TextBlock^ do
      begin
        case LoByte(Effects) of
          effWrap: tmp:=IDC_EFF_WRAP;
          effRoll: tmp:=IDC_EFF_ROLL;
          effPong: tmp:=IDC_EFF_PONG;
        else // like effCut
          tmp:=IDC_EFF_CUT;
        end;
        CheckDlgButton(Dialog,tmp,BST_CHECKED);

        SetDlgItemInt(Dialog,IDC_TIMER,UpdateTime,false);

        SetDlgItemInt(Dialog,IDC_ROLLSTEP,RollStep,false);
        SetDlgItemInt(Dialog,IDC_ROLLGAP ,RollGap ,false);
  //      SetDlgItemInt(Dialog,IDC_ROLLTAIL,RollTail,false);

        CheckDlgButton(Dialog,IDC_ALCENTER,ord((Effects and effCenter)<>0));

        SetDlgItemTextW(Dialog,IDC_FRAME_TEXT,PWATFrameData(FrameCtrl.CustomData).Template);
      end;

      SendDlgItemMessage(Dialog,IDC_MACRO_HELP,BM_SETIMAGE,IMAGE_ICON,Skin_LoadIcon(SKINICON_OTHER_HELP,0));

      TemplateChanged:=false;
      DlgInited:=true;
    end;

    WM_COMMAND: begin
      case (wParam shr 16) of
        EN_CHANGE: begin
          if Loword(wParam)=IDC_FRAME_TEXT then
            TemplateChanged:=True;
        end;

        BN_CLICKED: begin
          case LoWord(wParam) of
            IDC_MACRO_HELP: CallService(MS_WAT_MACROHELP,Dialog,0);
            IDC_FRMFONT: begin
              with PWATFrameData(FrameCtrl.CustomData).TextBlock^ do
              begin
                lf:=FontData;
  //            lf:=TextLF;
                FillChar(pcf,sizeOf(pcf),0);
                with pcf do
                begin
                  lStructSize:=SizeOf(pcf);
                  lpLogFont:=@lf;
                  Flags:=CF_EFFECTS+CF_FORCEFONTEXIST+CF_LIMITSIZE+CF_NOVERTFONTS+
                         CF_SCREENFONTS+CF_INITTOLOGFONTSTRUCT;
                  rgbColors:=TextColor;
                  nSizeMin:=6;
                  nSizeMax:=32;
                end;
                if ChooseFont(pcf) then
                begin
                  FontData:=lf; // paint directly
                  TextColor:=pcf.rgbColors;
                  SendMessage(GetParent(Dialog),PSM_CHANGED,0,0);
                end
                else
                  exit;
              end;
            end;
          end;
        end;
      end;

      if DlgInited then
        case wParam shr 16 of
          BN_CLICKED,
          EN_CHANGE: begin
            SendMessage(GetParent(Dialog),PSM_CHANGED,0,0);
          end;
        end;
    end;

    WM_NOTIFY: begin
      if integer(PNMHdr(lParam)^.code)=PSN_APPLY then
      begin
//        redraw:=false;
        with PWATFrameData(FrameCtrl.CustomData).TextBlock^ do
        begin
          tmp:=GetDlgItemInt(Dialog,IDC_TIMER,tmpb,false);
          if tmp>MaxTxtScrollSpeed then
            tmp:=MaxTxtScrollSpeed;

          if tmp<>UpdateTime then
          begin
            UpdateTime:=tmp;
{
            if UpdTimer<>0 then
              KillTimer(FrameWnd,UpdTimer);
            if (UpdInterval>0) and (FrameWnd<>0) then
              UpdTimer:=SetTimer(FrameWnd,TMR_TEXT,(MaxTxtScrollSpeed+1-UpdInterval)*100,nil)
            else
              UpdTimer:=0;
}
          end;

          // Text effects
          if      IsDlgButtonChecked(Dialog,IDC_EFF_CUT )<>BST_UNCHECKED then tmp:=effCut
          else if IsDlgButtonChecked(Dialog,IDC_EFF_WRAP)<>BST_UNCHECKED then tmp:=effWrap
          else if IsDlgButtonChecked(Dialog,IDC_EFF_ROLL)<>BST_UNCHECKED then tmp:=effRoll
          else if IsDlgButtonChecked(Dialog,IDC_EFF_PONG)<>BST_UNCHECKED then tmp:=effPong;
          if IsDlgButtonChecked(Dialog,IDC_ALCENTER)<>BST_UNCHECKED then
            tmp:=tmp or effCenter;
          Effects:=tmp;

          tmp1:=GetDlgItemInt(Dialog,IDC_ROLLSTEP,tmpb,false);
          if tmp1<>RollStep then
          begin
            RollStep:=tmp1;
          end;
          tmp1:=GetDlgItemInt(Dialog,IDC_ROLLGAP ,tmpb,false);
          if tmp1<>RollGap then
          begin
            RollGap:=tmp1;
          end;
  {
          tmp1:=GetDlgItemInt(Dialog,IDC_ROLLTAIL,tmpb,false);
          if tmp1<>RollTail then
          begin
            RollTail:=tmp1;
          end;
  }

          if TemplateChanged then
          begin
            mFreeMem(PWATFrameData(FrameCtrl.CustomData).Template);
            PWATFrameData(FrameCtrl.CustomData).Template:=GetDlgText(Dialog,IDC_FRAME_TEXT);
          end;

          TextLF:=FontData; // OK - saving for future?

          SaveTextSettings(TemplateChanged);
          TemplateChanged:=false;
        end;
      end;
    end;
  else
    {result:=}DefWindowProc(Dialog,hMessage,wParam,lParam);
  end;
end;