Develop and Download Open Source Software

Browse CVS Repository

Diff of /gikonavigoeson/gikonavi/Gesture.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.4.1 by h677, Sat Jul 9 05:28:35 2005 UTC revision 1.10 by h677, Mon Feb 11 13:46:13 2008 UTC
# Line 9  uses Line 9  uses
9  type  type
10          TMouseGesture = class(TObject)          TMouseGesture = class(TObject)
11          private          private
12                  FHook: Integer;                  FHook: Cardinal;
13                  FHandle: THandle;                  FHandle: THandle;
14                  FGestureItemList: TStringList;                  FGestureItemList: TStringList;
15                  FBeginGesture: Boolean;                  FBeginGesture: Boolean;
# Line 25  type Line 25  type
25                  function CheckAction(Message: Integer; x, y: Integer): Boolean;                  function CheckAction(Message: Integer; x, y: Integer): Boolean;
26                  procedure AddAction(sx, sy: Integer);                  procedure AddAction(sx, sy: Integer);
27                  function AddGesture(Item: string): Integer;                  function AddGesture(Item: string): Integer;
                 procedure ClearGesture;  
28                  function Get(Index: integer): string;                  function Get(Index: integer): string;
29                  procedure Put(Index: integer; Item: string);                  procedure Put(Index: integer; Item: string);
30          public          public
# Line 37  type Line 36  type
36                  property GestureCount: Integer read GetGestureCount;                  property GestureCount: Integer read GetGestureCount;
37                  property Margin: Integer read FMargin write FMargin;                  property Margin: Integer read FMargin write FMargin;
38                  function GetGestureStr: string;                  function GetGestureStr: string;
39                    procedure Clear;
40                  property OnGestureStart: TNotifyEvent read FOnGestureStart write FOnGestureStart;                  property OnGestureStart: TNotifyEvent read FOnGestureStart write FOnGestureStart;
41                  property OnGestureMove: TNotifyEvent read FOnGestureMove write FOnGestureMove;                  property OnGestureMove: TNotifyEvent read FOnGestureMove write FOnGestureMove;
42                  property OnGestureEnd: TNotifyEvent read FOnGestureEnd write FOnGestureEnd;                  property OnGestureEnd: TNotifyEvent read FOnGestureEnd write FOnGestureEnd;
# Line 49  var Line 49  var
49    
50  implementation  implementation
51    
52    uses
53            GikoSystem;
54    
55  constructor TMouseGesture.Create;  constructor TMouseGesture.Create;
56  begin  begin
57          inherited;          inherited;
# Line 62  end; Line 65  end;
65  destructor TMouseGesture.Destroy;  destructor TMouseGesture.Destroy;
66  begin  begin
67          UnHook;          UnHook;
68          ClearGesture;          Clear;
69          FGestureItemList.Free;          FGestureItemList.Free;
70          inherited;          inherited;
71  end;  end;
# Line 116  begin Line 119  begin
119                                  //マウスジェスチャーの対象と違うときは、開放する                                  //マウスジェスチャーの対象と違うときは、開放する
120                                  if (hwnd <> 0) and (hwnd <> FHandle) then begin                                  if (hwnd <> 0) and (hwnd <> FHandle) then begin
121                                          ReleaseCapture;                                          ReleaseCapture;
122                        SetCapture(FHandle);
123                                  end;                                  end;
                                 SetCapture(FHandle);  
124                                  dp := Point(x - FLastPoint.X, y - FLastPoint.Y);                                  dp := Point(x - FLastPoint.X, y - FLastPoint.Y);
125                                  sp := Point(Sign(dp.X), Sign(dp.Y));                                  sp := Point(Sign(dp.X), Sign(dp.Y));
126                                  if (dp.X * dp.X + dp.Y * dp.Y) > (FMargin * FMargin) then begin                                  if (dp.X * dp.X + dp.Y * dp.Y) > (FMargin * FMargin) then begin
# Line 130  begin Line 133  begin
133                                          FLastTime := GetTickCount;                                          FLastTime := GetTickCount;
134                                          FLastPoint := Point(x, y);                                          FLastPoint := Point(x, y);
135                                  end;                                  end;
136                                  //マウスを再設定                  Result := True;
137                                  if (hwnd <> 0) and (hwnd <> FHandle) then                  end;
                                         SetCapture(hwnd);  
                                   
                                 Result := True;  
                         end;  
138                  end;                  end;
139                  WM_RBUTTONDOWN: begin                  WM_RBUTTONDOWN: begin
140                          if not FCancelMode then begin                          if (not FCancelMode)  then begin
141                    if ( GikoSys.Setting.GestureIgnoreContext ) then begin
142                                    //今マウスをキャプチャーしているのを得る
143                                    hwnd := GetCapture;
144                                    //マウスジェスチャーの対象と違うときは、開放する
145                                    if (hwnd <> 0) and (hwnd <> FHandle) then begin
146                            Exit;
147                        end;
148                    end;
149                                  FBeginGesture := True;                                  FBeginGesture := True;
150                                  FLastTime := 0;                                  FLastTime := 0;
151                                  FLastPoint := Point(x, y);                                  FLastPoint := Point(x, y);
152                                  FStartPoint := Point(x, y);                                  FStartPoint := Point(x, y);
153                                  CheckAction := True;                                  Result := True;
154                                  SetCapture(FHandle);                                  SetCapture(FHandle);
155                          end;                          end;
156                  end;                  end;
157                  WM_RBUTTONUP: begin                  WM_RBUTTONUP: begin
158                          if FCancelMode then                          if FCancelMode then
159                                  FCancelMode := False                                  FCancelMode := False
160                          else begin                          else if (FBeginGesture) then begin
161                                  FBeginGesture := False;                                  FBeginGesture := False;
162                                  ReleaseCapture;                                  ReleaseCapture;
163                                  if FGestureItemList.Count <> 0 then begin                                  if FGestureItemList.Count <> 0 then begin
164                                          if Assigned(FOnGestureEnd) then                                          if Assigned(FOnGestureEnd) then begin
165                                                  FOnGestureEnd(Self);                                                  FOnGestureEnd(Self);
166                                          ClearGesture;                      end else begin
167                            Clear;
168                        end;
169                                  end else begin                                  end else begin
170                                          FCancelMode := True;                                          FCancelMode := True;
171                                          //ジェスチャーじゃなかった場合、マウスDOWN,UPをエミュレート                                          //ジェスチャーじゃなかった場合、マウスDOWN,UPをエミュレート
# Line 232  begin Line 241  begin
241  end;  end;
242    
243  //ジェスチャーをクリアする  //ジェスチャーをクリアする
244  procedure TMouseGesture.ClearGesture;  procedure TMouseGesture.Clear;
245  begin  begin
246          FGestureItemList.Clear;          FGestureItemList.Clear;
247  end;  end;

Legend:
Removed from v.1.1.4.1  
changed lines
  Added in v.1.10

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26