home *** CD-ROM | disk | FTP | other *** search
- unit sIBControls;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, Shared, StrUtils, IBQuery, IBDatabase, sStyleUtil, sControls,
- DBGridEh, sCustomComboBox, sSharedIB;
-
- type
-
- TsIBSorter = class(TsCustomSorter)
- private
- public
- procedure Execute; override;
-
- published
- property DBGrid;
- property Active;
- property OnDockDrop;
- property OnDockOver;
- property OnDragDrop;
- property OnDragOver;
- property OnEndDock;
- property OnEndDrag;
- property Align;
- property Alignment;
- property BevelInner;
- property BevelOuter;
- property BevelWidth;
- property BorderWidth;
- property BorderStyle;
- property Caption;
- property Color;
- property Ctl3D;
- property DragCursor;
- property Enabled;
- property FullRepaint;
- property Font;
- property ParentColor;
- property ParentCtl3D;
- property ParentFont;
- property ParentShowHint;
- property PopupMenu;
- property ShowHint;
- property TabOrder;
- property TabStop;
- property Visible;
- property OnClick;
- property OnDblClick;
- property OnEnter;
- property OnExit;
- property OnMouseDown;
- property OnMouseMove;
- property OnMouseUp;
- property OnResize;
- end;
-
- TsIBComboBox = class(TsCustomComboBox)
- private
- { Private declarations }
- protected
- FDatabase : TIBDatabase;
- { Protected declarations }
- public
- function Generate : integer; override;
- { Public declarations }
- published
-
- property Enabled;
- property Font;
- property Hint;
- property ItemHeight;
- property Items;
- property MaxLength;
- property DropDownCount;
- property ParentFont;
- property ParentShowHint;
- property PopupMenu;
- property ShowHint;
- property Sorted;
- property Style;
- property TabOrder;
- property Text;
- property Visible;
- property CharCase;
- property sStyle;
- property Active;
- property Database:TIBDatabase read FDatabase write FDatabase;
- property SQL;
- property CharsInCode;
-
- property OnChange;
- property OnClick;
- property OnContextPopup;
- property OnDblClick;
- property OnDragDrop;
- property OnDragOver;
- property OnDrawItem;
- property OnEndDock;
- property OnEndDrag;
- property OnKeyDown;
- property OnKeyPress;
- property OnKeyUp;
- property OnMeasureItem;
- property OnStartDock;
- property OnStartDrag;
- { Published declarations }
- end;
-
- implementation
-
- procedure TsIBSorter.Execute;
- var
- s, StartText : string;
- begin
- StartText := TIBQuery(DBGrid.DataSource.DataSet).SQL.Text;
- if pos('ORDER BY', UpperCase(StartText)) > 0 then begin
- StartText := copy(StartText, 1, pos('ORDER BY', UpperCase(StartText)) - 1);
- end;
- s := GenText;
- if s <> '' then begin
- SelectIBQuery(TIBQuery(DBGrid.DataSource.DataSet), StartText + ' order by ' + s);
- end;
- end;
-
- // ---------------------------------------------
- function TsIBComboBox.Generate : integer;
- var
- q: TIBQuery;
- s, t: string;
- begin
- Result := 0;
- if Assigned(Database) and (SQL.Text<>'') then begin
- q:=TIBQuery.Create(Self);
- q.Database := Database;
- q.SQL.Assign(SQL);
- q.Open;
-
- q.first;
- Clear;
- if sStyle.DefaultString<>'' then begin
- Items.Add(sStyle.DefaultString);
- end;
- while not q.eof do begin
- if (CharsInCode > 0) and (q.FieldCount > 1) then begin
- // t := StrUtils.AddCharR
-
- if Length(q.Fields[1].AsString) < CharsInCode then begin
- s:='0';
- while Length(s) < CharsInCode - length(q.Fields[1].AsString) do begin
- s:=s+'0';
- end;
- t := s + q.Fields[1].AsString + ' - ' + q.Fields[0].AsString;
- end
-
- else begin
- t := q.Fields[1].AsString + ' - ' + q.Fields[0].AsString;
- end;
- end
- else begin
- t := q.Fields[0].AsString;
- end;
- Items.Add(t);
- q.next;
- end;
- q.Free;
- if Items.Count < 24 then begin
- DropDownCount := Items.Count;
- end;
- Result := Items.Count;
- if sStyle.DefaultString <> '' then begin
- ItemIndex := 0;
- end;
- ItemHeight := 16;
- end;
- end;
-
- end.
-