Browse CVS Repository
Contents of /gikonavigoeson/gikonavi/GestureModel.pas
Parent Directory
| Revision Log
| Revision Graph
Revision 1.1 -
( show annotations)
( download)
( as text)
Mon Oct 11 14:38:58 2004 UTC
(19 years, 5 months ago)
by yoffy
Branch: MAIN
CVS Tags: v1_59_0_771, v1_59_0_770, v1_59_0_773, v1_59_0_772, v1_59_0_775, v1_59_0_774, v1_59_0_777, v1_59_0_776, v1_56_0_715, v1_59_0_778, v1_63_1_819, v1_57_0_737, v1_62_0_812, v1_57_0_735, v1_57_0_734, v1_57_0_733, v1_57_0_732, v1_57_0_731, v1_57_0_730, v1_50_2_606, v1_51_0_612, v1_50_0_581, v1_50_0_580, v1_50_0_587, v1_50_0_586, v1_57_0_739, v1_57_0_738, v1_59_1_765, v1_51_1_639, v1_53_0_671, v1_50_0_595, v1_60_0_788, v1_60_0_789, v1_54_0_677, v1_54_0_676, v1_50_0_572, v1_58_0_748, marged-Bb50, v1_58_0_745, v1_60_0_781, v1_60_0_782, v1_58_0_746, v1_60_0_784, v1_54_0_678, v1_60_0_786, v1_60_0_787, v1_56_0_707, v1_59_0_767, v1_56_0_705, v1_56_0_704, v1_56_0_703, v1_56_0_702, v1_56_0_701, v1_56_0_700, v1_59_1_778, v1_51_0_626, v1_57_0_723, b51, v1_52_1_658, v1_51_0_622, v1_59_0_768, v1_59_0_769, v1_50_0_598, v1_57_0_725, v1_57_0_726, v1_57_0_727, v1_57_0_720, v1_57_0_722, v1_57_1_744, v1_50_0_590, bv1_49_0_564, v1_50_0_593, v1_57_0_728, v1_57_0_729, v1_50_0_596, bv1_49_0_563, v1_52_0_646, v1_50_0_557, v1_57_0_736, v1_50_0_585, v1_51_0_611, v1_51_0_620, v1_52_0_644, v1_58_0_752, v1_58_0_750, v1_58_0_751, v1_58_0_756, v1_58_0_757, v1_58_0_754, v1_58_0_755, v1_58_0_759, v1_52_0_643, v1_57_0_719, v1_57_0_718, v1_56_0_716, v1_54_0_687, v1_56_0_710, v1_56_0_711, v1_56_1_717, v1_56_1_716, v1_51_0_634, v1_51_0_635, v1_51_0_636, v1_51_0_637, v1_54_0_688, v1_54_0_689, v1_51_0_632, v1_51_0_633, v1_50_0_603, v1_54_0_684, v1_50_0_582, v1_54_0_685, v1_53_0_664, v1_61_0_796, v1_61_0_797, v1_61_0_795, v1_52_0_647, v1_61_0_798, v1_61_0_799, v1_50_0_604, v1_51_0_638, v1_52_0_648, v1_53_0_661, v1_53_0_663, v1_53_0_662, v1_53_0_665, v1_53_0_667, v1_53_0_666, v1_53_0_669, v1_53_0_668, v1_55_0_692, v1_55_0_693, v1_55_0_696, v1_55_0_697, v1_55_0_694, v1_55_0_695, merged-remodeling, v1_50_0_577, v1_52_0_645, v1_52_0_651, v1_54_1_691, v1_52_0_650, v1_56_2_724, v1_50_0_606, v1_56_2_722, v1_50_0_588, v1_52_0_652, v1_55_1_697, v1_52_0_642, v1_52_0_654, v1_51_0_616, v1_56_0_714, v1_51_0_614, v1_51_0_615, v1_53_0_672, v1_51_0_613, v1_53_0_670, v1_63_0_818, v1_63_0_817, v1_63_0_816, v1_63_0_815, v1_51_1_640, v1_54_0_686, v1_51_0_618, v1_51_0_619, bv1_49_0_565, v1_54_0_680, v1_54_0_681, v1_62_0_805, v1_62_0_804, v1_62_0_807, v1_62_0_806, b50, v1_56_0_712, v1_62_0_803, v1_62_0_802, v1_56_0_713, v1_62_0_809, v1_50_0_574, v1_54_0_682, v1_50_0_584, v_step1, v1_56_0_721, v1_50_0_573, v1_50_0_600, v1_51_0_630, v1_50_0_571, v1_54_0_683, v1_51_0_631, v1_60_0_780, v1_60_0_779, v1_62_0_810, v1_62_0_811, v1_58_0_747, v1_60_0_783, root-of-draw, v1_50_0_576, v1_54_0_679, v1_59_2_785, marged_bRESPOPUP, v1_50_2_604, v1_50_0_578, v1_54_0_675, v1_51_0_628, v1_50_0_579, v1_51_0_617, root-of-Bb50, root-of-Bb51, v1_56_0_706, root-of-remodel, root-of-Bb53, v1_50_0_594, v1_52_1_657, v1_54_0_674, v1_52_0_660, v1_60_1_793, v1_50_0_602, v1_51_0_629, v1_54_0_690, v1_51_0_627, v1_50_0_601, v1_58_0_763, v1_58_0_762, v1_58_0_761, v1_58_0_760, v1_51_0_625, v1_62_1_813, v1_51_0_623, v1_57_2_749, v1_50_0_605, v1_57_0_742, v1_57_0_743, v1_57_0_740, v1_57_0_741, v1_52_0_655, v1_56_0_709, v1_57_0_744, v1_52_0_656, v1_56_0_708, v1_52_0_649, v1_61_0_800, v1_53_1_673, v1_50_0_599, v1_56_0_699, v1_56_0_698, v1_50_0_561, v1_51_0_624, v1_51_1_641, v1_51_0_621, v1_60_0_793, v1_60_0_792, v1_60_0_791, v1_60_0_790, v1_60_2_794, v1_61_1_801, HEAD
Branch point for: Bb57, Bb56, Bb55, Bb53, Bb52, Bb51, Bb62, Bb63, Bb60, Bb61, remodeling, Bb59, Bb58, Bb50, bRESPOPUP, bListSU, Bb54, Bdraw
File MIME type: text/x-pascal
・゙・ヲ・ケ・ク・ァ・ケ・チ・网ホトノイテ。」
build557
| 1 |
unit GestureModel; |
| 2 |
|
| 3 |
interface |
| 4 |
|
| 5 |
uses |
| 6 |
Windows, Messages, SysUtils, Classes, Controls, StrUtils, IniFiles, |
| 7 |
ActnList; |
| 8 |
|
| 9 |
type |
| 10 |
TGestureModel = class(TObject) |
| 11 |
private |
| 12 |
FGestureList: TStringList; |
| 13 |
FMargin: Integer; |
| 14 |
function CheckGestureStr(Gesture: string): Boolean; |
| 15 |
function GetActionItem(ActionList: TActionList; ActionStr: string): TAction; |
| 16 |
function Get(Index: Integer): string; |
| 17 |
function GetObject(Index: Integer): TObject; |
| 18 |
function GetCount: Integer; |
| 19 |
public |
| 20 |
constructor Create; |
| 21 |
destructor Destroy; override; |
| 22 |
procedure AddGesture(Gesture: string; Action: TAction); |
| 23 |
procedure DeleteGesture(Gesture: string); |
| 24 |
procedure ClearGesture; |
| 25 |
function GetGestureAction(Gesture: string): TAction; |
| 26 |
function GetActionGesture( action : TAction ) : string; |
| 27 |
property Margin: Integer read FMargin write FMargin; |
| 28 |
procedure LoadGesture(FileName: string; ActionList: TActionList); |
| 29 |
procedure SaveGesture(FileName: string); |
| 30 |
|
| 31 |
property Items[Index: Integer]: string read Get; default; |
| 32 |
property Objects[Index: Integer]: TObject read GetObject; |
| 33 |
property Count: Integer read GetCount; |
| 34 |
end; |
| 35 |
|
| 36 |
implementation |
| 37 |
|
| 38 |
constructor TGestureModel.Create; |
| 39 |
begin |
| 40 |
inherited Create; |
| 41 |
FGestureList := TStringList.Create; |
| 42 |
end; |
| 43 |
|
| 44 |
destructor TGestureModel.Destroy; |
| 45 |
begin |
| 46 |
FreeAndNil(FGestureList); |
| 47 |
inherited Destroy; |
| 48 |
end; |
| 49 |
|
| 50 |
//?スw?ス?ス?ス?ス?ス?ス?ス?スindex?ス?ス?スW?スF?スX?ス`?ス?ス?ス[?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス |
| 51 |
function TGestureModel.Get(Index: Integer): string; |
| 52 |
begin |
| 53 |
if (Index < 0) or (Index >= FGestureList.Count) then |
| 54 |
raise Exception.Create('ERR'); |
| 55 |
Result := FGestureList[Index]; |
| 56 |
end; |
| 57 |
|
| 58 |
//?スw?ス?ス?ス?ス?ス?ス?ス?スindex?ス?ス?スI?スu?スW?スF?スN?スg?ス?ス?ス?ス?ス?ス |
| 59 |
function TGestureModel.GetObject(Index: Integer): TObject; |
| 60 |
begin |
| 61 |
if (Index < 0) or (Index >= FGestureList.Count) then |
| 62 |
raise Exception.Create('ERR'); |
| 63 |
Result := FGestureList.Objects[Index]; |
| 64 |
end; |
| 65 |
|
| 66 |
//?スW?スF?スX?ス`?ス?ス?ス[?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス`?スF?スb?スN?ス?ス?スs?ス?ス |
| 67 |
function TGestureModel.CheckGestureStr(Gesture: string): Boolean; |
| 68 |
const |
| 69 |
G_STR: array[0..3] of string = ('?ス?ス', '?ス?ス', '?ス?ス', '?ス?ス'); |
| 70 |
var |
| 71 |
i: Integer; |
| 72 |
j: Integer; |
| 73 |
c: Boolean; |
| 74 |
begin |
| 75 |
Result := False; |
| 76 |
if Length(Gesture) = 0 then |
| 77 |
Exit; |
| 78 |
for i := 0 to (Length(Gesture) div 2) - 1 do begin |
| 79 |
c := False; |
| 80 |
for j := 0 to Length(G_STR) - 1 do begin |
| 81 |
if MidStr(Gesture, i + 1, 1) = G_STR[j] then begin |
| 82 |
c := True; |
| 83 |
Break; |
| 84 |
end; |
| 85 |
end; |
| 86 |
if not c then |
| 87 |
Exit; |
| 88 |
end; |
| 89 |
Result := True; |
| 90 |
end; |
| 91 |
|
| 92 |
//?スW?スF?スX?ス`?ス?ス?ス[?ス?ス?スX?スg?ス?ス?スT?スC?スY?ス?ス?ス?ス?ス?ス |
| 93 |
function TGestureModel.GetCount: Integer; |
| 94 |
begin |
| 95 |
Result := FGestureList.Count; |
| 96 |
end; |
| 97 |
|
| 98 |
//?スW?スF?スX?ス`?ス?ス?ス[?ス?ス?スA?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?スA?スN?スV?ス?ス?ス?ス?ス?ス?ス?ス?スX?スg?ス?ス?スo?ス^?ス?ス?ス?ス |
| 99 |
procedure TGestureModel.AddGesture(Gesture: string; Action: TAction); |
| 100 |
begin |
| 101 |
if (not CheckGestureStr(Gesture)) or (Action = nil) then |
| 102 |
Exit; |
| 103 |
DeleteGesture(Gesture); |
| 104 |
FGestureList.AddObject(Gesture, Action); |
| 105 |
end; |
| 106 |
|
| 107 |
//?スw?ス?ス?ス?ス?ス?ス?ス?ス?スW?スF?スX?ス`?ス?ス?ス[?ス?ス?ス?ス?ス?ス |
| 108 |
procedure TGestureModel.DeleteGesture(Gesture: string); |
| 109 |
var |
| 110 |
idx: Integer; |
| 111 |
begin |
| 112 |
idx := FGestureList.IndexOf(Gesture); |
| 113 |
if idx <> -1 then |
| 114 |
FGestureList.Delete(idx); |
| 115 |
end; |
| 116 |
|
| 117 |
//?スW?スF?スX?ス`?ス?ス?ス[?ス?ス?スX?スg?ス?ス?スN?ス?ス?スA |
| 118 |
procedure TGestureModel.ClearGesture; |
| 119 |
begin |
| 120 |
FGestureList.Clear; |
| 121 |
end; |
| 122 |
|
| 123 |
//?スW?スF?スX?ス`?ス?ス?ス[?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?スY?ス?ス?ス?ス?ス?ス?スA?スN?スV?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス |
| 124 |
function TGestureModel.GetGestureAction(Gesture: string): TAction; |
| 125 |
var |
| 126 |
idx: Integer; |
| 127 |
begin |
| 128 |
Result := nil; |
| 129 |
idx := FGestureList.IndexOf(Gesture); |
| 130 |
if idx <> -1 then |
| 131 |
if FGestureList.Objects[idx] is TAction then |
| 132 |
Result := TAction(FGestureList.Objects[idx]); |
| 133 |
end; |
| 134 |
|
| 135 |
// ?スA?スN?スV?ス?ス?ス?ス?ス?ス?ス?ス?スY?ス?ス?ス?ス?ス?ス?スW?スF?スX?ス`?ス?ス?ス[?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス |
| 136 |
function TGestureModel.GetActionGesture( action : TAction ) : string; |
| 137 |
var |
| 138 |
i : Integer; |
| 139 |
begin |
| 140 |
Result := ''; |
| 141 |
for i := 0 to FGestureList.Count - 1 do begin |
| 142 |
if FGestureList.Objects[ i ] = action then begin |
| 143 |
Result := FGestureList[ i ]; |
| 144 |
Break; |
| 145 |
end; |
| 146 |
end; |
| 147 |
end; |
| 148 |
|
| 149 |
//ini?ス?ス?ス?ス?スW?スF?スX?ス`?ス?ス?ス[?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス |
| 150 |
procedure TGestureModel.LoadGesture(FileName: string; ActionList: TActionList); |
| 151 |
var |
| 152 |
ini: TMemIniFile; |
| 153 |
i: Integer; |
| 154 |
key: string; |
| 155 |
GestureStr: string; |
| 156 |
Action: TAction; |
| 157 |
ActionStr: string; |
| 158 |
begin |
| 159 |
ini := TMemIniFile.Create(FileName); |
| 160 |
try |
| 161 |
i := 0; |
| 162 |
while (True) do begin |
| 163 |
key := 'Gesture' + IntToStr(i); |
| 164 |
GestureStr := ini.ReadString('MouseGesture', key, ''); |
| 165 |
key := 'Action' + IntToStr(i); |
| 166 |
ActionStr := ini.ReadString('MouseGesture', key, ''); |
| 167 |
if (GestureStr = '') or (ActionStr = '') then |
| 168 |
Break; |
| 169 |
Action := GetActionItem(ActionList, ActionStr); |
| 170 |
if Action <> nil then begin |
| 171 |
AddGesture(GestureStr, Action); |
| 172 |
end; |
| 173 |
inc(i); |
| 174 |
end; |
| 175 |
FMargin := ini.ReadInteger('MouseGesture', 'Margin', 15); |
| 176 |
finally |
| 177 |
ini.Free; |
| 178 |
end; |
| 179 |
end; |
| 180 |
|
| 181 |
//?スW?スF?スX?ス`?ス?ス?ス[?ス?ス?ス?ス?ス?スini?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス |
| 182 |
procedure TGestureModel.SaveGesture(FileName: string); |
| 183 |
var |
| 184 |
ini: TMemIniFile; |
| 185 |
i: Integer; |
| 186 |
key: string; |
| 187 |
begin |
| 188 |
ini := TMemIniFile.Create(FileName); |
| 189 |
try |
| 190 |
ini.EraseSection('MouseGesture'); |
| 191 |
for i := 0 to FGestureList.Count - 1 do begin |
| 192 |
if CheckGestureStr(FGestureList[i]) and (FGestureList.Objects[i] is TAction) then begin |
| 193 |
key := 'Gesture' + IntToStr(i); |
| 194 |
ini.WriteString('MouseGesture', key, FGestureList[i]); |
| 195 |
key := 'Action' + IntToStr(i); |
| 196 |
ini.WriteString('MouseGesture', key, TAction(FGestureList.Objects[i]).Name); |
| 197 |
end; |
| 198 |
end; |
| 199 |
ini.WriteInteger('MouseGesture', 'Margin', FMargin); |
| 200 |
ini.UpdateFile; |
| 201 |
finally |
| 202 |
ini.Free; |
| 203 |
end; |
| 204 |
end; |
| 205 |
|
| 206 |
//?スA?スN?スV?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス?スA?スN?スV?ス?ス?ス?ス?ス?ス?ス?ス?ス?ス |
| 207 |
function TGestureModel.GetActionItem(ActionList: TActionList; ActionStr: string): TAction; |
| 208 |
var |
| 209 |
i: Integer; |
| 210 |
begin |
| 211 |
Result := nil; |
| 212 |
for i := 0 to ActionList.ActionCount - 1 do begin |
| 213 |
if ActionList.Actions[i].Name = ActionStr then begin |
| 214 |
if ActionList.Actions[i] is TAction then begin |
| 215 |
Result := TAction(ActionList.Actions[i]); |
| 216 |
Exit; |
| 217 |
end; |
| 218 |
end; |
| 219 |
end; |
| 220 |
end; |
| 221 |
|
| 222 |
end. |
| |