When tComboBox is first component on Form, Gtk enable grab capture for it and not release from Darek

git-svn-id: trunk@8964 -
This commit is contained in:
mattias 2006-03-18 23:10:14 +00:00
parent b3acb323cf
commit ba79bfe6ab
7 changed files with 89 additions and 16 deletions

View File

@ -365,6 +365,7 @@ end;
------------------------------------------------------------------------------}
procedure TCustomSpeedButton.Paint;
var
fRect,
PaintRect: TRect;
GlyphWidth, GlyphHeight: Integer;
Offset, OffsetCap: TPoint;
@ -372,6 +373,7 @@ var
//BrushStyle : TBrushStyle;
M, S : integer;
TXTStyle : TTextStyle;
Flags,
SIndex : Longint;
TMP : String;
//xBevel : tBevelCut;
@ -424,8 +426,22 @@ begin
if Caption <> '' then begin
TMP := Caption;
TXTStyle := Canvas.TextStyle;
TXTStyle.Opaque := False;
TXTStyle.Clipping := True;
TXTStyle.ShowPrefix := True;
TXTStyle.Alignment := taLeftJustify;
TXTStyle.Layout := tlTop;
TXTStyle.SystemFont := Canvas.Font.IsDefault;//Match System Default Style
SIndex := DeleteAmpersands(TMP);
TextSize:= Canvas.TextExtent(TMP);
fRect:=PaintRect;
Flags:=DT_CalcRect;
if not TXTStyle.SingleLine then inc(Flags,DT_WordBreak)
else inc(Flags,DT_SingleLine);
DrawText(canvas.Handle,pChar(TMP),Length(TMP),fRect,flags);
TextSize.cy:=fRect.bottom-fRect.top;
TextSize.cx:=fRect.right-fRect.left;
If SIndex > 0 then
If SIndex <= Length(TMP) then begin
FShortcut := Ord(TMP[SIndex]);
@ -503,13 +519,7 @@ begin
FGlyph.Draw(Canvas, PaintRect, Offset, FState, Transparent, 0);
if Caption <> '' then begin
TXTStyle := Canvas.TextStyle;
TXTStyle.Opaque := False;
TXTStyle.Clipping := True;
TXTStyle.ShowPrefix := True;
TXTStyle.Alignment := taLeftJustify;
TXTStyle.Layout := tlTop;
TXTStyle.SystemFont := Canvas.Font.IsDefault;//Match System Default Style
With PaintRect, OffsetCap do begin
Left := Left + X;
Top := Top + Y;

View File

@ -395,7 +395,9 @@ var
begin
//DebugLn('gtktoggledCB ',DbgSName(TObject(Data)));
Result := CallBackDefaultReturn;
{$IFDEF EventTrace}
EventTrace('toggled', data);
{$ENDIF}
if LockOnChange(PgtkObject(Widget),0) > 0 then Exit;
if GtkWidgetIsA(Widget,gtk_toggle_button_get_type) then begin
@ -415,7 +417,9 @@ var
DesignOnlySignal: boolean;
begin
Result := CallBackDefaultReturn;
{$IFDEF EventTrace}
EventTrace('DrawAfter', data);
{$ENDIF}
if not (csDesigning in TComponent(Data).ComponentState) then begin
DesignOnlySignal:=GetDesignOnlySignalFlag(Widget,dstDrawAfter);
@ -440,7 +444,9 @@ var
DesignOnlySignal: boolean;
begin
Result := CallBackDefaultReturn;
{$IFDEF EventTrace}
EventTrace('ExposeAfter', data);
{$ENDIF}
if (Event^.Count > 0) then exit;
if not (csDesigning in TComponent(Data).ComponentState) then begin
@ -451,7 +457,7 @@ begin
DebugLn('gtkExposeAfter',
' Widget=',DbgS(Widget),'=',GetWidgetClassName(Widget),
' ',TComponent(Data).Name,
' ',Event^.area.x,',',Event^.area.y,',',Event^.area.width,',',Event^.area.height,
' ',dbgs(Event^.area.x),',',dbgs(Event^.area.y),',',dbgs(Event^.area.width),',',dbgs(Event^.area.height),
'');
{$ENDIF}
end;
@ -470,7 +476,9 @@ var
CurFocusWidget: PGtkWidget;
{$ENDIF}
begin
{$IFDEF EventTrace}
EventTrace('activate after', data);
{$ENDIF}
if (Widget=nil) or (Event=nil) then ;
FillChar(Mess,SizeOf(Mess),#0);
{$IFDEF VerboseFocus}
@ -524,7 +532,9 @@ var
LCLObject: TControl;
{$ENDIF}
begin
{$IFDEF EventTrace}
EventTrace('deactivate after', data);
{$ENDIF}
if (Widget=nil) or (Event=nil) then ;
{$IFDEF VerboseFocus}
write('gtkfrmdeactivate Widget=',DbgS(Widget),' ',Event^.theIn,
@ -649,12 +659,10 @@ begin
{$ENDIF}
UpdateMouseCaptureControl;
//TODO: fill in old focus
FillChar(Mess,SizeOf(Mess),0);
Mess.msg := LM_SETFOCUS;
DeliverMessage(Data, Mess);
Result:=true;
end;
@ -666,7 +674,9 @@ var
CurFocusWidget: PGtkWidget;
{$ENDIF}
begin
EventTrace('killfocus', data);
{$IFDEF EventTrace}
EventTrace('killfocusCB', data);
{$ENDIF}
if (Widget=nil) or (Event=nil) then ;
{$IFDEF VerboseFocus}
write('GTKillFocusCB Widget=',DbgS(Widget),' Event^.theIn=',Event^.theIn);
@ -711,7 +721,9 @@ var
{$ENDIF}
begin
if (Widget=nil) or (Event=nil) then ;
EventTrace('killfocus', data);
{$IFDEF EventTrace}
EventTrace('killfocusCBAfter', data);
{$ENDIF}
{$IFDEF VerboseFocus}
write('GTKillFocusCBAfter Widget=',DbgS(Widget),' Event^.theIn=',Event^.theIn);
LCLObject:=TObject(data);
@ -746,8 +758,11 @@ begin
FillChar(Mess,SizeOf(Mess),0);
Mess.msg := LM_KILLFOCUS;
ReleaseCaptureWidget(Widget);
//TODO: fill in new focus
Assert(False, Format('Trace:TODO: [gtkkillfocusCB] %s finish', [TObject(Data).ClassName]));
DeliverMessage(Data, Mess);
Result:=true;
@ -777,7 +792,9 @@ begin
exit;
end;
EventTrace('destroy', data);
{$IFDEF EventTrace}
EventTrace('destroyCB', data);
{$ENDIF}
//DebugLn('gtkdestroyCB Data="',DbgSName(TObject(Data)),'" LCLObject="',DbgSName(Info^.LCLObject),'" ',GetWidgetDebugReport(Widget));
FillChar(Mess,SizeOf(Mess),0);
Mess.msg := LM_DESTROY;
@ -806,7 +823,9 @@ function gtkresizeCB( widget: PGtkWidget; data: gPointer) : GBoolean; cdecl;
begin
Result := CallBackDefaultReturn;
if (Widget=nil) then ;
{$IFDEF EventTrace}
EventTrace('resize', data);
{$ENDIF}
// Mess.msg := LM_RESIZE;
// TControl(data).WindowProc(TLMessage(Mess));
Assert(False, 'Trace:TODO: [gtkresizeCB] fix (or remove) to new LM_SIZE');
@ -819,7 +838,9 @@ var
begin
Result := CallBackDefaultReturn;
if (Widget=nil) then ;
{$IFDEF EventTrace}
EventTrace('month changed', data);
{$ENDIF}
FillChar(Mess,SizeOf(Mess),0);
Mess.Msg := LM_MONTHCHANGED;
DeliverPostMessage(Data, Mess);
@ -1301,7 +1322,9 @@ begin
//if GetFixedWidget(Widget)<>nil then
// DebugLn('DDD2 ClientWindow=',DbgS(PGtkWidget(GetFixedWidget(Widget))^.Window));
{$IFDEF EventTrace}
EventTrace('Mouse button Press', data);
{$ENDIF}
UpdateMouseCaptureControl;
@ -3103,6 +3126,7 @@ begin
DeliverMessage(Data, Mess);
end;
{$I gtkDragCallback.inc}
{$I gtkListViewCallback.inc}
{$I gtkComboBoxCallback.inc}

View File

@ -992,6 +992,8 @@ var
ComboStrings: TStrings;
CurText: String;
begin
if not ComboBox.HandleAllocated then
RaiseGDBException('');
ComboWidget:=PGtkCombo(ComboBox.Handle);
ComboStrings:=TStrings(gtk_object_get_data(PGtkObject(ComboWidget),'LCLList'));
CurText:=GetComboBoxText(ComboWidget);
@ -3446,7 +3448,8 @@ function DeliverMessage(const Target: Pointer; var AMessage): Integer;
begin
if Target=nil then DebugLn('[DeliverMessage] Target = nil');
{$IFDEF VerboseDeliverMessage}
DebugLn('DeliverMessage ',DbgS(Target),
if TLMessage(AMessage).Msg<>LM_MOUSEMOVE then
DebugLn('DeliverMessage ',DbgS(Target),
' ',TComponent(Target).Name,':',TObject(Target).ClassName,
' Message=',GetMessageName(TLMessage(AMessage).Msg));
{$ENDIF}
@ -4421,6 +4424,9 @@ begin
DebugLn('UpdateMouseCaptureControl Capture changed from ',
'[',GetWidgetDebugReport(OldMouseCaptureWidget),']',
' to [',GetWidgetDebugReport(CurMouseCaptureWidget),']');
if CurMouseCaptureWidget<>nil then
DebugLn('parent ', GetWidgetDebugReport(CurMouseCaptureWidget^.Parent));
{$ENDIF}
// notify the new capture control
@ -4533,6 +4539,20 @@ begin
SetCaptureControl(nil);
end;
procedure ReleaseCaptureWidget(Widget : PGtkWidget);
begin
if (MouseCaptureWidget=nil) or (Widget=nil) then exit;
if (MouseCaptureWidget<>Widget) and (MouseCaptureWidget<>Widget^.parent) then exit;
{$IFDEF VerboseMouseCapture}
DebugLn('ReleaseCaptureControl ',dbgs(ord(MouseCaptureType)),' MouseCaptureWidget=[',GetWidgetDebugReport(MouseCaptureWidget),']');
{$ENDIF}
gtk_grab_remove(MouseCaptureWidget);
MouseCaptureWidget:=nil;
MouseCaptureType:=mctGTK;
SetCaptureControl(nil);
end;
{------------------------------------------------------------------------------
procedure: SetCursor
Params: AWinControl : TWinControl

View File

@ -530,6 +530,7 @@ procedure SetCursor(AWinControl: TWinControl; ACursor: TCursor);
procedure CaptureMouseForWidget(Widget: PGtkWidget; Owner: TMouseCaptureType);
function GetDefaultMouseCaptureWidget(Widget: PGtkWidget): PGtkWidget;
procedure ReleaseMouseCapture;
procedure ReleaseCaptureWidget(Widget : PGtkWidget);
procedure UpdateMouseCaptureControl;
// designing

View File

@ -620,6 +620,7 @@ end;
function TGtkWSCustomComboBox.GetItemIndex(
const ACustomComboBox: TCustomComboBox): integer;
begin
//DebugLn('TGtkWSCustomComboBox.GetItemIndex ',DbgSName(ACustomComboBox),' ',DebugGtkWidgets.GetInfo(Pointer(ACustomComboBox.Handle),true));
Result:=GetComboBoxItemIndex(ACustomComboBox);
end;

View File

@ -265,7 +265,8 @@ begin
else if FGtkListStore<>nil then begin
UpdateItemCache;
ListItem:=FCachedItems[Index];
gtk_list_store_set(FGtkListStore, @ListItem, [FColumnIndex+1, AnObject, -1]);
gtk_list_store_set(FGtkListStore, @ListItem,
[FColumnIndex+1, Pointer(AnObject), -1]);
end;
end;

View File

@ -773,6 +773,22 @@ begin
// RECEIVED from the interface, here are no defines
// of messages send to the interface
//-------------
LM_ACTIVATE : Result:='LM_ACTIVATE';
LM_SETFOCUS : Result:='LM_SETFOCUS';
LM_KILLFOCUS : Result:='LM_KILLFOCUS';
LM_SHOWWINDOW : Result:='LM_SHOWWINDOW';
LM_SIZE : Result:='LM_SIZE';
LM_MOVE : Result:='LM_MOVE';
// LM_MOUSEFIRST : Result:='LM_MOUSEFIRST';
LM_MOUSEMOVE : Result:='LM_MOUSEMOVE';
LM_LBUTTONDOWN : Result:='LM_LBUTTONDOWN';
LM_LBUTTONUP : Result:='LM_LBUTTONUP';
LM_CAPTURECHANGED : Result:='LM_CAPTURECHANGED';
LM_SELCHANGE : Result:='LM_SELCHANGE';
LM_USER :Result:='LM_USER';
//WM_USER :Result:='';
LM_DESTROY :Result:='LM_DESTROY';