TCustomEdit for wince interface from Felipe

git-svn-id: trunk@9012 -
This commit is contained in:
mattias 2006-03-24 15:52:18 +00:00
parent 96a32ac3a1
commit 451e5c4942
6 changed files with 398 additions and 5 deletions

1
.gitattributes vendored
View File

@ -2199,6 +2199,7 @@ lcl/interfaces/wince/wincewinapih.inc svneol=native#text/plain
lcl/interfaces/wince/wincewsbuttons.pp svneol=native#text/plain
lcl/interfaces/wince/wincewscontrols.pp svneol=native#text/plain
lcl/interfaces/wince/wincewsforms.pp svneol=native#text/plain
lcl/interfaces/wince/wincewsstdctrls.pp svneol=native#text/plain
lcl/intfgraphics.pas svneol=native#text/pascal
lcl/languages/lcl.ca.po svneol=native#text/plain
lcl/languages/lcl.de.po svneol=native#text/plain

View File

@ -2880,7 +2880,9 @@ end;
{------------------------------------------------------------------------------
ClipboardSelectionReceivedHandler
copy the received selection data record and buffer to
This handler is called whenever a clipboard owner sends data. Because the LCL
caches all requests, this is typically data from another application.
Copy the received selection data record and buffer to
internal record and buffer (ClipboardSelectionData)
------------------------------------------------------------------------------}
procedure ClipboardSelectionReceivedHandler(TargetWidget: PGtkWidget;
@ -2982,12 +2984,14 @@ begin
FormatID:=SelectionData^.Target;
if ((FormatID=gdk_atom_intern('COMPOUND_TEXT',GdkTrue))
and (ClipboardExtraGtkFormats[ClipboardType][gfCOMPOUND_TEXT]))
or ((FormatID=gdk_atom_intern('UTF8_STRING',GdkTrue))
and (ClipboardExtraGtkFormats[ClipboardType][gfUTF8_STRING]))
or ((FormatID=gdk_atom_intern('STRING',GdkTrue))
and (ClipboardExtraGtkFormats[ClipboardType][gfSTRING]))
or ((FormatID=gdk_atom_intern('TEXT',GdkTrue))
and (ClipboardExtraGtkFormats[ClipboardType][gfTEXT]))
then
FormatID:=gdk_atom_intern('text/plain',GdkFalse);
FormatID:=gdk_atom_intern('text/plain',GdkTrue);
{$IFDEF DEBUG_CLIPBOARD}
DebugLn('[ClipboardSelectionRequestHandler] FormatID=',dbgs(FormatID),'=',GdkAtomToStr(FormatID),' ',dbgs(ClipboardExtraGtkFormats[ClipboardType][gfCOMPOUND_TEXT]));

View File

@ -32,6 +32,9 @@
------------------------------------------------------------------------------}
function WindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
LParam: Windows.LParam): LResult; stdcall;
var
LMessage: TLMessage;
PLMsg: PLMessage;
begin
{$ifdef VerboseWinCE}
// WriteLn('WindowProc: Msg = ' + IntToStr(Msg));
@ -39,6 +42,9 @@ begin
Result := 0;
LMessage.Result := 0;
LMessage.Msg := LM_NULL;
case Msg of
WM_CLOSE:

View File

@ -84,11 +84,14 @@ type
const
BOOL_RESULT: Array[Boolean] Of String = ('False', 'True');
ClsName: array[0..6] of WideChar = ('W','i','n','d','o','w',#0);
// EditClsName: array[0..4] of WideChar = 'Edit'#0;
EditClsName: array[0..4] of WideChar = ('E','D','I','T',#0);
ButtonClsName: array[0..6] of WideChar = ('B','U','T','T','O','N',#0);
// ComboboxClsName: array[0..8] of WideChar = 'ComboBox'#0;
// TabControlClsName: array[0..15] of WideChar = 'SysTabControl32'#0;
CP_UTF7 = 65000; { UTF-7 translation }
CP_UTF8 = 65001; { UTF-8 translation }
{ export for widgetset implementation }
function WindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
@ -129,7 +132,7 @@ uses
// WinCEWSMenus,
// WinCEWSPairSplitter,
// WinCEWSSpin,
// WinCEWSStdCtrls,
WinCEWSStdCtrls,
// WinCEWSToolwin,
////////////////////////////////////////////////////
LCLProc;

View File

@ -159,7 +159,7 @@ begin
WriteLn('TWinCEWSCustomForm.CreateHandle');
{$endif}
MultiByteToWideChar(CP_ACP, 0, PChar(AWinControl.Caption), -1, @Str, 256);
MultiByteToWideChar(CP_UTF8, 0, PChar(AWinControl.Caption), -1, @Str, 256);
hwnd := CreateWindow(
@ClsName, // Name of the registered class

View File

@ -0,0 +1,379 @@
{ $Id: WinCEwsstdctrls.pp 8805 2006-02-23 09:40:21Z vincents $}
{
*****************************************************************************
* WinCEWSStdCtrls.pp *
* ------------------ *
* *
* *
*****************************************************************************
*****************************************************************************
* *
* This file is part of the Lazarus Component Library (LCL) *
* *
* See the file COPYING.LCL, 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 WinCEWSStdCtrls;
{$mode objfpc}{$H+}
interface
uses
// Libs
Windows,
// LCL
SysUtils, LCLType, Classes, StdCtrls, Controls, Graphics, Forms,
InterfaceBase,
// Widgetset
WSStdCtrls, WSLCLClasses, WinCEInt, WinCEWSControls;
type
{ TWinCEWSScrollBar }
TWinCEWSScrollBar = class(TWSScrollBar)
private
protected
public
{ class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class procedure SetParams(const AScrollBar: TCustomScrollBar); override;}
end;
{ TWinCEWSCustomGroupBox }
TWinCEWSCustomGroupBox = class(TWSCustomGroupBox)
private
protected
public
{ class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class procedure AdaptBounds(const AWinControl: TWinControl;
var Left, Top, Width, Height: integer; var SuppressMove: boolean); override;}
end;
{ TWinCEWSGroupBox }
TWinCEWSGroupBox = class(TWSGroupBox)
private
protected
public
end;
{ TWinCEWSCustomComboBox }
TWinCEWSCustomComboBox = class(TWSCustomComboBox)
private
protected
public
{ class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class procedure AdaptBounds(const AWinControl: TWinControl;
var Left, Top, Width, Height: integer; var SuppressMove: boolean); override;
class function GetSelStart(const ACustomComboBox: TCustomComboBox): integer; override;
class function GetSelLength(const ACustomComboBox: TCustomComboBox): integer; override;
class function GetItemIndex(const ACustomComboBox: TCustomComboBox): integer; override;
class function GetMaxLength(const ACustomComboBox: TCustomComboBox): integer; override;
class function GetText(const AWinControl: TWinControl; var AText: string): boolean; override;
class procedure SetArrowKeysTraverseList(const ACustomComboBox: TCustomComboBox;
NewTraverseList: boolean); override;
class procedure SetSelStart(const ACustomComboBox: TCustomComboBox; NewStart: integer); override;
class procedure SetSelLength(const ACustomComboBox: TCustomComboBox; NewLength: integer); override;
class procedure SetItemIndex(const ACustomComboBox: TCustomComboBox; NewIndex: integer); override;
class procedure SetMaxLength(const ACustomComboBox: TCustomComboBox; NewLength: integer); override;
class procedure SetReadOnly(const ACustomComboBox: TCustomComboBox; NewReadOnly: boolean); override;
class procedure SetStyle(const ACustomComboBox: TCustomComboBox; NewStyle: TComboBoxStyle); override;
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
class function GetItems(const ACustomComboBox: TCustomComboBox): TStrings; override;
class procedure Sort(const ACustomComboBox: TCustomComboBox; AList: TStrings; IsSorted: boolean); override;}
end;
{ TWinCEWSComboBox }
TWinCEWSComboBox = class(TWSComboBox)
private
protected
public
end;
{ TWinCEWSCustomListBox }
TWinCEWSCustomListBox = class(TWSCustomListBox)
private
protected
public
{ class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
class function GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean; override;
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; override;
class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; override;
class function GetTopIndex(const ACustomListBox: TCustomListBox): integer; override;
class procedure SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean); override;
class procedure SetBorder(const ACustomListBox: TCustomListBox); override;
class procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override;
class procedure SetSelectionMode(const ACustomListBox: TCustomListBox; const AExtendedSelect,
AMultiSelect: boolean); override;
class procedure SetStyle(const ACustomListBox: TCustomListBox); override;
class procedure SetSorted(const ACustomListBox: TCustomListBox; AList: TStrings; ASorted: boolean); override;
class procedure SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer); override;}
end;
{ TWinCEWSListBox }
TWinCEWSListBox = class(TWSListBox)
private
protected
public
end;
{ TWinCEWSCustomEdit }
TWinCEWSCustomEdit = class(TWSCustomEdit)
private
protected
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
{ class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override;
class function GetMaxLength(const ACustomEdit: TCustomEdit): integer; override;}
class function GetText(const AWinControl: TWinControl; var AText: string): boolean; override;
{ class procedure SetCharCase(const ACustomEdit: TCustomEdit; NewCase: TEditCharCase); override;
class procedure SetEchoMode(const ACustomEdit: TCustomEdit; NewMode: TEchoMode); override;
class procedure SetMaxLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
class procedure SetPasswordChar(const ACustomEdit: TCustomEdit; NewChar: char); override;
class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override;
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;}
end;
{ TWinCEWSCustomMemo }
TWinCEWSCustomMemo = class(TWSCustomMemo)
private
protected
public
{ class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class function GetStrings(const ACustomMemo: TCustomMemo): TStrings; override;
class procedure AppendText(const ACustomMemo: TCustomMemo; const AText: string); override;
class procedure SetScrollbars(const ACustomMemo: TCustomMemo; const NewScrollbars: TScrollStyle); override;
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
class procedure SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean); override;}
end;
{ TWinCEWSEdit }
TWinCEWSEdit = class(TWSEdit)
private
protected
public
end;
{ TWinCEWSMemo }
TWinCEWSMemo = class(TWSMemo)
private
protected
public
end;
{ TWinCEWSCustomStaticText }
TWinCEWSCustomStaticText = class(TWSCustomStaticText)
private
protected
public
{ class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class procedure SetAlignment(const ACustomStaticText: TCustomStaticText; const NewAlignment: TAlignment); override;}
end;
{ TWinCEWSStaticText }
TWinCEWSStaticText = class(TWSStaticText)
private
protected
public
end;
{ TWinCEWSButtonControl }
TWinCEWSButtonControl = class(TWSButtonControl)
private
protected
public
{ class procedure GetPreferredSize(const AWinControl: TWinControl;
var PreferredWidth, PreferredHeight: integer); override;}
end;
{ TWinCEWSCustomCheckBox }
TWinCEWSCustomCheckBox = class(TWSCustomCheckBox)
private
protected
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
{ class procedure GetPreferredSize(const AWinControl: TWinControl;
var PreferredWidth, PreferredHeight: integer); override;
class function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override;
class procedure SetShortCut(const ACustomCheckBox: TCustomCheckBox;
const OldShortCut, NewShortCut: TShortCut); override;
class procedure SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); override;}
end;
{ TWinCEWSCheckBox }
TWinCEWSCheckBox = class(TWSCheckBox)
private
protected
public
end;
{ TWinCEWSToggleBox }
TWinCEWSToggleBox = class(TWSToggleBox)
private
protected
public
{ class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;}
end;
{ TWinCEWSRadioButton }
TWinCEWSRadioButton = class(TWSRadioButton)
private
protected
public
{ class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;}
end;
implementation
{ TWinCEWSCustomEdit }
function TWinCEWSCustomEdit.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
hwnd: THandle;
Str: array[0..255] of WideChar;
begin
{$ifdef VerboseWinCE}
WriteLn('TWinCEWSCustomEdit.CreateHandle');
{$endif}
MultiByteToWideChar(CP_ACP, 0, PChar(AWinControl.Caption), -1, @Str, 256);
Result := CreateWindow(
@EditClsName, // Name of the registered class
@Str, // Title of the window
WS_CHILD or WS_VISIBLE, // Style of the window
AWinControl.Left, // x-position (at beginning)
AWinControl.Top, // y-position (at beginning)
AWinControl.Width, // window width
AWinControl.Height, // window height
AWinControl.Parent.Handle, // handle to parent or owner window
0, // handle to menu
System.hInstance, // handle to application instance
nil); // pointer to window-creation data
if (hwnd = 0) then WriteLn('CreateWindow failed');
Result := hwnd;
end;
function TWinCEWSCustomEdit.GetText(const AWinControl: TWinControl; var AText: string): boolean;
var
TextLen: dword;
Str: array of WideChar;
Buffer: array[0..255] of Char;
begin
Result := AWinControl.HandleAllocated;
if not Result then Exit;
TextLen := GetWindowTextLength(AWinControl.Handle);
SetLength(Str, TextLen);
GetWindowText(AWinControl.Handle, @Str, TextLen + 1);
WideCharToMultiByte(CP_ACP, 0, @Str, TextLen, @Buffer, 256, nil, nil);
AText := string(PChar(Buffer));
end;
{ TWinCEWSCustomCheckBox }
function TWinCEWSCustomCheckBox.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
hwnd: THandle;
Str: array[0..255] of WideChar;
begin
{$ifdef VerboseWinCE}
WriteLn('TWinCEWSCustomEdit.CreateHandle');
{$endif}
MultiByteToWideChar(CP_ACP, 0, PChar(AWinControl.Caption), -1, @Str, 256);
Result := CreateWindow(
@ButtonClsName, // Name of the registered class
@Str, // Title of the window
BS_CHECKBOX or WS_TABSTOP or WS_CHILD or WS_VISIBLE, // Style of the window
AWinControl.Left, // x-position (at beginning)
AWinControl.Top, // y-position (at beginning)
AWinControl.Width, // window width
AWinControl.Height, // window height
AWinControl.Parent.Handle, // handle to parent or owner window
0, // handle to menu
System.hInstance, // handle to application instance
nil); // pointer to window-creation data
if (hwnd = 0) then WriteLn('CreateWindow failed');
Result := hwnd;
end;
initialization
////////////////////////////////////////////////////
// I M P O R T A N T
////////////////////////////////////////////////////
// To improve speed, register only classes
// which actually implement something
////////////////////////////////////////////////////
// RegisterWSComponent(TScrollBar, TWinCEWSScrollBar);
// RegisterWSComponent(TCustomGroupBox, TWinCEWSCustomGroupBox);
// RegisterWSComponent(TGroupBox, TWinCEWSGroupBox);
// RegisterWSComponent(TCustomComboBox, TWinCEWSCustomComboBox);
// RegisterWSComponent(TComboBox, TWinCEWSComboBox);
// RegisterWSComponent(TCustomListBox, TWinCEWSCustomListBox);
// RegisterWSComponent(TListBox, TWinCEWSListBox);
RegisterWSComponent(TCustomEdit, TWinCEWSCustomEdit);
// RegisterWSComponent(TCustomMemo, TWinCEWSCustomMemo);
// RegisterWSComponent(TEdit, TWinCEWSEdit);
// RegisterWSComponent(TMemo, TWinCEWSMemo);
// RegisterWSComponent(TButtonControl, TWinCEWSButtonControl);
RegisterWSComponent(TCustomCheckBox, TWinCEWSCustomCheckBox);
// RegisterWSComponent(TCheckBox, TWinCEWSCheckBox);
// RegisterWSComponent(TToggleBox, TWinCEWSToggleBox);
// RegisterWSComponent(TRadioButton, TWinCEWSRadioButton);
// RegisterWSComponent(TCustomStaticText, TWinCEWSCustomStaticText);
// RegisterWSComponent(TStaticText, TWinCEWSStaticText);
////////////////////////////////////////////////////
end.