Changeset 829 for cprs/trunk/CPRS-Lib/ORCtrls.pas
- Timestamp:
- Jul 7, 2010, 4:31:10 PM (14 years ago)
- File:
-
- 1 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
Note:
See TracChangeset
for help on using the changeset viewer.