Some 64bit changes for TWS.Create Timer

Fixed gtk2 listbox events
Partially fixed gtk2 painting issues  bug #964
Fixed bug #7067
Gtk2 Opendialogs now use GtkFileChooserDialog
Added a check for the clipboard in case it get stuck in a repeat loop
lclgtkcellrenderer now knows the itemindex to paint correctly

git-svn-id: trunk@10067 -
This commit is contained in:
andrew 2006-10-15 13:27:27 +00:00
parent 676fd7a234
commit fc03d1600d
18 changed files with 94 additions and 71 deletions

View File

@ -77,8 +77,8 @@ type
// create and destroy
function CreateComponent(Sender : TObject): THandle; virtual; abstract;
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc): integer; virtual; abstract;
function DestroyTimer(TimerHandle: integer): boolean; virtual; abstract;
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc): THandle; virtual; abstract;
function DestroyTimer(TimerHandle: THandle): boolean; virtual; abstract;
{$DEFINE IF_BASE_MEMBER}
{$I winapih.inc}
@ -124,4 +124,4 @@ const
{$I intfbasewinapi.inc}
{$I intfbaselcl.inc}
end.
end.

View File

@ -78,8 +78,8 @@ type
// create and destroy
function CreateComponent(Sender : TObject): THandle; override;
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : integer; override;
function DestroyTimer(TimerHandle: integer) : boolean; override;
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : THandle; override;
function DestroyTimer(TimerHandle: THandle) : boolean; override;
// the winapi compatibility methods
{$I carbonwinapih.inc}

View File

@ -378,12 +378,12 @@ begin
Result:=0;
end;
function TCarbonWidgetSet.CreateTimer(Interval: integer; TimerFunc: TFNTimerProc): integer;
function TCarbonWidgetSet.CreateTimer(Interval: integer; TimerFunc: TFNTimerProc): THandle;
begin
Result:=0;
end;
function TCarbonWidgetSet.DestroyTimer(TimerHandle: integer): boolean;
function TCarbonWidgetSet.DestroyTimer(TimerHandle: THandle): boolean;
begin
Result:=false;
end;

View File

@ -446,6 +446,9 @@ function gtkExposeEventAfter(Widget: PGtkWidget; Event : PGDKEventExpose;
Data: gPointer): GBoolean; cdecl;
var
DesignOnlySignal: boolean;
{$IFDEF GTK2}
children: PGList;
{$ENDIF}
begin
Result := CallBackDefaultReturn;
{$IFDEF EventTrace}
@ -471,6 +474,21 @@ begin
// the expose area is ok, but some gtk widgets repaints everything on expose
// -> maximize the area
DeliverGtkPaintMessage(Data,Widget,@Event^.Area,true);
{$IFDEF GTK2}
// Some widgets in gtk2 don't have their own exclusive "windows" so a synthetic event must be sent
if GTK_IS_FIXED(Widget) then begin
children := gtk_container_get_children(PGtkContainer(Widget));
while children <> nil do begin
if (children^.data <> nil) then begin
if GTK_WIDGET_NO_WINDOW(PGtkWidget(children^.data)) then
gtk_container_propagate_expose(PGtkContainer(Widget), PGtkWidget(children^.data), Event);
if children^.next = nil then break;
children := children^.next;
end;
end;
g_list_free(children);
end;
{$ENDIF}
end;
function gtkfrmactivateAfter(widget: PGtkWidget; Event : PgdkEventFocus;
@ -2065,6 +2083,7 @@ begin
if (AHistoryEntry<>nil) and (AHistoryEntry^.Filename<>nil) then begin
// user has choosen a history file
// -> select it in the filedialog
{$IFDEF GTK1}
gtk_file_selection_complete(PGtkFileSelection(theDialog.Handle),
AHistoryEntry^.Filename);
// restore filter
@ -2076,10 +2095,15 @@ begin
CheckFilterActivated(ActiveFilterMenuItem);
end;
end;
{$ELSE}
gtk_file_chooser_set_current_folder(PGtkFileChooser(theDialog.Handle),AHistoryEntry^.Filename);
{$ENDIF}
UpdateDetailView(TOpenDialog(theDialog));
end;
{$IFDEF GTK1}
// check if filter activated
CheckFilterActivated(Widget);
{$ENDIF}
end;
end;

View File

@ -325,8 +325,8 @@ type
// create and destroy
function CreateComponent(Sender : TObject): THandle; override;
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : integer; override;
function DestroyTimer(TimerHandle: integer) : boolean; override;
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : THandle; override;
function DestroyTimer(TimerHandle: THandle) : boolean; override;
procedure DestroyLCLComponent(Sender: TObject);virtual;
{$I gtkwinapih.inc}
@ -339,6 +339,9 @@ type
{$I gtklistslh.inc}
{$I gtkfiledialogutilsh.inc}
procedure CreateOpenDialogHistory(OpenDialog: TOpenDialog;
SelWidget: PGtkWidget);
var
GTKWidgetSet: TGTKWidgetSet;

View File

@ -1994,7 +1994,7 @@ End;
Design: A callback to the TTimer class is implemented.
------------------------------------------------------------------------------}
function TGtkWidgetSet.CreateTimer(Interval: integer;
TimerFunc: TFNTimerProc) : integer;
TimerFunc: TFNTimerProc) : THandle;
var
TimerInfo: PGtkITimerinfo;
begin
@ -2026,7 +2026,7 @@ end;
WARNING: There seems to be a bug in gtk-1.2.x which breaks gtk_timeout_remove
thus we can't dispose PGtkITimerinfo here (s.a. gtkTimerCB).
------------------------------------------------------------------------------}
function TGtkWidgetSet.DestroyTimer(TimerHandle: integer) : boolean;
function TGtkWidgetSet.DestroyTimer(TimerHandle: THandle) : boolean;
var
n : integer;
TimerInfo : PGtkITimerinfo;
@ -4466,8 +4466,12 @@ begin
// create a HBox so that the history is left justified
HBox:=gtk_hbox_new(false,0);
gtk_object_set_data(PGtkObject(SelWidget), 'LCLHistoryHBox', HBox);
{$IFDEF GTK1}
gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(SelWidget)^.main_vbox),
HBox,false,false,0);
{$ELSE}
gtk_file_chooser_set_extra_widget(PGtkDialog(SelWidget),HBox);
{$ENDIF}
// create the label 'History:'
s:=rsgtkHistory;
@ -4481,7 +4485,7 @@ begin
HistoryPullDownWidget);
gtk_box_pack_start(GTK_BOX(HBox),HistoryPullDownWidget,false,false,5);
gtk_widget_show(HistoryPullDownWidget);
gtk_widget_show(HBox);
gtk_widget_show_all(HBox);
// create the menu (the content of the pull down)
MenuWidget:=gtk_menu_new;

View File

@ -3424,6 +3424,7 @@ var
FileSelWidget: PGtkFileSelection;
LCLFilterMenu, LCLHistoryMenu: PGTKWidget;
begin
if (ADialog=nil) or (not ADialog.HandleAllocated) then exit;
DlgWindow:=PGtkWidget(ADialog.Handle);
{$IFDEF VerboseTransient}
@ -3431,7 +3432,9 @@ begin
{$ENDIF}
gtk_window_set_transient_for(PGtkWindow(DlgWindow),nil);
if ADialog is TOpenDialog then begin
{$IFDEF GTK2}
FileSelWidget:=GTK_FILE_CHOOSER(DlgWindow);
{$ELSE}
FileSelWidget:=GTK_FILE_SELECTION(DlgWindow);
FreeWidgetInfo(FileSelWidget^.selection_entry);
FreeWidgetInfo(FileSelWidget^.dir_list);
@ -3439,6 +3442,7 @@ begin
LCLFilterMenu:=PGTKWidget(gtk_object_get_data(PGtkObject(FileSelWidget),
'LCLFilterMenu'));
if LCLFilterMenu<>nil then FreeWidgetInfo(LCLFilterMenu);
{$ENDIF}
LCLHistoryMenu:=PGTKWidget(gtk_object_get_data(PGtkObject(FileSelWidget),
'LCLHistoryMenu'));
if LCLHistoryMenu<>nil then FreeWidgetInfo(LCLHistoryMenu);
@ -3457,6 +3461,7 @@ begin
gtk_object_set_data(PGtkObject(DlgWindow),'LCLHistoryList',nil);
end;
{$IFDEF GTK1}
// free filter
FilterList:=TFPList(gtk_object_get_data(PGtkObject(DlgWindow),
'LCLFilterList'));
@ -3472,6 +3477,7 @@ begin
FilterList.Free;
gtk_object_set_data(PGtkObject(DlgWindow),'LCLFilterList',nil);
end;
{$ENDIF}
// free preview handle
if ADialog is TPreviewFileDialog then begin
@ -6663,6 +6669,7 @@ function RequestSelectionData(ClipboardWidget: PGtkWidget;
var
TimeID: cardinal;
c: PClipboardEventData;
sanity: Integer = 0;
begin
{$IFDEF DEBUG_CLIPBOARD}
DebugLn('[RequestSelectionData] FormatID=',dbgs(FormatID));
@ -6671,8 +6678,7 @@ begin
if (ClipboardWidget=nil) or (FormatID=0)
or (ClipboardTypeAtoms[ClipboardType]=0) then exit;
TimeID:=0; // = GDK_CURRENT_TIME, better use the current event^.time, but
// how to retrieve that value?
TimeID:= gdk_event_get_time(gtk_get_current_event);
// IMPORTANT: To retrieve data from xterm or kde applications
// the time id must be 0 or event^.time
repeat
@ -6693,7 +6699,8 @@ begin
break;
ClipboardSelectionData.Remove(c);
Dispose(c);
until false;
Inc(sanity);
until false or (sanity > 1000000);
try
if not WaitForClipboardAnswer(c) then exit;
Result:=c^.Data;

View File

@ -69,6 +69,8 @@ var
AreaRect: TRect;
State: TBaseOwnerDrawState;
Msg: TLMDrawListItem;
ItemPath: PGtkTreePath;
Column: PGtkTreeViewColumn;
begin
DebugLn(['LCLIntfCellRenderer_Render cell=',dbgs(cell),
' ',GetWidgetDebugReport(Widget),' ',
@ -97,10 +99,13 @@ begin
exit;
// get itemindex and area
ItemIndex:=0; // ToDo
//Model:=PGtkTreeModel(gtk_tree_view_get_model(PGtkTreeView(Widget)));
//gtk_tree_model_get(Model);
ItemIndex:=0;
if GTK_IS_TREE_VIEW(Widget) then begin
gtk_tree_view_get_path_at_pos(PGtkTreeView(Widget),cell_area^.x, cell_area^.y, ItemPath, column, nil, nil);
if ItemPath <> nil then
ItemIndex := StrToInt(gtk_tree_path_to_string(ItemPath));
end;
AreaRect:=Bounds(background_area^.x,background_area^.y,
background_area^.Width,background_area^.Height);

View File

@ -127,7 +127,6 @@ begin
Result := False;
end;
{$IFDEF HasGTK2_6}
procedure Gtk2FileChooserResponseCB(widget: PGtkFileChooser; arg1: gint; data: gpointer); cdecl;
procedure AddFile(List: TStrings; const NewFile: string);
@ -188,7 +187,6 @@ begin
//?? StoreCommonDialogSetup(theDialog);
theDialog.UserChoice := mrOK;
end;
{$ENDIF}
Procedure gtk_clb_toggle(cellrenderertoggle : PGtkCellRendererToggle; arg1 : PGChar;
WinControl: TWinControl); cdecl;
@ -842,13 +840,13 @@ end;
------------------------------------------------------------------------------}
procedure TGtk2WidgetSet.InitializeOpenDialog(OpenDialog: TOpenDialog;
SelWidget: PGtkWidget);
{$IFDEF HasGTK2_6}
var
FileSelWidget: PGtkFileChooser;
HelpButton: PGtkWidget;
{$ENDIF}
FrameWidget: PGtkWidget;
HBox: PGtkWidget;
FileDetailLabel: PGtkWidget;
begin
{$IFDEF HasGTK2_6}
FileSelWidget := GTK_FILE_CHOOSER(SelWidget);
// Help button
@ -864,17 +862,20 @@ begin
// History List - a frame with an option menu
CreateOpenDialogHistory(OpenDialog, SelWidget);
// // Filter - a frame with an option menu
// Filter
CreateOpenDialogFilter(OpenDialog,SelWidget);
(*
// Details - a frame with a label
if (ofViewDetail in OpenDialog.Options) then begin
// create the frame around the information
FrameWidget:=gtk_frame_new(PChar(rsFileInformation));
gtk_box_pack_start(GTK_BOX(FileSelWidget^.main_vbox),
FrameWidget,false,false,0);
//gtk_box_pack_start(GTK_BOX(FileSelWidget^.main_vbox),
// FrameWidget,false,false,0);
gtk_box_pack_start(GTK_BOX(gtk_file_chooser_get_extra_widget(
PGtkFileChooser(SelWidget))), FrameWidget,false,false,0);
gtk_widget_show(FrameWidget);
// create a HBox, so that the information is left justified
HBox:=gtk_hbox_new(false,0);
@ -887,7 +888,7 @@ begin
FileDetailLabel:=nil;
gtk_object_set_data(PGtkObject(SelWidget), 'FileDetailLabel',
FileDetailLabel);
*)
// preview
if (OpenDialog is TPreviewFileDialog) then
CreatePreviewDialogControl(TPreviewFileDialog(OpenDialog), SelWidget);
@ -898,9 +899,6 @@ begin
//if InitialFilter <> 'none' then
// PopulateFileAndDirectoryLists(FileSelWidget, InitialFilter);
{$ELSE}
inherited InitializeOpenDialog(OpenDialog,SelWidget);
{$ENDIF NONO}
end;
{------------------------------------------------------------------------------
@ -913,13 +911,10 @@ end;
------------------------------------------------------------------------------}
procedure TGtk2WidgetSet.InitializeFileDialog(FileDialog: TFileDialog;
var SelWidget: PGtkWidget; Title: PChar);
{$IFDEF HasGTK2_6}
var
Action: TGtkFileChooserAction;
Button1: String;
{$ENDIF}
begin
{$IFDEF HasGTK2_6}
Action := GTK_FILE_CHOOSER_ACTION_OPEN;
Button1 := GTK_STOCK_OPEN;
@ -944,22 +939,16 @@ begin
InitializeOpenDialog(TOpenDialog(FileDialog), SelWidget);
InitializeCommonDialog(TCommonDialog(FileDialog), SelWidget);
{$ELSE}
inherited InitializeFileDialog(FileDialog,SelWidget,Title);
{$ENDIF}
end;
function TGtk2WidgetSet.CreateOpenDialogFilter(OpenDialog: TOpenDialog;
SelWidget: PGtkWidget): string;
{$IFDEF HasGTK2_6}
var
FilterList: TFPList;
i, j: integer;
s: String;
GtkFilter: PGtkFileFilter;
{$ENDIF}
begin
{$IFDEF HasGTK2_6}
ExtractFilterList(OpenDialog.Filter, FilterList, false);
if FilterList.Count > 0 then begin
j := 1;
@ -982,21 +971,15 @@ begin
gtk_object_set_data(PGtkObject(SelWidget), 'LCLFilterList', FilterList);
Result := 'hm'; { Don't use '' as null return as this is used for *.* }
{$ELSE}
Result:=inherited CreateOpenDialogFilter(OpenDialog,SelWidget);
{$ENDIF}
end;
procedure TGtk2WidgetSet.CreatePreviewDialogControl(
PreviewDialog: TPreviewFileDialog; SelWidget: PGtkWidget);
{$IFDEF HasGTK2_6}
var
PreviewWidget: PGtkWidget;
AControl: TPreviewFileControl;
FileChooser: PGtkFileChooser;
{$ENDIF}
begin
{$IFDEF HasGTK2_6}
AControl := PreviewDialog.PreviewFileControl;
if AControl = nil then Exit;
@ -1011,9 +994,6 @@ begin
gtk_file_chooser_set_preview_widget(FileChooser, PreviewWidget);
gtk_widget_show(PreviewWidget);
{$ELSE}
inherited CreatePreviewDialogControl(PreviewDialog,SelWidget);
{$ENDIF}
end;
{$IFDEF ASSERT_IS_ON}

View File

@ -518,8 +518,8 @@ begin
else
ColSizing := GTK_TREE_VIEW_COLUMN_FIXED;
gtk_tree_view_column_set_sizing(GtkColumn, ColSizing);
gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN (GtkColumn), True);
gtk_tree_view_column_set_sizing(GtkColumn, ColSizing);
end;
end;

View File

@ -456,7 +456,7 @@ begin
end;
WidgetInfo := GetWidgetInfo(p, False);
SetCallbacks(p, WidgetInfo);
SetCallbacks(TempWidget, WidgetInfo);
end;
class procedure TGtk2WSCustomListBox.SetCallbacks(

View File

@ -70,9 +70,9 @@ type
function InitHintFont(HintFont: TObject): Boolean; override;
// create and destroy
function CreateComponent(Sender : TObject): THandle; override; // deprecated
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc): integer; override;
function DestroyTimer(TimerHandle: integer): boolean; override;
function CreateComponent(Sender : TObject): LCLType.THandle; override; // deprecated
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc): LCLType.THandle; override;
function DestroyTimer(TimerHandle: LCLType.THandle): boolean; override;
// device contexts
function IsValidDC(const DC: HDC): Boolean; virtual;

View File

@ -51,13 +51,13 @@ end;
Creates a new timer and sets the callback event.
------------------------------------------------------------------------------}
function TQtWidgetSet.CreateTimer(Interval: integer;
TimerFunc: TFNTimerProc): integer;
TimerFunc: TFNTimerProc): LCLType.THandle;
var
QtTimer: TQtTimer;
begin
QtTimer := TQtTimer.CreateTimer(Interval, TimerFunc, App);
Result := Integer(QtTimer);
Result := PtrInt(QtTimer);
end;
{------------------------------------------------------------------------------
@ -67,7 +67,7 @@ end;
Destroys a timer.
------------------------------------------------------------------------------}
function TQtWidgetSet.DestroyTimer(TimerHandle: integer): boolean;
function TQtWidgetSet.DestroyTimer(TimerHandle: LCLType.THandle): boolean;
begin
TQtTimer(TimerHandle).Free;
@ -162,7 +162,7 @@ end;
Deprecated, never call this function
------------------------------------------------------------------------------}
function TQtWidgetSet.CreateComponent(Sender : TObject): THandle;
function TQtWidgetSet.CreateComponent(Sender : TObject): LCLType.THandle;
begin
Result := 0;
end;

View File

@ -200,8 +200,8 @@ Type
// create and destroy
function CreateComponent(Sender : TObject): THandle; override;
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : integer; override;
function DestroyTimer(TimerHandle: Integer) : boolean; override;
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : THandle; override;
function DestroyTimer(TimerHandle: THandle) : boolean; override;
// thread synchronize support
procedure HandleWakeMainThread(Sender: TObject);

View File

@ -421,7 +421,7 @@ end;
Design: A timer which calls TimerCallBackProc, is created.
The TimerCallBackProc calls the TimerFunc.
------------------------------------------------------------------------------}
function TWin32WidgetSet.CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : integer;
function TWin32WidgetSet.CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : THandle;
var
TimerInfo: PWin32TimerInfo;
begin
@ -446,7 +446,7 @@ end;
Params: TimerHandle
Returns:
------------------------------------------------------------------------------}
function TWin32WidgetSet.DestroyTimer(TimerHandle: Integer) : boolean;
function TWin32WidgetSet.DestroyTimer(TimerHandle: THandle) : boolean;
var
n : integer;
TimerInfo : PWin32Timerinfo;

View File

@ -188,8 +188,8 @@ type
// create and destroy
function CreateComponent(Sender : TObject): THandle; override;
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : integer; override;
function DestroyTimer(TimerHandle: Integer) : boolean; override;
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : THandle; override;
function DestroyTimer(TimerHandle: THandle) : boolean; override;

View File

@ -326,12 +326,12 @@ begin
end;
function TWinCEWidgetSet.CreateTimer(Interval: integer; TimerFunc: TFNTimerProc
): integer;
): THandle;
begin
end;
function TWinCEWidgetSet.DestroyTimer(TimerHandle: Integer): boolean;
function TWinCEWidgetSet.DestroyTimer(TimerHandle: THandle): boolean;
begin
end;

View File

@ -53,7 +53,7 @@ type
TWSCommonDialogClass = class of TWSCommonDialog;
TWSCommonDialog = class(TWSLCLComponent)
class function CreateHandle(const ACommonDialog: TCommonDialog): integer; virtual;
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; virtual;
class procedure ShowModal(const ACommonDialog: TCommonDialog); virtual;
class procedure DestroyHandle(const ACommonDialog: TCommonDialog); virtual;
end;
@ -96,7 +96,7 @@ type
implementation
class function TWSCommonDialog.CreateHandle(const ACommonDialog: TCommonDialog): integer;
class function TWSCommonDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
begin
Result := 0;
end;
@ -124,4 +124,4 @@ initialization
// RegisterWSComponent(TColorButton, TWSColorButton);
// RegisterWSComponent(TFontDialog, TWSFontDialog);
////////////////////////////////////////////////////
end.
end.