Changeset 829 for cprs/trunk/CPRS-Lib
- Timestamp:
- Jul 7, 2010, 4:31:10 PM (14 years ago)
- Location:
- cprs/trunk/CPRS-Lib
- Files:
-
- 16 added
- 12 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/trunk/CPRS-Lib/ORCtrls.pas
r456 r829 7 7 uses Windows, Messages, SysUtils, Classes, Graphics, Controls, StdCtrls, Forms, 8 8 ComCtrls, Commctrl, Buttons, ExtCtrls, Grids, ImgList, Menus, CheckLst, 9 Accessibility_TLB, Variants;9 Variants, VAClasses; 10 10 11 11 const … … 21 21 22 22 type 23 24 TORStaticText = class(TStaticText) 25 private 26 FOnEnter: TNotifyEvent; 27 FOnExit: TNotifyEvent; 28 published 29 property OnEnter: TNotifyEvent read FOnEnter write FOnEnter; 30 property OnExit: TNotifyEvent read FOnExit write FOnExit; 31 procedure DoEnter; override; 32 procedure DoExit; override; 23 IORBlackColorModeCompatible = interface(IInterface) 24 ['{3554985C-F524-45FA-8C27-4CDD8357DB08}'] 25 procedure SetBlackColorMode(Value: boolean); 33 26 end; 34 27 … … 81 74 end; 82 75 83 TORListBox = class(TListBox )76 TORListBox = class(TListBox, IVADynamicProperty, IORBlackColorModeCompatible) 84 77 private 85 78 FFocusIndex: Integer; // item with focus when using navigation keys … … 127 120 FMItems: TORStrings; // Used to save corresponding M strings ("the pieces") 128 121 FCaption: TStaticText; // Used to supply a title to IAccessible interface 129 FAccessible: IAccessible;130 122 FCaseChanged: boolean; // If true, the names are stored in the database as all caps, but loaded and displayed in mixed-case 131 123 FLookupPiece: integer; // If zero, list look-up comes from display string; if non-zero, indicates which piece of the item needs to be used for list lookup 132 procedure WMGetObject(var Message: TMessage); message WM_GETOBJECT; 124 FIsPartOfComboBox: boolean; 125 FBlackColorMode: boolean; 126 FHideSelection: boolean; 133 127 procedure AdjustScrollBar; 134 128 procedure CreateScrollBar; … … 214 208 procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState); override; 215 209 function GetIndexFromY(YPos :integer) :integer; 210 property isPartOfComboBox: boolean read FIsPartOfComboBox write FIsPartOfComboBox default False; 216 211 property HideSynonyms: boolean read FHideSynonyms write SetHideSynonyms default FALSE; 217 212 property SynonymChars: string read FSynonymChars write SetSynonymChars; … … 241 236 property CheckedState[Index: Integer]: TCheckBoxState read GetCheckedState write SetCheckedState; 242 237 property MItems: TStrings read GetMItems write SetMItems; 243 procedure MakeAccessible(Accessible: IAccessible);244 238 function VerifyUnique(SelectIndex: Integer; iText: String): integer; 239 procedure SetBlackColorMode(Value: boolean); 240 function SupportsDynamicProperty(PropertyID: integer): boolean; 241 function GetDynamicProperty(PropertyID: integer): string; 242 property HideSelection: boolean read FHideSelection write FHideSelection; 245 243 published 246 244 property AllowGrayed: boolean read FAllowGrayed write FAllowGrayed default FALSE; … … 303 301 end; 304 302 305 TORComboBox = class(TWinControl )303 TORComboBox = class(TWinControl, IVADynamicProperty, IORBlackColorModeCompatible) 306 304 private 307 305 FItems: TStrings; // points to Items in FListBox … … 340 338 FCharsNeedMatch: integer; // how many text need to be matched for auto selection 341 339 FUniqueAutoComplete: Boolean; // If true only perform autocomplete for unique list items. 340 FBlackColorMode: boolean; 341 FDisableHints: boolean; // true if hints have been disabled because drop down window was opened 342 FDropDownStatusChangedCount: integer; // prevents multiple calls to disabling hint window 343 procedure DropDownStatusChanged(opened: boolean); 344 procedure ClearDropDownStatus; 342 345 function EditControl: TWinControl; 343 346 procedure AdjustSizeOfSelf; … … 440 443 procedure SetLookupPiece(const Value: integer); 441 444 procedure SetUniqueAutoComplete(const Value: Boolean); 445 procedure LoadComboBoxImage; 442 446 protected 443 447 procedure DropPanelBtnPressed(OKBtn, AutoClose: boolean); … … 452 456 public 453 457 constructor Create(AOwner: TComponent); override; 458 destructor Destroy; override; 454 459 function AddReference(const S: string; AReference: Variant): Integer; 455 460 procedure Clear; … … 458 463 procedure InitLongList(S: string); 459 464 procedure InsertSeparator; 465 procedure Invalidate; override; 460 466 procedure SetTextAutoComplete(TextToMatch : String); 461 467 function GetIEN(AnIndex: Integer): Int64; … … 466 472 procedure InsertReference(Index: Integer; const S: string; AReference: Variant); 467 473 procedure SelectAll; 468 function MakeAccessible( Accessible: IAccessible): TORListBox; 474 procedure SetBlackColorMode(Value: boolean); 475 function SupportsDynamicProperty(PropertyID: integer): boolean; 476 function GetDynamicProperty(PropertyID: integer): string; 469 477 property DisplayText[Index: Integer]: string read GetDisplayText; 470 478 property DroppedDown: Boolean read FDroppedDown write SetDroppedDown; … … 648 656 649 657 650 TCaptionTreeView = class(TTreeView )658 TCaptionTreeView = class(TTreeView, IVADynamicProperty) 651 659 private 652 660 procedure SetCaption(const Value: string); … … 654 662 protected 655 663 FCaptionComponent: TStaticText; 664 public 665 function SupportsDynamicProperty(PropertyID: integer): boolean; 666 function GetDynamicProperty(PropertyID: integer): string; 656 667 published 657 668 property Align; … … 665 676 FTag: integer; 666 677 FStringData: string; 667 FAccessible: IAccessible;668 678 FCaption: string; 669 procedure WMGetObject(var Message: TMessage); message WM_GETOBJECT;670 679 function GetParent: TORTreeNode; 671 680 procedure SetCaption(const Value: string); … … 679 688 function GetORTreeView: TORTreeView; 680 689 public 681 procedure MakeAccessible(Accessible: IAccessible);682 690 procedure SetPiece(PieceNum: Integer; const NewPiece: string); 683 691 procedure EnsureVisible; 684 property Accessible: IAccessible read FAccessible write MakeAccessible;685 692 property Bold: boolean read GetBold write SetBold; 686 693 property Tag: integer read FTag write FTag; … … 700 707 FPiece: integer; 701 708 FOnAddition: TTVExpandedEvent; 702 FAccessible: IAccessible;703 709 FShortNodeCaptions: boolean; 704 710 FOnNodeCaptioning: TNodeCaptioningEvent; 705 procedure WMGetObject(var Message: TMessage); message WM_GETOBJECT;706 711 procedure SetShortNodeCaptions(const Value: boolean); 707 712 protected … … 716 721 public 717 722 constructor Create(AOwner: TComponent); override; 718 procedure MakeAccessible(Accessible: IAccessible);719 723 function FindPieceNode(Value: string; 720 724 ParentDelim: Char = #0; StartNode: TTreeNode = nil): TORTreeNode; overload; … … 776 780 TGrayedStyle = (gsNormal, gsQuestionMark, gsBlueQuestionMark); 777 781 778 TORCheckBox = class(TCheckBox )782 TORCheckBox = class(TCheckBox, IORBlackColorModeCompatible) 779 783 private 780 784 FStringData: string; … … 793 797 FAssociate: TControl; 794 798 FFocusOnBox: boolean; 799 FBlackColorMode: boolean; 795 800 procedure SetFocusOnBox(value: boolean); 796 801 procedure CNMeasureItem (var Message: TWMMeasureItem); message CN_MEASUREITEM; … … 835 840 destructor Destroy; override; 836 841 procedure AutoAdjustSize; 842 procedure SetBlackColorMode(Value: boolean); 837 843 property SingleLine: boolean read FSingleLine; 838 844 property StringData: string read FStringData write FStringData; … … 899 905 end; 900 906 901 TCaptionListBox = class(TListBox )907 TCaptionListBox = class(TListBox, IVADynamicProperty) 902 908 private 903 909 FHoverItemPos: integer; 904 FAccessible: IAccessible;905 910 FRightClickSelect: boolean; // When true, a right click selects teh item 906 911 FHintOnItem: boolean; 907 912 procedure SetCaption(const Value: string); 908 913 function GetCaption: string; 909 procedure WMGetObject(var Message: TMessage); message WM_GETOBJECT;910 914 procedure WMRButtonUp(var Message: TWMRButtonUp); message WM_RBUTTONUP; 911 915 procedure WMMouseMove(var Message: TWMMouseMove); message WM_MOUSEMOVE; 916 procedure WMKeyDown(var Message: TWMKeyDown); message WM_KEYDOWN; 917 procedure MoveFocusDown; 918 procedure MoveFocusUp; 912 919 protected 913 920 FCaptionComponent: TStaticText; 914 921 procedure DoEnter; override; 915 922 public 916 procedure MakeAccessible( Accessible: IAccessible); 923 function SupportsDynamicProperty(PropertyID: integer): boolean; 924 function GetDynamicProperty(PropertyID: integer): string; 917 925 published 918 926 property RightClickSelect: boolean read FRightClickSelect write FRightClickSelect default FALSE; … … 922 930 end; 923 931 924 TCaptionCheckListBox = class(TCheckListBox )932 TCaptionCheckListBox = class(TCheckListBox, IVADynamicProperty) 925 933 private 926 934 procedure SetCaption(const Value: string); … … 928 936 protected 929 937 FCaptionComponent: TStaticText; 938 public 939 function SupportsDynamicProperty(PropertyID: integer): boolean; 940 function GetDynamicProperty(PropertyID: integer): string; 930 941 published 931 942 property Caption: string read GetCaption write SetCaption; 932 943 end; 933 944 934 TCaptionMemo = class(TMemo )945 TCaptionMemo = class(TMemo, IVADynamicProperty) 935 946 private 936 947 procedure SetCaption(const Value: string); … … 938 949 protected 939 950 FCaptionComponent: TStaticText; 951 public 952 function SupportsDynamicProperty(PropertyID: integer): boolean; 953 function GetDynamicProperty(PropertyID: integer): string; 940 954 published 941 955 property Caption: string read GetCaption write SetCaption; 942 956 end; 943 957 944 TCaptionEdit = class(TEdit )958 TCaptionEdit = class(TEdit, IVADynamicProperty) 945 959 private 946 960 procedure SetCaption(const Value: string); … … 948 962 protected 949 963 FCaptionComponent: TStaticText; 964 public 965 function SupportsDynamicProperty(PropertyID: integer): boolean; 966 function GetDynamicProperty(PropertyID: integer): string; 950 967 published 951 968 property Align; … … 953 970 end; 954 971 955 TCaptionRichEdit = class(TRichEdit )972 TCaptionRichEdit = class(TRichEdit, IVADynamicProperty) 956 973 private 957 FAccessible: IAccessible;958 procedure WMGetObject(var Message: TMessage); message WM_GETOBJECT;959 974 protected 960 975 FCaption: string; 961 976 public 962 procedure MakeAccessible(Accessible: IAccessible); 977 function SupportsDynamicProperty(PropertyID: integer): boolean; 978 function GetDynamicProperty(PropertyID: integer): string; 963 979 published 964 980 property Align; … … 966 982 end; 967 983 968 TCaptionComboBox = class(TComboBox )984 TCaptionComboBox = class(TComboBox, IVADynamicProperty) 969 985 private 970 986 procedure SetCaption(const Value: string); … … 972 988 protected 973 989 FCaptionComponent: TStaticText; 990 public 991 function SupportsDynamicProperty(PropertyID: integer): boolean; 992 function GetDynamicProperty(PropertyID: integer): string; 974 993 published 975 994 property Caption: string read GetCaption write SetCaption; 976 995 end; 977 996 978 TCaptionListView = class(TListView) 997 TCaptionListView = class(TListView, IVADynamicProperty) 998 public 999 function SupportsDynamicProperty(PropertyID: integer): boolean; 1000 function GetDynamicProperty(PropertyID: integer): string; 979 1001 published 980 1002 property Caption; 981 1003 end; 982 1004 983 TCaptionStringGrid = class(TStringGrid )1005 TCaptionStringGrid = class(TStringGrid, IVADynamicProperty) 984 1006 private 985 1007 FJustToTab: boolean; 986 1008 FCaption: string; 987 FAccessible: IAccessible;988 procedure WMGetObject(var Message: TMessage); message WM_GETOBJECT;989 1009 protected 990 1010 procedure KeyUp(var Key: Word; Shift: TShiftState); override; 991 1011 public 992 procedure MakeAccessible( Accessible: IAccessible);993 1012 procedure IndexToColRow( index: integer; var Col: integer; var Row: integer); 994 1013 function ColRowToIndex( Col: integer; Row: Integer): integer; 1014 function SupportsDynamicProperty(PropertyID: integer): boolean; 1015 function GetDynamicProperty(PropertyID: integer): string; 995 1016 published 996 1017 property Caption: string read FCaption write FCaption; … … 1015 1036 1016 1037 uses 1017 uAccessAPI;1038 VAUtils; 1018 1039 1019 1040 const … … 1424 1445 'ORCB_RADIO_DISABLED_UNCHECKED', 'ORCB_RADIO_DISABLED_CHECKED'); 1425 1446 1426 var 1427 ORCBImages: array[TORCBImgIdx] of TBitMap; 1428 1429 function GetORCBBitmap(Idx: TORCBImgIdx): TBitmap; 1430 begin 1431 if(not assigned(ORCBImages[Idx])) then 1432 begin 1433 ORCBImages[Idx] := TBitMap.Create; 1434 ORCBImages[Idx].LoadFromResourceName(HInstance, CheckBoxImageResNames[Idx]); 1435 end; 1436 Result := ORCBImages[Idx]; 1447 BlackCheckBoxImageResNames: array[TORCBImgIdx] of PChar = ( 1448 'BLACK_ORLB_FLAT_UNCHECKED', 'BLACK_ORLB_FLAT_CHECKED', 'BLACK_ORLB_FLAT_GRAYED', 1449 'BLACK_ORCB_QUESTIONMARK', 'BLACK_ORCB_BLUEQUESTIONMARK', 1450 'BLACK_ORCB_DISABLED_UNCHECKED', 'BLACK_ORCB_DISABLED_CHECKED', 1451 'BLACK_ORCB_DISABLED_GRAYED', 'BLACK_ORCB_DISABLED_QUESTIONMARK', 1452 'BLACK_ORLB_FLAT_UNCHECKED', 'BLACK_ORLB_FLAT_CHECKED', 'BLACK_ORLB_FLAT_GRAYED', 1453 'BLACK_ORCB_RADIO_UNCHECKED', 'BLACK_ORCB_RADIO_CHECKED', 1454 'BLACK_ORCB_RADIO_DISABLED_UNCHECKED', 'BLACK_ORCB_RADIO_DISABLED_CHECKED'); 1455 1456 var 1457 ORCBImages: array[TORCBImgIdx, Boolean] of TBitMap; 1458 1459 function GetORCBBitmap(Idx: TORCBImgIdx; BlackMode: boolean): TBitmap; 1460 var 1461 ResName: string; 1462 begin 1463 if(not assigned(ORCBImages[Idx, BlackMode])) then 1464 begin 1465 ORCBImages[Idx, BlackMode] := TBitMap.Create; 1466 if BlackMode then 1467 ResName := BlackCheckBoxImageResNames[Idx] 1468 else 1469 ResName := CheckBoxImageResNames[Idx]; 1470 ORCBImages[Idx, BlackMode].LoadFromResourceName(HInstance, ResName); 1471 end; 1472 Result := ORCBImages[Idx, BlackMode]; 1437 1473 end; 1438 1474 … … 1440 1476 var 1441 1477 i: TORCBImgIdx; 1478 mode: boolean; 1442 1479 1443 1480 begin 1444 1481 for i := low(TORCBImgIdx) to high(TORCBImgIdx) do 1445 1482 begin 1446 if(assigned(ORCBImages[i])) then 1447 ORCBImages[i].Free; 1448 end; 1449 end; 1450 1451 { TORStaticText } 1452 1453 procedure TORStaticText.DoEnter; 1454 begin 1455 inherited DoEnter; 1456 if Assigned(FOnEnter) then 1457 FOnEnter(Self); 1458 end; 1459 1460 procedure TORStaticText.DoExit; 1461 begin 1462 inherited DoExit; 1463 if Assigned(FOnExit) then 1464 FOnExit(Self); 1483 for Mode := false to true do 1484 begin 1485 if(assigned(ORCBImages[i, Mode])) then 1486 ORCBImages[i, Mode].Free; 1487 end; 1488 end; 1465 1489 end; 1466 1490 … … 1658 1682 FCaseChanged := TRUE; 1659 1683 FLookupPiece := 0; 1684 FIsPartOfComboBox := False; 1660 1685 end; 1661 1686 … … 1768 1793 SetString(Result, Buf, Len); 1769 1794 end; 1795 end; 1796 1797 function TORListBox.GetDynamicProperty(PropertyID: integer): string; 1798 begin 1799 if PropertyID = DynaPropAccesibilityCaption then 1800 Result := GetCaption 1801 else 1802 Result := ''; 1770 1803 end; 1771 1804 … … 2016 2049 case Message.CharCode of 2017 2050 VK_LBUTTON, VK_RETURN, VK_SPACE: 2018 if FocusIndex > -1 then 2019 begin 2020 if MultiSelect then 2051 begin 2052 if (FocusIndex < 0) and (CheckBoxes or MultiSelect) and (Count > 0) then // JNM - 508 compliance 2053 SetFocusIndex(0); 2054 if FocusIndex > -1 then 2021 2055 begin 2022 IsSelected := LongBool(Perform(LB_GETSEL, FocusIndex, 0)); 2023 Perform(LB_SETSEL, Longint(not IsSelected), FocusIndex); 2024 end 2025 else Perform(LB_SETCURSEL, FocusIndex, 0); 2026 // Send WM_COMMAND here because LBN_SELCHANGE not triggered by LB_SETSEL 2027 // and LBN_SELCHANGE is what eventually triggers the Click event. 2028 // The LBN_SELCHANGE documentation implies we should send the control id, which is 2029 // 32 bits long, in the high word of WPARAM (16 bits). Since that won't work - we'll 2030 // try sending the item index instead. 2031 //PostMessage() not SendMessage() is Required here for checkboxes, SendMessage() doesn't 2032 //Allow the Checkbox state on the control to be updated 2033 if CheckBoxes then 2034 PostMessage(Parent.Handle, WM_COMMAND, MAKELONG(FocusIndex, LBN_SELCHANGE), LPARAM(Handle)) 2035 else 2036 SendMessage(Parent.Handle, WM_COMMAND, MAKELONG(FocusIndex, LBN_SELCHANGE), LPARAM(Handle)); 2056 if MultiSelect then 2057 begin 2058 IsSelected := LongBool(Perform(LB_GETSEL, FocusIndex, 0)); 2059 Perform(LB_SETSEL, Longint(not IsSelected), FocusIndex); 2060 end 2061 else Perform(LB_SETCURSEL, FocusIndex, 0); 2062 // Send WM_COMMAND here because LBN_SELCHANGE not triggered by LB_SETSEL 2063 // and LBN_SELCHANGE is what eventually triggers the Click event. 2064 // The LBN_SELCHANGE documentation implies we should send the control id, which is 2065 // 32 bits long, in the high word of WPARAM (16 bits). Since that won't work - we'll 2066 // try sending the item index instead. 2067 //PostMessage() not SendMessage() is Required here for checkboxes, SendMessage() doesn't 2068 //Allow the Checkbox state on the control to be updated 2069 if CheckBoxes then 2070 PostMessage(Parent.Handle, WM_COMMAND, MAKELONG(FocusIndex, LBN_SELCHANGE), LPARAM(Handle)) 2071 else 2072 SendMessage(Parent.Handle, WM_COMMAND, MAKELONG(FocusIndex, LBN_SELCHANGE), LPARAM(Handle)); 2073 end; 2037 2074 end; 2038 2075 VK_PRIOR: SetFocusIndex(FocusIndex - FLargeChange); … … 2236 2273 begin 2237 2274 FLastItemIndex := ItemIndex; 2275 if (not isPartOfComboBox) and (ItemIndex <> -1) then 2276 SetFocusIndex(ItemIndex); 2238 2277 if Assigned(FOnChange) then FOnChange(Self); 2239 2278 end; … … 2248 2287 { if (Items.Count > 0) and (Not IsAMouseButtonDown()) and (ItemIndex = -1) then 2249 2288 SetFocusIndex(TopIndex);//ItemIndex := TopIndex; } 2289 if FHideSelection and (ItemIndex < 0) and (FFocusIndex >= 0) then 2290 ItemIndex := FFocusIndex; 2250 2291 inherited DoEnter; 2251 2292 end; 2252 2293 2253 2294 procedure TORListBox.DoExit; 2295 var 2296 SaveIndex: integer; 2254 2297 { make sure item tip is hidden for this listbox when focus shifts to something else } 2255 2298 begin 2299 if FHideSelection then 2300 begin 2301 SaveIndex := ItemIndex; 2302 ItemIndex := -1; 2303 FFocusIndex := SaveIndex; 2304 end; 2305 2256 2306 uItemTip.Hide; 2257 2307 FItemTipActive := False; … … 2321 2371 procedure TORListBox.KeyPress(var Key: Char); 2322 2372 begin 2373 {inherited KeyPress is changing the ' ' into #0, had to move conditional before inherited.} 2374 if (Key = ' ') then begin 2375 ToggleCheckBox(ItemIndex); 2376 {The space bar causes the focus to jump to an item in the list that starts with 2377 a space. Disable that function.} 2378 Key := #0; 2379 end; 2323 2380 inherited; 2324 if (Key = ' ') then ToggleCheckBox(ItemIndex);2325 2381 end; 2326 2382 … … 2459 2515 begin 2460 2516 if(FFlatCheckBoxes) then 2461 BMap := GetORCBBitmap(iiFlatUnChecked )2517 BMap := GetORCBBitmap(iiFlatUnChecked, FBlackColorMode) 2462 2518 else 2463 BMap := GetORCBBitmap(iiUnchecked );2519 BMap := GetORCBBitmap(iiUnchecked, FBlackColorMode); 2464 2520 end; 2465 2521 cbChecked: 2466 2522 begin 2467 2523 if(FFlatCheckBoxes) then 2468 BMap := GetORCBBitmap(iiFlatChecked )2524 BMap := GetORCBBitmap(iiFlatChecked, FBlackColorMode) 2469 2525 else 2470 BMap := GetORCBBitmap(iiChecked );2526 BMap := GetORCBBitmap(iiChecked, FBlackColorMode); 2471 2527 end; 2472 2528 else // cbGrayed: 2473 2529 begin 2474 2530 if(FFlatCheckBoxes) then 2475 BMap := GetORCBBitmap(iiFlatGrayed )2531 BMap := GetORCBBitmap(iiFlatGrayed, FBlackColorMode) 2476 2532 else 2477 BMap := GetORCBBitmap(iiGrayed );2533 BMap := GetORCBBitmap(iiGrayed, FBlackColorMode); 2478 2534 end; 2479 2535 end; … … 2482 2538 begin 2483 2539 if(FFlatCheckBoxes) then 2484 BMap := GetORCBBitmap(iiFlatGrayed )2540 BMap := GetORCBBitmap(iiFlatGrayed, FBlackColorMode) 2485 2541 else 2486 BMap := GetORCBBitmap(iiGrayed );2542 BMap := GetORCBBitmap(iiGrayed, FBlackColorMode); 2487 2543 end; 2488 2544 TmpR := Rect; … … 2584 2640 end; 2585 2641 end; // -- special long list processing - end 2642 if (Value = SFI_END) or (not (Value < Items.Count)) then Value := Items.Count - 1; 2586 2643 if (Value = SFI_TOP) or (Value < 0) then Value := 0; 2587 if (Value = SFI_END) or (not (Value < Items.Count)) then Value := Items.Count - 1;2588 2644 FFocusIndex := Value; 2589 ItemIndex := Value; 2645 if Focused or (not FHideSelection) then 2646 ItemIndex := Value; 2590 2647 if MultiSelect then Perform(LB_SETCARETINDEX, FFocusIndex, 0) // LPARAM=0, scrolls into view 2591 2648 else … … 2850 2907 end; 2851 2908 2909 function TORListBox.SupportsDynamicProperty(PropertyID: integer): boolean; 2910 begin 2911 Result := (PropertyID = DynaPropAccesibilityCaption); 2912 end; 2913 2852 2914 procedure TORListBox.SetHideSynonyms(Value :boolean); 2853 2915 var … … 2930 2992 Strings: TStringList; 2931 2993 i, Pos: Integer; 2932 ItemRec : PItemRec;2994 ItemRec, ItemRec2: PItemRec; 2933 2995 SaveListMode: Boolean; 2934 2996 RealVerify: Boolean; … … 2960 3022 begin 2961 3023 Pos := Items.AddObject(Strings[i], ItemRec^.UserObject); 2962 References[Pos] := ItemRec^.Reference; 3024 // CQ 11491 - Changing TabPositions, etc. was wiping out check box status. 3025 FFromSelf := True; 3026 ItemRec2 := PItemRec(SendMessage(Handle,LB_GETITEMDATA, Pos, 0)); 3027 FFromSelf := False; 3028 if(assigned(ItemRec2)) then 3029 begin 3030 ItemRec2^.Reference := ItemRec^.Reference; 3031 ItemRec2^.CheckedState := ItemRec^.CheckedState; 3032 end; 2963 3033 end; 2964 3034 end; … … 3505 3575 end; 3506 3576 3577 procedure TORListBox.SetBlackColorMode(Value: boolean); 3578 begin 3579 FBlackColorMode := Value; 3580 end; 3581 3507 3582 procedure TORListBox.SetCaption(const Value: string); 3508 3583 begin … … 3527 3602 end; 3528 3603 3529 procedure TORListBox.MakeAccessible(Accessible: IAccessible); 3530 begin 3531 if Assigned(FAccessible) and Assigned(Accessible) then 3532 raise Exception.Create(Caption + ' List Box is already Accessible!') 3533 else 3534 FAccessible := Accessible; 3535 end; 3536 3537 procedure TORListBox.WMGetObject(var Message: TMessage); 3538 begin 3539 if (Message.LParam = integer(OBJID_CLIENT)) and Assigned(FAccessible) then 3540 Message.Result := GetLResult(Message.wParam, FAccessible) 3541 else 3542 inherited; 3604 // In Delphi 2006, hint windows will cause the TORComboBox drop down list to 3605 // move behind a Stay on Top form. Hints are also problematic with item tips in 3606 // the drop down list, so we disable them when ever a drop down list is open, 3607 // on all forms, not just stay on top forms. 3608 var 3609 uDropPanelOpenCount: integer = 0; 3610 uOldShowHintsSetting: boolean; 3611 3612 procedure DropDownPanelOpened; 3613 begin 3614 if uDropPanelOpenCount=0 then 3615 uOldShowHintsSetting := Application.ShowHint; 3616 Application.ShowHint := FALSE; 3617 inc(uDropPanelOpenCount); 3618 end; 3619 3620 procedure DropDownPanelClosed; 3621 begin 3622 dec(uDropPanelOpenCount); 3623 if uDropPanelOpenCount<=0 then 3624 begin 3625 uDropPanelOpenCount := 0; 3626 if not Application.ShowHint then 3627 Application.ShowHint := uOldShowHintsSetting 3628 end; 3543 3629 end; 3544 3630 … … 3690 3776 const 3691 3777 ComboBoxImages: array[boolean] of string = ('BMP_CBODOWN_DISABLED', 'BMP_CBODOWN'); 3692 3778 BlackComboBoxImages: array[boolean] of string = ('BLACK_BMP_CBODOWN_DISABLED', 'BLACK_BMP_CBODOWN'); 3779 3693 3780 procedure TORComboEdit.CreateParams(var Params: TCreateParams); 3694 3781 { sets a one line edit box to multiline style so the editing rectangle can be changed } … … 3740 3827 FCheckBoxEditColor := clBtnFace; 3741 3828 FListBox := TORListBox.Create(Self); 3829 FListBox.isPartOfComboBox := True; 3742 3830 FListBox.Parent := Self; 3743 3831 FListBox.TabStop := False; … … 3866 3954 end; 3867 3955 3956 procedure TORComboBox.DropDownStatusChanged(opened: boolean); 3957 begin 3958 if opened then 3959 begin 3960 if not FDropPanel.Visible then 3961 begin 3962 if FDropDownStatusChangedCount = 0 then 3963 begin 3964 FDisableHints := TRUE; 3965 DropDownPanelOpened; 3966 end; 3967 inc(FDropDownStatusChangedCount); 3968 end; 3969 end 3970 else 3971 begin 3972 dec(FDropDownStatusChangedCount); 3973 if FDropDownStatusChangedCount <= 0 then 3974 begin 3975 if FDisableHints then 3976 begin 3977 DropDownPanelClosed; 3978 FDisableHints := FALSE; 3979 end; 3980 FDropDownStatusChangedCount := 0; 3981 end; 3982 end; 3983 end; 3984 3985 procedure TORComboBox.ClearDropDownStatus; 3986 begin 3987 FDropDownStatusChangedCount := 1; 3988 DropDownStatusChanged(FALSE); 3989 end; 3990 3991 destructor TORComboBox.Destroy; 3992 begin 3993 ClearDropDownStatus; 3994 inherited; 3995 end; 3996 3868 3997 procedure TORComboBox.DoEnter; 3869 3998 {var … … 3902 4031 end; 3903 4032 inherited DoExit; 4033 end; 4034 4035 procedure TORComboBox.LoadComboBoxImage; 4036 var 4037 imageName: string; 4038 begin 4039 if assigned(FDropBtn) then 4040 begin 4041 if FBlackColorMode then 4042 imageName := BlackComboBoxImages[inherited Enabled] 4043 else 4044 imageName := ComboBoxImages[inherited Enabled]; 4045 FDropBtn.Glyph.LoadFromResourceName(hInstance, imageName); 4046 end; 3904 4047 end; 3905 4048 … … 4098 4241 4099 4242 procedure TORComboBox.FwdKeyPress(Sender: TObject; var Key: Char); 4243 var 4244 KeyCode: integer; 4100 4245 { prevents return from being used by editbox (otherwise sends a newline & text vanishes) } 4101 4246 begin 4102 // may want to make the tab beep if tab key (#9) - can't tab until list raised 4103 if (Key in [#9, #13]) or (FListBox.FCheckBoxes and (Key = #32)) then 4104 begin 4247 KeyCode := ord(Key); 4248 if (KeyCode = VK_RETURN) and (Style = orcsDropDown) and DroppedDown then 4249 begin 4250 DroppedDown := FALSE; 4105 4251 Key := #0; 4106 Exit; 4107 end; 4108 if Assigned(FOnKeyPress) then FOnKeyPress(Self, Key); 4252 end 4253 else 4254 begin 4255 // may want to make the tab beep if tab key (#9) - can't tab until list raised 4256 if (KeyCode = VK_RETURN) or (KeyCode = VK_TAB) or (FListBox.FCheckBoxes and (KeyCode = VK_SPACE)) then 4257 begin 4258 Key := #0; 4259 Exit; 4260 end; 4261 if Assigned(FOnKeyPress) then FOnKeyPress(Self, Key); 4262 end; 4109 4263 end; 4110 4264 … … 4168 4322 FCheckedState := FListBox.GetCheckedString; 4169 4323 end; 4324 DropDownStatusChanged(TRUE); 4170 4325 FDropPanel.Visible := True; 4171 4326 FDropPanel.BringToFront; … … 4178 4333 uItemTip.Hide; 4179 4334 FDropPanel.Hide; 4335 DropDownStatusChanged(FALSE); 4180 4336 if(FListBox.FCheckBoxes) and (assigned(FOnChange)) and 4181 4337 (FCheckedState <> FListBox.GetCheckedString) then … … 4265 4421 begin 4266 4422 if FDropBtn <> nil then FDropBtn.Free; 4267 if FDropPanel <> nil then FDropPanel.Free; 4423 if FDropPanel <> nil then 4424 begin 4425 ClearDropDownStatus; 4426 FDropPanel.Free; 4427 end; 4268 4428 FDropBtn := nil; 4269 4429 FDropPanel := nil; … … 4280 4440 if(assigned(FEditPanel) and (csDesigning in ComponentState)) then 4281 4441 FEditPanel.ControlStyle := FEditPanel.ControlStyle - [csAcceptsControls]; 4282 FDropBtn.Glyph.LoadFromResourceName(hInstance, ComboBoxImages[inherited Enabled]); 4442 LoadComboBoxImage; 4443 // FDropBtn.Glyph.LoadFromResourceName(hInstance, ComboBoxImages[inherited Enabled]); 4283 4444 FDropBtn.OnMouseDown := DropButtonDown; 4284 4445 FDropBtn.OnMouseUp := DropButtonUp; … … 4292 4453 FListBox.FParentCombo := Self; 4293 4454 FListBox.Parent := FDropPanel; 4455 ClearDropDownStatus; 4294 4456 if FListBox.FScrollBar <> nil then FListBox.FScrollBar.Parent := FDropPanel; // if long 4295 4457 end else … … 4328 4490 end; 4329 4491 4492 function TORComboBox.SupportsDynamicProperty(PropertyID: integer): boolean; 4493 begin 4494 Result := (PropertyID = DynaPropAccesibilityCaption); 4495 end; 4496 4330 4497 // Since TORComboBox is composed of several controls (FEditBox, FListBox, FDropBtn), the 4331 4498 // following functions and procedures map public and published properties to their related … … 4373 4540 end; 4374 4541 4542 procedure TORComboBox.Invalidate; 4543 begin 4544 inherited; 4545 FEditBox.Invalidate; 4546 FListBox.Invalidate; 4547 if assigned(FEditPanel) then 4548 FEditPanel.Invalidate; 4549 if assigned(FDropBtn) then 4550 FDropBtn.Invalidate; 4551 if assigned(FDropPanel) then 4552 FDropPanel.Invalidate; 4553 end; 4554 4375 4555 function TORComboBox.GetAutoSelect: Boolean; 4376 4556 begin … … 4393 4573 end; 4394 4574 4575 function TORComboBox.GetDynamicProperty(PropertyID: integer): string; 4576 begin 4577 if PropertyID = DynaPropAccesibilityCaption then 4578 Result := GetCaption 4579 else 4580 Result := ''; 4581 end; 4582 4395 4583 function TORComboBox.GetItemHeight: Integer; 4396 4584 begin … … 4516 4704 begin 4517 4705 FEditBox.AutoSelect := Value; 4706 end; 4707 4708 procedure TORComboBox.SetBlackColorMode(Value: boolean); 4709 begin 4710 if FBlackColorMode <> Value then 4711 begin 4712 FBlackColorMode := Value; 4713 FListBox.SetBlackColorMode(Value); 4714 LoadComboBoxImage; 4715 end; 4518 4716 end; 4519 4717 … … 4774 4972 if (inherited GetEnabled <> Value) then 4775 4973 begin 4974 DroppedDown := FALSE; 4776 4975 inherited SetEnabled(Value); 4777 4976 if assigned(FDropBtn) then 4778 FDropBtn.Glyph.LoadFromResourceName(hInstance, ComboBoxImages[Value]); 4977 LoadComboBoxImage; 4978 // FDropBtn.Glyph.LoadFromResourceName(hInstance, ComboBoxImages[Value]); 4779 4979 end; 4780 4980 end; … … 4837 5037 begin 4838 5038 result := FListBox.Caption; 4839 end;4840 4841 function TORComboBox.MakeAccessible(Accessible: IAccessible): TORListBox;4842 begin4843 FListBox.MakeAccessible(Accessible);4844 result := FListBox;4845 5039 end; 4846 5040 … … 5261 5455 ORCtrls.SetPiece(FStringData, FDelim, FPiece, Value); 5262 5456 end; 5263 end;5264 5265 procedure TORTreeNode.MakeAccessible(Accessible: IAccessible);5266 begin5267 if Assigned(FAccessible) and Assigned(Accessible) then5268 raise Exception.Create(Text + ' Tree Node is already Accessible!')5269 else5270 begin5271 FAccessible := Accessible;5272 end;5273 end;5274 5275 procedure TORTreeNode.WMGetObject(var Message: TMessage);5276 begin5277 if (Message.LParam = integer(OBJID_CLIENT)) and Assigned(FAccessible) then5278 Message.Result := GetLResult(Message.wParam, FAccessible)5279 else5280 inherited;5281 5457 end; 5282 5458 … … 5522 5698 else 5523 5699 Result := ''; 5524 end;5525 5526 procedure TORTreeView.MakeAccessible(Accessible: IAccessible);5527 begin5528 if Assigned(FAccessible) and Assigned(Accessible) then5529 raise Exception.Create(Text + ' Tree View is already Accessible!')5530 else5531 begin5532 FAccessible := Accessible;5533 end;5534 end;5535 5536 procedure TORTreeView.WMGetObject(var Message: TMessage);5537 begin5538 if (Message.LParam = integer(OBJID_CLIENT)) and Assigned(FAccessible) then5539 Message.Result := GetLResult(Message.wParam, FAccessible)5540 else5541 inherited;5542 5700 end; 5543 5701 … … 5908 6066 end; 5909 6067 end; 5910 Bitmap := GetORCBBitmap(ImgIdx );6068 Bitmap := GetORCBBitmap(ImgIdx, FBlackColorMode); 5911 6069 end 5912 6070 else … … 6050 6208 R.Top:= FocusRect.Top 6051 6209 else 6210 begin 6052 6211 R.Top:= ((ClientHeight - Bitmap.Height + 1) div 2) - 1; 6053 6212 if R.Top < 0 then R.Top := 0 6213 end; 6054 6214 Draw(R.Left, R.Top, Bitmap); 6055 6215 end; … … 6145 6305 end; 6146 6306 6307 procedure TORCheckBox.SetBlackColorMode(Value: boolean); 6308 begin 6309 if FBlackColorMode <> Value then 6310 begin 6311 FBlackColorMode := Value; 6312 Invalidate; 6313 end; 6314 end; 6315 6147 6316 procedure TORCheckBox.AutoAdjustSize; 6148 6317 var … … 6276 6445 if DoCtrl then 6277 6446 Ctrl.Enabled := Checked; 6278 if(Ctrl is TWinControl) then 6447 6448 // added (csAcceptsControls in Ctrl.ControlStyle) below to prevent disabling of 6449 // child sub controls, like the TBitBtn in the TORComboBox. If the combo box is 6450 // already disabled, we don't want to disable the button as well - when we do, we 6451 // lose the disabled glyph that is stored on that button for the combo box. 6452 6453 if(Ctrl is TWinControl) and (csAcceptsControls in Ctrl.ControlStyle) then 6279 6454 begin 6280 6455 for i := 0 to TWinControl(Ctrl).ControlCount-1 do … … 6500 6675 end; 6501 6676 6502 procedure TCaptionListBox.MakeAccessible(Accessible: IAccessible);6503 begin 6504 if Assigned(FAccessible) and Assigned(Accessible)then6505 raise Exception.Create(Caption + ' List Box is already Accessible!')6677 function TCaptionListBox.GetDynamicProperty(PropertyID: integer): string; 6678 begin 6679 if PropertyID = DynaPropAccesibilityCaption then 6680 Result := GetCaption 6506 6681 else 6507 FAccessible := Accessible; 6682 Result := ''; 6683 end; 6684 6685 6686 procedure TCaptionListBox.MoveFocusUp; 6687 begin 6688 if ItemIndex > 0 then 6689 Perform(LB_SETCARETINDEX, ItemIndex - 1, 0); 6690 end; 6691 6692 procedure TCaptionListBox.MoveFocusDown; 6693 begin 6694 if ItemIndex < (Items.Count-1) then 6695 Perform(LB_SETCARETINDEX, ItemIndex + 1, 0); 6508 6696 end; 6509 6697 … … 6522 6710 end; 6523 6711 6524 procedure TCaptionListBox.WMGetObject(var Message: TMessage); 6525 begin 6526 if (Message.LParam = integer(OBJID_CLIENT)) and Assigned(FAccessible) then 6527 Message.Result := GetLResult(Message.wParam, FAccessible) 6528 else 6529 inherited; 6712 function TCaptionListBox.SupportsDynamicProperty(PropertyID: integer): boolean; 6713 begin 6714 Result := (PropertyID = DynaPropAccesibilityCaption); 6715 end; 6716 6717 procedure TCaptionListBox.WMKeyDown(var Message: TWMKeyDown); 6718 var 6719 IsSelected: LongBool; 6720 begin 6721 if Boolean(Hi(GetKeyState(VK_CONTROL))) and MultiSelect then 6722 case Message.CharCode of 6723 VK_SPACE: 6724 begin 6725 IsSelected := LongBool(Perform(LB_GETSEL, ItemIndex, 0)); 6726 Perform(LB_SETSEL, Longint(not IsSelected), ItemIndex); 6727 end; 6728 VK_LEFT, VK_UP: MoveFocusUp; 6729 VK_RIGHT, VK_DOWN: MoveFocusDown; 6730 else inherited; 6731 end 6732 else inherited; 6530 6733 end; 6531 6734 … … 6591 6794 end; 6592 6795 6796 function TCaptionCheckListBox.GetDynamicProperty(PropertyID: integer): string; 6797 begin 6798 if PropertyID = DynaPropAccesibilityCaption then 6799 Result := GetCaption 6800 else 6801 Result := ''; 6802 end; 6803 6593 6804 procedure TCaptionCheckListBox.SetCaption(const Value: string); 6594 6805 begin … … 6605 6816 end; 6606 6817 6818 function TCaptionCheckListBox.SupportsDynamicProperty( 6819 PropertyID: integer): boolean; 6820 begin 6821 Result := (PropertyID = DynaPropAccesibilityCaption); 6822 end; 6823 6607 6824 { TCaptionMemo } 6608 6825 … … 6613 6830 else 6614 6831 result := FCaptionComponent.Caption; 6832 end; 6833 6834 function TCaptionMemo.GetDynamicProperty(PropertyID: integer): string; 6835 begin 6836 if PropertyID = DynaPropAccesibilityCaption then 6837 Result := GetCaption 6838 else 6839 Result := ''; 6615 6840 end; 6616 6841 … … 6629 6854 end; 6630 6855 6856 function TCaptionMemo.SupportsDynamicProperty(PropertyID: integer): boolean; 6857 begin 6858 Result := (PropertyID = DynaPropAccesibilityCaption); 6859 end; 6860 6631 6861 { TCaptionEdit } 6632 6862 … … 6637 6867 else 6638 6868 result := FCaptionComponent.Caption; 6869 end; 6870 6871 function TCaptionEdit.GetDynamicProperty(PropertyID: integer): string; 6872 begin 6873 if PropertyID = DynaPropAccesibilityCaption then 6874 Result := GetCaption 6875 else 6876 Result := ''; 6639 6877 end; 6640 6878 … … 6653 6891 end; 6654 6892 6893 function TCaptionEdit.SupportsDynamicProperty(PropertyID: integer): boolean; 6894 begin 6895 Result := (PropertyID = DynaPropAccesibilityCaption); 6896 end; 6897 6655 6898 { TCaptionRichEdit } 6656 6899 6657 procedure TCaptionRichEdit.MakeAccessible(Accessible: IAccessible);6658 begin 6659 if Assigned(FAccessible) and Assigned(Accessible)then6660 raise Exception.Create(Caption + ' Rich Edit is already Accessible!')6900 function TCaptionRichEdit.GetDynamicProperty(PropertyID: integer): string; 6901 begin 6902 if PropertyID = DynaPropAccesibilityCaption then 6903 Result := FCaption 6661 6904 else 6662 FAccessible := Accessible; 6663 end; 6664 6665 procedure TCaptionRichEdit.WMGetObject(var Message: TMessage); 6666 begin 6667 if (Message.LParam = integer(OBJID_CLIENT)) and Assigned(FAccessible) then 6668 Message.Result := GetLResult(Message.wParam, FAccessible) 6905 Result := ''; 6906 end; 6907 6908 6909 function TCaptionRichEdit.SupportsDynamicProperty(PropertyID: integer): boolean; 6910 begin 6911 Result := (PropertyID = DynaPropAccesibilityCaption); 6912 end; 6913 6914 { TCaptionTreeView} 6915 6916 function TCaptionTreeView.GetCaption: string; 6917 begin 6918 result := inherited Caption; 6919 end; 6920 6921 function TCaptionTreeView.GetDynamicProperty(PropertyID: integer): string; 6922 begin 6923 if PropertyID = DynaPropAccesibilityCaption then 6924 Result := GetCaption 6669 6925 else 6670 inherited; 6671 end; 6672 6673 { TCaptionTreeView} 6674 6675 function TCaptionTreeView.GetCaption: string; 6676 begin 6677 result := inherited Caption; 6926 Result := ''; 6678 6927 end; 6679 6928 … … 6693 6942 end; 6694 6943 6944 function TCaptionTreeView.SupportsDynamicProperty(PropertyID: integer): boolean; 6945 begin 6946 Result := (PropertyID = DynaPropAccesibilityCaption); 6947 end; 6948 6695 6949 { TCaptionComboBox } 6696 6950 … … 6701 6955 else 6702 6956 result := FCaptionComponent.Caption; 6957 end; 6958 6959 function TCaptionComboBox.GetDynamicProperty(PropertyID: integer): string; 6960 begin 6961 if PropertyID = DynaPropAccesibilityCaption then 6962 Result := GetCaption 6963 else 6964 Result := ''; 6703 6965 end; 6704 6966 … … 6717 6979 end; 6718 6980 6981 function TCaptionComboBox.SupportsDynamicProperty(PropertyID: integer): boolean; 6982 begin 6983 Result := (PropertyID = DynaPropAccesibilityCaption); 6984 end; 6985 6719 6986 { TORAlignSpeedButton } 6720 6987 … … 6742 7009 result := (ColCount - FixedCols) * (Row - FixedRows) + 6743 7010 (Col - FixedCols) + 1; 7011 end; 7012 7013 function TCaptionStringGrid.GetDynamicProperty(PropertyID: integer): string; 7014 begin 7015 if PropertyID = DynaPropAccesibilityCaption then 7016 Result := FCaption 7017 else 7018 Result := ''; 6744 7019 end; 6745 7020 … … 6761 7036 end; 6762 7037 6763 procedure TCaptionStringGrid.MakeAccessible(Accessible: IAccessible); 6764 begin 6765 if Assigned(FAccessible) and Assigned(Accessible) then 6766 raise Exception.Create(Caption + 'String Grid is already Accessible!') 6767 else 6768 FAccessible := Accessible; 6769 end; 6770 6771 procedure TCaptionStringGrid.WMGetObject(var Message: TMessage); 6772 begin 6773 if (Message.LParam = integer(OBJID_CLIENT)) and Assigned(FAccessible) then 6774 Message.Result := GetLResult(Message.wParam, FAccessible) 6775 else 6776 inherited; 7038 7039 function TCaptionStringGrid.SupportsDynamicProperty( 7040 PropertyID: integer): boolean; 7041 begin 7042 Result := (PropertyID = DynaPropAccesibilityCaption); 6777 7043 end; 6778 7044 … … 6810 7076 if LongList then 6811 7077 begin 6812 //Currently Do nothing for LongLists 6813 { if CompareText(iText, Copy(DisplayText[SelectIndex+1], 1, Length(iText))) = 0 then 6814 Result := -1;} 7078 //Implemented for CQ: 10092, PSI-04-057 7079 //asume long lists are alphabetically ordered... 7080 if CompareText(iText, Copy(DisplayText[SelectIndex+1], 1, Length(iText))) = 0 then 7081 Result := -1; 6815 7082 end 6816 7083 else //Not a LongList … … 6836 7103 end; 6837 7104 7105 { TCaptionListView } 7106 7107 function TCaptionListView.GetDynamicProperty(PropertyID: integer): string; 7108 begin 7109 if PropertyID = DynaPropAccesibilityCaption then 7110 Result := Caption 7111 else 7112 Result := ''; 7113 end; 7114 7115 function TCaptionListView.SupportsDynamicProperty(PropertyID: integer): boolean; 7116 begin 7117 Result := (PropertyID = DynaPropAccesibilityCaption); 7118 end; 7119 6838 7120 initialization 6839 7121 //uItemTip := TItemTip.Create(Application); // all listboxes share a single ItemTip window -
cprs/trunk/CPRS-Lib/ORCtrlsDsgn.pas
r456 r829 153 153 begin 154 154 RegisterComponents('CPRS', 155 [TOR StaticText, TORListBox, TORComboBox, TORAutoPanel, TOROffsetLabel, TORAlignEdit,155 [TORListBox, TORComboBox, TORAutoPanel, TOROffsetLabel, TORAlignEdit, 156 156 TORAlignButton, TORAlignSpeedButton, TORTreeView, TORCheckBox, TORListView, 157 157 TKeyClickPanel, TKeyClickRadioGroup, TCaptionListBox, TCaptionCheckListBox, -
cprs/trunk/CPRS-Lib/ORDtTm.dfm
r456 r829 1 1 object ORfrmDtTm: TORfrmDtTm 2 Left = 5 503 Top = 4 742 Left = 586 3 Top = 483 4 4 BorderIcons = [] 5 5 BorderStyle = bsDialog -
cprs/trunk/CPRS-Lib/ORDtTm.pas
r456 r829 7 7 uses 8 8 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, 9 Grids, Calendar, ExtCtrls, ORFn, ORNet, ORDtTmCal, Mask, ComCtrls, ORCtrls; 9 Grids, Calendar, ExtCtrls, ORFn, ORNet, ORDtTmCal, Mask, ComCtrls, OR2006Compatibility, 10 ORCtrls, VAClasses; 10 11 11 12 type 12 TORfrmDtTm = class(T Form)13 TORfrmDtTm = class(Tfrm2006Compatibility) 13 14 bvlFrame: TBevel; 14 15 lblDate: TPanel; … … 51 52 FNowPressed: Boolean; 52 53 TimeIsRequired: Boolean; 54 protected 55 procedure Loaded; override; 53 56 end; 54 57 … … 75 78 end; 76 79 80 // 508 class 81 TORDateButton = class (TBitBtn); 82 77 83 { TORDateBox } 78 84 … … 82 88 end; 83 89 84 TORDateBox = class(TORDateEdit )90 TORDateBox = class(TORDateEdit, IVADynamicProperty, IORBlackColorModeCompatible) 85 91 private 86 92 FFMDateTime: TFMDateTime; 87 93 FDateOnly: Boolean; 88 94 FRequireTime: Boolean; 89 FButton: T BitBtn;95 FButton: TORDateButton; 90 96 FFormat: string; 91 97 FTimeIsNow: Boolean; 92 98 FTemplateField: boolean; 93 99 FCaption: TStaticText; 100 FBlackColorMode: boolean; 94 101 procedure ButtonClick(Sender: TObject); 95 102 function GetFMDateTime: TFMDateTime; … … 104 111 procedure SetCaption(const Value: string); 105 112 function GetCaption(): string; 106 107 113 protected 108 114 procedure Change; override; 109 115 procedure KeyDown(var Key: Word; Shift: TShiftState); override; 116 property DateButton: TORDateButton read FButton; 110 117 public 111 118 constructor Create(AOwner: TComponent); override; 112 119 function IsValid: Boolean; 113 120 procedure Validate(var ErrMsg: string); 121 procedure SetBlackColorMode(Value: boolean); 122 function SupportsDynamicProperty(PropertyID: integer): boolean; 123 function GetDynamicProperty(PropertyID: integer): string; 114 124 property Format: string read FFormat write FFormat; 115 125 property RelativeTime: string read GetRelativeTime; … … 122 132 end; 123 133 124 TORDateCombo = class(TCustomPanel) 134 // 508 classes 135 TORDayCombo = class (TORComboBox); 136 TORMonthCombo = class (TORComboBox); 137 TORYearEdit = class(TMaskEdit) 138 private 139 FTemplateField: boolean; 140 procedure SetTemplateField(const Value: boolean); 141 protected 142 property TemplateField: boolean read FTemplateField write SetTemplateField; 143 end; 144 145 TORYearEditClass = Class of TORYearEdit; 146 147 TORDateCombo = class(TCustomPanel, IORBlackColorModeCompatible) 125 148 private 126 149 FYearChanging: boolean; 127 FMonthCombo: TOR ComboBox;128 FDayCombo: TOR ComboBox;129 FYearEdit: T MaskEdit;150 FMonthCombo: TORMonthCombo; 151 FDayCombo: TORDayCombo; 152 FYearEdit: TORYearEdit; 130 153 FYearUD: TUpDown; 131 FCalBtn: T SpeedButton;154 FCalBtn: TORDateButton; 132 155 FIncludeMonth: boolean; 133 156 FIncludeDay: boolean; … … 141 164 FRebuilding: boolean; 142 165 FTemplateField: boolean; 166 FBlackColorMode: boolean; 167 FORYearEditClass: TORYearEditClass; 143 168 procedure SetIncludeBtn(const Value: boolean); 144 169 procedure SetIncludeDay(Value: boolean); … … 153 178 procedure SetTemplateField(const Value: boolean); 154 179 protected 155 procedure Rebuild; 180 procedure Rebuild; virtual; 156 181 function InitDays(GetSize: boolean): integer; 157 182 function InitMonths(GetSize: boolean): integer; … … 169 194 procedure Paint; override; 170 195 procedure Resized(Sender: TObject); 196 property MonthCombo: TORMonthCombo read FMonthCombo; 197 property DayCombo: TORDayCombo read FDayCombo; 198 property YearEdit: TORYearEdit read FYearEdit; 199 property YearUD: TUpDown read FYearUD; 200 property CalBtn: TORDateButton read FCalBtn; 201 property ORYearEditClass: TORYearEditClass read FORYearEditClass write FORYearEditClass; 171 202 public 172 203 constructor Create(AOwner: TComponent); override; 173 204 destructor Destroy; override; 174 205 function DateText: string; 206 procedure SetBlackColorMode(Value: boolean); 175 207 property TemplateField: boolean read FTemplateField write SetTemplateField; 176 208 property FMDate: TFMDateTime read GetFMDate write SetFMDate; … … 280 312 end; 281 313 314 procedure LoadEllipsis(bitmap: TBitMap; BlackColorMode: boolean); 315 var 316 ResName: string; 317 begin 318 if BlackColorMode then 319 ResName := 'BLACK_BMP_ELLIPSIS' 320 else 321 ResName := 'BMP_ELLIPSIS'; 322 bitmap.LoadFromResourceName(hInstance, ResName); 323 end; 324 282 325 { TfrmORDtTm -------------------------------------------------------------------------------- } 283 326 … … 351 394 procedure TORfrmDtTm.lstHourClick(Sender: TObject); 352 395 begin 396 if lstHour.ItemIndex = 0 then lstMinute.Items[0] := ':01 --' else lstMinute.Items[0] := ':00 --'; //<------ NEW CODE 353 397 if lstMinute.ItemIndex < 0 then lstMinute.ItemIndex := 0; 354 398 lstMinuteClick(Self); … … 374 418 375 419 AMinute := lstMinute.ItemIndex * 5; 420 if (AnHour = 0) and (AMinute = 0) then AMinute := 1; //<-------------- NEW CODE 376 421 FFromSelf := True; 377 422 // if ampm time - … … 410 455 begin 411 456 x := Trim(txtTime.Text); 412 if (x='00:00') or (x='0:00') or (x='00:00:00') or (x='0:00:00') then x := '00:00:01'; 457 //if (x='00:00') or (x='0:00') or (x='00:00:00') or (x='0:00:00') then x := '00:00:01'; 458 if (x='00:00') or (x='0:00') or (x='00:00:00') or (x='0:00:00') then x := '00:01'; //<------- CHANGED CODE 413 459 StrToTime(x); 414 460 txtTime.Text := x; … … 420 466 begin 421 467 ModalResult := mrCancel; 468 end; 469 470 procedure TORfrmDtTm.Loaded; 471 begin 472 inherited Loaded; 473 UpdateColorsFor508Compliance(Self); 422 474 end; 423 475 … … 515 567 begin 516 568 inherited Create(AOwner); 517 FButton := T BitBtn.Create(Self);569 FButton := TORDateButton.Create(Self); 518 570 FButton.Parent := Self; 519 571 FButton.Width := 18; … … 521 573 FButton.OnClick := ButtonClick; 522 574 FButton.TabStop := False; 523 FButton.Glyph.LoadFromResourceName(hInstance, 'BMP_ELLIPSIS'); 575 FBlackColorMode := False; 576 LoadEllipsis(FButton.Glyph, FALSE); 524 577 FButton.Visible := True; 525 578 FFormat := FMT_DATETIME; … … 567 620 end; 568 621 622 function TORDateBox.SupportsDynamicProperty(PropertyID: integer): boolean; 623 begin 624 Result := (PropertyID = DynaPropAccesibilityCaption); 625 end; 626 569 627 procedure TORDateBox.ButtonClick(Sender: TObject); 570 628 var … … 696 754 if Length(x) = 0 then Result := True else Result := False; 697 755 if Length(Text) = 0 then Result := False; 756 end; 757 758 procedure TORDateBox.SetBlackColorMode(Value: boolean); 759 begin 760 if FBlackColorMode <> Value then 761 begin 762 FBlackColorMode := Value; 763 LoadEllipsis(FButton.Glyph, FBlackColorMode); 764 end; 698 765 end; 699 766 … … 717 784 end; 718 785 786 function TORDateBox.GetDynamicProperty(PropertyID: integer): string; 787 begin 788 if PropertyID = DynaPropAccesibilityCaption then 789 Result := GetCaption 790 else 791 Result := ''; 792 end; 793 719 794 function IsLeapYear(AYear: Integer): Boolean; 720 795 begin … … 745 820 LastYear = 2200; 746 821 747 type748 TORDateComboEdit = class(TMaskEdit)749 private750 FTemplateField: boolean;751 procedure SetTemplateField(const Value: boolean);752 protected753 property TemplateField: boolean read FTemplateField write SetTemplateField;754 end;755 756 822 { TORDateComboEdit } 757 823 758 procedure TOR DateComboEdit.SetTemplateField(const Value: boolean);824 procedure TORYearEdit.SetTemplateField(const Value: boolean); 759 825 begin 760 826 if(FTemplateField <> Value) then … … 779 845 FIncludeBtn := TRUE; 780 846 OnResize := Resized; 847 FORYearEditClass := TORYearEdit; 781 848 end; 782 849 … … 868 935 if(not assigned(FMonthCombo)) then 869 936 begin 870 FMonthCombo := TOR ComboBox.Create(Self);937 FMonthCombo := TORMonthCombo.Create(Self); 871 938 FMonthCombo.Parent := Self; 872 939 FMonthCombo.Top := 0; … … 874 941 FMonthCombo.Style := orcsDropDown; 875 942 FMonthCombo.DropDownCount := 13; 943 FMonthCombo.ListItemsOnly := True; 876 944 FMonthCombo.OnChange := MonthChanged; 877 945 end; … … 888 956 if(not assigned(FDayCombo)) then 889 957 begin 890 FDayCombo := TOR ComboBox.Create(Self);958 FDayCombo := TORDayCombo.Create(Self); 891 959 FDayCombo.Parent := Self; 892 960 FDayCombo.Top := 0; 893 961 FDayCombo.Style := orcsDropDown; 962 FDayCombo.ListItemsOnly := True; 894 963 FDayCombo.OnChange := DayChanged; 895 964 FDayCombo.DropDownCount := 11; … … 914 983 if(not assigned(FYearEdit)) then 915 984 begin 916 FYearEdit := TORDateComboEdit.Create(Self);985 FYearEdit := FORYearEditClass.Create(Self); 917 986 FYearEdit.Parent := Self; 918 987 FYearEdit.Top := 0; … … 922 991 end; 923 992 FYearEdit.Font := Font; 924 TORDateComboEdit(FYearEdit).TemplateField := FTemplateField;993 FYearEdit.TemplateField := FTemplateField; 925 994 Wide := GetYearSize; 926 995 FYearEdit.Width := Wide; … … 947 1016 if(not assigned(FCalBtn)) then 948 1017 begin 949 FCalBtn := TSpeedButton.Create(Self); 1018 FCalBtn := TORDateButton.Create(Self); 1019 FCalBtn.TabStop := FALSE; 950 1020 FCalBtn.Parent := Self; 951 1021 FCalBtn.Top := 0; 952 FCalBtn.Glyph.LoadFromResourceName(hInstance, 'BMP_ELLIPSIS');1022 LoadEllipsis(FCalBtn.Glyph, FBlackColorMode); 953 1023 FCalBtn.OnClick := BtnClicked; 954 1024 end; … … 973 1043 FRebuilding := FALSE; 974 1044 end; 1045 end; 1046 end; 1047 1048 procedure TORDateCombo.SetBlackColorMode(Value: boolean); 1049 begin 1050 if FBlackColorMode <> Value then 1051 begin 1052 FBlackColorMode := Value; 1053 if assigned(FCalBtn) then 1054 LoadEllipsis(FCalBtn.Glyph, FBlackColorMode); 975 1055 end; 976 1056 end; -
cprs/trunk/CPRS-Lib/ORDtTmRng.dfm
r456 r829 18 18 Left = 8 19 19 Top = 44 20 Width = 5 320 Width = 52 21 21 Height = 13 22 22 Caption = 'Begin Date' … … 25 25 Left = 145 26 26 Top = 44 27 Width = 4 527 Width = 44 28 28 Height = 13 29 29 Caption = 'End Date' -
cprs/trunk/CPRS-Lib/ORDtTmRng.pas
r456 r829 5 5 uses 6 6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 7 StdCtrls, ORFn, OR DtTm;7 StdCtrls, ORFn, OR2006Compatibility, ORDtTm; 8 8 9 9 type 10 TORfrmDateRange = class(T Form)10 TORfrmDateRange = class(Tfrm2006Compatibility) 11 11 lblStart: TLabel; 12 12 lblStop: TLabel; … … 21 21 FCalStart: TORDateBox; 22 22 FCalStop: TORDateBox; 23 protected 24 procedure Loaded; override; 23 25 end; 24 26 … … 217 219 FCalStop.TabOrder := 1; 218 220 ResizeAnchoredFormToFont(self); 221 UpdateColorsFor508Compliance(self); 219 222 end; 220 223 … … 225 228 end; 226 229 230 procedure TORfrmDateRange.Loaded; 231 begin 232 inherited Loaded; 233 UpdateColorsFor508Compliance(Self); 234 end; 235 227 236 end. -
cprs/trunk/CPRS-Lib/ORFn.pas
r456 r829 6 6 7 7 uses SysUtils, Windows, Messages, Classes, Controls, StdCtrls, ExtCtrls, ComCtrls, Forms, 8 Graphics, Menus, RichEdit ;8 Graphics, Menus, RichEdit, Buttons; 9 9 10 10 const … … 13 13 BOOLCHAR: array[Boolean] of Char = ('0', '1'); 14 14 UM_STATUSTEXT = (WM_USER + 302); // used to send update status msg to main form 15 COLOR_CREAM = $F0FBFF; 15 16 var 17 ScrollBarHeight: integer = 0; 16 18 17 19 type … … 66 68 function DelimCount(const Str, Delim: string): integer; 67 69 procedure QuickCopy(AFrom, ATo: TObject); 70 procedure QuickAdd(AFrom, ATo: TObject); 71 procedure FastAssign(source, destination: TStrings); 72 procedure FastAddStrings(source, destination: TStrings); 68 73 function ValidFileName(const InitialFileName: string): string; 69 74 … … 84 89 procedure ResizeFormToFont(AForm: TForm); 85 90 procedure ResizeAnchoredFormToFont( AForm: TForm); 91 procedure AdjustForWindowsXPStyleTitleBar(AForm: TForm); 86 92 function ResizeWidth( OldFont: TFont; NewFont: TFont; OldWidth: integer): integer; 87 93 function ResizeHeight( OldFont: TFont; NewFont: TFont; OldHeight: integer): integer; … … 96 102 function PopupComponent(Sender: TObject; PopupMenu: TPopupMenu): TComponent; 97 103 procedure ReformatMemoParagraph(AMemo: TCustomMemo); 98 function ReadOnlyColor: TColor; 104 105 function BlackColorScheme: Boolean; 106 function NormalColorScheme: Boolean; 107 function Get508CompliantColor(Color: TColor): TColor; 108 procedure UpdateColorsFor508Compliance(control: TControl; InputEditControl: boolean = FALSE); 109 procedure UpdateReadOnlyColorScheme(Control: TControl; ReadOnly: boolean); 99 110 100 111 { ListBox Grid functions } … … 116 127 function TabIsPressed : Boolean; 117 128 function ShiftTabIsPressed : Boolean; 129 function EnterIsPressed : Boolean; 118 130 119 131 implementation // --------------------------------------------------------------------------- 120 132 121 133 uses 122 ORCtrls, Grids, Chart, CheckLst ;134 ORCtrls, Grids, Chart, CheckLst, VAUtils; 123 135 124 136 const … … 606 618 function Piece(const S: string; Delim: char; PieceNum: Integer): string; 607 619 { returns the Nth piece (PieceNum) of a string delimited by Delim } 608 var 609 i: Integer; 610 Strt, Next: PChar; 611 begin 612 i := 1; 613 Strt := PChar(S); 614 Next := StrScan(Strt, Delim); 615 while (i < PieceNum) and (Next <> nil) do 616 begin 617 Inc(i); 618 Strt := Next + 1; 619 Next := StrScan(Strt, Delim); 620 end; 621 if Next = nil then Next := StrEnd(Strt); 622 if i < PieceNum then Result := '' else SetString(Result, Strt, Next - Strt); 620 begin 621 Result := VAUtils.Piece(S, Delim, PieceNum); 623 622 end; 624 623 625 624 function Pieces(const S: string; Delim: char; FirstNum, LastNum: Integer): string; 626 { returns several contiguous pieces } 627 var 628 PieceNum: Integer; 629 begin 630 Result := ''; 631 for PieceNum := FirstNum to LastNum do Result := Result + Piece(S, Delim, PieceNum) + Delim; 632 if Length(Result) > 0 then Delete(Result, Length(Result), 1); 625 begin 626 Result := VAUtils.Pieces(S, Delim, FirstNum, LastNum); 633 627 end; 634 628 … … 779 773 if obj is TListBox then 780 774 str[idx] := TListBox(obj).Items 775 else 776 if obj is TORComboBox then 777 str[idx] := TORComboBox(obj).Items 778 else 779 if obj is TComboBox then 780 str[idx] := TComboBox(obj).Items 781 781 else 782 782 if obj is TRichEdit then … … 815 815 if fix[0] then TRichEdit(AFrom).PlainText := FALSE; 816 816 if fix[1] then TRichEdit(ATo).PlainText := FALSE; 817 if ATo is TRichEdit then 818 TRichEdit(ATo).SelStart := Length(TRichEdit(ATo).Lines.Text); //CQ: 16461 819 end; 820 821 type 822 QuickAddError = class(Exception); 823 824 procedure QuickAdd(AFrom, ATo: TObject); 825 var 826 ms: TMemoryStream; 827 idx: integer; 828 str: array[0..1] of TStrings; 829 fix: array[0..1] of boolean; 830 831 procedure GetStrings(obj: TObject); 832 begin 833 if (CompareText(obj.ClassName, 'TRichEditStrings') = 0) then 834 raise QuickCopyError.Create('You must pass the TRichEdit object into QuickAdd, NOT it''s Lines property.'); 835 if obj is TStrings then 836 str[idx] := TStrings(obj) 837 else 838 if obj is TMemo then 839 str[idx] := TMemo(obj).Lines 840 else 841 if obj is TORListBox then 842 str[idx] := TORListBox(obj).Items 843 else 844 if obj is TListBox then 845 str[idx] := TListBox(obj).Items 846 else 847 if obj is TORComboBox then 848 str[idx] := TORComboBox(obj).Items 849 else 850 if obj is TComboBox then 851 str[idx] := TComboBox(obj).Items 852 else 853 if obj is TRichEdit then 854 begin 855 with TRichEdit(obj) do 856 begin 857 str[idx] := Lines; 858 if not PlainText then 859 begin 860 fix[idx] := TRUE; 861 PlainText := TRUE; 862 end; 863 end; 864 end 865 else 866 raise QuickAddError.Create('Unsupported object type (' + obj.ClassName + 867 ') passed into QuickAdd.'); 868 inc(idx); 869 end; 870 871 872 begin 873 fix[0] := FALSE; 874 fix[1] := FALSE; 875 idx := 0; 876 GetStrings(AFrom); 877 GetStrings(ATo); 878 ms := TMemoryStream.Create; 879 try 880 str[1].SaveToStream(ms); 881 ms.Seek(0, soFromEnd); 882 str[0].SaveToStream(ms); 883 ms.Seek(0, soFromBeginning); 884 str[1].Clear; 885 str[1].LoadFromStream(ms); 886 finally 887 ms.Free; 888 end; 889 if fix[0] then TRichEdit(AFrom).PlainText := FALSE; 890 if fix[1] then TRichEdit(ATo).PlainText := FALSE; 891 end; 892 893 procedure FastAssign(source, destination: TStrings); 894 // do not use this with RichEdit Lines unless source is RichEdit with PlainText 895 var 896 ms: TMemoryStream; 897 begin 898 destination.Clear; 899 if (source is TStringList) and (destination is TStringList) then 900 destination.Assign(source) 901 else 902 if (CompareText(source.ClassName, 'TRichEditStrings') = 0) then 903 destination.Assign(source) 904 else 905 begin 906 ms := TMemoryStream.Create; 907 try 908 source.SaveToStream(ms); 909 ms.Seek(0, soFromBeginning); 910 destination.LoadFromStream(ms); 911 finally 912 ms.Free; 913 end; 914 end; 915 end; 916 917 procedure FastAddStrings(source, destination: TStrings); 918 // do not use this with RichEdit Lines unless source and destination are RichEdit with PlainText 919 var 920 ms: TMemoryStream; 921 begin 922 if (source is TStringList) and (destination is TStringList) then 923 destination.AddStrings(source) 924 else 925 begin 926 ms := TMemoryStream.Create; 927 try 928 destination.SaveToStream(ms); 929 ms.Seek(0, soFromEnd); 930 source.SaveToStream(ms); 931 ms.Seek(0, soFromBeginning); 932 destination.Clear; 933 destination.LoadFromStream(ms); 934 finally 935 ms.Free; 936 end; 937 end; 817 938 end; 818 939 … … 861 982 end; {for i} 862 983 AList.Clear; 863 AList.Assign(NewList);984 FastAssign(NewList, AList); 864 985 finally 865 986 NewList.Free; … … 1248 1369 end; 1249 1370 1371 var 1372 AlignList, AnchorList: TStringList; 1373 1374 function AnchorsToStr(Control: TControl): string; 1375 var 1376 j: TAnchorKind; 1377 1378 begin 1379 Result := ''; 1380 for j := low(TAnchorKind) to high(TAnchorKind) do 1381 if j in Control.Anchors then 1382 Result := result + '1' 1383 else 1384 Result := result + '0' 1385 end; 1386 1387 function StrToAnchors(i: integer): TAnchors; 1388 var 1389 j: TAnchorKind; 1390 value: string; 1391 idx : integer; 1392 begin 1393 Result := []; 1394 value := AnchorList[i]; 1395 idx := 1; 1396 for j := low(TAnchorKind) to high(TAnchorKind) do 1397 begin 1398 if copy(value,idx,1) = '1' then 1399 include(Result, j); 1400 inc(idx); 1401 end; 1402 end; 1403 1404 procedure SuspendAlign(AForm: TForm); 1405 var 1406 i: integer; 1407 control: TControl; 1408 begin 1409 AForm.DisableAlign; 1410 AlignList.Clear; 1411 AnchorList.Clear; 1412 for i := 0 to AForm.ControlCount-1 do 1413 begin 1414 control := AForm.Controls[i]; 1415 AlignList.Add(IntToStr(ord(control.align))); 1416 control.Align := alNone; 1417 AnchorList.Add(AnchorsToStr(control)); 1418 control.Anchors := []; 1419 end; 1420 end; 1421 1422 procedure RestoreAlign(AForm: TForm); 1423 var 1424 i: integer; 1425 control: TControl; 1426 begin 1427 try 1428 for i := 0 to AForm.ControlCount-1 do 1429 begin 1430 control := AForm.Controls[i]; 1431 control.Align := TAlign(StrToIntDef(AlignList[i],0)); 1432 control.Anchors := StrToAnchors(i); 1433 end; 1434 AlignList.Clear; 1435 AnchorList.Clear; 1436 finally 1437 AForm.EnableAlign; 1438 end; 1439 end; 1440 1250 1441 procedure ResizeFormToFont(AForm: TForm); 1251 1442 var 1252 1443 Rect: TRect; 1253 begin 1444 OldResize: TNotifyEvent; 1445 begin 1446 // CQ# 11481 apply size changes to form all at once, instead of piece by piece. Otherwise, 1447 // multiple calls to fAutoSz.FormResize, even if the form has not resized, can distort 1448 // the controls beyond the size of the form. 1254 1449 with AForm do begin 1255 ClientWidth := ResizeWidth( Font, MainFont, ClientWidth); 1256 ClientHeight := ResizeHeight( Font, MainFont, ClientHeight); 1257 HorzScrollBar.Range := ResizeWidth( Font, MainFont, HorzScrollBar.Range); 1258 VertScrollBar.Range := ResizeHeight( Font, MainFont, VertScrollBar.Range); 1259 Rect := BoundsRect; 1260 ForceInsideWorkArea(Rect); 1261 BoundsRect := Rect; 1262 ResizeFontsInDescendants( Font, MainFont, AForm); 1263 //Important: We are using the font to calculate everything, so don't 1264 //change font until now. 1265 Font.Size := MainFont.Size; 1450 OldResize := AForm.OnResize; 1451 AForm.OnResize := nil; 1452 try 1453 SuspendAlign(AForm); 1454 try 1455 HorzScrollBar.Range := ResizeWidth( Font, MainFont, HorzScrollBar.Range); 1456 VertScrollBar.Range := ResizeHeight( Font, MainFont, VertScrollBar.Range); 1457 ClientWidth := ResizeWidth( Font, MainFont, ClientWidth); 1458 ClientHeight := ResizeHeight( Font, MainFont, ClientHeight); 1459 Rect := BoundsRect; 1460 ForceInsideWorkArea(Rect); 1461 BoundsRect := Rect; 1462 finally 1463 RestoreAlign(AForm); 1464 end; 1465 ResizeFontsInDescendants( Font, MainFont, AForm); 1466 //Important: We are using the font to calculate everything, so don't 1467 //change font until now. 1468 Font.Size := MainFont.Size; 1469 finally 1470 if(Assigned(OldResize)) then 1471 begin 1472 AForm.OnResize := OldResize; 1473 OldResize(AForm); 1474 end; 1475 end; 1266 1476 end; 1267 1477 end; … … 1270 1480 var 1271 1481 Rect: TRect; 1482 OldResize: TNotifyEvent; 1483 1272 1484 begin 1273 1485 with AForm do begin 1274 ClientWidth := ResizeWidth( Font, MainFont, ClientWidth); 1275 ClientHeight := ResizeHeight( Font, MainFont, ClientHeight); 1276 HorzScrollBar.Range := ResizeWidth( Font, MainFont, HorzScrollBar.Range); 1277 VertScrollBar.Range := ResizeHeight( Font, MainFont, VertScrollBar.Range); 1278 Rect := BoundsRect; 1279 ForceInsideWorkArea(Rect); 1280 BoundsRect := Rect; 1281 ResizeDescendants( Font, MainFont, AForm); 1282 ResizeFontsInDescendants( Font, MainFont, AForm); 1283 //Important: We are using the font to calculate everything, so don't 1284 //change font until now. 1285 Font.Size := MainFont.Size; 1486 // CQ# 11481 - see ResizeFormToFont 1487 OldResize := AForm.OnResize; 1488 AForm.OnResize := nil; 1489 try 1490 HorzScrollBar.Range := ResizeWidth( Font, MainFont, HorzScrollBar.Range); 1491 VertScrollBar.Range := ResizeHeight( Font, MainFont, VertScrollBar.Range); 1492 ClientWidth := ResizeWidth( Font, MainFont, ClientWidth); 1493 ClientHeight := ResizeHeight( Font, MainFont, ClientHeight); 1494 Rect := BoundsRect; 1495 ForceInsideWorkArea(Rect); 1496 BoundsRect := Rect; 1497 ResizeDescendants( Font, MainFont, AForm); 1498 ResizeFontsInDescendants( Font, MainFont, AForm); 1499 //Important: We are using the font to calculate everything, so don't 1500 //change font until now. 1501 Font.Size := MainFont.Size; 1502 finally 1503 if(Assigned(OldResize)) then 1504 begin 1505 AForm.OnResize := OldResize; 1506 OldResize(AForm); 1507 end; 1508 end; 1509 end; 1510 end; 1511 1512 // CQ 11485 - Adjusts all forms - adds additional height to the form to 1513 // adjust for Windows XP style title bars, and for large fonts in title bar 1514 procedure AdjustForWindowsXPStyleTitleBar(AForm: TForm); 1515 const 1516 DEFAULT_CAPTION_HEIGHT = 19; 1517 DEFAULT_MENU_HEIGHT = 19; 1518 1519 var 1520 dxsb, dysb, dy, menuDY: integer; 1521 1522 begin 1523 // Call GetSystemMetrics each time because values can change between calls 1524 dy := GetSystemMetrics(SM_CYCAPTION) - DEFAULT_CAPTION_HEIGHT; 1525 if (AForm.Menu <> nil) then 1526 begin 1527 menuDY := GetSystemMetrics(SM_CYMENU) - DEFAULT_MENU_HEIGHT; 1528 inc(dy, menuDY); 1529 end; 1530 if dy <> 0 then 1531 begin 1532 SuspendAlign(AForm); 1533 try 1534 // Assitional adjustment to allow scroll bars to dissappear 1535 dxsb := GetSystemMetrics(SM_CXVSCROLL); 1536 dysb := GetSystemMetrics(SM_CYHSCROLL); 1537 AForm.Height := AForm.Height + dy + dysb; 1538 AForm.Width := AForm.Width + dxsb; 1539 AForm.Height := AForm.Height - dysb; 1540 AForm.Width := AForm.Width - dxsb; 1541 finally 1542 RestoreAlign(AForm); 1543 end; 1286 1544 end; 1287 1545 end; … … 1329 1587 begin 1330 1588 DC := GetDC(0); 1331 SaveFont := SelectObject(DC, AFontHandle); 1332 GetTextExtentPoint32(DC, PChar(x), Length(x), TextSize); 1333 Result := TextSize.cx; 1334 SelectObject(DC, SaveFont); 1335 ReleaseDC(0, DC); 1589 try 1590 SaveFont := SelectObject(DC, AFontHandle); 1591 try 1592 GetTextExtentPoint32(DC, PChar(x), Length(x), TextSize); 1593 Result := TextSize.cx; 1594 finally 1595 SelectObject(DC, SaveFont); 1596 end; 1597 finally 1598 ReleaseDC(0, DC); 1599 end; 1336 1600 end; 1337 1601 … … 1344 1608 begin 1345 1609 DC := GetDC(0); 1346 SaveFont := SelectObject(DC, AFontHandle); 1347 GetTextExtentPoint32(DC, PChar(x), Length(x), TextSize); 1348 Result := TextSize.cy; 1349 SelectObject(DC, SaveFont); 1350 ReleaseDC(0, DC); 1610 try 1611 SaveFont := SelectObject(DC, AFontHandle); 1612 try 1613 GetTextExtentPoint32(DC, PChar(x), Length(x), TextSize); 1614 Result := TextSize.cy; 1615 finally 1616 SelectObject(DC, SaveFont); 1617 end; 1618 finally 1619 ReleaseDC(0, DC); 1620 end; 1621 if Result > 255 then // CQ 11493 1622 Result := 255; // This is maximum allowed by a Windows 1351 1623 end; 1352 1624 … … 1393 1665 end; 1394 1666 end; 1667 if Result > 255 then // CQ 11492 1668 Result := 255; // This is maximum allowed by a Windows 1395 1669 end; 1396 1670 … … 1471 1745 1472 1746 var 1473 uReadOnlyColor: TColor; 1474 uHaveReadOnlyColor: boolean = FALSE; 1475 1476 function ReadOnlyColor: TColor; 1477 begin 1478 if not uHaveReadOnlyColor then 1479 begin 1480 uHaveReadOnlyColor := TRUE; 1481 if ColorToRGB(clWindow) = ColorToRGB(clWhite) then 1482 uReadOnlyColor := $00F0FBFF 1747 uNormalColorScheme: boolean = false; 1748 uBlackColorScheme: boolean = false; 1749 uWhiteColorScheme: boolean = false; 1750 uMaroonColorWhenBlack: TColor = clMaroon; 1751 uCheckColorScheme: boolean = true; 1752 PURE_BLACK: longint = 0; 1753 1754 const 1755 uBorderlessWindowColorWhenBlack: TColor = clNavy; 1756 1757 1758 procedure CheckColorScheme; 1759 begin 1760 if uCheckColorScheme then 1761 begin 1762 uNormalColorScheme := 1763 ((ColorToRGB(clWindow) = ColorToRGB(clWhite)) and 1764 (ColorToRGB(clWindowText) = ColorToRGB(clBlack)) and 1765 (ColorToRGB(clInfoText) = ColorToRGB(clBlack)) and 1766 (ColorToRGB(clInfoBk) <> ColorToRGB(clWhite))); 1767 1768 uBlackColorScheme := ((ColorToRGB(clBtnFace) = ColorToRGB(clBlack)) and 1769 (ColorToRGB(clWindow) = ColorToRGB(clBlack))); 1770 uWhiteColorScheme := ((ColorToRGB(clBtnFace) = ColorToRGB(clWhite)) and 1771 (ColorToRGB(clWindow) = ColorToRGB(clWhite))); 1772 1773 if uBlackColorScheme then 1774 begin 1775 if(ColorToRGB(clGrayText) = ColorToRGB(clWindowText)) then 1776 uMaroonColorWhenBlack := clHighlightText 1777 else 1778 uMaroonColorWhenBlack := clGrayText; 1779 end; 1780 1781 uCheckColorScheme := FALSE; 1782 end; 1783 end; 1784 1785 function BlackColorScheme: Boolean; 1786 begin 1787 if uCheckColorScheme then CheckColorScheme; 1788 Result := uBlackColorScheme; 1789 end; 1790 1791 function NormalColorScheme: Boolean; 1792 begin 1793 if uCheckColorScheme then CheckColorScheme; 1794 Result := uNormalColorScheme; 1795 end; 1796 1797 function Get508CompliantColor(Color: TColor): TColor; 1798 begin 1799 Result := Color; 1800 if NormalColorScheme then exit; 1801 1802 case Color of 1803 clCream: Result := clInfoBk; 1804 clBlack: Result := clWindowText; 1805 clWhite: Result := clWindow; 1806 end; 1807 1808 if uBlackColorScheme then 1809 begin 1810 case Color of 1811 clBlue: Result := clAqua; 1812 clMaroon: Result := uMaroonColorWhenBlack; 1813 // clRed: Result := clFuchsia; 1814 end; 1815 end; 1816 1817 if uWhiteColorScheme then 1818 begin 1819 case Color of 1820 clGrayText: Result := clGray; 1821 end; 1822 end; 1823 end; 1824 1825 type 1826 TExposedControl = class(TControl) 1827 public 1828 property Color; 1829 property Font; 1830 end; 1831 1832 TExposedCustomEdit = class(TCustomEdit) 1833 public 1834 property BorderStyle; 1835 property ReadOnly; 1836 end; 1837 1838 procedure UpdateColorsFor508Compliance(control: TControl; InputEditControl: boolean = FALSE); 1839 var 1840 BitMapLevelCheck: integer; 1841 Level: integer; 1842 1843 1844 procedure BlackColorSchemeUpdate(control: TControl); 1845 var 1846 bitmap: TBitMap; 1847 edit: TExposedCustomEdit; 1848 x,y: integer; 1849 cbmCtrl: IORBlackColorModeCompatible; 1850 1851 begin 1852 if uBlackColorScheme then 1853 begin 1854 if Level < BitMapLevelCheck then 1855 begin 1856 if control.GetInterface(IORBlackColorModeCompatible, cbmCtrl) then 1857 begin 1858 cbmCtrl.SetBlackColorMode(TRUE); 1859 BitMapLevelCheck := Level; 1860 cbmCtrl := nil; 1861 end 1862 else 1863 begin 1864 if (control is TBitBtn) then 1865 begin 1866 bitmap := TBitBtn(control).Glyph; 1867 for x := 0 to bitmap.Width-1 do 1868 begin 1869 for y := 0 to bitmap.Height-1 do 1870 begin 1871 if ColorToRGB(bitmap.Canvas.Pixels[x,y]) = PURE_BLACK then 1872 bitmap.Canvas.Pixels[x,y] := clWindowText; 1873 end; 1874 end; 1875 end; 1876 end; 1877 end; 1878 1879 if (control is TCustomEdit) and InputEditControl then 1880 begin 1881 edit := TExposedCustomEdit(control); 1882 if (edit.BorderStyle = bsNone) then 1883 edit.Color := uBorderlessWindowColorWhenBlack; 1884 end; 1885 1886 end; 1887 end; 1888 1889 procedure ComponentUpdateColorsFor508Compliance(control: TControl); 1890 var 1891 OldComponentColor, OldFontColor, NewComponentColor, NewFontColor: TColor; 1892 begin 1893 OldComponentColor := TExposedControl(control).Color; 1894 OldFontColor := TExposedControl(control).Font.Color; 1895 NewComponentColor := Get508CompliantColor(OldComponentColor); 1896 if NewComponentColor = clInfoBk then 1897 begin 1898 if (OldFontColor = clInfoBk) or (OldFontColor = clCream) then 1899 NewFontColor := clInfoBk // used for hiding text 1900 else 1901 NewFontColor := clInfoText; 1902 end 1483 1903 else 1484 uReadOnlyColor := clWindow; 1485 end; 1486 Result := uReadOnlyColor; 1904 NewFontColor := Get508CompliantColor(OldFontColor); 1905 if NewComponentColor <> OldComponentColor then 1906 TExposedControl(control).Color := NewComponentColor; 1907 if NewFontColor <> OldFontColor then 1908 TExposedControl(control).Font.Color := NewFontColor; 1909 BlackColorSchemeUpdate(control); 1910 end; 1911 1912 procedure ScanAllComponents(control: TControl); 1913 var 1914 i: integer; 1915 1916 begin 1917 ComponentUpdateColorsFor508Compliance(Control); 1918 if control is TWinControl then 1919 begin 1920 inc(Level); 1921 try 1922 for i := 0 to TWinControl(Control).ControlCount-1 do 1923 begin 1924 ScanAllComponents(TWinControl(Control).Controls[i]); 1925 end; 1926 finally 1927 dec(Level); 1928 if BitMapLevelCheck = Level then 1929 BitMapLevelCheck := MaxInt; 1930 end; 1931 end; 1932 end; 1933 1934 begin 1935 if NormalColorScheme then exit; 1936 BitMapLevelCheck := MaxInt; 1937 Level := 0; 1938 ScanAllComponents(control); 1939 end; 1940 1941 procedure UpdateReadOnlyColorScheme(Control: TControl; ReadOnly: boolean); 1942 begin 1943 with TExposedControl(Control) do 1944 begin 1945 if ReadOnly then 1946 begin 1947 Color := Get508CompliantColor(clCream); 1948 Font.Color := clInfoText; 1949 end 1950 else 1951 begin 1952 Color := clWindow; 1953 Font.Color := clWindowText; 1954 end; 1955 end; 1487 1956 end; 1488 1957 … … 1521 1990 end; 1522 1991 Canvas.FillRect(ARect); 1523 Canvas.Pen.Color := clSilver;1992 Canvas.Pen.Color := Get508CompliantColor(clSilver); 1524 1993 Canvas.MoveTo(ARect.Left, ARect.Bottom - 1); 1525 1994 Canvas.LineTo(ARect.Right, ARect.Bottom - 1); … … 1714 2183 begin 1715 2184 Result := Boolean(Hi(GetKeyState(VK_TAB))) and not Boolean(Hi(GetKeyState(VK_SHIFT))); 2185 Result := Result and not Boolean(Hi(GetKeyState(VK_CONTROL))); 1716 2186 end; 1717 2187 … … 1719 2189 begin 1720 2190 Result := Boolean(Hi(GetKeyState(VK_TAB))) and Boolean(Hi(GetKeyState(VK_SHIFT))); 1721 end; 1722 2191 Result := Result and not Boolean(Hi(GetKeyState(VK_CONTROL))); 2192 end; 2193 2194 function EnterIsPressed : Boolean; 2195 begin 2196 Result := Boolean(Hi(GetKeyState(VK_RETURN))); 2197 end; 1723 2198 1724 2199 initialization … … 1726 2201 FBaseFont.Name := BaseFontName; 1727 2202 FBaseFont.Size := BaseFontSize; 2203 ScrollBarHeight := GetSystemMetrics(SM_CYHSCROLL); 2204 AlignList := TStringList.Create; 2205 AnchorList := TStringList.Create; 2206 PURE_BLACK := ColorToRGB(clBlack); 1728 2207 1729 2208 finalization 1730 2209 FBaseFont.Free; 1731 2210 KillObj(@IdleCaller); 2211 FreeAndNil(AlignList); 2212 FreeAndNil(AnchorList); 1732 2213 1733 2214 end. -
cprs/trunk/CPRS-Lib/ORNet.pas
r456 r829 43 43 {$ENDIF} 44 44 RPCLastCall: string; 45 46 AppStartedCursorForm: TForm = nil; 45 47 46 48 implementation … … 263 265 AStringList.Add(' '); 264 266 AStringList.Add('Results -----------------------------------------------------------------'); 265 AStringList.AddStrings(RPCBrokerV.Results);267 FastAddStrings(RPCBrokerV.Results, AStringList); 266 268 uCallList.Add(AStringList); 267 269 if uShowRPCs then StatusText(''); … … 347 349 end; 348 350 351 function GetRPCCursor: TCursor; 352 var 353 pt: TPoint; 354 begin 355 Result := crHourGlass; 356 if assigned(AppStartedCursorForm) and (AppStartedCursorForm.Visible) then 357 begin 358 pt := Mouse.CursorPos; 359 if PtInRect(AppStartedCursorForm.BoundsRect, pt) then 360 Result := crAppStart; 361 end; 362 end; 363 349 364 procedure CallV(const RPCName: string; const AParam: array of const); 350 365 { calls the broker leaving results in results property which must be read by caller } … … 353 368 begin 354 369 SavedCursor := Screen.Cursor; 355 Screen.Cursor := crHourGlass;370 Screen.Cursor := GetRPCCursor; 356 371 SetParams(RPCName, AParam); 357 372 CallBroker; //RPCBrokerV.Call; … … 365 380 begin 366 381 SavedCursor := Screen.Cursor; 367 Screen.Cursor := crHourGlass;382 Screen.Cursor := GetRPCCursor; 368 383 SetParams(RPCName, AParam); 369 384 CallBroker; //RPCBrokerV.Call; … … 379 394 if ReturnData = nil then raise Exception.Create('TString not created'); 380 395 SavedCursor := Screen.Cursor; 381 Screen.Cursor := crHourGlass;396 Screen.Cursor := GetRPCCursor; 382 397 SetParams(RPCName, AParam); 383 398 CallBroker; //RPCBrokerV.Call; 384 ReturnData.Assign(RPCBrokerV.Results);399 FastAssign(RPCBrokerV.Results, ReturnData); 385 400 Screen.Cursor := SavedCursor; 386 401 end; … … 395 410 begin 396 411 SavedCursor := Screen.Cursor; 397 Screen.Cursor := crHourGlass;412 Screen.Cursor := GetRPCCursor; 398 413 SetParams(RPCName, AParam); 399 414 RPCBrokerV.Call; … … 450 465 procedure LoadRPCData(Dest: TStrings; ID: Integer); 451 466 begin 452 if (ID > -1) and (ID < uCallList.Count) then Dest.Assign(TStringList(uCallList.Items[ID]));467 if (ID > -1) and (ID < uCallList.Count) then FastAssign(TStringList(uCallList.Items[ID]), Dest); 453 468 end; 454 469 -
cprs/trunk/CPRS-Lib/ORSystem.pas
r456 r829 2 2 3 3 {$O-} 4 {$WARN SYMBOL_PLATFORM OFF} 4 5 5 6 interface … … 19 20 CPRS_LAST_DATE = 'Software\Vista\CPRS\DateUpdated'; 20 21 21 { values that can be passed to FileVersionValue }22 FILE_VER_COMPANYNAME = '\StringFileInfo\040904E4\CompanyName';23 FILE_VER_FILEDESCRIPTION = '\StringFileInfo\040904E4\FileDescription';24 FILE_VER_FILEVERSION = '\StringFileInfo\040904E4\FileVersion';25 FILE_VER_INTERNALNAME = '\StringFileInfo\040904E4\InternalName';26 FILE_VER_LEGALCOPYRIGHT = '\StringFileInfo\040904E4\LegalCopyright';27 FILE_VER_ORIGINALFILENAME = '\StringFileInfo\040904E4\OriginalFilename';28 FILE_VER_PRODUCTNAME = '\StringFileInfo\040904E4\ProductName';29 FILE_VER_PRODUCTVERSION = '\StringFileInfo\040904E4\ProductVersion';30 FILE_VER_COMMENTS = '\StringFileInfo\040904E4\Comments';31 32 33 22 function AppOutOfDate(AppName: string): Boolean; 34 23 function ClientVersion(const AFileName: string): string; … … 40 29 //procedure FileCopy(const FromFileName, ToFileName: string); 41 30 //procedure FileCopyWithDate(const FromFileName, ToFileName: string); 42 function FileVersionValue(const AFileName, AValueName: string): string;43 31 function FullToFilePart(const AFileName: string): string; 44 32 function FullToPathPart(const AFileName: string): string; … … 60 48 procedure RunProgram(const AppName: string); 61 49 function UpdateSelf: Boolean; 50 function BorlandDLLVersionOK: boolean; 62 51 63 52 implementation … … 110 99 // check for different file date in the gold directory 111 100 GoldName := RegReadStr(CPRS_REG_GOLD); 112 if Length(GoldName) = 0 then Exit; 101 if (Length(GoldName) = 0) then exit; 102 if not DirectoryExists(GoldName) then 103 begin 104 if Pos('"', Goldname) > 0 then 105 begin 106 Goldname := Copy(GoldName, 2, MaxInt); 107 if Pos('"', Goldname) > 0 then 108 Goldname := Copy(GoldName, 1, Length(GoldName) - 1); 109 end; 110 end; 111 if (not DirectoryExists(GoldName)) then Exit; 113 112 GoldName := GoldName + FullToFilePart(AppName); 114 113 if FileExists(GoldName) then … … 139 138 IntToStr(HIWORD(dwFileVersionLS)) + '.' + 140 139 IntToStr(LOWORD(dwFileVersionLS)); 141 end;142 end;143 144 function FileVersionValue(const AFileName, AValueName: string): string;145 type146 PValBuf = ^TValBuf;147 TValBuf = array[0..255] of Char;148 var149 VerSize, ValSize, AHandle: DWORD;150 VerBuf: Pointer;151 ValBuf: PValBuf;152 begin153 Result := '';154 VerSize:=GetFileVersionInfoSize(PChar(AFileName), AHandle);155 if VerSize > 0 then156 begin157 GetMem(VerBuf, VerSize);158 try159 GetFileVersionInfo(PChar(AFileName), AHandle, VerSize, VerBuf);160 VerQueryValue(VerBuf, PChar(AValueName), Pointer(ValBuf), ValSize);161 SetString(Result, ValBuf^, ValSize);162 finally163 FreeMem(VerBuf);164 end;165 140 end; 166 141 end; … … 551 526 *) 552 527 528 function BorlandDLLVersionOK: boolean; 529 const 530 DLL_CURRENT_VERSION = 10; 531 TC_DLL_ERR = 'ERROR - BORLNDMM.DLL'; 532 TX_NO_RUN = 'This version of CPRS is unable to run because' + CRLF; 533 TX_NO_DLL = 'no copy of BORLNDMM.DLL can be found' + CRLF + 534 'in your workstation''s current PATH.'; 535 TX_OLD_DLL1 = 'the copy of BORLNDMM.DLL located at:' + CRLF + CRLF; 536 TX_OLD_DLL2 = CRLF + CRLF + 'is out of date (Version '; 537 TX_CALL_IRM = CRLF + CRLF +'Please contact IRM for assistance.'; 538 var 539 DLLHandle: HMODULE; 540 DLLNamePath: array[0..261] of Char; 541 DLLVersion: string; 542 begin 543 Result := TRUE; 544 DLLHandle := GetModuleHandle('BORLNDMM.DLL'); 545 if DLLHandle <=0 then 546 begin 547 InfoBox(TX_NO_RUN + TX_NO_DLL + TX_CALL_IRM, TC_DLL_ERR, MB_ICONERROR or MB_OK); 548 Result := FALSE; 549 Exit; 550 end; 551 Windows.GetModuleFileName(DLLHandle, DLLNamePath, 261); 552 DLLVersion := ClientVersion(DLLNamePath); 553 if StrToIntDef(Piece(DLLVersion, '.', 1), 0) < DLL_CURRENT_VERSION then 554 begin 555 InfoBox(TX_NO_RUN + TX_OLD_DLL1 + ' ' + DLLNamePath + TX_OLD_DLL2 + DLLVersion + ')' + 556 TX_CALL_IRM, TC_DLL_ERR, MB_ICONERROR or MB_OK); 557 Result := false; 558 end; 559 end; 560 553 561 end.
Note:
See TracChangeset
for help on using the changeset viewer.