Implemented UTF-8 support. Fixed mouse messages. Other small fixes. Removed deprecated file.

git-svn-id: trunk@10059 -
This commit is contained in:
sekelsenmat 2006-10-12 03:17:37 +00:00
parent 1806819c79
commit a284a1aea3
12 changed files with 85 additions and 115 deletions

1
.gitattributes vendored
View File

@ -2389,7 +2389,6 @@ lcl/interfaces/gtk2/gtk2wstoolwin.pp svneol=native#text/pascal
lcl/interfaces/gtk2/interfaces.pas svneol=native#text/pascal
lcl/interfaces/qt/README.txt svneol=native#text/plain
lcl/interfaces/qt/interfaces.pp svneol=native#text/pascal
lcl/interfaces/qt/qt.pp svneol=native#text/pascal
lcl/interfaces/qt/qt4.pas svneol=native#text/plain
lcl/interfaces/qt/qtcallback.inc svneol=native#text/pascal
lcl/interfaces/qt/qtint.pp svneol=native#text/pascal

View File

@ -1,66 +0,0 @@
{
*****************************************************************************
* *
* This file is part of the Lazarus Component Library (LCL) *
* *
* See the file COPYING.modifiedLGPL, included in this distribution, *
* for details about the copyright. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
*****************************************************************************
}
unit qt;
interface
{$linklib lzqt}
{$linklib c}
const
WIDGET = 1;
WIDGET_BUTTON = 2;
WIDGET_PUSH_BUTTON = 3;
WIDGET_CHECK_BOX = 4;
WIDGET_RADIO_BUTTON = 5;
WIDGET_DIALOG = 6;
WIDGET_DIALOG_FILE = 7;
WIDGET_MESSAGE_BOX = 8;
WIDGET_TAB_DIALOG = 9;
WIDGET_FRAME = 10;
WIDGET_GROUP_BOX = 11;
WIDGET_BUTTON_GROUP = 12;
WIDGET_LCD_NUMBER = 13;
WIDGET_LABEL = 14;
WIDGET_MENU_BAR = 15;
WIDGET_LISTBOX = 16;
WIDGET_MULTI_LINE_EDIT = 17;
WIDGET_POPUP_MENU = 18;
WIDGET_LINE_EDIT = 19;
WIDGET_SCROLL_BAR = 20;
WIDGET_TAB_BAR = 21;
WIDGET_WINDOW = 22;
{
//event callback definitions
MousePressedEvent(qwid,button,x,y,state)
}
procedure InitializeEngine;cdecl;external;
function CreateWidget(wtype: longint):longint;cdecl;external;
procedure MainLoop;cdecl;external;
procedure ReparentWidget(qwidparent: longint; qwidchild: longint);cdecl;external;
procedure SetMainWidget(qwid:longint);cdecl;external;
procedure ShowWidget(wid: longint);cdecl;external;
procedure MoveWidget(qwid: longint; x: longint; y: longint);cdecl;external;
procedure ResizeWidget(qwid: longint; h: longint; w: longint);cdecl;external;
procedure SetWidgetText(qwid: longint; wtext: pchar);cdecl;external;
procedure HookMousePressedEvent(qwid: longint; ptrcall: pointer);cdecl;external;
procedure SetData(qwid: longint; data: pointer);cdecl;external;
function GetData(qwid:longint):pointer;cdecl;external;
procedure Shutdown;cdecl;external;
implementation
end.

View File

@ -340,7 +340,7 @@ procedure TQtFont.setRawName(p1: string);
var
Str: WideString;
begin
Str := WideString(p1);
Str := UTF8Decode(p1);
QFont_setRawName(Widget, @Str);
end;
@ -349,7 +349,7 @@ procedure TQtFont.setFamily(p1: string);
var
Str: WideString;
begin
Str := WideString(p1);
Str := UTF8Decode(p1);
QFont_setFamily(Widget, @Str);
end;

View File

@ -142,12 +142,16 @@ end;
procedure TQtListStrings.ExternalUpdate(var Astr: TStringList; Clear: Boolean);
var
i: Integer;
TmpStr: WideString;
begin
FUpdating := True;
if Clear then
QListWidget_clear(FQtListWidget);
for i := 0 to AStr.Count -1 do
QListWidget_additem(FQtListWidget, @WideString(Astr[i]));
begin
TmpStr := UTF8Decode(Astr[i]);
QListWidget_additem(FQtListWidget, @TmpStr);
end;
FUpdating := False;
IsChanged;
FUpdating := False;
@ -550,6 +554,7 @@ procedure TQtComboStrings.ExternalUpdate(var Astr: TStringList; Clear: Boolean);
var
i: Integer;
data: QVariantH;
TmpStr: WideString;
begin
data := QVariant_create(10); //Creates dummy data
@ -558,7 +563,10 @@ begin
if Clear then
QComboBox_clear(FQtComboBox);
for i := 0 to AStr.Count -1 do
QComboBox_additem(FQtComboBox, @WideString(Astr[i]), data);
begin
TmpStr := UTF8Decode(Astr[i]);
QComboBox_additem(FQtComboBox, @TmpStr, data);
end;
FUpdating := False;
IsChanged;
FUpdating := False;

View File

@ -508,7 +508,7 @@ begin
else Msg.Msg := LM_KEYDOWN;
{------------------------------------------------------------------------------
Translates a Qt4 Key to a LCL VK_ key
Translates a Qt4 Key to a LCL VK_* key
------------------------------------------------------------------------------}
Msg.CharCode := QtKeyToLCLKey(QKeyEvent_key(QKeyEventH(Event)));
@ -531,19 +531,34 @@ end;
procedure TQtWidget.SlotMouse(Event: QEventH); cdecl;
var
Msg: TLMMouse;
MousePos: TPoint;
begin
{$ifdef VerboseQt}
WriteLn('TQtWidget.SlotMouse');
{$endif}
FillChar(Msg, SizeOf(Msg), #0);
QCursor_pos(@MousePos);
Msg.XPos := SmallInt(MousePos.X);
Msg.YPos := SmallInt(MousePos.Y);
case QEvent_type(Event) of
QEventMouseButtonPress: Exit; //Msg.Msg := LM_CLICKED;
QEventMouseButtonRelease: Msg.Msg := LM_CLICKED;
QEventMouseButtonPress: Msg.Msg := LM_PRESSED;
QEventMouseButtonRelease:
begin
Msg.Msg := LM_CLICKED;
try
LCLObject.WindowProc(TLMessage(Msg));
except
Application.HandleException(nil);
end;
Msg.Msg := LM_RELEASED;
end;
QEventMouseButtonDblClick: Msg.Msg := LM_CLICKED;
else
Msg.Msg := LM_CLICKED;
end;
try
@ -561,8 +576,22 @@ end;
procedure TQtWidget.SlotMouseMove(Event: QEventH); cdecl;
var
Msg: TLMMouseMove;
MousePos: TPoint;
begin
FillChar(Msg, SizeOf(Msg), #0);
QCursor_pos(@MousePos);
Msg.XPos := SmallInt(MousePos.X);
Msg.YPos := SmallInt(MousePos.Y);
Msg.Msg := LM_MOUSEMOVE;
try
LCLObject.WindowProc(TLMessage(Msg));
except
Application.HandleException(nil);
end;
end;
{------------------------------------------------------------------------------
@ -1110,7 +1139,7 @@ begin
WriteLn('TQtPushButton.Create');
{$endif}
Str := WideString(AWinControl.Caption);
Str := UTF8Decode(AWinControl.Caption);
Parent := TQtWidget(AWinControl.Parent.Handle).Widget;
Widget := QPushButton_create(@Str, Parent);
@ -1305,7 +1334,7 @@ begin
QWidget_setGeometry(Widget, AWinControl.Left, AWinControl.Top,
AWinControl.Width, AWinControl.Height);
Str := WideString(AWinControl.Caption);
Str := UTF8Decode(AWinControl.Caption);
SetText(@Str);
end;
@ -1436,7 +1465,7 @@ begin
AWinControl.Width, AWinControl.Height);
end;
Str := WideString(AWinControl.Caption);
Str := UTF8Decode(AWinControl.Caption);
SetText(@Str);
end;
@ -1524,7 +1553,7 @@ begin
AWinControl.Width, AWinControl.Height);
end;
Str := WideString(AWinControl.Caption);
Str := UTF8Decode(AWinControl.Caption);
SetText(@Str);
end;
@ -1704,7 +1733,7 @@ begin
WriteLn('TQtLineEdit.Create');
{$endif}
Parent := TQtWidget(AWinControl.Parent.Handle).Widget;
Str := WideString((AWinControl as TCustomEdit).Text);
Str := UTF8Decode((AWinControl as TCustomEdit).Text);
Widget := QLineEdit_create(@Str, Parent);
// Sets it´ s initial properties
@ -1868,7 +1897,7 @@ begin
// Add the items to the combo box
for i := 0 to (AWinControl as TCustomComboBox).Items.Count - 1 do
begin
Str := WideString((AWinControl as TCustomComboBox).Items.Strings[i]);
Str := UTF8Decode((AWinControl as TCustomComboBox).Items.Strings[i]);
QComboBox_addItem(QComboBoxH(Widget), @Str, data);
end;
@ -2014,7 +2043,7 @@ begin
// Sets the initial items
for I := 0 to TCustomListBox(AWinControl).Items.Count - 1 do
begin
Text := WideString(TCustomListBox(AWinControl).Items.Strings[i]);
Text := UTF8Decode(TCustomListBox(AWinControl).Items.Strings[i]);
QListWidget_addItem(QListWidgetH(Widget), @Text);
end;
@ -2244,7 +2273,7 @@ begin
Parent := TQtWidget(AWinControl.Parent.Handle).Widget;
Widget := QStatusBar_create(Parent);
Text := WideString(AWinControl.Caption);
Text := UTF8Decode(AWinControl.Caption);
showMessage(@Text);
// Sets it´ s initial properties

View File

@ -426,7 +426,7 @@ begin
Exit;
end;
WideStr := WideString(Str);
WideStr := UTF8Decode(Str);
TQtDeviceContext(DC).drawText(Rect.Left, Rect.Top, @WideStr);
@ -496,7 +496,7 @@ begin
if not IsValidDC(DC) then Exit;
WideStr := WideString(Str);
WideStr := UTF8Decode(Str);
// if TQtDeviceContext(DC).isDrawing then TQtDeviceContext(DC).drawText(X, Y, @WideStr)
// else TQtDeviceContext(DC).AddObject(dcTextOut, @WideStr, X, Y);
@ -1839,7 +1839,7 @@ begin
if not IsValidDC(DC) then Exit;
WideStr := WideString(Str);
WideStr := UTF8Decode(Str);
// if TQtDeviceContext(DC).isDrawing then TQtDeviceContext(DC).drawText(X, Y, @WideStr)
// else TQtDeviceContext(DC).AddObject(dcTextOut, @WideStr, X, Y);

View File

@ -139,7 +139,7 @@ var
begin
TQtAbstractButton(AWinControl.Handle).Text(@Str);
AText := string(Str);
AText := UTF8Encode(Str);
Result := True;
end;
@ -153,7 +153,7 @@ class procedure TQtWSButton.SetText(const AWinControl: TWinControl; const AText:
var
Str: WideString;
begin
Str := WideString(AText);
Str := UTF8Decode(AText);
TQtAbstractButton(AWinControl.Handle).SetText(@Str);
end;
@ -217,7 +217,7 @@ var
begin
TQtAbstractButton(AWinControl.Handle).Text(@Str);
AText := string(Str);
AText := UTF8Encode(Str);
Result := True;
end;
@ -232,7 +232,7 @@ class procedure TQtWSBitBtn.SetText(const AWinControl: TWinControl;
var
Str: WideString;
begin
Str := WideString(AText);
Str := UTF8Decode(AText);
TQtAbstractButton(AWinControl.Handle).SetText(@Str);
end;

View File

@ -133,15 +133,15 @@ begin
ReturnText := '';
Caption := WideString(ACommonDialog.Title);
Caption := UTF8Decode(ACommonDialog.Title);
if ACommonDialog is TFileDialog then
begin
FileDialog := TFileDialog(ACommonDialog);
Dir := WideString(FileDialog.InitialDir);
Dir := UTF8Decode(FileDialog.InitialDir);
Filter := WideString(FileDialog.Filter);
Filter := UTF8Decode(FileDialog.Filter);
{------------------------------------------------------------------------------
This is a parser that converts LCL filter strings to Qt filter strings
@ -210,7 +210,7 @@ begin
else
QFileDialog_getOpenFileName(@ReturnText, Parent, @Caption, @Dir, @Filter, @selectedFilter, options);
FileDialog.FileName := string(ReturnText);
FileDialog.FileName := UTF8Encode(ReturnText);
if ReturnText = '' then ACommonDialog.UserChoice := mrCancel
else ACommonDialog.UserChoice := mrOK;

View File

@ -340,7 +340,7 @@ class procedure TQtWSCustomNotebook.AddPage(const ANotebook: TCustomNotebook;
var
Str: WideString;
begin
Str := WideString(AChild.Caption);
Str := UTF8Decode(AChild.Caption);
TQtTabWidget(ANotebook.Handle).insertTab(AIndex, TQtWidget(AChild.Handle).Widget, @Str);
end;

View File

@ -148,7 +148,7 @@ begin
// Set´s initial properties
Str := WideString(AWinControl.Caption);
Str := UTF8Decode(AWinControl.Caption);
QtMainWindow.SetWindowTitle(@Str);
@ -194,7 +194,7 @@ var
begin
TQtWidget(AWinControl.Handle).WindowTitle(@Str);
AText := String(Str);
AText := UTF8Encode(Str);
Result := True;
end;
@ -210,7 +210,7 @@ class procedure TQtWSCustomForm.SetText(const AWinControl: TWinControl; const AT
var
Str: WideString;
begin
Str := WideString(AText);
Str := UTF8Decode(AText);
TQtWidget(AWinControl.Handle).SetWindowTitle(@Str);
end;

View File

@ -140,7 +140,7 @@ begin
{ Count indicates the number of subitems this item has }
else if AMenuItem.Count > 0 then
begin
Text := WideString(AMenuItem.Caption);
Text := UTF8Decode(AMenuItem.Caption);
Menu := MenuBar.addMenu(@Text);
@ -150,7 +150,7 @@ begin
begin
ActionHandle := True;
Text := WideString(AMenuItem.Caption);
Text := UTF8Decode(AMenuItem.Caption);
Action := MenuBar.addAction(@Text);
@ -178,7 +178,7 @@ begin
{ Count indicates the number of subitems this item has }
else if AMenuItem.Count > 0 then
begin
Text := WideString(AMenuItem.Caption);
Text := UTF8Decode(AMenuItem.Caption);
Menu := ParentMenu.addMenu(@Text);
@ -188,7 +188,7 @@ begin
begin
ActionHandle := True;
Text := WideString(AMenuItem.Caption);
Text := UTF8Decode(AMenuItem.Caption);
Action := ParentMenu.addAction(@Text);

View File

@ -496,7 +496,7 @@ var
begin
if Length(AText) = 0 then
exit;
Astr := WideString(AText);
Astr := UTF8Decode(AText);
//QTextEdit_append(QTextEditH(ACustomMemo.Handle),@Astr);
QTextEdit_append(QTextEditH(TQtWidget(ACustomMemo.Handle).Widget),@Astr);
@ -544,7 +544,7 @@ var
begin
QTextEdit_toPlainText(QTextEditH(TQtWidget(AWinControl.Handle).Widget), @Str);
AText := String(Str);
AText := UTF8Encode(Str);
Result := True;
end;
@ -558,7 +558,7 @@ class procedure TQtWSCustomMemo.SetText(const AWinControl: TWinControl; const AT
var
AString: WideString;
begin
AString := WideString(AText);
AString := UTF8Decode(AText);
QTextEdit_append(QTextEditH(TQtWidget(AWinControl.Handle).Widget), @AString);
end;
@ -614,7 +614,7 @@ var
begin
QLineEdit_text(QLineEditH(TQtWidget(AWinControl.Handle).Widget), @Str);
AText := String(Str);
AText := UTF8Encode(Str);
Result := True;
end;
@ -628,7 +628,7 @@ class procedure TQtWSCustomEdit.SetText(const AWinControl: TWinControl; const AT
var
AString: WideString;
begin
AString := WideString(AText);
AString := UTF8Decode(AText);
QLineEdit_setText(QLineEditH(TQtWidget(AWinControl.Handle).Widget), @AString);
end;
@ -687,7 +687,7 @@ var
begin
TQtStaticText(AWinControl.Handle).Text(@Str);
AText := string(Str);
AText := UTF8Encode(Str);
Result := True;
end;
@ -701,7 +701,7 @@ class procedure TQtWSCustomStaticText.SetText(const AWinControl: TWinControl; co
var
Str: WideString;
begin
Str := WideString(AText);
Str := UTF8Decode(AText);
TQtStaticText(AWinControl.Handle).SetText(@Str);
end;
@ -760,7 +760,7 @@ var
begin
TQtAbstractButton(AWinControl.Handle).Text(@Str);
AText := string(Str);
AText := UTF8Encode(Str);
Result := True;
end;
@ -774,7 +774,7 @@ class procedure TQtWSCustomCheckBox.SetText(const AWinControl: TWinControl; cons
var
Str: WideString;
begin
Str := WideString(AText);
Str := UTF8Decode(AText);
TQtAbstractButton(AWinControl.Handle).SetText(@Str);
end;
@ -865,7 +865,7 @@ var
begin
TQtAbstractButton(AWinControl.Handle).Text(@Str);
AText := string(Str);
AText := UTF8Encode(Str);
Result := True;
end;
@ -881,7 +881,7 @@ class procedure TQtWSRadioButton.SetText(const AWinControl: TWinControl; const A
var
Str: WideString;
begin
Str := WideString(AText);
Str := UTF8Decode(AText);
TQtAbstractButton(AWinControl.Handle).SetText(@Str);
end;
@ -956,7 +956,7 @@ begin
Result := THandle(QtGroupBox);
Str := WideString(AWinControl.Caption);
Str := UTF8Decode(AWinControl.Caption);
QGroupBox_setTitle(QGroupBoxH(QtGroupBox.Widget), @Str);
end;