From a1f4823efed17adf5eb9c5137ba12a5feee2753e Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Tue, 2 Apr 2013 12:59:45 +0100 Subject: Bump the version numbers --- src/VERSION_FILE.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/VERSION_FILE.inc b/src/VERSION_FILE.inc index f5780fb3..212d4aea 100644 --- a/src/VERSION_FILE.inc +++ b/src/VERSION_FILE.inc @@ -1 +1 @@ -FPGUI_VERSION = '0.8'; +FPGUI_VERSION = '1.0'; -- cgit v1.2.3-70-g09d2 From 2c763a10566c402893c86a780373d356d13b927d Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Wed, 3 Apr 2013 00:39:28 +0100 Subject: minor code formatting --- src/corelib/render/software/Agg2D.pas | 82 +++++++++++++++++------------------ 1 file changed, 41 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/corelib/render/software/Agg2D.pas b/src/corelib/render/software/Agg2D.pas index 280736af..50a68fb8 100644 --- a/src/corelib/render/software/Agg2D.pas +++ b/src/corelib/render/software/Agg2D.pas @@ -40,51 +40,51 @@ interface {$ENDIF} uses - agg_basics , - agg_array , - agg_trans_affine , - agg_trans_viewport , - agg_path_storage , - agg_conv_stroke , - agg_conv_transform , - agg_conv_curve , - agg_conv_dash , - agg_rendering_buffer , - agg_renderer_base , - agg_renderer_scanline , - agg_span_gradient , - agg_span_image_filter_rgba , - agg_span_image_resample_rgba , - agg_span_converter , - agg_span_interpolator_linear , - agg_span_allocator , - agg_rasterizer_scanline_aa , - agg_gamma_functions , - agg_scanline_u , - agg_arc , - agg_bezier_arc , - agg_rounded_rect , - agg_font_engine , - agg_font_cache_manager , - agg_pixfmt , - agg_pixfmt_rgb , - agg_pixfmt_rgba , - agg_color , - agg_math_stroke , - agg_image_filters , - agg_vertex_source , - agg_render_scanlines , + agg_basics , + agg_array , + agg_trans_affine , + agg_trans_viewport , + agg_path_storage , + agg_conv_stroke , + agg_conv_transform , + agg_conv_curve , + agg_conv_dash , + agg_rendering_buffer , + agg_renderer_base , + agg_renderer_scanline , + agg_span_gradient , + agg_span_image_filter_rgba , + agg_span_image_resample_rgba , + agg_span_converter , + agg_span_interpolator_linear , + agg_span_allocator , + agg_rasterizer_scanline_aa , + agg_gamma_functions , + agg_scanline_u , + agg_arc , + agg_bezier_arc , + agg_rounded_rect , + agg_font_engine , + agg_font_cache_manager , + agg_pixfmt , + agg_pixfmt_rgb , + agg_pixfmt_rgba , + agg_color , + agg_math_stroke , + agg_image_filters , + agg_vertex_source , + agg_render_scanlines , {$IFDEF AGG2D_USE_FREETYPE } - agg_font_freetype , + agg_font_freetype , {$ENDIF } {$IFDEF AGG2D_USE_WINFONTS} - agg_font_win32_tt , + agg_font_win32_tt , {$ENDIF } - Math , - Classes, - SysUtils, + Math, + Classes, + SysUtils, // This allows for platform specific uses clauses {$define uses_interface} @@ -98,8 +98,8 @@ uses {$I agg_platform_x11.inc} {$ENDIF} - fpg_base, - fpg_main; + fpg_base, + fpg_main; { GLOBAL VARIABLES & CONSTANTS } const -- cgit v1.2.3-70-g09d2 From 4edb9ace210a3f38dc562d8986c68b31197f3514 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Wed, 3 Apr 2013 12:26:27 +0100 Subject: debug support --- src/corelib/fpg_base.pas | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/fpg_base.pas b/src/corelib/fpg_base.pas index 5158540e..07d44191 100644 --- a/src/corelib/fpg_base.pas +++ b/src/corelib/fpg_base.pas @@ -22,6 +22,9 @@ unit fpg_base; // To enable the AggPas powered Canvas {.$define AGGCanvas} +// For debug use only +{.$define GDEBUG} + interface uses @@ -780,6 +783,9 @@ uses fpg_form, // needed for fpgApplication.CreateForms() typinfo, process, + {$IFDEF GDEBUG} + dbugintf, + {$ENDIF} dateutils; @@ -2617,7 +2623,9 @@ begin p.CommandLine := GetHelpViewer + ' ' + HelpFile else p.CommandLine := GetHelpViewer + ' ' + HelpFile + ' -n ' + IntToStr(AHelpContext); -//writeln('DEBUG: TfpgApplicationBase.ContextHelp > ', p.CommandLine); + {$ifdef GDEBUG} + senddebug(p.CommandLine); + {$endif} end else p.CommandLine := GetHelpViewer; @@ -2640,7 +2648,9 @@ begin if fpgFileExists(HelpFile) then begin p.CommandLine := GetHelpViewer + ' ' + HelpFile + ' -s ' + AHelpKeyword; -//writeln('DEBUG: TfpgApplicationBase.ContextHelp > ', p.CommandLine); + {$ifdef GDEBUG} + senddebug(p.CommandLine); + {$endif} end else p.CommandLine := GetHelpViewer; -- cgit v1.2.3-70-g09d2 From 1c6b5d4b9f14adc892492b0201eafb2fb09b88ef Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Thu, 4 Apr 2013 23:44:37 +0100 Subject: bmp code now raises an exception for a unknown BMP format. Before it would have done a writeln() which would go unnoticed under Linux, and cause an AV under Windows GUI apps. --- src/corelib/fpg_imgfmt_bmp.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/fpg_imgfmt_bmp.pas b/src/corelib/fpg_imgfmt_bmp.pas index 353b3216..5add70ba 100644 --- a/src/corelib/fpg_imgfmt_bmp.pas +++ b/src/corelib/fpg_imgfmt_bmp.pas @@ -314,7 +314,7 @@ begin until linecnt >= img.Height; end; else - writeln('Unsupported BMP format!'); + raise Exception.Create('Unsupported BMP format!'); end; if ppal <> nil then -- cgit v1.2.3-70-g09d2 From 4c625c152b36b259435db5feffec7598f99f37ea Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Fri, 5 Apr 2013 10:05:09 +0100 Subject: Initial support for reading OS/2 Bitmap files. They have a slightly different structure to Windows BMP files - now the more common format. --- src/corelib/fpg_imgfmt_bmp.pas | 231 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+) (limited to 'src') diff --git a/src/corelib/fpg_imgfmt_bmp.pas b/src/corelib/fpg_imgfmt_bmp.pas index 5add70ba..296e515d 100644 --- a/src/corelib/fpg_imgfmt_bmp.pas +++ b/src/corelib/fpg_imgfmt_bmp.pas @@ -39,6 +39,9 @@ uses fpg_utils; +procedure ReadImage_OS2BMP(img: TfpgImage; bmp: Pointer; bmpsize: longword); forward; + + function CreateImage_BMP(bmp: Pointer; bmpsize: longword): TfpgImage; begin Result := TfpgImage.Create; @@ -147,6 +150,13 @@ begin p := bmp; PByte(bh) := p; + + if bh^.signature = $4d62 then { 'bM' } + begin + ReadImage_OS2BMP(img, bmp, bmpsize); + exit; + end; + ppal := nil; if bh^.filesize <> bmpsize then Exit; //==> @@ -323,5 +333,226 @@ begin img.UpdateImage; end; +type + { These records come from the HelpBitmap unit - part of DocView } + INFBITMAPHEADER = packed record + // BITMAP FILE HEADER + usType: uint16; // = 'bM' + cbSize: uint32; + xHotspot: uint16; + yHotspot: uint16; + DataOffset: uint32; // =size(hdr)+size(palette) + // BITMAP INFO HEADER + cbFIx: uint32; // =size(info_hdr) (usually = 12?) + Width: uint16; // width size + Height: uint16; // height size + cPlanes: uint16; // planes, =1 (always seems to be one) + BitCount: uint16; // bits per pixel + // followed by RGB triples if <= 8bpp + end; + + +procedure ReadImage_OS2BMP(img: TfpgImage; bmp: Pointer; bmpsize: longword); +var + bh: ^INFBITMAPHEADER; + p: PByte; + ppal: plongword; + pcol: Plongword; + palsize: integer; + pdata: PByte; + b: byte; + bit: byte; + bcnt: byte; + linecnt: integer; + pixelcnt: integer; + pdest: Plongword; + depth: integer; + + function GetPalColor(cindex: longword): longword; + var + pc: Plongword; + begin + pc := ppal; + Inc(pc, cindex); + Result := pc^; + end; + +begin + if img = nil then + Exit; //==> + + img.FreeImage; + + ppal := nil; + p := bmp; + PByte(bh) := p; + + pdata := bmp; + Inc(pdata, bh^.DataOffset); + Inc(p, SizeOf(INFBITMAPHEADER)); + + depth := bh^.BitCount; + + if depth > 1 then + img.AllocateImage(32, bh^.Width, bh^.Height)// color image (RGB or Indexed) + else + begin + img.AllocateImage(1, bh^.Width, bh^.Height); + img.AllocateMask; + end; + + if depth <= 8 then + begin + // reading color palette + case depth of + 1: palsize := 2; + 4: palsize := 16; + else + palsize := 256; + end; + + GetMem(ppal, palsize * SizeOf(longword)); + + pcol := ppal; + pixelcnt := 0; + while (p) < (pdata) do + begin + pcol^ := (LongWord(p[3]) shl 24) + (LongWord(p[2]) shl 16) + (LongWord(p[1]) shl 8) + LongWord(p[0]); + Inc(pcol); + inc(p, 4); + Inc(pixelcnt); + end; + end; + + pdest := img.ImageData; + Inc(pdest, img.Width * (img.Height - 1)); // bottom-up line order + p := bmp; + Inc(p, bh^.DataOffset); + + // reading the data... + case depth of + 1: + begin + // direct line transfer + //writeln('reading 1-bit color bitmap'); + linecnt := 0; + bcnt := img.Width div 32; + if (img.Width and $1F) > 0 then + Inc(bcnt); + + pdest := img.ImageData; + Inc(pdest, bcnt * (img.Height - 1)); // bottom-up line order + repeat + move(p^, pdest^, bcnt * 4); + Inc(p, bcnt * 4); + Dec(pdest, bcnt); + Inc(linecnt); + until linecnt >= img.Height; + + //Writeln(linecnt,' lines loaded.'); + move(img.ImageData^, img.MaskData^, img.ImageDataSize); + img.Invert(True); + end; + + 4: + begin + //writeln('reading 4-bit color'); + linecnt := 0; + repeat + // parse one line.. + bit := 0; + pixelcnt := 0; + bcnt := 0; + repeat + if bit = 0 then + b := (p^ shr 4) and $0F + else + begin + b := p^ and $0F; + Inc(p); + Inc(bcnt); + end; + + pdest^ := GetPalColor(b); + Inc(pdest); + Inc(pixelcnt); + bit := bit xor 1; + until pixelcnt >= img.Width; + + while (bcnt mod 4) <> 0 do + begin + Inc(bcnt); + Inc(p); + end; + + Inc(linecnt); + Dec(pdest, img.Width * 2); // go to next line + until linecnt >= img.Height; + end; + + 8: + begin + //writeln('reading 8-bit color'); + linecnt := 0; + repeat + // parse one line.. + pixelcnt := 0; + repeat + pdest^ := GetPalColor(p^); + Inc(p); + Inc(pdest); + Inc(pixelcnt); + until pixelcnt >= img.Width; + + while (pixelcnt mod 4) <> 0 do + begin + Inc(pixelcnt); + Inc(p); + end; + + Inc(linecnt); + Dec(pdest, img.Width * 2); // go to next line + until linecnt >= img.Height; + end; + + 24: + begin + //writeln('reading truecolor'); + linecnt := 0; + repeat + // parse one line.. + pixelcnt := 0; + repeat + pdest^ := p^; + Inc(p); + pdest^ := pdest^ or (longword(p^) shl 8); + Inc(p); + pdest^ := pdest^ or (longword(p^) shl 16) or ($FF shl 24) {alpha set to full opaque}; + Inc(p); + Inc(pdest); + Inc(pixelcnt); + until pixelcnt >= img.Width; + + pixelcnt := img.Width * 3; + while (pixelcnt mod 4) <> 0 do + begin + Inc(pixelcnt); + Inc(p); + end; + + Inc(linecnt); + Dec(pdest, img.Width * 2); // go to next line + until linecnt >= img.Height; + end; + else + raise Exception.Create('Unsupported BMP format!'); + end; + + if ppal <> nil then + FreeMem(ppal); + + img.UpdateImage; +end; + end. -- cgit v1.2.3-70-g09d2 From fafdc9027a0ebbf7646ecc65cffb04f12f2a979d Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Sat, 6 Apr 2013 02:36:50 +0100 Subject: os/2 bitmaps with bitdepth of 1,4 or 8 have a 3 byte color palette. I originally read it as a 4-byte color palette. This fixes the colors of images (mostly), but there still seems to be some or other decoding issues with larger than 65KB images. --- src/corelib/fpg_imgfmt_bmp.pas | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/fpg_imgfmt_bmp.pas b/src/corelib/fpg_imgfmt_bmp.pas index 296e515d..ff354898 100644 --- a/src/corelib/fpg_imgfmt_bmp.pas +++ b/src/corelib/fpg_imgfmt_bmp.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Toolkit - Copyright (C) 2006 - 2010 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2013 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -415,11 +415,12 @@ begin pcol := ppal; pixelcnt := 0; + // OS/2 1.x bitmap with uses 3-byte palette while (p) < (pdata) do begin - pcol^ := (LongWord(p[3]) shl 24) + (LongWord(p[2]) shl 16) + (LongWord(p[1]) shl 8) + LongWord(p[0]); + pcol^ := (LongWord($FF) shl 24) + (LongWord(p[2]) shl 16) + (LongWord(p[1]) shl 8) + LongWord(p[0]); Inc(pcol); - inc(p, 4); + inc(p, 3); Inc(pixelcnt); end; end; -- cgit v1.2.3-70-g09d2 From 4a16290513e9719cf71987da9b325d0534dde54f Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Mon, 8 Apr 2013 01:40:14 +0100 Subject: tree keyboard handling: we never tested for ShiftState --- src/gui/fpg_tree.pas | 111 ++++++++++++++++++++++++++------------------------- 1 file changed, 57 insertions(+), 54 deletions(-) (limited to 'src') diff --git a/src/gui/fpg_tree.pas b/src/gui/fpg_tree.pas index 4a4316ac..8935ec36 100644 --- a/src/gui/fpg_tree.pas +++ b/src/gui/fpg_tree.pas @@ -1868,74 +1868,77 @@ var OldSelection: TfpgTreeNode; begin OldSelection := Selection; - case KeyCode of - keyRight: - begin - Consumed := True; - Selection.Expand; - DoExpand(Selection); - ResetScrollbar; - RePaint; - end; + if ShiftState = [] then + begin + case KeyCode of + keyRight: + begin + Consumed := True; + Selection.Expand; + DoExpand(Selection); + ResetScrollbar; + RePaint; + end; - keyLeft: - begin - Consumed := True; - Selection.Collapsed := true; - ResetScrollbar; - RePaint; - end; + keyLeft: + begin + Consumed := True; + Selection.Collapsed := true; + ResetScrollbar; + RePaint; + end; - keyUp: - begin - if Selection = nil then - Selection := RootNode.FirstSubNode - else - if Selection <> RootNode then + keyUp: + begin + if Selection = nil then + Selection := RootNode.FirstSubNode + else + if Selection <> RootNode then + begin + if NodeIsVisible(selection) then + begin + h := PrevVisualNode(Selection); + if (h <> RootNode) and (h <> nil) then + Selection := h; + end + else + begin + Selection := RootNode.FirstSubNode; + end; + end; + Consumed := True; + end; + + keyDown: + begin + Consumed := True; + if Selection = nil then + Selection := RootNode.FirstSubNode + else begin if NodeIsVisible(selection) then begin - h := PrevVisualNode(Selection); - if (h <> RootNode) and (h <> nil) then + h := NextVisualNode(Selection); + if (h <> nil) then Selection := h; end else - begin Selection := RootNode.FirstSubNode; - end; end; - Consumed := True; - end; + end; - keyDown: - begin - Consumed := True; - if Selection = nil then - Selection := RootNode.FirstSubNode - else + keyPageUp: begin - if NodeIsVisible(selection) then - begin - h := NextVisualNode(Selection); - if (h <> nil) then - Selection := h; - end - else - Selection := RootNode.FirstSubNode; + FVScrollbar.PageUp; end; - end; - - keyPageUp: - begin - FVScrollbar.PageUp; - end; - keyPageDown: - begin - FVScrollbar.PageDown; - end; - else - Consumed := False; + keyPageDown: + begin + FVScrollbar.PageDown; + end; + else + Consumed := False; + end; end; if Selection <> OldSelection then -- cgit v1.2.3-70-g09d2 From 274c52a488fe61036ed8cb520c7d2c15412bc827 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Mon, 8 Apr 2013 01:41:02 +0100 Subject: popupmenu: Adds a convenience function AddSeparator() I like less typing. ;-) --- src/gui/fpg_menu.pas | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/gui/fpg_menu.pas b/src/gui/fpg_menu.pas index 8da9302f..91db5992 100644 --- a/src/gui/fpg_menu.pas +++ b/src/gui/fpg_menu.pas @@ -135,6 +135,7 @@ type destructor Destroy; override; procedure Close; override; function AddMenuItem(const AMenuName: TfpgString; const hotkeydef: string; OnClickProc: TNotifyEvent): TfpgMenuItem; + procedure AddSeparator; function MenuItemByName(const AMenuName: TfpgString): TfpgMenuItem; function MenuItem(const AMenuPos: integer): TfpgMenuItem; // added to allow for localization property BeforeShow: TNotifyEvent read FBeforeShow write FBeforeShow; @@ -1406,6 +1407,11 @@ begin end; end; +procedure TfpgPopupMenu.AddSeparator; +begin + AddMenuitem('-', '', nil); +end; + function TfpgPopupMenu.MenuItemByName(const AMenuName: TfpgString): TfpgMenuItem; var i: integer; -- cgit v1.2.3-70-g09d2 From eb124eb39b49ce513e5585657fcec92efe6f51b2 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Mon, 8 Apr 2013 01:43:59 +0100 Subject: Menu shortcuts with F1 key combinations never worked. The global F1 (application help) shortcut handling never looked at the ShiftState value. So if we had a popup menu with F1->help; Ctrl+F1->About, the second item's shortcut with be interpreted as F1 only. --- src/corelib/fpg_widget.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/fpg_widget.pas b/src/corelib/fpg_widget.pas index 67206557..a74c1b30 100644 --- a/src/corelib/fpg_widget.pas +++ b/src/corelib/fpg_widget.pas @@ -960,7 +960,7 @@ begin dir := 0; - if not consumed and (keycode = fpgApplication.HelpKey) then + if not consumed and (keycode = fpgApplication.HelpKey) and (shiftstate=[]) then begin InvokeHelp; consumed := True; -- cgit v1.2.3-70-g09d2 From beb50d953be276106e166c1a1c6ed33761bf0627 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Mon, 8 Apr 2013 09:04:35 +0100 Subject: New overloaded LoadImage_PNG() This allows us to read the image from a byte array, just like we do with BMP images. --- src/corelib/fpg_imgfmt_png.pas | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/fpg_imgfmt_png.pas b/src/corelib/fpg_imgfmt_png.pas index c0659d2e..c95150e4 100644 --- a/src/corelib/fpg_imgfmt_png.pas +++ b/src/corelib/fpg_imgfmt_png.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Toolkit - Copyright (C) 2006 - 2012 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2013 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -31,6 +31,7 @@ uses function LoadImage_PNG(const AFileName: TfpgString): TfpgImage; overload; function LoadImage_PNG(AStream: TStream): TfpgImage; overload; +function LoadImage_PNG(const AImageData: Pointer; const AImageDataSize: LongWord): TfpgImage; overload; function LoadImage_PNG(AInstance: THandle; const AResName: String; AResType: PChar): TfpgImage; overload; function LoadImage_PNGcrop(const AMaxWidth, AMaxHeight: integer; const AFileName: TfpgString): TfpgImage; @@ -114,6 +115,19 @@ begin end; end; +function LoadImage_PNG(const AImageData: Pointer; const AImageDataSize: LongWord): TfpgImage; +var + s: TMemoryStream; +begin + s := TMemoryStream.Create; + try + s.Write(AImageData^, AImageDataSize); + Result := LoadImage_PNG(s); + finally + s.Free; + end; +end; + function LoadImage_PNG(AInstance: THandle; const AResName: String; AResType: PChar): TfpgImage; var res: TResourceStream; -- cgit v1.2.3-70-g09d2