Ignore:
Timestamp:
Sep 17, 2008, 5:34:43 PM (16 years ago)
Author:
Kevin Toppenberg
Message:

Resync

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/branches/GUI-config/CPRS-Lib/ORCtrls.pas

    r476 r492  
    2121
    2222type
     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
    2335  TORComboBox = class;                           // forward declaration for FParentCombo
    2436
     
    230242    property MItems: TStrings read GetMItems write SetMItems;
    231243    procedure MakeAccessible(Accessible: IAccessible);
     244    function VerifyUnique(SelectIndex: Integer; iText: String): integer;
    232245  published
    233246    property AllowGrayed: boolean read FAllowGrayed write FAllowGrayed default FALSE;
     
    325338    FCheckBoxEditColor: TColor;                  // Edit Box color for Check Box Combo List, when not in Focus
    326339    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.
    327342    function EditControl: TWinControl;
    328343    procedure AdjustSizeOfSelf;
     
    342357    procedure FwdNeedData(Sender: TObject; const StartFrom: string;
    343358      Direction, InsertAt: Integer);
     359    procedure SetNumForMatch(const NumberForMatch: integer);
    344360    function GetAutoSelect: Boolean;
    345361    function GetColor: TColor;
     
    423439    function GetLookupPiece: integer;
    424440    procedure SetLookupPiece(const Value: integer);
     441    procedure SetUniqueAutoComplete(const Value: Boolean);
    425442  protected
    426443    procedure DropPanelBtnPressed(OKBtn, AutoClose: boolean);
     
    441458    procedure InitLongList(S: string);
    442459    procedure InsertSeparator;
     460    procedure SetTextAutoComplete(TextToMatch : String);
    443461    function GetIEN(AnIndex: Integer): Int64;
    444462    function SelectByIEN(AnIEN: Int64): Integer;
     
    522540    property OnResize;
    523541    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;
    524549  end;
    525550
     
    776801    procedure WMSize           (var Message: TWMSize);          message WM_SIZE;
    777802    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;
    778805    function GetImageList: TCustomImageList;
    779806    function GetImageIndexes: string;
     
    874901  TCaptionListBox = class(TListBox)
    875902  private
     903    FHoverItemPos: integer;
    876904    FAccessible: IAccessible;
    877905    FRightClickSelect: boolean;                  // When true, a right click selects teh item
     906    FHintOnItem: boolean;
    878907    procedure SetCaption(const Value: string);
    879908    function GetCaption: string;
    880909    procedure WMGetObject(var Message: TMessage); message WM_GETOBJECT;
    881910    procedure WMRButtonUp(var Message: TWMRButtonUp); message WM_RBUTTONUP;
     911    procedure WMMouseMove(var Message: TWMMouseMove); message WM_MOUSEMOVE;
    882912  protected
    883913    FCaptionComponent: TStaticText;
     914    procedure DoEnter; override;
    884915  public
    885916    procedure MakeAccessible( Accessible: IAccessible);
     
    887918    property RightClickSelect: boolean read FRightClickSelect write FRightClickSelect default FALSE;
    888919    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;
    889922  end;
    890923
     
    918951    property Align;
    919952    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;
    920966  end;
    921967
     
    9611007function CalcShortName( LongName: string; PrevLongName: string): string;
    9621008
     1009{Returns True if any one of 3 mouse buttons are down left, right, or middle}
     1010function IsAMouseButtonDown : boolean;
     1011
    9631012implementation  // ---------------------------------------------------------------------------
    9641013
     
    10061055    FPoint: TPoint;
    10071056    FSelected: boolean;
     1057    FTabs: array[0..MAX_TABS] of Integer;         // Holds the pixel offsets for tabs
     1058    procedure GetTabSettings;
    10081059  protected
    10091060    constructor Create(AOwner: TComponent); override;
     
    10541105begin
    10551106  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;
    10611118end;
    10621119
     
    12341291    y := ((ClientRect.Bottom - ClientRect.Top) - FontHeightPixel(Canvas.Font.Handle)) div 2;
    12351292    //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);
    12381296  end;
    12391297end;
     
    12531311end;
    12541312
     1313procedure TItemTip.GetTabSettings;
     1314var
     1315  DX, X, i, count: integer;
     1316 
     1317begin
     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;
     1342end;
     1343
    12551344procedure TItemTip.UpdateText(CatchMouse: Boolean);
    12561345var
     
    12701359    Canvas.Font.Color := clWindowText;
    12711360  end;
    1272   Caption := FListBox.DisplayText[FListItem];
     1361  Caption := #9 + FListBox.DisplayText[FListItem];
    12731362  if Copy(Caption, 1, 2) = '__' then Caption := ' ';  // so separators don't extend past window
     1363
     1364  GetTabSettings;
     1365
    12741366  AWidth := LOWORD(GetTabbedTextExtent(Canvas.Handle, PChar(Caption), Length(Caption),
    1275     FListBox.FTabPix[0], FListBox.FTabPix[1]));
     1367    MAX_TABS+1, FTabs[0]));
    12761368  // inherent scrollbar may not always be visible in a long list
    12771369  if FListBox.LongList
     
    13551447      ORCBImages[i].Free;
    13561448  end;
     1449end;
     1450
     1451{ TORStaticText }
     1452
     1453procedure TORStaticText.DoEnter;
     1454begin
     1455  inherited DoEnter;
     1456  if Assigned(FOnEnter) then
     1457     FOnEnter(Self);
     1458end;
     1459
     1460procedure TORStaticText.DoExit;
     1461begin
     1462  inherited DoExit;
     1463  if Assigned(FOnExit) then
     1464     FOnExit(Self);
    13571465end;
    13581466
     
    19212029      // 32 bits long, in the high word of WPARAM (16 bits).  Since that won't work - we'll
    19222030      // 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));
    19242037    end;
    19252038    VK_PRIOR:          SetFocusIndex(FocusIndex - FLargeChange);
     
    21312244begin
    21322245  //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; }
    21332250  inherited DoEnter;
    21342251end;
     
    36403757  FEditBox.OnKeyUp := FwdKeyUp;
    36413758  FEditBox.Visible := True;
     3759  fCharsNeedMatch := 1; 
    36423760end;
    36433761
     
    37493867
    37503868procedure TORComboBox.DoEnter;
     3869{var
     3870  key : word;}
    37513871{ select all the text in the editbox when recieve focus - done first so OnEnter can deselect }
    37523872begin
    37533873  //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;              }
    37543884  inherited DoEnter;
    37553885  PostMessage(Handle, UM_GOTFOCUS, 0, 0)
     
    38003930  with FEditBox do x := Copy(Text, 1, SelStart);
    38013931  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);
    38033939  if FListItemsOnly and (SelectIndex < 0) and (x <> '') then
    38043940  begin
     
    38914027{ passed selected navigation keys to listbox, applies special handling to backspace and F4 }
    38924028var
    3893   i: Integer;
    3894   x: string;
     4029  i,iPos: Integer;
     4030  x,AString: string;
    38954031begin
    38964032  // special case: when default action taken (RETURN) make sure FwdChangeDelayed is called first
     
    39024038    if (FStyle = orcsDropDown) and not DroppedDown then DroppedDown := True;
    39034039    // 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;
    39054056    FListBox.Perform(WM_KEYDOWN, Key, 1);
    39064057  end;
     
    47034854  FListBox.CaseChanged := Value;
    47044855end;
    4705    
     4856
    47064857function TORComboBox.GetLookupPiece: integer;
    47074858begin
     
    47474898  H := ClientHeight;
    47484899  W := ClientWidth;
     4900  if (H = 0) or (W = 0) then exit;
    47494901  for i := 0 to Control.ControlCount - 1 do
    47504902  begin
     
    61576309end;
    61586310
     6311procedure TORCheckBox.BMGetCheck(var Message: TMessage);
     6312begin
     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;
     6322end;
     6323
     6324procedure TORCheckBox.BMGetState(var Message: TMessage);
     6325begin
     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;}
     6332end;
     6333
    61596334{ TORListView }
    61606335
     
    63106485{ TCaptionListBox }
    63116486
     6487procedure TCaptionListBox.DoEnter;
     6488begin
     6489  inherited;
     6490  if HintOnItem then
     6491    FHoverItemPos := -1; //CQ: 7178 & 9911 - used as last item index for ListBox
     6492end;
     6493
    63126494function TCaptionListBox.GetCaption: string;
    63136495begin
     
    63466528  else
    63476529    inherited;
     6530end;
     6531
     6532procedure TCaptionListBox.WMMouseMove(var Message: TWMMouseMove);
     6533var
     6534  i : integer;
     6535begin
     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;
    63486550end;
    63496551
     
    64516653end;
    64526654
     6655{ TCaptionRichEdit }
     6656
     6657procedure TCaptionRichEdit.MakeAccessible(Accessible: IAccessible);
     6658begin
     6659  if Assigned(FAccessible) and Assigned(Accessible) then
     6660    raise Exception.Create(Caption + ' Rich Edit is already Accessible!')
     6661  else
     6662    FAccessible := Accessible;
     6663end;
     6664
     6665procedure TCaptionRichEdit.WMGetObject(var Message: TMessage);
     6666begin
     6667  if (Message.LParam = integer(OBJID_CLIENT)) and Assigned(FAccessible) then
     6668    Message.Result := GetLResult(Message.wParam, FAccessible)
     6669  else
     6670    inherited;
     6671end;
    64536672
    64546673{ TCaptionTreeView}
     
    65586777end;
    65596778
     6779function IsAMouseButtonDown : boolean;
     6780begin
     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;
     6787end;
     6788
     6789procedure TORComboBox.SetNumForMatch(const NumberForMatch: integer);
     6790begin
     6791  if NumberForMatch < 1 then
     6792    FCharsNeedMatch := 1
     6793  else if NumberForMatch > 15 then
     6794    FCharsNeedMatch := 15
     6795  else
     6796    FCharsNeedMatch := NumberForMatch;
     6797end;
     6798
     6799procedure TORComboBox.SetUniqueAutoComplete(const Value: Boolean);
     6800begin
     6801  FUniqueAutoComplete := Value;
     6802end;
     6803
     6804function TORListBox.VerifyUnique(SelectIndex: Integer; iText: String): integer;
     6805var
     6806  i : integer;
     6807  counter : integer;
     6808begin
     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;
     6827end;
     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.
     6831procedure TORComboBox.SetTextAutoComplete(TextToMatch: String);
     6832begin
     6833  Text := TextToMatch;
     6834  SelStart := Length(Text);
     6835  FwdChangeDelayed;
     6836end;
     6837
    65606838initialization
    65616839  //uItemTip := TItemTip.Create(Application);  // all listboxes share a single ItemTip window
Note: See TracChangeset for help on using the changeset viewer.