Enclosed a new patch for Qt. It provides:
1) A cosmetic correction in qt4.pas to avoid a warning about enumerates types not ascending.
2) A couple a cosmetic corrections on QtWsControls and QtWsStdControls, to get rid of methods never used.
3) Removed from QtWsControls a partial implementation of SpinEdit, left over from copying from gtk, which breaks things.
4) Modified qtmemostrings.inc, with some clean up, plus the Delphi compatible implementation of TMemo.OnChange: OnChange is generated both for user and program changes, but user changes set TMemo.modified true, while program changes do not.
The conditional DelphiOnChange has been therefore removed.Included also a small test program to exercise TMemo. (and to compare it's behavior with different interfaces).
Giuliano
Index: qtmemostrings.inc =================================================================== --- qtmemostrings.inc (revisione 9256) +++ qtmemostrings.inc (copia locale) @@ -13,6 +13,7 @@ FUpdating: Boolean; // We're changing Qt Widget procedure InternalUpdate; procedure ExternalUpdate(var Astr: WideString; Clear: Boolean = True); + procedure IsChanged; // OnChange triggered by program action protected function GetTextStr: string; override; function GetCount: integer; override; @@ -38,16 +39,9 @@ Implementation } -{------------------------------------------------------------------------------ - DelphiOnChange sets Delphi compatibility for OnChange event: - If defined, OnChange is generated whenever there's a change - If undefined, OnChange is generated if change is caused by user action - ------------------------------------------------------------------------------} -{$define DelphiOnChange} - {------------------------------------------------------------------------------ - Method: TQtMemoStrings.InternalUpdate + Private Method: TQtMemoStrings.InternalUpdate Params: None Returns: Nothing @@ -63,31 +57,44 @@ end; {------------------------------------------------------------------------------ - Method: TQtMemoStrings.ExternalUpdate + Private Method: TQtMemoStrings.ExternalUpdate Params: Astr: Text for Qt Widget; Clear: if we must clear first Returns: Nothing Updates Qt Widget from text - If DelphiOnChange, generates OnChange Event ------------------------------------------------------------------------------} procedure TQtMemoStrings.ExternalUpdate(var Astr: WideString; Clear: Boolean = True); -{$ifdef DelphiOnChange} -var - Mess: TLMessage; -{$endif} +{var + Mess: TLMessage;} begin FUpdating := True; if Clear then QTextEdit_clear(FQtTextEdit); QTextEdit_append(FQtTextEdit,@Astr); - FUpdating := False; -{$ifdef DelphiOnChange} - FillChar(Mess, SizeOf(Mess), #0); + {FillChar(Mess, SizeOf(Mess), #0); Mess.Msg := CM_TEXTCHANGED; - FOwner.Dispatch(TLMessage(Mess)); -{$endif} + (FOwner as TCustomMemo).Modified := False; + FOwner.Dispatch(TLMessage(Mess));} + IsChanged; + FUpdating := False; end; {------------------------------------------------------------------------------ + Private Method: TQtMemoStrings.IsChanged + Params: None + Returns: Nothing + + Triggers the OnChange Event, with modified set to false + ------------------------------------------------------------------------------} +procedure TQtMemoStrings.IsChanged; +begin + if Assigned((FOwner as TCustomMemo).OnChange) then begin + (FOwner as TCustomMemo).Modified := False; + (FOwner as TCustomMemo).OnChange(self); + end; +end; + +{------------------------------------------------------------------------------ Method: TQtMemoStrings.GetTextStr Params: None Returns: a string @@ -191,9 +198,10 @@ FTextChanged := True; FillChar(Mess, SizeOf(Mess), #0); Mess.Msg := CM_TEXTCHANGED; + //(FOwner as TCustomMemo).Modified := True; FOwner.Dispatch(TLMessage(Mess)); end; - Result := False; + Result := True; end; {------------------------------------------------------------------------------ @@ -206,9 +214,6 @@ procedure TQtMemoStrings.Assign(Source: TPersistent); var Astr: WideString; -{$ifdef DelphiOnChange} - Mess: TLMessage; -{$endif} begin if (Source=Self) or (Source=nil) then exit; if Source is TStrings then begin @@ -217,11 +222,6 @@ Astr := FStringList.Text; ExternalUpdate(Astr,True); FTextChanged := False; -{$ifdef DelphiOnChange} - FillChar(Mess, SizeOf(Mess), #0); - Mess.Msg := CM_TEXTCHANGED; - FOwner.Dispatch(TLMessage(Mess)); -{$endif} exit; end; Inherited Assign(Source); @@ -235,21 +235,19 @@ Clears all. ------------------------------------------------------------------------------} procedure TQtMemoStrings.Clear; -{$ifdef DelphiOnChange} var Mess: TLMessage; -{$endif} begin FUpdating := True; FStringList.Clear; QTextEdit_clear(FQtTextEdit); FTextChanged := False; FUpdating := False; -{$ifdef DelphiOnChange} - FillChar(Mess, SizeOf(Mess), #0); + {FillChar(Mess, SizeOf(Mess), #0); Mess.Msg := CM_TEXTCHANGED; - FOwner.Dispatch(TLMessage(Mess)); -{$endif} + (FOwner as TCustomMemo).Modified := False; + FOwner.Dispatch(TLMessage(Mess));} + IsChanged; end; {------------------------------------------------------------------------------ Index: qtwscontrols.pp =================================================================== --- qtwscontrols.pp (revisione 9256) +++ qtwscontrols.pp (copia locale) @@ -252,10 +252,12 @@ if not AWinControl.HandleAllocated then exit; case AWinControl.fCompStyle of //csComboBox: - csEdit,csSpinedit: + csEdit: QLineEdit_text(QLineEditH(TQtWidget(AWinControl.Handle).Widget),@AString); - csMemo: - QTextEdit_toPlainText(QTextEditH(TQtWidget(AWinControl.Handle).Widget),@AString); + //csSpinedit: TODO + // QLineEdit_text(QLineEditH(TQtWidget(AWinControl.Handle).Widget),@AString); + // csMemo: Not Used + // QTextEdit_toPlainText(QTextEditH(TQtWidget(AWinControl.Handle).Widget),@AString); else Result := false; end; @@ -270,11 +272,12 @@ if not AWinControl.HandleAllocated then exit; AString := AText; case AWinControl.fCompStyle of - csEdit,csSpinedit: + csEdit: QLineEdit_setText(QLineEditH(TQtWidget(AWinControl.Handle).Widget),@AString); - //csStaticText: - csMemo: - QTextEdit_append(QTextEditH(TQtWidget(AWinControl.Handle).Widget),@AString); + //csSpinEdit: ToDo + //csStaticText: ToDo + //csMemo: Not used + //QTextEdit_append(QTextEditH(TQtWidget(AWinControl.Handle).Widget),@AString); end; end; @@ -293,4 +296,4 @@ // RegisterWSComponent(TCustomControl, TQtWSCustomControl); // RegisterWSComponent(TImageList, TQtWSImageList); //////////////////////////////////////////////////// -end. \ Nessun a-capo alla fine del file +end. Index: qt4.pas =================================================================== --- qt4.pas (revisione 9256) +++ qt4.pas (copia locale) @@ -1154,7 +1154,6 @@ QEventClose = 19, QEventQuit = 20, QEventParentChange = 21, - QEventParentAboutToChange = 131, QEventThreadChange = 22, QEventWindowActivate = 24, QEventWindowDeactivate = 25, @@ -1172,7 +1171,7 @@ QEventSpeech = 42, QEventMetaCall = 43, QEventSockAct = 50, - QEventWinEventAct = 132, + QEventShortcutOverride = 51, QEventDeferredDelete = 52, QEventDragEnter = 60, QEventDragMove = 61, @@ -1210,10 +1209,10 @@ QEventStyleChange = 100, QEventIconTextChange = 101, QEventModifiedChange = 102, - QEventMouseTrackingChange = 109, QEventWindowBlocked = 103, QEventWindowUnblocked = 104, QEventWindowStateChange = 105, + QEventMouseTrackingChange = 109, QEventToolTip = 110, QEventWhatsThis = 111, QEventStatusTip = 112, @@ -1222,8 +1221,8 @@ QEventActionRemoved = 115, QEventFileOpen = 116, QEventShortcut = 117, - QEventShortcutOverride = 51, QEventWhatsThisClicked = 118, + QEventAccessibilityHelp = 119, QEventToolBarChange = 120, QEventApplicationActivated = 121, QEventApplicationDeactivated = 122, @@ -1234,8 +1233,9 @@ QEventHoverEnter = 127, QEventHoverLeave = 128, QEventHoverMove = 129, - QEventAccessibilityHelp = 119, QEventAccessibilityDescription = 130, + QEventParentAboutToChange = 131, + QEventWinEventAct = 132, QEventAcceptDropsChange = 152, QEventMenubarUpdated = 153, QEventZeroTimerEvent = 154, Index: qtwsstdctrls.pp =================================================================== --- qtwsstdctrls.pp (revisione 9256) +++ qtwsstdctrls.pp (copia locale) @@ -154,7 +154,7 @@ const AParams: TCreateParams): HWND; override; class procedure DestroyHandle(const AWinControl: TWinControl); override; public - class procedure AppendText(const ACustomMemo: TCustomMemo; const AText: string); override; +// class procedure AppendText(const ACustomMemo: TCustomMemo; const AText: string); override; class function GetStrings(const ACustomMemo: TCustomMemo): TStrings; override; // class procedure SetScrollbars(const ACustomMemo: TCustomMemo; const NewScrollbars: TScrollStyle); virtual; class procedure SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean); override; @@ -320,7 +320,7 @@ Params: None Returns: Nothing ------------------------------------------------------------------------------} -class procedure TQtWSCustomMemo.AppendText(const ACustomMemo: TCustomMemo; const AText: string); +{class procedure TQtWSCustomMemo.AppendText(const ACustomMemo: TCustomMemo; const AText: string); var Astr: WideString; begin @@ -330,7 +330,7 @@ //QTextEdit_append(QTextEditH(ACustomMemo.Handle),@Astr); QTextEdit_append(QTextEditH(TQtWidget(ACustomMemo.Handle).Widget),@Astr); -end; +end;} {------------------------------------------------------------------------------
QtTest.tar.bz2
Description: BZip2 compressed data