diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-31 09:44:32 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-31 09:44:32 +0000 |
commit | 0fdfd9d1251f47d40a4fa9fc3d4599ef713a7999 (patch) | |
tree | c39b544202d4db5d3d871d84391935758bc7a181 /src | |
parent | 0e2ffba0302d927fa856cbd62f725417714cc74c (diff) | |
download | fpGUI-0fdfd9d1251f47d40a4fa9fc3d4599ef713a7999.tar.xz |
* Fixed FillRectangle() under GDI and X11.
* Implemented Enable/Disbled state in TfpgComboBox.
* Fixed painting issues in TfpgScrollbar and TfpgMemo (tested
under X11).
* Moved SetEnabled and SetVisible in TfpgWidget to protected
and virtual.
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/fpgfx.pas | 4 | ||||
-rw-r--r-- | src/corelib/gdi/gfx_gdi.pas | 2 | ||||
-rw-r--r-- | src/corelib/gfx_widget.pas | 4 | ||||
-rw-r--r-- | src/corelib/x11/gfx_x11.pas | 7 | ||||
-rw-r--r-- | src/gui/gui_combobox.pas | 19 | ||||
-rw-r--r-- | src/gui/gui_edit.pas | 7 | ||||
-rw-r--r-- | src/gui/gui_memo.pas | 45 | ||||
-rw-r--r-- | src/gui/gui_scrollbar.pas | 6 |
8 files changed, 47 insertions, 47 deletions
diff --git a/src/corelib/fpgfx.pas b/src/corelib/fpgfx.pas index 826a45f3..6410afde 100644 --- a/src/corelib/fpgfx.pas +++ b/src/corelib/fpgfx.pas @@ -224,6 +224,8 @@ type procedure SetCaret(acanvas: TfpgCanvas; x, y, w, h: TfpgCoord); procedure UnSetCaret(acanvas: TfpgCanvas); procedure InvertCaret; + property Width: integer read FWidth; + property Height: integer read FHeight; end; var @@ -982,7 +984,7 @@ begin FCanvas := nil; FTop := 0; FLeft := 0; - FWidth := 1; + FWidth := 2; FHeight := 8; FTimer := TfpgTimer.Create(FInterval); FTimer.OnTimer := @OnTimerTime; diff --git a/src/corelib/gdi/gfx_gdi.pas b/src/corelib/gdi/gfx_gdi.pas index f9a40f77..1cae9066 100644 --- a/src/corelib/gdi/gfx_gdi.pas +++ b/src/corelib/gdi/gfx_gdi.pas @@ -1251,7 +1251,7 @@ procedure TfpgCanvasImpl.DoFillRectangle(x1, y1, x2, y2: TfpgCoord); var r: TRect; begin - r := Rect(x1, y1, x2, y2); + r := Rect(x1, y1, x2+1, y2+1); Windows.FillRect(Fgc, r, FBrush); end; diff --git a/src/corelib/gfx_widget.pas b/src/corelib/gfx_widget.pas index 0323eb40..24f05244 100644 --- a/src/corelib/gfx_widget.pas +++ b/src/corelib/gfx_widget.pas @@ -39,8 +39,6 @@ type procedure MsgMouseExit(var msg: TfpgMessageRec); message FPGM_MOUSEEXIT; procedure MsgMouseScroll(var msg: TfpgMessageRec); message FPGM_SCROLL; procedure SetActiveWidget(const AValue: TfpgWidget); - procedure SetEnabled(const AValue: boolean); - procedure SetVisible(const AValue: boolean); protected FVisible: boolean; FEnabled: boolean; @@ -52,6 +50,8 @@ type FAlign: TAlign; function GetParent: TfpgWidget; reintroduce; procedure SetParent(const AValue: TfpgWidget); reintroduce; + procedure SetEnabled(const AValue: boolean); virtual; + procedure SetVisible(const AValue: boolean); virtual; procedure DoAlign(aalign: TAlign); procedure HandlePaint; virtual; procedure HandleResize(awidth, aheight: TfpgCoord); virtual; diff --git a/src/corelib/x11/gfx_x11.pas b/src/corelib/x11/gfx_x11.pas index ce63fdfd..65d14754 100644 --- a/src/corelib/x11/gfx_x11.pas +++ b/src/corelib/x11/gfx_x11.pas @@ -1405,12 +1405,7 @@ end; procedure TfpgCanvasImpl.DoFillRectangle(x1, y1, x2, y2: TfpgCoord); begin - // Remember this for when we add Canvas.Pen support! - { Note: By default XFillRectangle doesn't paint the same size rectangle that - XDrawRectangle does - given the same coordinates! In this case we enlarge - the Width and Height to paint consistant rectangle sizes, even thought it - might repaint the same (only a few) pixels twice. } - XFillRectangle(xapplication.display, FDrawHandle, Fgc, x1, y1, x2-x1, y2-y1); + XFillRectangle(xapplication.display, FDrawHandle, Fgc, x1, y1, x2-x1+1, y2-y1+1); end; procedure TfpgCanvasImpl.DoXORFillRectangle(col: TfpgColor; x, y, w, h: TfpgCoord); diff --git a/src/gui/gui_combobox.pas b/src/gui/gui_combobox.pas index 35bb39e7..c5b35342 100644 --- a/src/gui/gui_combobox.pas +++ b/src/gui/gui_combobox.pas @@ -35,6 +35,7 @@ type procedure SetFocusItem(const AValue: integer); protected FMargin: integer; + procedure SetEnabled(const AValue: boolean); override; property DropDownCount: integer read FDropDownCount write SetDropDownCount default 8; procedure HandleLMouseDown(x, y: integer; shiftstate: TShiftState); override; procedure HandlePaint; override; @@ -247,6 +248,12 @@ begin FFocusItem := AValue; end; +procedure TfpgCustomComboBox.SetEnabled(const AValue: boolean); +begin + inherited SetEnabled(AValue); + FInternalBtn.Enabled := AValue; +end; + procedure TfpgCustomComboBox.HandleLMouseDown(x, y: integer; shiftstate: TShiftState); begin inherited HandleLMouseDown(x, y, shiftstate); @@ -257,13 +264,14 @@ procedure TfpgCustomComboBox.HandlePaint; var r: TRect; begin - inherited HandlePaint; Canvas.BeginDraw; +// inherited HandlePaint; Canvas.ClearClipRect; + r := Rect(0, 0, Width-1, Height-1); Canvas.DrawControlFrame(0, 0, Width, Height); // internal background rectangle (without frame) - r := Rect(2, 2, Width-2, Height-2); + InflateRect(r, -2, -2); Canvas.SetClipRect(r); if Enabled then @@ -283,14 +291,17 @@ begin end else begin - Canvas.SetColor(FBackgroundColor); + if Enabled then + Canvas.SetColor(FBackgroundColor) + else + Canvas.SetColor(clWindowBackground); Canvas.SetTextColor(clText1); end; Canvas.FillRectangle(r); // Draw select item's text if FocusItem > -1 then - Canvas.DrawString(FMargin+1, FMargin, Text); + fpgStyle.DrawString(Canvas, FMargin+1, FMargin, Text, Enabled); Canvas.EndDraw; end; diff --git a/src/gui/gui_edit.pas b/src/gui/gui_edit.pas index 02710088..2597f976 100644 --- a/src/gui/gui_edit.pas +++ b/src/gui/gui_edit.pas @@ -207,17 +207,18 @@ var begin Canvas.BeginDraw; Canvas.ClearClipRect; + r := Rect(0, 0, Width-1, Height-1); Canvas.DrawControlFrame(0, 0, Width, Height); - r := Rect(2, 2, Width-2, Height-2); + InflateRect(r, -2, -2); Canvas.SetClipRect(r); if Enabled then Canvas.SetColor(FBackgroundColor) else Canvas.SetColor(clWindowBackground); - Canvas.FillRectAngle(r); + dtext := GetDrawText; Canvas.SetTextColor(clText1); Canvas.SetFont(FFont); @@ -244,7 +245,7 @@ begin // drawing cursor tw := FFont.TextWidth(UTF8copy(dtext, 1, FCursorPos)); - fpgCaret.SetCaret(Canvas, -FDrawOffset + FSideMargin + tw, 3, 2, FFont.Height - 1); + fpgCaret.SetCaret(Canvas, -FDrawOffset + FSideMargin + tw, 3, fpgCaret.Width, FFont.Height); end else fpgCaret.UnSetCaret(Canvas); diff --git a/src/gui/gui_memo.pas b/src/gui/gui_memo.pas index d3ff7864..8beb96cf 100644 --- a/src/gui/gui_memo.pas +++ b/src/gui/gui_memo.pas @@ -155,6 +155,7 @@ begin FVScrollBar.Top := 2; FVScrollBar.Left := Width - FVScrollBar.Width - 2; FVScrollBar.Height := VHeight; + FVScrollBar.UpdateWindowPosition; FHScrollBar.UpdateWindowPosition; end; @@ -167,12 +168,12 @@ begin FHeight := FFont.Height * 3 + 4; FWidth := 120; FLineHeight := FFont.Height + 2; - FSelecting := False; FSideMargin := 3; FMaxLength := 0; - - FOnChange := nil; + FWrapping := False; + FOnChange := nil; + FBackgroundColor := clBoxColor; FLines := TStringList.Create; FFirstLine := 1; @@ -184,8 +185,6 @@ begin FSelStartLine := 0; FSelEndLine := 0; - FBackgroundColor := clBoxColor; - FDrawOffset := 0; FMouseDragging := False; @@ -197,8 +196,6 @@ begin FHScrollBar.Orientation := orHorizontal; FHScrollBar.OnScroll := @HScrollBarMove; FHScrollBar.ScrollStep := 5; - - FWrapping := False; end; destructor TfpgMemo.Destroy; @@ -424,7 +421,6 @@ begin end; // vertical adjust - if FCursorLine < FFirstLine then FFirstLine := FCursorLine; if FCursorline - FFirstLine + 1 > VisibleLines then @@ -590,9 +586,6 @@ end; procedure TfpgMemo.HandleShow; begin - // FVScrollBar.SetDimensions(width-18,0,18,height); - // FHScrollBar.SetDimensions(0,height-18,width-18,18); - // FHScrollBar.Visible := false; inherited HandleShow; RecalcLongestLine; UpdateScrollBar; @@ -628,20 +621,18 @@ var begin Canvas.BeginDraw; Canvas.ClearClipRect; - fpgStyle.DrawControlFrame(Canvas, 0, 0, Width, Height); + r := Rect(0, 0, Width-1, Height-1); + Canvas.DrawControlFrame(0, 0, Width, Height); - r.Left := 2; - r.Top := 2; - r.Right := Width - 4; - r.Bottom := Height - 4; + InflateRect(r, -2, -2); Canvas.SetClipRect(r); - + if Enabled then Canvas.SetColor(FBackgroundColor) else Canvas.SetColor(clWindowBackground); + Canvas.FillRectAngle(r); - Canvas.FillRectAngle(2, 2, Width - 4, Height - 4); Canvas.SetFont(FFont); if (FSelStartLine shl 16) + FSelStartPos <= (FSelEndLine shl 16) + FSelEndPos then @@ -690,21 +681,20 @@ begin begin // drawing cursor tw := FFont.TextWidth(UTF8Copy(ls, 1, FCursorPos)); - fpgCaret.SetCaret(Canvas, -FDrawOffset + FSideMargin + tw, yp, 1, FFont.Height); + fpgCaret.SetCaret(Canvas, -FDrawOffset + FSideMargin + tw, yp, fpgCaret.Width, FFont.Height); end; - - end; + end; { if } yp := yp + LineHeight; - if yp > Height then Break; - end; + end; { for } if not Focused then fpgCaret.UnSetCaret(Canvas); - if FHScrollBar.Visible and FVScrollBar.Visible then begin + if FHScrollBar.Visible and FVScrollBar.Visible then + begin Canvas.SetColor(clWindowBackground); Canvas.FillRectangle(FHScrollBar.Left + FHScrollBar.Width, FVScrollBar.Top + FVScrollBar.Height, @@ -1203,14 +1193,15 @@ begin begin if FSelOffset < 0 then begin - Result := Copy16(FText,1+FSelStart + FSelOffset,-FSelOffset); + Result := Copy(FText,1+FSelStart + FSelOffset,-FSelOffset); end else begin - result := Copy16(FText,1+FSelStart,FSelOffset); + result := Copy(FText,1+FSelStart,FSelOffset); end; end - else Result := ''; + else + Result := ''; } end; diff --git a/src/gui/gui_scrollbar.pas b/src/gui/gui_scrollbar.pas index a76e9f9a..67716276 100644 --- a/src/gui/gui_scrollbar.pas +++ b/src/gui/gui_scrollbar.pas @@ -99,7 +99,7 @@ begin if Orientation = orVertical then begin - DrawButton(0, 0, Width, Width, 'sys.sb.up' ,FStartBtnPressed); + DrawButton(0, 0, Width, Width, 'sys.sb.up', FStartBtnPressed); DrawButton(0, Height - Width, Width, Width, 'sys.sb.down', FEndBtnPressed); end else @@ -165,12 +165,12 @@ begin if Orientation = orVertical then begin - Canvas.FillRectangle(0, Width-1, Width-1, Height - (2*Width)-2); + Canvas.FillRectangle(0, Width, Width-1, Height-1 - Width); area := Height - (Width shl 1); end else begin - Canvas.FillRectangle(Height-1, 0, Width - (2*Height)-2, Height-1); + Canvas.FillRectangle(Height, 0, Width - Height-1, Height); area := Width - (Height shl 1); end; |