Changeset 492 for cprs/branches/GUI-config/CPRS-Lib/ORCtrls.pas
- Timestamp:
- Sep 17, 2008, 5:34:43 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/branches/GUI-config/CPRS-Lib/ORCtrls.pas
r476 r492 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; 33 end; 34 23 35 TORComboBox = class; // forward declaration for FParentCombo 24 36 … … 230 242 property MItems: TStrings read GetMItems write SetMItems; 231 243 procedure MakeAccessible(Accessible: IAccessible); 244 function VerifyUnique(SelectIndex: Integer; iText: String): integer; 232 245 published 233 246 property AllowGrayed: boolean read FAllowGrayed write FAllowGrayed default FALSE; … … 325 338 FCheckBoxEditColor: TColor; // Edit Box color for Check Box Combo List, when not in Focus 326 339 FTemplateField: boolean; 340 FCharsNeedMatch: integer; // how many text need to be matched for auto selection 341 FUniqueAutoComplete: Boolean; // If true only perform autocomplete for unique list items. 327 342 function EditControl: TWinControl; 328 343 procedure AdjustSizeOfSelf; … … 342 357 procedure FwdNeedData(Sender: TObject; const StartFrom: string; 343 358 Direction, InsertAt: Integer); 359 procedure SetNumForMatch(const NumberForMatch: integer); 344 360 function GetAutoSelect: Boolean; 345 361 function GetColor: TColor; … … 423 439 function GetLookupPiece: integer; 424 440 procedure SetLookupPiece(const Value: integer); 441 procedure SetUniqueAutoComplete(const Value: Boolean); 425 442 protected 426 443 procedure DropPanelBtnPressed(OKBtn, AutoClose: boolean); … … 441 458 procedure InitLongList(S: string); 442 459 procedure InsertSeparator; 460 procedure SetTextAutoComplete(TextToMatch : String); 443 461 function GetIEN(AnIndex: Integer): Int64; 444 462 function SelectByIEN(AnIEN: Int64): Integer; … … 522 540 property OnResize; 523 541 property OnSynonymCheck: TORSynonymCheckEvent read GetOnSynonymCheck write SetOnSynonymCheck; 542 property CharsNeedMatch: integer read FCharsNeedMatch write SetNumForMatch; 543 {UniqueAutoComplete Was added as a result of the following defects: 544 7293 - PTM 85: Backspace and Dosage: Desired dosage does not populate if dosage is not in local dosage field 545 7337 - PTM 160 Meds: #8 IMO - Simple - Change Order in which Error generated if "Enter" is hit instead of "OK" 546 7278 - PTM 36 Meds: Select 40000 UNT/2ML and backspace to 4000 the dose selected remains 40000 547 7284 - Inconsistencies of pulling in a dose from the Possible Dose File } 548 property UniqueAutoComplete: Boolean read FUniqueAutoComplete write SetUniqueAutoComplete default False; 524 549 end; 525 550 … … 776 801 procedure WMSize (var Message: TWMSize); message WM_SIZE; 777 802 procedure BMSetCheck (var Message: TMessage); message BM_SETCHECK; 803 procedure BMGetCheck (var Message: TMessage); message BM_GETCHECK; 804 procedure BMGetState (var Message: TMessage); message BM_GETSTATE; 778 805 function GetImageList: TCustomImageList; 779 806 function GetImageIndexes: string; … … 874 901 TCaptionListBox = class(TListBox) 875 902 private 903 FHoverItemPos: integer; 876 904 FAccessible: IAccessible; 877 905 FRightClickSelect: boolean; // When true, a right click selects teh item 906 FHintOnItem: boolean; 878 907 procedure SetCaption(const Value: string); 879 908 function GetCaption: string; 880 909 procedure WMGetObject(var Message: TMessage); message WM_GETOBJECT; 881 910 procedure WMRButtonUp(var Message: TWMRButtonUp); message WM_RBUTTONUP; 911 procedure WMMouseMove(var Message: TWMMouseMove); message WM_MOUSEMOVE; 882 912 protected 883 913 FCaptionComponent: TStaticText; 914 procedure DoEnter; override; 884 915 public 885 916 procedure MakeAccessible( Accessible: IAccessible); … … 887 918 property RightClickSelect: boolean read FRightClickSelect write FRightClickSelect default FALSE; 888 919 property Caption: string read GetCaption write SetCaption; 920 //Make the ListBox's hint contain the contents of the listbox Item the mouse is currently over. 921 property HintOnItem: boolean read FHintOnItem write FHintOnItem default FALSE; 889 922 end; 890 923 … … 918 951 property Align; 919 952 property Caption: string read GetCaption write SetCaption; 953 end; 954 955 TCaptionRichEdit = class(TRichEdit) 956 private 957 FAccessible: IAccessible; 958 procedure WMGetObject(var Message: TMessage); message WM_GETOBJECT; 959 protected 960 FCaption: string; 961 public 962 procedure MakeAccessible(Accessible: IAccessible); 963 published 964 property Align; 965 property Caption: string read FCaption write FCaption; 920 966 end; 921 967 … … 961 1007 function CalcShortName( LongName: string; PrevLongName: string): string; 962 1008 1009 {Returns True if any one of 3 mouse buttons are down left, right, or middle} 1010 function IsAMouseButtonDown : boolean; 1011 963 1012 implementation // --------------------------------------------------------------------------- 964 1013 … … 1006 1055 FPoint: TPoint; 1007 1056 FSelected: boolean; 1057 FTabs: array[0..MAX_TABS] of Integer; // Holds the pixel offsets for tabs 1058 procedure GetTabSettings; 1008 1059 protected 1009 1060 constructor Create(AOwner: TComponent); override; … … 1054 1105 begin 1055 1106 DC := GetDC(0); 1056 SaveFont := SelectObject(DC, FontHandle); 1057 GetTextExtentPoint32(DC, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 52, Extent); 1058 Result := Trunc((Extent.cx / 26 + 1) / 2); // Round() doesn't line up with dialog units 1059 SelectObject(DC, SaveFont); 1060 ReleaseDC(0, DC); 1107 try 1108 SaveFont := SelectObject(DC, FontHandle); 1109 try 1110 GetTextExtentPoint32(DC, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 52, Extent); 1111 Result := Trunc((Extent.cx / 26 + 1) / 2); // Round() doesn't line up with dialog units 1112 finally 1113 SelectObject(DC, SaveFont); 1114 end; 1115 finally 1116 ReleaseDC(0, DC); 1117 end; 1061 1118 end; 1062 1119 … … 1234 1291 y := ((ClientRect.Bottom - ClientRect.Top) - FontHeightPixel(Canvas.Font.Handle)) div 2; 1235 1292 //TextOut(ClientRect.Left + 1, ClientRect.Top - 1, AString); 1236 TabbedTextOut(Handle, 1, y, PChar(AString), Length(AString), FListBox.FTabPix[0], 1237 FListBox.FTabPix[1], -1); 1293 // WARNING - Do NOT change the X pos or the tab starting pos - this will cause a missmatch 1294 // between the hint window and what the control displayes 1295 TabbedTextOut(Handle, 0, y, PChar(AString), Length(AString), MAX_TABS+1, FTabs[0], 0); 1238 1296 end; 1239 1297 end; … … 1253 1311 end; 1254 1312 1313 procedure TItemTip.GetTabSettings; 1314 var 1315 DX, X, i, count: integer; 1316 1317 begin 1318 Count := FListBox.FTabPix[0]; 1319 FTabs[0] := 1; // Set first tab stop to location 1 for display purposes 1320 if(Count = 1) then 1321 begin 1322 DX := FListBox.FTabPix[1]; 1323 X := (DX * 2) - 1; 1324 end 1325 else 1326 begin 1327 DX := FontWidthPixel(FListBox.Font.Handle) * 8; // windows tab default is 8 chars 1328 X := FListBox.FTabPix[Count]; 1329 X := Trunc(X / DX) + 1; 1330 X := (X * DX) - 1; // get the next tab position after that which is specified 1331 end; 1332 for i := 1 to MAX_TABS do 1333 begin 1334 if(i <= Count) then 1335 FTabs[i] := FListBox.FTabPix[i] - 1 1336 else 1337 begin 1338 FTabs[i] := X; 1339 inc(X, DX); 1340 end; 1341 end; 1342 end; 1343 1255 1344 procedure TItemTip.UpdateText(CatchMouse: Boolean); 1256 1345 var … … 1270 1359 Canvas.Font.Color := clWindowText; 1271 1360 end; 1272 Caption := FListBox.DisplayText[FListItem];1361 Caption := #9 + FListBox.DisplayText[FListItem]; 1273 1362 if Copy(Caption, 1, 2) = '__' then Caption := ' '; // so separators don't extend past window 1363 1364 GetTabSettings; 1365 1274 1366 AWidth := LOWORD(GetTabbedTextExtent(Canvas.Handle, PChar(Caption), Length(Caption), 1275 FListBox.FTabPix[0], FListBox.FTabPix[1]));1367 MAX_TABS+1, FTabs[0])); 1276 1368 // inherent scrollbar may not always be visible in a long list 1277 1369 if FListBox.LongList … … 1355 1447 ORCBImages[i].Free; 1356 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); 1357 1465 end; 1358 1466 … … 1921 2029 // 32 bits long, in the high word of WPARAM (16 bits). Since that won't work - we'll 1922 2030 // try sending the item index instead. 1923 SendMessage(Parent.Handle, WM_COMMAND, MAKELONG(FocusIndex, LBN_SELCHANGE), LPARAM(Handle)); 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)); 1924 2037 end; 1925 2038 VK_PRIOR: SetFocusIndex(FocusIndex - FLargeChange); … … 2131 2244 begin 2132 2245 //if Items.Count > 0 then SetFocusIndex(TopIndex); // this seems to cause problems 2246 //Fix For ClearQuest: HDS00001576 2247 //This fix has been commented out, becuase it causes problems 2248 { if (Items.Count > 0) and (Not IsAMouseButtonDown()) and (ItemIndex = -1) then 2249 SetFocusIndex(TopIndex);//ItemIndex := TopIndex; } 2133 2250 inherited DoEnter; 2134 2251 end; … … 3640 3757 FEditBox.OnKeyUp := FwdKeyUp; 3641 3758 FEditBox.Visible := True; 3759 fCharsNeedMatch := 1; 3642 3760 end; 3643 3761 … … 3749 3867 3750 3868 procedure TORComboBox.DoEnter; 3869 {var 3870 key : word;} 3751 3871 { select all the text in the editbox when recieve focus - done first so OnEnter can deselect } 3752 3872 begin 3753 3873 //FEditBox.SelectAll; 3874 //Fix For ClearQuest: HDS00001576 3875 //This fix has been commented out, becuase it causes problems 3876 { with FListBox do 3877 if (Items.Count > 0) and (Not IsAMouseButtonDown()) and (ItemIndex = -1) then 3878 begin 3879 key := VK_UP; 3880 FwdKeyDown(Self,key,[]); 3881 //Calling keyUp after key down creates a better mimic of a Keystroke. 3882 FwdKeyUp(Self,key,[]); //fixes clearquest: HDS00001418 3883 end; } 3754 3884 inherited DoEnter; 3755 3885 PostMessage(Handle, UM_GOTFOCUS, 0, 0) … … 3800 3930 with FEditBox do x := Copy(Text, 1, SelStart); 3801 3931 FLastInput := x; 3802 SelectIndex := FListBox.SelectString(x); 3932 SelectIndex := -1; 3933 if Length(x) >= CharsNeedMatch then 3934 SelectIndex := FListBox.SelectString(x); 3935 if (Length(x) < CharsNeedMatch) and (FListBox.ItemIndex > -1) then 3936 SelectIndex := FListBox.SelectString(x); 3937 if UniqueAutoComplete then 3938 SelectIndex := FListBox.VerifyUnique(SelectIndex,x); 3803 3939 if FListItemsOnly and (SelectIndex < 0) and (x <> '') then 3804 3940 begin … … 3891 4027 { passed selected navigation keys to listbox, applies special handling to backspace and F4 } 3892 4028 var 3893 i : Integer;3894 x : string;4029 i,iPos: Integer; 4030 x,AString: string; 3895 4031 begin 3896 4032 // special case: when default action taken (RETURN) make sure FwdChangeDelayed is called first … … 3902 4038 if (FStyle = orcsDropDown) and not DroppedDown then DroppedDown := True; 3903 4039 // handle special case of FocusIndex, WM_KEYDOWN will increment from -1 to 0 3904 if FListBox.ItemIndex = -1 then FListBox.FFocusIndex := -1; 4040 if FListBox.ItemIndex = -1 then 4041 begin 4042 FListBox.FFocusIndex := -1; 4043 //Move to correct position when Unique AutoComplete is on. 4044 if UniqueAutoComplete then 4045 begin 4046 AString := Copy(FEditBox.Text, 1, SelStart); 4047 iPos := SendMessage(FListBox.Handle, LB_FINDSTRING, -1, Longint(PChar(AString))); 4048 if iPos = LB_ERR then iPos := -1; 4049 if iPos > -1 then 4050 begin 4051 FListBox.FFocusIndex := iPos-1; 4052 FListBox.ItemIndex := FListBox.FFocusIndex; 4053 end; 4054 end; 4055 end; 3905 4056 FListBox.Perform(WM_KEYDOWN, Key, 1); 3906 4057 end; … … 4703 4854 FListBox.CaseChanged := Value; 4704 4855 end; 4705 4856 4706 4857 function TORComboBox.GetLookupPiece: integer; 4707 4858 begin … … 4747 4898 H := ClientHeight; 4748 4899 W := ClientWidth; 4900 if (H = 0) or (W = 0) then exit; 4749 4901 for i := 0 to Control.ControlCount - 1 do 4750 4902 begin … … 6157 6309 end; 6158 6310 6311 procedure TORCheckBox.BMGetCheck(var Message: TMessage); 6312 begin 6313 {This Allows JAWS to report the state when tabbed into or using the read object 6314 keys (Ins+Tab)} 6315 {if Self.GrayedStyle = gsBlueQuestionMark then 6316 Message.Result := BST_INDETERMINATE 6317 else} 6318 if Self.Checked then 6319 Message.Result := BST_CHECKED 6320 else 6321 Message.Result := BST_UNCHECKED; 6322 end; 6323 6324 procedure TORCheckBox.BMGetState(var Message: TMessage); 6325 begin 6326 //This gives JAWS ability to read state when spacebar is pressed. 6327 //Commented out because JAWS reads states, but inversly. Working with freedom... 6328 { if Self.Checked then 6329 Message.Result := BST_CHECKED 6330 else 6331 Message.Result := BST_UNCHECKED;} 6332 end; 6333 6159 6334 { TORListView } 6160 6335 … … 6310 6485 { TCaptionListBox } 6311 6486 6487 procedure TCaptionListBox.DoEnter; 6488 begin 6489 inherited; 6490 if HintOnItem then 6491 FHoverItemPos := -1; //CQ: 7178 & 9911 - used as last item index for ListBox 6492 end; 6493 6312 6494 function TCaptionListBox.GetCaption: string; 6313 6495 begin … … 6346 6528 else 6347 6529 inherited; 6530 end; 6531 6532 procedure TCaptionListBox.WMMouseMove(var Message: TWMMouseMove); 6533 var 6534 i : integer; 6535 begin 6536 inherited; 6537 //CQ: 7178 & 9911 - FHoverItemPos should be set to -1 in OnEnter 6538 //Make the TListBox's hint contain the contents of the listbox Item the mouse is currently over 6539 if HintOnItem then 6540 begin 6541 i := ItemAtPos(Point(Message.XPos, Message.YPos), true); 6542 if i <> FHoverItemPos then 6543 Application.CancelHint; 6544 if i = -1 then 6545 Hint := '' 6546 else 6547 Hint := Items[i]; 6548 FHoverItemPos := i; 6549 end; 6348 6550 end; 6349 6551 … … 6451 6653 end; 6452 6654 6655 { TCaptionRichEdit } 6656 6657 procedure TCaptionRichEdit.MakeAccessible(Accessible: IAccessible); 6658 begin 6659 if Assigned(FAccessible) and Assigned(Accessible) then 6660 raise Exception.Create(Caption + ' Rich Edit is already Accessible!') 6661 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) 6669 else 6670 inherited; 6671 end; 6453 6672 6454 6673 { TCaptionTreeView} … … 6558 6777 end; 6559 6778 6779 function IsAMouseButtonDown : boolean; 6780 begin 6781 if Boolean(Hi(GetKeyState(VK_MBUTTON))) or 6782 Boolean(Hi(GetKeyState(VK_LBUTTON))) or 6783 Boolean(Hi(GetKeyState(VK_RBUTTON))) then 6784 Result := true 6785 else 6786 Result := false; 6787 end; 6788 6789 procedure TORComboBox.SetNumForMatch(const NumberForMatch: integer); 6790 begin 6791 if NumberForMatch < 1 then 6792 FCharsNeedMatch := 1 6793 else if NumberForMatch > 15 then 6794 FCharsNeedMatch := 15 6795 else 6796 FCharsNeedMatch := NumberForMatch; 6797 end; 6798 6799 procedure TORComboBox.SetUniqueAutoComplete(const Value: Boolean); 6800 begin 6801 FUniqueAutoComplete := Value; 6802 end; 6803 6804 function TORListBox.VerifyUnique(SelectIndex: Integer; iText: String): integer; 6805 var 6806 i : integer; 6807 counter : integer; 6808 begin 6809 Result := SelectIndex; 6810 if LongList then 6811 begin 6812 //Currently Do nothing for LongLists 6813 { if CompareText(iText, Copy(DisplayText[SelectIndex+1], 1, Length(iText))) = 0 then 6814 Result := -1;} 6815 end 6816 else //Not a LongList 6817 begin 6818 counter := 0; 6819 for i := 0 to Items.Count-1 do 6820 if CompareText(iText, Copy(DisplayText[i], 1, Length(iText))) = 0 then 6821 Inc(counter); 6822 if counter > 1 then 6823 Result := -1; 6824 end; 6825 FFocusIndex := Result; 6826 ItemIndex := Result; 6827 end; 6828 6829 //This procedure sets the Text property equal to the TextToMatch parameter, then calls 6830 //FwdChangeDelayed which will perform an auto-completion on the text. 6831 procedure TORComboBox.SetTextAutoComplete(TextToMatch: String); 6832 begin 6833 Text := TextToMatch; 6834 SelStart := Length(Text); 6835 FwdChangeDelayed; 6836 end; 6837 6560 6838 initialization 6561 6839 //uItemTip := TItemTip.Create(Application); // all listboxes share a single ItemTip window
Note:
See TracChangeset
for help on using the changeset viewer.