Changeset 1679 for cprs/trunk/CPRS-Chart/rMisc.pas
- Timestamp:
- May 7, 2015, 12:34:29 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/trunk/CPRS-Chart/rMisc.pas
r830 r1679 3 3 interface 4 4 5 uses SysUtils, Windows, Classes, Forms, Controls, ComCtrls, Grids, ORFn, ORNet; 5 uses SysUtils, Windows, Classes, Forms, Controls, ComCtrls, Grids, ORFn, ORNet, 6 Menus, Contnrs, StrUtils; 6 7 7 8 const … … 9 10 10 11 type 11 TToolItem = record 12 TToolMenuItem = class 13 public 12 14 Caption: string; 15 Caption2: string; 13 16 Action: string; 14 end; 15 16 TToolItemList = array[0..MAX_TOOLITEMS] of TToolItem; 17 17 MenuID: string; 18 SubMenuID: string; 19 MenuItem: TMenuItem; 20 end; 21 22 var 23 uToolMenuItems: TObjectList = nil; 24 25 type 18 26 {An Object of this Class is Created to Hold the Sizes of Controls(Forms) 19 27 while the app is running, thus reducing calls to RPCs SAVESIZ and LOADSIZ} … … 30 38 31 39 function DetailPrimaryCare(const DFN: string): TStrings; //*DFN* 32 procedure GetToolMenu (var ToolItems: TToolItemList; var OverLimit: boolean);40 procedure GetToolMenu; 33 41 procedure ListSymbolTable(Dest: TStrings); 34 42 function MScalar(const x: string): string; … … 45 53 procedure SetUserWidths(var AControl: TControl); 46 54 procedure SetUserColumns(var AControl: TControl); 55 procedure SetUserString(StrName: string; var Str: string); 47 56 function StrUserBounds(AControl: TControl): string; 48 57 function StrUserBounds2(AName: string; v1, v2, v3, v4: integer): string; 49 58 function StrUserWidth(AControl: TControl): string; 50 59 function StrUserColumns(AControl: TControl): string; 60 function StrUserString(StrName: string; Str: string): string; 51 61 function UserFontSize: integer; 52 62 procedure SaveUserFontSize( FontSize: integer); … … 68 78 end; 69 79 70 procedure GetToolMenu(var ToolItems: TToolItemList; var OverLimit: boolean); 71 var 72 i: Integer; 73 x: string; 74 LoopIndex: integer; 75 begin 76 for i := 0 to MAX_TOOLITEMS do with ToolItems[i] do 77 begin 78 Caption := ''; 79 Action := ''; 80 end; 80 const 81 SUBMENU_KEY = 'SUBMENU'; 82 SUBMENU_KEY_LEN = length(SUBMENU_KEY); 83 SUB_LEFT = '['; 84 SUB_RIGHT = ']'; 85 MORE_ID = 'MORE^'; 86 MORE_NAME = 'More...'; 87 88 procedure GetToolMenu; 89 var 90 i, p, LastIdx, count, MenuCount: Integer; 91 id, x: string; 92 LastItem, item: TToolMenuItem; 93 caption, action: string; 94 CurrentMenuID: string; 95 MenuIDs: TStringList; 96 begin 97 if not assigned(uToolMenuItems) then 98 uToolMenuItems := TObjectList.Create 99 else 100 uToolMenuItems.Clear; 81 101 CallV('ORWU TOOLMENU', [nil]); 82 OverLimit := (MAX_TOOLITEMS < RPCBrokerV.Results.Count - 1); 83 LoopIndex := Min(MAX_TOOLITEMS, RPCBrokerV.Results.Count - 1); 84 with RPCBrokerV do for i := 0 to LoopIndex do with ToolItems[i] do 85 begin 86 x := Piece(Results[i], U, 1); 87 Caption := Piece(x, '=', 1); 88 Action := Copy(x, Pos('=', x) + 1, Length(x)); 102 MenuIDs := TStringList.Create; 103 try 104 for i := 0 to RPCBrokerV.Results.Count - 1 do 105 begin 106 x := Piece(RPCBrokerV.Results[i], U, 1); 107 item := TToolMenuItem.Create; 108 Caption := Piece(x, '=', 1); 109 Action := Copy(x, Pos('=', x) + 1, Length(x)); 110 item.Caption2 := Caption; 111 if UpperCase(copy(Action,1,SUBMENU_KEY_LEN)) = SUBMENU_KEY then 112 begin 113 id := UpperCase(Trim(Copy(Action, SUBMENU_KEY_LEN+1, MaxInt))); 114 if (LeftStr(id,1) = SUB_LEFT) and (RightStr(id,1) = SUB_RIGHT) then 115 id := copy(id, 2, length(id)-2); 116 item.MenuID := id; 117 Action := ''; 118 if MenuIDs.IndexOf(item.MenuID) < 0 then 119 MenuIDs.Add(item.MenuID) 120 else 121 begin 122 item.SubMenuID := item.MenuID; 123 item.MenuID := ''; 124 end; 125 end; 126 if RightStr(Caption, 1) = SUB_RIGHT then 127 begin 128 p := length(Caption) - 2; 129 while (p > 0) and (Caption[p] <> SUB_LEFT) do 130 dec(p); 131 if (p > 0) and (Caption[p] = SUB_LEFT) then 132 begin 133 item.SubMenuID := UpperCase(Trim(copy(Caption,p+1, length(Caption)-1-p))); 134 Caption := copy(Caption,1,p-1); 135 end; 136 end; 137 item.Caption := Caption; 138 item.Action := Action; 139 uToolMenuItems.add(item); 140 end; 141 // see if all child menu items have parents 142 for I := 0 to uToolMenuItems.Count - 1 do 143 begin 144 item := TToolMenuItem(uToolMenuItems[i]); 145 if MenuIDs.IndexOf(item.SubMenuID) < 0 then 146 begin 147 item.SubMenuID := ''; 148 item.Caption := item.Caption2; 149 end; 150 end; 151 152 // see if there are more than MAX_TOOLITEMS in the root menu 153 // if there are, add automatic sub menus 154 LastIdx := (MAX_TOOLITEMS - 1); 155 count := 0; 156 CurrentMenuID := ''; 157 i := 0; 158 LastItem := nil; 159 MenuCount := 0; 160 repeat 161 item := TToolMenuItem(uToolMenuItems[i]); 162 if item.SubMenuID = '' then 163 begin 164 item.SubMenuID := CurrentMenuID; 165 inc(count); 166 if Count > MAX_TOOLITEMS then 167 begin 168 item.SubMenuID := ''; 169 inc(MenuCount); 170 item := TToolMenuItem.Create; 171 item.Caption := MORE_NAME; 172 item.MenuID := MORE_ID + IntToStr(MenuCount); 173 item.SubMenuID := CurrentMenuID; 174 CurrentMenuID := item.MenuID; 175 LastItem.SubMenuID := CurrentMenuID; 176 uToolMenuItems.Insert(LastIdx, item); 177 inc(LastIdx,MAX_TOOLITEMS); 178 Count := 1; 179 end; 180 LastItem := item; 181 end; 182 inc(i); 183 until i >= uToolMenuItems.Count; 184 185 finally 186 MenuIDs.Free; 89 187 end; 90 188 end; … … 251 349 end; 252 350 351 procedure SetUserString(StrName: string; var Str: string); 352 begin 353 Str := uColumns.Values[StrName]; 354 end; 355 253 356 procedure SaveUserBounds(AControl: TControl); 254 357 var 255 358 x: string; 359 NewHeight: integer; 256 360 begin 257 361 if (AControl is TForm) and (TForm(AControl).WindowState = wsMaximized) then … … 259 363 else 260 364 with AControl do 261 x := IntToStr(Left) + ',' + IntToStr(Top) + ',' + 262 IntToStr(Width) + ',' + IntToStr(Height); 365 begin 366 //Done to remove the adjustment for Window XP style before saving the form size 367 NewHeight := Height - (GetSystemMetrics(SM_CYCAPTION) - 19); 368 x := IntToStr(Left) + ',' + IntToStr(Top) + ',' + 369 IntToStr(Width) + ',' + IntToStr(NewHeight); 370 end; 263 371 // CallV('ORWCH SAVESIZ', [AControl.Name, x]); 264 372 SizeHolder.SetSize(AControl.Name, x); … … 348 456 end; 349 457 458 function StrUserString(StrName: string; Str: string): string; 459 begin 460 Result := 'C' + U + StrName + U + Str; 461 end; 462 350 463 { TSizeHolder } 351 464 … … 355 468 i: integer; 356 469 begin 357 for i := 0 to FNameList.Count-1 do begin 358 if Piece(FNameList[i],U,1) = 'C' then 359 theList.Add(FNameList[i] + U + FSizeList[i]) 360 else 361 theList.Add('B' + U + FNameList[i] + U + FSizeList[i]); 362 end; 470 for i := 0 to FNameList.Count-1 do 471 theList.Add('B' + U + FNameList[i] + U + FSizeList[i]); 363 472 end; 364 473 … … 399 508 else //Currently is in the NameList 400 509 rSizeVal := FSizeList[nameIndex]; 401 if (rSizeVal = '') and (Piece(AName,U,1) = 'C') then begin402 if not Assigned(uColumns) then LoadSizes;403 rSizeVal := uColumns.Values[Piece(AName,U,2)];404 end;405 510 result := rSizeVal; 406 511 end; … … 430 535 if uWidths <> nil then uWidths.Free; 431 536 if uColumns <> nil then uColumns.Free; 537 if assigned(uToolMenuItems) then 538 FreeAndNil(uToolMenuItems); 432 539 433 540 end.
Note:
See TracChangeset
for help on using the changeset viewer.