diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-08-21 13:58:32 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-08-21 13:58:32 +0000 |
commit | 10bbbbb92387d85bff694007b73b3104710b0ad6 (patch) | |
tree | 9b8fac5ab5e31a3d86afc301642eda2a50f44593 /src/corelib | |
parent | 35d6da8fd2ecbd015634c7bf56659f1415fb9f10 (diff) | |
download | fpGUI-10bbbbb92387d85bff694007b73b3104710b0ad6.tar.xz |
* GDI: Fixed popup window support.
* Improved menu painting with a bit of optimization.
* GDI: Implemented OnDoubleClick in TfpgWidget.
* Implemented DoubleClick in FileDialog (tested under Windows only)
* GDI: Fixed minor bug in DoWindowToScreen which prevented
popup windows from working.
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/gdi/gfx_gdi.pas | 133 | ||||
-rw-r--r-- | src/corelib/gfx_popupwindow.pas | 1 | ||||
-rw-r--r-- | src/corelib/gfx_widget.pas | 9 | ||||
-rw-r--r-- | src/corelib/x11/gfx_x11.pas | 4 |
4 files changed, 49 insertions, 98 deletions
diff --git a/src/corelib/gdi/gfx_gdi.pas b/src/corelib/gdi/gfx_gdi.pas index f14c26ac..f6a2dbb3 100644 --- a/src/corelib/gdi/gfx_gdi.pas +++ b/src/corelib/gdi/gfx_gdi.pas @@ -189,7 +189,8 @@ uses gfx_widget, gui_form, // remove this!!!!! gfx_UTF8Utils, - math; + math, + gfx_popupwindow; var wapplication: TfpgApplication; @@ -320,91 +321,10 @@ begin EY := EP.Y; end; -(* -procedure SendMouseMessage(wg : TWidget; msg : UINT; button : integer; wParam : WPARAM; lParam : LPARAM); -var - p3 : integer; - x,y : integer; - wwg : TWidget; - pwg : TWidget; - h : THANDLE; - pt : TPOINT; -begin - x := SmallInt(lParam and $FFFF); - y := SmallInt((lParam and $FFFF0000) shr 16); - - p3 := button shl 8; - - if (wParam and MK_CONTROL) <> 0 then p3 := p3 or ss_control; - if (wParam and MK_SHIFT) <> 0 then p3 := p3 or ss_shift; - - - wwg := wg; - - if (PopupListFirst <> nil) then - begin - if wg = nil then Writeln('wg is NIL !!!'); - - pt.x := x; - pt.y := y; - - ClientToScreen(wg.WinHandle, pt); - - //Writeln('click x=',pt.X,' y=',pt.y); - - h := WindowFromPoint(pt); - wwg := GetMyWidgetFromHandle(h); - - // if wwg <> nil then writeln('widget ok.'); - - pwg := wwg; - while (pwg <> nil) and (pwg.Parent <> nil) do pwg := pwg.Parent; - - if ((pwg = nil) or (PopupListFind(pwg.WinHandle) = nil)) and (not PopupDontCloseWidget(wwg)) and - ((msg = MSG_MOUSEDOWN) or (msg = MSG_MOUSEUP)) then - begin - ClosePopups; - - SendMessage(nil, wwg, MSG_POPUPCLOSE, 0, 0, 0 ); - end; - - // sending the message... - if wwg <> nil then - begin - ScreenToClient(wwg.WinHandle, pt); - x := pt.x; - y := pt.y; - end; - end; - - if ptkTopModalForm <> nil then - begin - pwg := WidgetParentForm(wwg); - if (pwg <> nil) and (ptkTopModalForm <> pwg) then wwg := nil; - end; - - if wwg <> nil then - begin - if (Msg = MSG_MOUSEDOWN) and (PopupListFirst = nil) then - begin - SetCapture(wwg.WinHandle); - end - else if (Msg = MSG_MOUSEUP) and (PopupListFirst = nil) then - begin - ReleaseCapture(); - end; - - SendMessage(nil, wwg, Msg, x, y, p3); - - end; - -end; - -*) - function fpgWindowProc(hwnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; var w: TfpgWindowImpl; + pw: TfpgWindowImpl; kwg: TfpgWidget; mw: TfpgWindowImpl; kcode: integer; @@ -525,6 +445,31 @@ begin msgp.mouse.x := smallint(lParam and $FFFF); msgp.mouse.y := smallint((lParam and $FFFF0000) shr 16); + { This closes popup windows when you click the mouse elsewhere } + if (PopupListFirst <> nil) then + begin + pt.x := msgp.mouse.x; + pt.y := msgp.mouse.y; + ClientToScreen(w.WinHandle, pt); + h := WindowFromPoint(pt); + mw := GetMyWidgetFromHandle(h); + pw := mw; + while (pw <> nil) and (pw.Parent <> nil) do + pw := TfpgWindowImpl(pw.Parent); + if ((pw = nil) or (PopupListFind(pw.WinHandle) = nil)) and (not PopupDontCloseWidget(TfpgWidget(mw))) and + ((uMsg = WM_LBUTTONDOWN) or (uMsg = WM_LBUTTONUP)) then + begin + ClosePopups; + fpgSendMessage(nil, mw, FPGM_POPUPCLOSE); + end; +// if mw <> nil then +// begin // ???? +// ScreenToClient(mw.WinHandle, pt); +// msgp.mouse.x := pt.x; +// msgp.mouse.y := pt.y; +// end; + end; { if } + if (wapplication.TopModalForm <> nil) then begin mw := nil; @@ -535,7 +480,6 @@ begin if not blockmsg then begin -// writeln(' we are continueing the event processing...'); case uMsg of WM_MOUSEMOVE: mcode := FPGM_MOUSEMOVE; @@ -543,15 +487,15 @@ begin WM_RBUTTONDOWN: begin mcode := FPGM_MOUSEDOWN; - // if PopupListFirst = nil then - SetCapture(w.WinHandle); + if PopupListFirst = nil then + SetCapture(w.WinHandle); end; WM_LBUTTONUP, WM_RBUTTONUP: begin mcode := FPGM_MOUSEUP; - // if PopupListFirst = nil then - ReleaseCapture(); + if PopupListFirst = nil then + ReleaseCapture; end; WM_LBUTTONDBLCLK: mcode := FPGM_DOUBLECLICK; @@ -681,17 +625,18 @@ begin begin if (wParam = 0) and (wapplication.TopModalForm = w) then begin - blockmsg := true; + blockmsg := True; end else if (wParam <> 0) and (wapplication.TopModalForm <> w) then begin - blockmsg := true; + blockmsg := True; end; end; - {$Note Complete this!} -// if (PopupListFirst <> nil) and (PopupListFirst.Visible) then -// blockmsg := True; + if (PopupListFirst <> nil) and (PopupListFirst.Visible) then + begin + blockmsg := True; + end; if not blockmsg then Result := Windows.DefWindowProc(hwnd, uMsg, wParam, lParam); @@ -1063,7 +1008,7 @@ end; function TfpgWindowImpl.DoWindowToScreen(ASource: TfpgWindowBase; const AScreenPos: TPoint): TPoint; begin - if not HandleIsValid then + if not ASource.HandleIsValid then Exit; //==> Result.X := AScreenPos.X; diff --git a/src/corelib/gfx_popupwindow.pas b/src/corelib/gfx_popupwindow.pas index 82e6f578..0c1d981c 100644 --- a/src/corelib/gfx_popupwindow.pas +++ b/src/corelib/gfx_popupwindow.pas @@ -217,7 +217,6 @@ var begin PopupListAdd(self); DontCloseWidget := nil; - // translate coordinates pt := WindowToScreen(AWidget, Point(x, y)); // reposition diff --git a/src/corelib/gfx_widget.pas b/src/corelib/gfx_widget.pas index 3934616f..c2b60c06 100644 --- a/src/corelib/gfx_widget.pas +++ b/src/corelib/gfx_widget.pas @@ -18,6 +18,7 @@ type TfpgWidget = class(TfpgWindow) private FAlignRect: TfpgRect; + FOnDoubleClick: TMouseButtonEvent; FOnMouseDown: TMouseButtonEvent; FOnMouseEnter: TNotifyEvent; FOnMouseExit: TNotifyEvent; @@ -84,6 +85,7 @@ type property OnMouseMove: TMouseMoveEvent read FOnMouseMove write FOnMouseMove; property OnMouseDown: TMouseButtonEvent read FOnMouseDown write FOnMouseDown; property OnMouseUp: TMouseButtonEvent read FOnMouseUp write FOnMouseUp; + property OnDoubleClick: TMouseButtonEvent read FOnDoubleClick write FOnDoubleClick; //property OnKeyPress: TKeyPressEvent read FOnKeyPress write FOnKeyPress; public constructor Create(AOwner: TComponent); override; @@ -338,7 +340,12 @@ procedure TfpgWidget.MsgDoubleClick(var msg: TfpgMessageRec); begin // If we don't generate a mouse down, we get a rapid click // delay under Windows. - HandleLMouseDown(msg.Params.mouse.x, msg.Params.mouse.y, msg.Params.mouse.shiftstate); +// HandleLMouseDown(msg.Params.mouse.x, msg.Params.mouse.y, msg.Params.mouse.shiftstate); + HandleDoubleClick(msg.Params.mouse.x, msg.Params.mouse.y, + msg.Params.mouse.Buttons, msg.Params.mouse.shiftstate); + if Assigned(FOnDoubleClick) then + FOnDoubleClick(self, mbLeft, msg.Params.mouse.shiftstate, + Point(msg.Params.mouse.x, msg.Params.mouse.y)); end; procedure TfpgWidget.MsgMouseEnter(var msg: TfpgMessageRec); diff --git a/src/corelib/x11/gfx_x11.pas b/src/corelib/x11/gfx_x11.pas index 9f2d7c55..1ed0af85 100644 --- a/src/corelib/x11/gfx_x11.pas +++ b/src/corelib/x11/gfx_x11.pas @@ -1121,8 +1121,8 @@ var dy: integer; cw: TfpgWinHandle; begin -// if not HandleIsValid then -// Exit; //==> + if not ASource.HandleIsValid then + Exit; //==> XTranslateCoordinates(xapplication.display, TfpgWindowImpl(ASource).WinHandle, XDefaultRootWindow(xapplication.display), AScreenPos.X, AScreenPos.Y, @dx, @dy, @cw); |