Improves Cocoa widgetset

git-svn-id: trunk@15570 -
This commit is contained in:
sekelsenmat 2008-06-25 01:51:30 +00:00
parent 14ecdf824d
commit 53eb1c68b1
6 changed files with 623 additions and 2 deletions

3
.gitattributes vendored
View File

@ -3099,9 +3099,12 @@ lcl/interfaces/cocoa/Makefile.fpc svneol=native#text/plain
lcl/interfaces/cocoa/cocoaint.pas svneol=native#text/plain
lcl/interfaces/cocoa/cocoaobject.inc svneol=native#text/plain
lcl/interfaces/cocoa/cocoaprivate.pp svneol=native#text/plain
lcl/interfaces/cocoa/cocoatrayicon.inc svneol=native#text/plain
lcl/interfaces/cocoa/cocoawinapi.inc svneol=native#text/plain
lcl/interfaces/cocoa/cocoawinapih.inc svneol=native#text/plain
lcl/interfaces/cocoa/cocoawsextctrls.pas svneol=native#text/plain
lcl/interfaces/cocoa/cocoawsforms.pp svneol=native#text/plain
lcl/interfaces/cocoa/cocoawsmenus.pas svneol=native#text/plain
lcl/interfaces/cocoa/cocoawsstdctrls.pp svneol=native#text/plain
lcl/interfaces/cocoa/interfaces.pas svneol=native#text/plain
lcl/interfaces/fpgui/Makefile.fpc svneol=native#text/plain

View File

@ -137,14 +137,14 @@ uses
// CocoaWSDialogs,
// CocoaWSDirSel,
// CocoaWSEditBtn,
// CocoaWSExtCtrls,
CocoaWSExtCtrls,
// CocoaWSExtDlgs,
// CocoaWSFileCtrl,
CocoaWSForms,
// CocoaWSGrids,
// CocoaWSImgList,
// CocoaWSMaskEdit,
// CocoaWSMenus,
CocoaWSMenus,
// CocoaWSPairSplitter,
// CocoaWSSpin,
CocoaWSStdCtrls;

View File

@ -0,0 +1,105 @@
{%mainunit cocoawsextctrls.pp}
{$STATIC ON}
type
{ TPrivateCocoaCocoaTrayIcon }
TPrivateCocoaCocoaTrayIcon = class(NSObject)
public
{ Fields }
bar: NSStatusBar;
item: NSStatusItem;
image: NSImage;
menu: NSMenu;
{ Structural Methods }
// constructor Create; override;
end;
{ TCocoaWSCustomTrayIcon }
class function TCocoaWSCustomTrayIcon.Hide(const ATrayIcon: TCustomTrayIcon): Boolean;
var
APrivateTrayIcon: TPrivateCocoaCocoaTrayIcon;
begin
APrivateTrayIcon := TPrivateCocoaCocoaTrayIcon(ATrayIcon.Handle);
if APrivateTrayIcon.item <> nil then
begin
APrivateTrayIcon.item.Free;
APrivateTrayIcon.item := nil;
end;
Result := True;
end;
{
}
class function TCocoaWSCustomTrayIcon.Show(const ATrayIcon: TCustomTrayIcon): Boolean;
var
APrivateTrayIcon: TPrivateCocoaCocoaTrayIcon;
ASize: NSSize;
ACGRect: CGRect;
AcurrentContext: NSGraphicsContext;
begin
{$ifdef VerboseCocoaTrayIcon}
WriteLn(':>[TCocoaWSCustomTrayIcon.Show]');
{$endif VerboseCocoaTrayIcon}
Result := False;
{ Creates the handle }
APrivateTrayIcon := TPrivateCocoaCocoaTrayIcon.Create;
APrivateTrayIcon.bar := NSStatusBar.systemStatusBar();
ATrayIcon.Handle := PtrInt(APrivateTrayIcon);
{ Shows the icon }
{ if APrivateTrayIcon.item <> nil then Exit(True);
APrivateTrayIcon.item := NSStatusItem.CreateWithHandle(APrivateTrayIcon.bar.statusItemWithLength(NSSquareStatusItemLength));
APrivateTrayIcon.item.retain();
APrivateTrayIcon.item.setImage(APrivateTrayIcon.image.Handle);}
{ Inserts the menu }
{ if ATrayIcon.PopUpMenu <> nil then
begin
APrivateTrayIcon.menu := APrivateTrayIcon.CreateMenu(ATrayIcon.PopUpMenu);
APrivateTrayIcon.item.setMenu(APrivateTrayIcon.menu.Handle);
end;}
Result := True;
{$ifdef VerboseCocoaTrayIcon}
{ WriteLn(':<[TCocoaWSCustomTrayIcon.Show]',
' Handle: ', IntToHex(ATrayIcon.Handle, 8),
' ACGRect.size.width: ', ACGRect.size.width,
' ACGRect.size.height: ', ACGRect.size.height,
' ACGRect.origin.x: ', ACGRect.origin.x,
' ACGRect.origin.y: ', ACGRect.origin.y,
' TCocoaBitmap(ATrayIcon.Icon.Handle).CGImage ', IntToHex(Int64(TCocoaBitmap(ATrayIcon.Icon.Handle).CGImage), 8)
);}
{$endif VerboseCocoaTrayIcon}
end;
class procedure TCocoaWSCustomTrayIcon.InternalUpdate(const ATrayIcon: TCustomTrayIcon);
begin
end;
class function TCocoaWSCustomTrayIcon.ShowBalloonHint(const ATrayIcon: TCustomTrayIcon): Boolean;
begin
Result := True;
end;
class function TCocoaWSCustomTrayIcon.GetPosition(const ATrayIcon: TCustomTrayIcon): TPoint;
begin
Result := Point(0, 0);
end;

View File

@ -0,0 +1,260 @@
{ $Id: cocoawsextctrls.pp 15459 2008-06-18 20:23:05Z sekelsenmat $}
{
*****************************************************************************
* CocoaWSExtCtrls.pp *
* ------------------- *
* *
* *
*****************************************************************************
*****************************************************************************
* *
* This file is part of the Lazarus Component Library (LCL) *
* *
* See the file COPYING.modifiedLGPL, included in this distribution, *
* for details about the copyright. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
*****************************************************************************
}
unit CocoaWSExtCtrls;
{$mode delphi}
interface
uses
// libs
{$ifdef ver2_2_0}
FPCMacOSAll,
{$else}
MacOSAll,
{$endif}
// Cocoa
appkit, foundation, objc,
// LCL
Classes, Controls, ExtCtrls, LCLType, LCLProc, Graphics, Math, SysUtils,
// widgetset
WSExtCtrls, WSLCLClasses, WSControls, WSProc,
// LCL Cocoa
CocoaPrivate;
type
{ TCocoaWSCustomPage }
TCocoaWSCustomPage = class(TWSCustomPage)
private
protected
public
{ class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure UpdateProperties(const ACustomPage: TCustomPage); override;}
end;
{ TCocoaWSCustomNotebook }
TCocoaWSCustomNotebook = class(TWSCustomNotebook)
private
protected
public
{ class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure AddPage(const ANotebook: TCustomNotebook; const AChild: TCustomPage; const AIndex: integer); override;
class procedure MovePage(const ANotebook: TCustomNotebook; const AChild: TCustomPage; const NewIndex: integer); override;
class procedure RemovePage(const ANotebook: TCustomNotebook; const AIndex: integer); override;
//class function GetNotebookMinTabHeight(const AWinControl: TWinControl): integer; override;
//class function GetNotebookMinTabWidth(const AWinControl: TWinControl): integer; override;
//class function GetPageRealIndex(const ANotebook: TCustomNotebook; AIndex: Integer): Integer; override;
//class function GetTabIndexAtPos(const ANotebook: TCustomNotebook; const AClientPos: TPoint): integer; override;
class procedure SetPageIndex(const ANotebook: TCustomNotebook; const AIndex: integer); override;
class procedure SetTabPosition(const ANotebook: TCustomNotebook; const ATabPosition: TTabPosition); override;
class procedure ShowTabs(const ANotebook: TCustomNotebook; AShowTabs: boolean); override;}
end;
{ TCocoaWSPage }
TCocoaWSPage = class(TWSPage)
private
protected
public
end;
{ TCocoaWSNotebook }
TCocoaWSNotebook = class(TWSNotebook)
private
protected
public
end;
{ TCocoaWSShape }
TCocoaWSShape = class(TWSShape)
private
protected
public
end;
{ TCocoaWSCustomSplitter }
TCocoaWSCustomSplitter = class(TWSCustomSplitter)
private
protected
public
end;
{ TCocoaWSSplitter }
TCocoaWSSplitter = class(TWSSplitter)
private
protected
public
end;
{ TCocoaWSPaintBox }
TCocoaWSPaintBox = class(TWSPaintBox)
private
protected
public
end;
{ TCocoaWSCustomImage }
TCocoaWSCustomImage = class(TWSCustomImage)
private
protected
public
end;
{ TCocoaWSImage }
TCocoaWSImage = class(TWSImage)
private
protected
public
end;
{ TCocoaWSBevel }
TCocoaWSBevel = class(TWSBevel)
private
protected
public
end;
{ TCocoaWSCustomRadioGroup }
TCocoaWSCustomRadioGroup = class(TWSCustomRadioGroup)
private
protected
public
end;
{ TCocoaWSRadioGroup }
TCocoaWSRadioGroup = class(TWSRadioGroup)
private
protected
public
end;
{ TCocoaWSCustomCheckGroup }
TCocoaWSCustomCheckGroup = class(TWSCustomCheckGroup)
private
protected
public
end;
{ TCocoaWSCheckGroup }
TCocoaWSCheckGroup = class(TWSCheckGroup)
private
protected
public
end;
{ TCocoaWSCustomLabeledEdit }
TCocoaWSCustomLabeledEdit = class(TWSCustomLabeledEdit)
private
protected
public
end;
{ TCocoaWSLabeledEdit }
TCocoaWSLabeledEdit = class(TWSLabeledEdit)
private
protected
public
end;
{ TCocoaWSCustomPanel }
TCocoaWSCustomPanel = class(TWSCustomPanel)
private
protected
public
end;
{ TCocoaWSPanel }
TCocoaWSPanel = class(TWSPanel)
private
protected
public
end;
{ TCocoaWSCustomTrayIcon }
TCocoaWSCustomTrayIcon = class(TWSCustomTrayIcon)
public
class function Hide(const ATrayIcon: TCustomTrayIcon): Boolean; override;
class function Show(const ATrayIcon: TCustomTrayIcon): Boolean; override;
class procedure InternalUpdate(const ATrayIcon: TCustomTrayIcon); override;
class function ShowBalloonHint(const ATrayIcon: TCustomTrayIcon): Boolean; override;
class function GetPosition(const ATrayIcon: TCustomTrayIcon): TPoint; override;
end;
implementation
{$include cocoatrayicon.inc}
initialization
////////////////////////////////////////////////////
// I M P O R T A N T
////////////////////////////////////////////////////
// To improve speed, register only classes
// which actually implement something
////////////////////////////////////////////////////
/// RegisterWSComponent(TCustomPage, TCocoaWSCustomPage);
/// RegisterWSComponent(TCustomNotebook, TCocoaWSCustomNotebook);
// RegisterWSComponent(TPage, TCocoaWSPage);
// RegisterWSComponent(TNotebook, TCocoaWSNotebook);
// RegisterWSComponent(TShape, TCocoaWSShape);
// RegisterWSComponent(TCustomSplitter, TCocoaWSCustomSplitter);
// RegisterWSComponent(TSplitter, TCocoaWSSplitter);
// RegisterWSComponent(TPaintBox, TCocoaWSPaintBox);
// RegisterWSComponent(TCustomImage, TCocoaWSCustomImage);
// RegisterWSComponent(TImage, TCocoaWSImage);
// RegisterWSComponent(TBevel, TCocoaWSBevel);
// RegisterWSComponent(TCustomRadioGroup, TCocoaWSCustomRadioGroup);
// RegisterWSComponent(TRadioGroup, TCocoaWSRadioGroup);
// RegisterWSComponent(TCustomCheckGroup, TCocoaWSCustomCheckGroup);
// RegisterWSComponent(TCheckGroup, TCocoaWSCheckGroup);
// RegisterWSComponent(TBoundLabel, TCocoaWSBoundLabel);
// RegisterWSComponent(TCustomLabeledEdit, TCocoaWSCustomLabeledEdit);
// RegisterWSComponent(TLabeledEdit, TCocoaWSLabeledEdit);
// RegisterWSComponent(TCustomPanel, TCocoaWSCustomPanel);
// RegisterWSComponent(TPanel, TCocoaWSPanel);
RegisterWSComponent(TCustomTrayIcon, TCocoaWSCustomTrayIcon);
////////////////////////////////////////////////////
end.

View File

@ -0,0 +1,252 @@
{ $Id: Cocoawsmenus.pp 15309 2008-06-04 22:12:59Z vincents $}
{
*****************************************************************************
* CocoaWSMenus.pp *
* ------------ *
* *
* *
*****************************************************************************
*****************************************************************************
* *
* This file is part of the Lazarus Component Library (LCL) *
* *
* See the file COPYING.modifiedLGPL, included in this distribution, *
* for details about the copyright. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
*****************************************************************************
}
unit CocoaWSMenus;
{$mode objfpc}{$H+}
interface
uses
// Libs
{$ifdef ver2_2_0}
FPCMacOSAll,
{$else}
MacOSAll,
{$endif}
// LCL
Controls, Forms, Menus, Graphics, LCLType, LMessages, LCLProc, Classes,
// Widgetset
WSMenus, WSLCLClasses,
// LCL Cocoa
CocoaPrivate;
type
{ TCocoaWSMenuItem }
TCocoaWSMenuItem = class(TWSMenuItem)
private
protected
public
class procedure AttachMenu(const AMenuItem: TMenuItem); override;
class function CreateHandle(const AMenuItem: TMenuItem): HMENU; override;
class procedure DestroyHandle(const AMenuItem: TMenuItem); override;
class procedure SetCaption(const AMenuItem: TMenuItem; const ACaption: string); override;
class procedure SetShortCut(const AMenuItem: TMenuItem; const OldShortCut, NewShortCut: TShortCut); override;
class procedure SetVisible(const AMenuItem: TMenuItem; const Visible: boolean); override;
class function SetCheck(const AMenuItem: TMenuItem; const Checked: boolean): boolean; override;
class function SetEnable(const AMenuItem: TMenuItem; const Enabled: boolean): boolean; override;
class function SetRadioItem(const AMenuItem: TMenuItem; const RadioItem: boolean): boolean; override;
//class function SetRightJustify(const AMenuItem: TMenuItem; const Justified: boolean): boolean; override;
end;
{ TCocoaWSMenu }
TCocoaWSMenu = class(TWSMenu)
private
protected
public
class function CreateHandle(const AMenu: TMenu): HMENU; override;
end;
{ TCocoaWSMainMenu }
TCocoaWSMainMenu = class(TWSMainMenu)
private
protected
public
end;
{ TCocoaWSPopupMenu }
TCocoaWSPopupMenu = class(TWSPopupMenu)
private
protected
public
class procedure Popup(const APopupMenu: TPopupMenu; const X, Y: Integer); override;
end;
implementation
{ TCocoaWSMenu }
{------------------------------------------------------------------------------
Method: TCocoaWSMenu.CreateHandle
Params: AMenu - LCL menu
Returns: Handle to the menu in Cocoa interface
Creates new menu in Cocoa interface
------------------------------------------------------------------------------}
class function TCocoaWSMenu.CreateHandle(const AMenu: TMenu): HMENU;
begin
// Result := HMENU(TCocoaMenu.Create(AMenu.Items, True));
end;
{ TCocoaWSMenuItem }
{------------------------------------------------------------------------------
Method: TCocoaWSMenuItem.AttachMenu
Params: AMenuItem - LCL menu item
Attaches menu item to its parent menu in Cocoa interface
------------------------------------------------------------------------------}
class procedure TCocoaWSMenuItem.AttachMenu(const AMenuItem: TMenuItem);
begin
end;
{------------------------------------------------------------------------------
Method: TCocoaWSMenuItem.CreateHandle
Params: AMenuItem - LCL menu item
Returns: Handle to the menu item in Cocoa interface
Creates new menu item in Cocoa interface
------------------------------------------------------------------------------}
class function TCocoaWSMenuItem.CreateHandle(const AMenuItem: TMenuItem): HMENU;
begin
// Result := HMENU(TCocoaMenu.Create(AMenuItem));
end;
{------------------------------------------------------------------------------
Method: TCocoaWSMenuItem.DestroyHandle
Params: AMenuItem - LCL menu item
Destroys menu item in Cocoa interface
------------------------------------------------------------------------------}
class procedure TCocoaWSMenuItem.DestroyHandle(const AMenuItem: TMenuItem);
begin
end;
{------------------------------------------------------------------------------
Method: TCocoaWSMenuItem.SetCaption
Params: AMenuItem - LCL menu item
ACaption - Menu item caption
Sets the caption of menu item in Cocoa interface
------------------------------------------------------------------------------}
class procedure TCocoaWSMenuItem.SetCaption(const AMenuItem: TMenuItem;
const ACaption: string);
begin
end;
{------------------------------------------------------------------------------
Method: TCocoaWSMenuItem.SetShortCut
Params: AMenuItem - LCL menu item
OldShortCut - Old shortcut
NewShortCut - New shortcut
Sets the shortcut of menu item in Cocoa interface
------------------------------------------------------------------------------}
class procedure TCocoaWSMenuItem.SetShortCut(const AMenuItem: TMenuItem;
const OldShortCut, NewShortCut: TShortCut);
begin
end;
{------------------------------------------------------------------------------
Method: TCocoaWSMenuItem.SetVisible
Params: AMenuItem - LCL menu item
Visible - Menu item visibility
Sets the visibility of menu item in Cocoa interface
------------------------------------------------------------------------------}
class procedure TCocoaWSMenuItem.SetVisible(const AMenuItem: TMenuItem;
const Visible: boolean);
begin
end;
{------------------------------------------------------------------------------
Method: TCocoaWSMenuItem.SetCheck
Params: AMenuItem - LCL menu item
Checked - Menu item checked
Returns: If the function succeeds
Sets the check of menu item in Cocoa interface
------------------------------------------------------------------------------}
class function TCocoaWSMenuItem.SetCheck(const AMenuItem: TMenuItem;
const Checked: boolean): boolean;
begin
end;
{------------------------------------------------------------------------------
Method: TCocoaWSMenuItem.SetEnable
Params: AMenuItem - LCL menu item
Enabled - Menu item enabled
Returns: If the function succeeds
Sets the enabled of menu item in Cocoa interface
------------------------------------------------------------------------------}
class function TCocoaWSMenuItem.SetEnable(const AMenuItem: TMenuItem;
const Enabled: boolean): boolean;
begin
end;
{------------------------------------------------------------------------------
Method: TCocoaWSMenuItem.SetRadioItem
Params: AMenuItem - LCL menu item
RadioItem - Menu item has radio
Returns: If the function succeeds
Sets the radio behaviour of menu item in Cocoa interface
------------------------------------------------------------------------------}
class function TCocoaWSMenuItem.SetRadioItem(const AMenuItem: TMenuItem;
const RadioItem: boolean): boolean;
begin
end;
{ TCocoaWSPopupMenu }
{------------------------------------------------------------------------------
Method: TCocoaWSPopupMenu.Popup
Params: APopupMenu - LCL popup menu
X, Y - Screen coordinates to popup
Popups menu in Cocoa interface
------------------------------------------------------------------------------}
class procedure TCocoaWSPopupMenu.Popup(const APopupMenu: TPopupMenu; const X,
Y: integer);
begin
end;
initialization
////////////////////////////////////////////////////
// I M P O R T A N T
////////////////////////////////////////////////////
// To improve speed, register only classes
// which actually implement something
////////////////////////////////////////////////////
/// RegisterWSComponent(TMenuItem, TCocoaWSMenuItem);
/// RegisterWSComponent(TMenu, TCocoaWSMenu);
// RegisterWSComponent(TMainMenu, TCocoaWSMainMenu);
/// RegisterWSComponent(TPopupMenu, TCocoaWSPopupMenu);
////////////////////////////////////////////////////
end.

View File

@ -33,6 +33,7 @@ uses
{$else}
MacOSAll,
{$endif}
// Cocoa
foundation, appkit,
// LCL
Controls, StdCtrls, Graphics, LCLType, LMessages, LCLProc, Classes,