diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2013-04-10 00:09:29 +0100 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2013-04-10 00:09:29 +0100 |
commit | d24464c8646ffd19e9b02de93626dd20054e2da5 (patch) | |
tree | afaaf3caa81c9d15084d03be62b3f8f57d3444d8 /src | |
parent | de7e463e6210c28b56ba853ec2c2fdfd404a7a1f (diff) | |
parent | 6fa2f7ef71b16815e64e6ff547c9fcd6562be87b (diff) | |
download | fpGUI-d24464c8646ffd19e9b02de93626dd20054e2da5.tar.xz |
Merge branch 'release-1.0'
Diffstat (limited to 'src')
-rw-r--r-- | src/VERSION_FILE.inc | 2 | ||||
-rw-r--r-- | src/corelib/fpg_base.pas | 14 | ||||
-rw-r--r-- | src/corelib/fpg_imgfmt_bmp.pas | 236 | ||||
-rw-r--r-- | src/corelib/fpg_imgfmt_png.pas | 16 | ||||
-rw-r--r-- | src/corelib/fpg_widget.pas | 2 | ||||
-rw-r--r-- | src/corelib/render/software/Agg2D.pas | 82 | ||||
-rw-r--r-- | src/gui/fpg_menu.pas | 6 | ||||
-rw-r--r-- | src/gui/fpg_tree.pas | 111 |
8 files changed, 367 insertions, 102 deletions
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'; 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; diff --git a/src/corelib/fpg_imgfmt_bmp.pas b/src/corelib/fpg_imgfmt_bmp.pas index 353b3216..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, @@ -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; //==> @@ -314,7 +324,229 @@ begin until linecnt >= img.Height; end; else - writeln('Unsupported BMP format!'); + raise Exception.Create('Unsupported BMP format!'); + end; + + if ppal <> nil then + FreeMem(ppal); + + 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; + // OS/2 1.x bitmap with uses 3-byte palette + while (p) < (pdata) do + begin + pcol^ := (LongWord($FF) shl 24) + (LongWord(p[2]) shl 16) + (LongWord(p[1]) shl 8) + LongWord(p[0]); + Inc(pcol); + inc(p, 3); + 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 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; 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; 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 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; 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 |