From: <ah...@us...> - 2009-08-23 10:43:16
|
Revision: 12464 http://jvcl.svn.sourceforge.net/jvcl/?rev=12464&view=rev Author: ahuser Date: 2009-08-23 10:43:09 +0000 (Sun, 23 Aug 2009) Log Message: ----------- - JvWizards: Clean up - Mantis #4874: JvXPButton.IsLocked => Down: Boolean Modified Paths: -------------- trunk/jvcl/run/JvWizard.pas trunk/jvcl/run/JvXPButtons.pas trunk/jvcl/run/JvXPCore.pas Modified: trunk/jvcl/run/JvWizard.pas =================================================================== --- trunk/jvcl/run/JvWizard.pas 2009-08-23 09:42:02 UTC (rev 12463) +++ trunk/jvcl/run/JvWizard.pas 2009-08-23 10:43:09 UTC (rev 12464) @@ -1252,9 +1252,7 @@ procedure TJvWizardNavigateButton.SetCaption(const Value: string); begin if Assigned(FControl) then - begin FControl.Caption := Value; - end; end; procedure TJvWizardNavigateButton.SetGlyph(const Value: TBitmap); @@ -1440,7 +1438,6 @@ end; end; - procedure TJvWizardRouteMapControl.CMDesignHitTest(var Msg: TCMDesignHitTest); begin if PageAtPos(Point(Msg.XPos, Msg.YPos)) <> nil then @@ -1449,7 +1446,6 @@ inherited; end; - function TJvWizardRouteMapControl.PageAtPos(Pt: TPoint): TJvWizardCustomPage; begin { Return the page object at the particular point in the route @@ -1480,8 +1476,6 @@ inherited MouseDown(Button, Shift, X, Y); end; - - procedure TJvWizardRouteMapControl.SetParent(AParent: TWinControl); var I: Integer; @@ -2255,7 +2249,6 @@ inherited Destroy; end; - procedure TJvWizardCustomPage.CreateParams(var Params: TCreateParams); begin inherited CreateParams(Params); @@ -2263,7 +2256,6 @@ Style := Style and not (CS_HREDRAW or CS_VREDRAW); end; - procedure TJvWizardCustomPage.AdjustClientRect(var Rect: TRect); begin inherited AdjustClientRect(Rect); @@ -2271,26 +2263,23 @@ Rect.Top := Rect.Top + FHeader.Height; end; -procedure TJvWizardCustomPage.EnableButton(AButton: TJvWizardButtonKind; AEnabled: Boolean); // Arioch +procedure TJvWizardCustomPage.EnableButton(AButton: TJvWizardButtonKind; AEnabled: Boolean); var IsEnabled: Boolean; - tmpSet: TJvWizardButtonSet; + ButtonSet: TJvWizardButtonSet; begin - tmpSet := [AButton]; - IsEnabled := (tmpSet * EnabledButtons) <> []; + ButtonSet := [AButton]; + IsEnabled := (ButtonSet * EnabledButtons) <> []; if AEnabled <> IsEnabled then begin if AEnabled then - EnabledButtons := EnabledButtons + tmpSet + EnabledButtons := EnabledButtons + ButtonSet else - EnabledButtons := EnabledButtons - tmpSet; + EnabledButtons := EnabledButtons - ButtonSet; end; end; - - procedure TJvWizardCustomPage.CMEnabledChanged(var Msg: TMessage); - var NextPage: TJvWizardCustomPage; begin @@ -2311,25 +2300,19 @@ end; end; - - procedure TJvWizardCustomPage.CMTextChanged(var Msg: TMessage); - begin Invalidate; if Assigned(FWizard) and Assigned(FWizard.FRouteMap) then FWizard.FRouteMap.DoUpdatePage(Self); end; - - procedure TJvWizardCustomPage.CMFontChanged(var Msg: TMessage); begin FHeader.AdjustTitleFont; inherited; end; - procedure TJvWizardCustomPage.SetWizard(AWizard: TJvWizard); begin if FWizard <> AWizard then @@ -2370,7 +2353,6 @@ end; end; - procedure TJvWizardCustomPage.WMEraseBkgnd(var Msg: TWMEraseBkgnd); begin {$IFDEF JVCLThemesEnabledD56} @@ -2385,7 +2367,6 @@ {$ENDIF COMPILER9_UP} end; - procedure TJvWizardCustomPage.Paint; var ARect: TRect; @@ -2439,20 +2420,14 @@ procedure TJvWizardCustomPage.Enter(const FromPage: TJvWizardCustomPage); begin - if Assigned(FOnEnterPage) and Enabled and - not (csDesigning in ComponentState) then - begin + if Assigned(FOnEnterPage) and Enabled and not (csDesigning in ComponentState) then FOnEnterPage(Self, FromPage); - end; end; procedure TJvWizardCustomPage.ExitPage(const ToPage: TJvWizardCustomPage); begin - if Assigned(FOnExitPage) and Enabled and - not (csDesigning in ComponentState) then - begin + if Assigned(FOnExitPage) and Enabled and not (csDesigning in ComponentState) then FOnExitPage(Self, ToPage); - end; end; procedure TJvWizardCustomPage.ImageChanged(Sender: TObject); @@ -2698,7 +2673,6 @@ Result := TJvWizardCustomPage(FPages[PageIndex]); end; -// Nonn ... function TJvWizard.FindNextEnabledPage(PageIndex: Integer; const Step: Integer = 1; CheckDisable: Boolean = True): TJvWizardCustomPage; var @@ -2709,14 +2683,12 @@ APage := FindNextPage(APage.PageIndex, Step, CheckDisable); Result := APage; end; -// ...Nonn procedure TJvWizard.SelectFirstPage; var AFirstPage: TJvWizardCustomPage; begin - // Nonn AFirstPage := FindNextPage(-1, 1, not (csDesigning in ComponentState)); - AFirstPage := FindNextEnabledPage(-1, 1, not (csDesigning in ComponentState)); // Nonn + AFirstPage := FindNextEnabledPage(-1, 1, not (csDesigning in ComponentState)); if Assigned(AFirstPage) then begin if not (csDesigning in ComponentState) and Assigned(FOnSelectFirstPage) then @@ -2730,8 +2702,7 @@ var ALastPage: TJvWizardCustomPage; begin -// Nonn ALastPage := FindNextPage(FPages.Count, -1, - ALastPage := FindNextEnabledPage(FPages.Count, -1, // Nonn + ALastPage := FindNextEnabledPage(FPages.Count, -1, not (csDesigning in ComponentState)); if Assigned(ALastPage) then begin @@ -2746,8 +2717,7 @@ var ANextPage: TJvWizardCustomPage; begin -// Nonn ANextPage := FindNextPage(GetActivePageIndex, 1, - ANextPage := FindNextEnabledPage(GetActivePageIndex, 1, // Nonn + ANextPage := FindNextEnabledPage(GetActivePageIndex, 1, not (csDesigning in ComponentState)); if Assigned(ANextPage) then begin @@ -2762,8 +2732,7 @@ var APriorPage: TJvWizardCustomPage; begin -// Nonn APriorPage := FindNextPage(GetActivePageIndex, -1, - APriorPage := FindNextEnabledPage(GetActivePageIndex, -1, // Nonn + APriorPage := FindNextEnabledPage(GetActivePageIndex, -1, not (csDesigning in ComponentState)); if Assigned(APriorPage) then begin @@ -2918,7 +2887,6 @@ ActivePage := nil; end; - procedure TJvWizard.WMEraseBkgnd(var Msg: TWMEraseBkgnd); begin {$IFDEF JVCLThemesEnabledD56} @@ -2928,7 +2896,6 @@ Msg.Result := 1; end; - procedure TJvWizard.Paint; var R: TRect; @@ -3019,7 +2986,6 @@ Msg.Result := 1; end; - procedure TJvWizard.AdjustClientRect(var Rect: TRect); begin { All wizard's child controls (Pages, RouteMap, etc) whose align @@ -3032,13 +2998,11 @@ Rect.Bottom := Rect.Bottom - FButtonBarHeight; end; - procedure TJvWizard.WMGetDlgCode(var Msg: TWMGetDlgCode); begin Msg.Result := DLGC_WANTALLKEYS or DLGC_WANTARROWS; end; - procedure TJvWizard.UpdateButtonsStatus; var AKind: TJvWizardButtonKind; Modified: trunk/jvcl/run/JvXPButtons.pas =================================================================== --- trunk/jvcl/run/JvXPButtons.pas 2009-08-23 09:42:02 UTC (rev 12463) +++ trunk/jvcl/run/JvXPButtons.pas 2009-08-23 10:43:09 UTC (rev 12464) @@ -69,9 +69,11 @@ FSmoothEdges: Boolean; FSpacing: Byte; FWordWrap: Boolean; + FDown: Boolean; procedure CMDialogKey(var Msg: TCMDialogKey); message CM_DIALOGKEY; procedure ImageListChange(Sender: TObject); procedure GlyphChange(Sender: TObject); + procedure SetDown(const Value: Boolean); protected function GetActionLinkClass: TControlActionLinkClass; override; function IsSpecialDrawState(IgnoreDefault: Boolean = False): Boolean; @@ -93,6 +95,7 @@ property AutoGray: Boolean read FAutoGray write SetAutoGray default True; property Cancel: Boolean read FCancel write FCancel default False; property Default: Boolean read FDefault write SetDefault default False; + property Down: Boolean read FDown write SetDown default False; property Glyph: TJvPicture read FGlyph write SetGlyph; property Layout: TJvXPLayout read FLayout write SetLayout default blGlyphLeft; property ShowAccelChar: Boolean read FShowAccelChar write SetShowAccelChar default True; @@ -122,6 +125,7 @@ property AutoGray; property Cancel; property Default; + property Down; property Glyph; property Layout; property ModalResult; @@ -377,7 +381,6 @@ Result := TJvXPCustomButtonActionLink; end; - procedure TJvXPCustomButton.CMDialogKey(var Msg: TCMDialogKey); begin inherited; @@ -413,9 +416,18 @@ end; end; +procedure TJvXPCustomButton.SetDown(const Value: Boolean); +begin + if Value <> FDown then + begin + FDown := Value; + LockedInvalidate; + end; +end; + procedure TJvXPCustomButton.SetGlyph(Value: TJvPicture); begin - if FGlyph <> Value then + if Value <> FGlyph then begin FGlyph.Assign(Value); LockedInvalidate; @@ -525,8 +537,8 @@ function TJvXPCustomButton.IsSpecialDrawState(IgnoreDefault: Boolean = False): Boolean; begin - if dsClicked in DrawState then - Result := not (dsHighlight in DrawState) + if (dsClicked in DrawState) or Down then + Result := not ((dsHighlight in DrawState) or Down) else Result := (dsHighlight in DrawState) or (dsFocused in DrawState); if not IgnoreDefault then @@ -604,7 +616,7 @@ begin Bitmap := TBitmap.Create; try - if dsHighlight in DrawState then + if (dsHighlight in DrawState) then Bitmap.Assign(FHlGradient) else Bitmap.Assign(FFcGradient); @@ -615,7 +627,7 @@ end; // draw background gradient... - if not ((dsHighlight in DrawState) and (dsClicked in DrawState)) then + if not (Down or ((dsHighlight in DrawState) and (dsClicked in DrawState))) then begin Offset := 2 * Integer(IsSpecialDrawState); BitBlt(Handle, 1 + Offset, 1 + Offset, Width - 3 * Offset, Height - 3 * Offset, @@ -623,9 +635,8 @@ end // ...or click gradient. else - begin BitBlt(Handle, 1, 1, Width, Height, FCkGradient.Canvas.Handle, 0, 0, SRCCOPY); - end; + // draw border lines. if Enabled then Pen.Color := dxColor_Btn_Enb_Border_WXP @@ -709,7 +720,7 @@ end; // should we draw the pressed state? - DrawPressed := (dsHighlight in DrawState) and (dsClicked in DrawState); + DrawPressed := Down or ((dsHighlight in DrawState) and (dsClicked in DrawState)); if DrawPressed then OffsetRect(Rect, 1, 1); @@ -892,7 +903,6 @@ {nothing}; if GetCapture <> 0 then SendMessage(GetCapture, WM_CANCELMODE, 0, 0); - end; end; Modified: trunk/jvcl/run/JvXPCore.pas =================================================================== --- trunk/jvcl/run/JvXPCore.pas 2009-08-23 09:42:02 UTC (rev 12463) +++ trunk/jvcl/run/JvXPCore.pas 2009-08-23 10:43:09 UTC (rev 12464) @@ -135,7 +135,7 @@ private FClicking: Boolean; FDrawState: TJvXPDrawState; - FIsLocked: Boolean; + FIsLocked: Integer; FIsSibling: Boolean; FModalResult: TModalResult; FOnMouseLeave: TNotifyEvent; @@ -152,25 +152,26 @@ procedure WMMouseMove(var Msg: TWMMouse); message WM_MOUSEMOVE; procedure WMSize(var Msg: TWMSize); message WM_SIZE; procedure WMWindowPosChanged(var Msg: TWMWindowPosChanged); message WM_WINDOWPOSCHANGED; + function GetIsLocked: Boolean; protected ExControlStyle: TJvXPControlStyle; - procedure InternalRedraw; dynamic; - procedure HookBorderChanged; dynamic; - procedure HookEnabledChanged; dynamic; - procedure HookFocusedChanged; dynamic; - procedure HookMouseDown; dynamic; - procedure HookMouseEnter; dynamic; - procedure HookMouseLeave; dynamic; - procedure HookMouseMove(X: Integer = 0; Y: Integer = 0); dynamic; - procedure HookMouseUp; dynamic; - procedure HookParentColorChanged; dynamic; - procedure HookParentFontChanged; dynamic; - procedure HookPosChanged; dynamic; - procedure HookResized; dynamic; - procedure HookTextChanged; dynamic; - procedure BeginUpdate; dynamic; - procedure EndUpdate; dynamic; - procedure LockedInvalidate; dynamic; + procedure InternalRedraw; virtual; + procedure HookBorderChanged; virtual; + procedure HookEnabledChanged; virtual; + procedure HookFocusedChanged; virtual; + procedure HookMouseDown; virtual; + procedure HookMouseEnter; virtual; + procedure HookMouseLeave; virtual; + procedure HookMouseMove(X: Integer = 0; Y: Integer = 0); virtual; + procedure HookMouseUp; virtual; + procedure HookParentColorChanged; virtual; + procedure HookParentFontChanged; virtual; + procedure HookPosChanged; virtual; + procedure HookResized; virtual; + procedure HookTextChanged; virtual; + procedure BeginUpdate; virtual; + procedure EndUpdate; virtual; + procedure LockedInvalidate; virtual; procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; procedure Click; override; @@ -181,7 +182,7 @@ constructor Create(AOwner: TComponent); override; property Canvas; property DrawState: TJvXPDrawState read FDrawState write FDrawState; - property IsLocked: Boolean read FIsLocked write FIsLocked; + property IsLocked: Boolean read GetIsLocked {write FIsLocked}; // AHUser: Use BeginUpdate/EndUpdate property IsSibling: Boolean read FIsSibling write FIsSibling; end; @@ -348,24 +349,27 @@ ExControlStyle := [csRedrawEnabledChanged, csRedrawFocusedChanged, csRedrawMouseDown, csRedrawMouseEnter, csRedrawMouseLeave, csRedrawMouseUp, csRedrawParentColorChanged, csRedrawCaptionChanged]; - FClicking := False; FDrawState := [dsDefault]; - FIsLocked := False; - FIsSibling := False; FModalResult := 0; end; procedure TJvXPCustomControl.BeginUpdate; begin - FIsLocked := True; + Inc(FIsLocked); end; procedure TJvXPCustomControl.EndUpdate; begin - FIsLocked := False; + Assert(FIsLocked > 0, 'Unpaired call to TJvXPCustomControl.EndUpdate'); // do not localize + Dec(FIsLocked); InternalRedraw; end; +function TJvXPCustomControl.GetIsLocked: Boolean; +begin + Result := FIsLocked > 0; +end; + procedure TJvXPCustomControl.LockedInvalidate; begin if not IsLocked then @@ -374,7 +378,7 @@ procedure TJvXPCustomControl.InternalRedraw; begin - if not FIsLocked then + if not IsLocked then Invalidate; end; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |