mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-22 12:02:29 +02:00

------------------------------------------------------------------------ r19294 | paul | 2009-04-10 11:17:35 +0800 (Птн, 10 Апр 2009) | 1 line lcl, win32: start optimizations: imglist (all), controls (all), combtrls (statubar) ------------------------------------------------------------------------ r19305 | martin | 2009-04-10 21:53:27 +0800 (Птн, 10 Апр 2009) | 1 line Moved "DoneRegisterCheck" to global LCL ------------------------------------------------------------------------ r19306 | martin | 2009-04-10 22:14:57 +0800 (Птн, 10 Апр 2009) | 1 line Moved "DoneRegisterCheck" to global LCL (more) ------------------------------------------------------------------------ r19307 | martin | 2009-04-10 22:22:44 +0800 (Птн, 10 Апр 2009) | 1 line changed case true => True ------------------------------------------------------------------------ r19308 | paul | 2009-04-10 22:28:28 +0800 (Птн, 10 Апр 2009) | 1 line fix file case ------------------------------------------------------------------------ r19311 | martin | 2009-04-10 23:09:16 +0800 (Птн, 10 Апр 2009) | 1 line Moved Registration of TCustomCalendar ------------------------------------------------------------------------ r19312 | martin | 2009-04-10 23:28:03 +0800 (Птн, 10 Апр 2009) | 1 line Moved PropertyToSkip for TCalender ------------------------------------------------------------------------ r19314 | paul | 2009-04-10 23:50:30 +0800 (Птн, 10 Апр 2009) | 1 line merge r13913 #999e8b059d ------------------------------------------------------------------------ r19315 | paul | 2009-04-10 23:53:07 +0800 (Птн, 10 Апр 2009) | 1 line cleanup WSCalendar ------------------------------------------------------------------------ r19316 | paul | 2009-04-11 00:37:44 +0800 (Сбт, 11 Апр 2009) | 1 line finish with ComCtrls ------------------------------------------------------------------------ r19318 | martin | 2009-04-11 01:37:40 +0800 (Сбт, 11 Апр 2009) | 1 line Moved dialogs ------------------------------------------------------------------------ r19319 | martin | 2009-04-11 01:47:30 +0800 (Сбт, 11 Апр 2009) | 1 line Moved dialogs ------------------------------------------------------------------------ r19320 | martin | 2009-04-11 02:47:52 +0800 (Сбт, 11 Апр 2009) | 1 line Moved ExtCtrls, ExtDlgs ------------------------------------------------------------------------ r19321 | martin | 2009-04-11 03:23:32 +0800 (Сбт, 11 Апр 2009) | 1 line Moved PropertyToSkip ------------------------------------------------------------------------ r19322 | martin | 2009-04-11 03:37:39 +0800 (Сбт, 11 Апр 2009) | 1 line Moved StdCtrls ------------------------------------------------------------------------ r19323 | martin | 2009-04-11 04:05:50 +0800 (Сбт, 11 Апр 2009) | 1 line Moved Buttons ------------------------------------------------------------------------ r19325 | paul | 2009-04-11 11:02:26 +0800 (Сбт, 11 Апр 2009) | 1 line remove DirSel ------------------------------------------------------------------------ r19326 | paul | 2009-04-11 11:11:37 +0800 (Сбт, 11 Апр 2009) | 1 line RegisterArrow ------------------------------------------------------------------------ r19327 | paul | 2009-04-11 11:32:09 +0800 (Сбт, 11 Апр 2009) | 1 line register WS classes only for TCustomXXX classes if they are available (like TCustomScrollBar instead of TScrollBar) and only for those descendants which really differ (like TRadioButton, TToggleButton) ------------------------------------------------------------------------ r19328 | paul | 2009-04-11 11:40:00 +0800 (Сбт, 11 Апр 2009) | 1 line RegisterCustomCheckBox ------------------------------------------------------------------------ r19329 | paul | 2009-04-11 11:57:22 +0800 (Сбт, 11 Апр 2009) | 1 line RegisterXXX for Forms ------------------------------------------------------------------------ r19330 | paul | 2009-04-11 12:13:05 +0800 (Сбт, 11 Апр 2009) | 1 line RegisterCustomGrid + move of RegisterPropertyToSkip ------------------------------------------------------------------------ r19331 | paul | 2009-04-11 12:24:29 +0800 (Сбт, 11 Апр 2009) | 1 line RegisterXXX for Menus ------------------------------------------------------------------------ r19332 | paul | 2009-04-11 12:35:16 +0800 (Сбт, 11 Апр 2009) | 1 line RegisterXXX for PairSplitter ------------------------------------------------------------------------ r19333 | paul | 2009-04-11 12:47:39 +0800 (Сбт, 11 Апр 2009) | 1 line RegisterXXX for Spin ------------------------------------------------------------------------ r19334 | paul | 2009-04-11 12:58:55 +0800 (Сбт, 11 Апр 2009) | 1 line RegisterCustomRubberBand ------------------------------------------------------------------------ r19335 | paul | 2009-04-11 13:31:43 +0800 (Сбт, 11 Апр 2009) | 1 line remove 2 initialization sections ------------------------------------------------------------------------ r19336 | paul | 2009-04-11 13:46:26 +0800 (Сбт, 11 Апр 2009) | 1 line remove TPopupNotifier.png from LCL ------------------------------------------------------------------------ r19338 | paul | 2009-04-11 13:54:03 +0800 (Сбт, 11 Апр 2009) | 1 line cleanup ------------------------------------------------------------------------ r19341 | paul | 2009-04-11 14:59:27 +0800 (Сбт, 11 Апр 2009) | 1 line cleanup ------------------------------------------------------------------------ r19343 | martin | 2009-04-11 19:59:18 +0800 (Сбт, 11 Апр 2009) | 1 line Reduced Unit-Circles, by moving Register* into WS* units ------------------------------------------------------------------------ r19344 | martin | 2009-04-11 20:22:49 +0800 (Сбт, 11 Апр 2009) | 1 line Dummy file for gtk ------------------------------------------------------------------------ r19345 | martin | 2009-04-11 21:06:55 +0800 (Сбт, 11 Апр 2009) | 1 line Initial move of gtk1 register ------------------------------------------------------------------------ r19346 | martin | 2009-04-11 21:19:48 +0800 (Сбт, 11 Апр 2009) | 1 line Missing dependencies in gtk1 wsfactory ------------------------------------------------------------------------ r19347 | martin | 2009-04-11 22:36:42 +0800 (Сбт, 11 Апр 2009) | 1 line Declare register* in interface, to keep external linker happy ------------------------------------------------------------------------ r19348 | martin | 2009-04-11 23:34:16 +0800 (Сбт, 11 Апр 2009) | 1 line Declare register* in interface, to keep external linker happy ------------------------------------------------------------------------ r19349 | martin | 2009-04-11 23:39:20 +0800 (Сбт, 11 Апр 2009) | 1 line moved uses for factory ------------------------------------------------------------------------ r19350 | martin | 2009-04-11 23:41:57 +0800 (Сбт, 11 Апр 2009) | 1 line corrected a few accidental "Result := False" ------------------------------------------------------------------------ r19351 | paul | 2009-04-12 00:04:15 +0800 (Вск, 12 Апр 2009) | 1 line removed unused units ------------------------------------------------------------------------ r19352 | paul | 2009-04-12 00:05:26 +0800 (Вск, 12 Апр 2009) | 1 line qt: move RegisterWS calls to qtwsfactory ------------------------------------------------------------------------ r19354 | paul | 2009-04-12 01:04:04 +0800 (Вск, 12 Апр 2009) | 1 line wince: move RegisterWS calls to WinCEWSFactory ------------------------------------------------------------------------ r19356 | martin | 2009-04-12 01:39:56 +0800 (Вск, 12 Апр 2009) | 1 line moved GTK2 ------------------------------------------------------------------------ r19357 | martin | 2009-04-12 01:45:31 +0800 (Вск, 12 Апр 2009) | 1 line moved GTK2 / missing units ------------------------------------------------------------------------ r19358 | martin | 2009-04-12 01:57:43 +0800 (Вск, 12 Апр 2009) | 1 line Fixed one return value from register ------------------------------------------------------------------------ r19360 | martin | 2009-04-12 02:47:42 +0800 (Вск, 12 Апр 2009) | 1 line Gtk2 , needs 2 registrations for WinControl ------------------------------------------------------------------------ r19361 | martin | 2009-04-12 02:57:58 +0800 (Вск, 12 Апр 2009) | 1 line Gtk2 , needs 2nd registrations ------------------------------------------------------------------------ r19368 | paul | 2009-04-12 13:09:59 +0800 (Вск, 12 Апр 2009) | 1 line cleanup ------------------------------------------------------------------------ r19373 | paul | 2009-04-12 13:45:17 +0800 (Вск, 12 Апр 2009) | 1 line wince: forgotten file ------------------------------------------------------------------------ r19374 | paul | 2009-04-12 14:04:04 +0800 (Вск, 12 Апр 2009) | 1 line carbon: move RegisterWSComponent to CarbonWSFactory ------------------------------------------------------------------------ r19375 | paul | 2009-04-12 14:27:47 +0800 (Вск, 12 Апр 2009) | 1 line cleanup ------------------------------------------------------------------------ git-svn-id: trunk@19376 -
168 lines
6.0 KiB
ObjectPascal
168 lines
6.0 KiB
ObjectPascal
{ $Id$}
|
|
{
|
|
*****************************************************************************
|
|
* GtkWSCalendar.pp *
|
|
* ---------------- *
|
|
* *
|
|
* *
|
|
*****************************************************************************
|
|
|
|
*****************************************************************************
|
|
* *
|
|
* This file is part of the Lazarus Component Library (LCL) *
|
|
* *
|
|
* See the file COPYING.modifiedLGPL.txt, 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 GtkWSCalendar;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
// Bindings
|
|
{$IFDEF gtk2}
|
|
glib2, gdk2pixbuf, gdk2, gtk2, Pango,
|
|
{$ELSE}
|
|
glib, gdk, gtk, gdkpixbuf, GtkFontCache,
|
|
{$ENDIF}
|
|
// RTL, FCL, LCL
|
|
SysUtils, Classes, Controls, Calendar, LCLType, LMessages,
|
|
InterfaceBase,
|
|
// Widgetset
|
|
GtkProc, GtkDef, GtkInt, GtkWsControls,
|
|
WSCalendar, WSLCLClasses, WSProc;
|
|
|
|
type
|
|
|
|
{ TGtkWSCustomCalendar }
|
|
|
|
TGtkWSCustomCalendar = class(TWSCustomCalendar)
|
|
private
|
|
protected
|
|
class procedure SetCallbacks(const AGtkWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo); virtual;
|
|
class function GetCalendar(const ACalendar: TCustomCalendar): PGtkCalendar; inline;
|
|
published
|
|
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
|
|
|
class function GetDateTime(const ACalendar: TCustomCalendar): TDateTime; override;
|
|
class procedure SetDateTime(const ACalendar: TCustomCalendar; const ADateTime: TDateTime); override;
|
|
class procedure SetDisplaySettings(const ACalendar: TCustomCalendar;
|
|
const ADisplaySettings: TDisplaySettings); override;
|
|
end;
|
|
|
|
implementation
|
|
|
|
class procedure TGtkWSCustomCalendar.SetCallbacks(const AGtkWidget: PGtkWidget;
|
|
const AWidgetInfo: PWidgetInfo);
|
|
begin
|
|
TGtkWSWinControl.SetCallbacks(PGtkObject(AGtkWidget), TComponent(AWidgetInfo^.LCLObject));
|
|
with TGtkWidgetset(Widgetset) do
|
|
begin
|
|
SetCallback(LM_MONTHCHANGED, PGtkObject(AGtkWidget), AWidgetInfo^.LCLObject);
|
|
SetCallback(LM_YEARCHANGED, PGtkObject(AGtkWidget), AWidgetInfo^.LCLObject);
|
|
SetCallback(LM_DAYCHANGED, PGtkObject(AGtkWidget), AWidgetInfo^.LCLObject);
|
|
end;
|
|
end;
|
|
|
|
class function TGtkWSCustomCalendar.GetCalendar(const ACalendar: TCustomCalendar): PGtkCalendar; inline;
|
|
begin
|
|
Result := PGtkCalendar(GetWidgetInfo(PGtkWidget(ACalendar.Handle))^.CoreWidget);
|
|
end;
|
|
|
|
class function TGtkWSCustomCalendar.CreateHandle(
|
|
const AWinControl: TWinControl; const AParams: TCreateParams
|
|
): TLCLIntfHandle;
|
|
var
|
|
FrameWidget, CalendarWidget: PGtkWidget;
|
|
WidgetInfo: PWidgetInfo;
|
|
Allocation: TGtkAllocation;
|
|
begin
|
|
FrameWidget := gtk_frame_new(nil);
|
|
CalendarWidget := gtk_calendar_new();
|
|
gtk_container_add(PGtkContainer(FrameWidget), CalendarWidget);
|
|
gtk_widget_show_all(FrameWidget);
|
|
|
|
Result := TLCLIntfHandle(PtrUInt(FrameWidget));
|
|
{$IFDEF DebugLCLComponents}
|
|
DebugGtkWidgets.MarkCreated(FrameWidget, dbgsName(AWinControl));
|
|
{$ENDIF}
|
|
|
|
WidgetInfo := CreateWidgetInfo(FrameWidget, AWinControl, AParams);
|
|
WidgetInfo^.CoreWidget := CalendarWidget;
|
|
SetMainWidget(FrameWidget, CalendarWidget);
|
|
|
|
Allocation.X := AParams.X;
|
|
Allocation.Y := AParams.Y;
|
|
Allocation.Width := AParams.Width;
|
|
Allocation.Height := AParams.Height;
|
|
gtk_widget_size_allocate(PGtkWidget(Result), @Allocation);
|
|
|
|
Set_RC_Name(AWinControl, FrameWidget);
|
|
SetCallBacks(FrameWidget, WidgetInfo);
|
|
end;
|
|
|
|
class function TGtkWSCustomCalendar.GetDateTime(const ACalendar: TCustomCalendar): TDateTime;
|
|
var
|
|
Year, Month, Day: guint; //used for csCalendar
|
|
begin
|
|
Result := 0;
|
|
if not WSCheckHandleAllocated(ACalendar, 'GetDateTime') then
|
|
Exit;
|
|
gtk_calendar_get_date(GetCalendar(ACalendar), @Year, @Month, @Day);
|
|
//For some reason, the month is zero based.
|
|
Result := EncodeDate(Year, Month + 1, Day);
|
|
end;
|
|
|
|
class procedure TGtkWSCustomCalendar.SetDateTime(const ACalendar: TCustomCalendar; const ADateTime: TDateTime);
|
|
var
|
|
Year, Month, Day: string;
|
|
GtkCalendar: PGtkCalendar;
|
|
begin
|
|
if not WSCheckHandleAllocated(ACalendar, 'SetDateTime') then
|
|
Exit;
|
|
GtkCalendar := GetCalendar(ACalendar);
|
|
Year := FormatDateTime('yyyy', ADateTime);
|
|
Month := FormatDateTime('mm', ADateTime);
|
|
Day := FormatDateTime('dd', ADateTime);
|
|
gtk_calendar_select_month(GtkCalendar, StrtoInt(Month) - 1, StrToInt(Year));
|
|
gtk_calendar_select_day(GtkCalendar, StrToInt(Day));
|
|
end;
|
|
|
|
class procedure TGtkWSCustomCalendar.SetDisplaySettings(const ACalendar: TCustomCalendar;
|
|
const ADisplaySettings: TDisplaySettings);
|
|
var
|
|
num: dword;
|
|
gtkcalendardisplayoptions : TGtkCalendarDisplayOptions;
|
|
begin
|
|
if not WSCheckHandleAllocated(ACalendar, 'SetDisplaySettings') then
|
|
Exit;
|
|
num := 0;
|
|
if (dsShowHeadings in ADisplaySettings) then
|
|
num := Num + (1 shl 0);
|
|
|
|
if (dsShowDayNames in ADisplaySettings) then
|
|
num := Num + (1 shl 1);
|
|
|
|
if (dsNoMonthChange in ADisplaySettings) then
|
|
num := Num + (1 shl 2);
|
|
|
|
if (dsShowWeekNumbers in ADisplaySettings) then
|
|
num := Num + (1 shl 3);
|
|
|
|
if (dsStartMonday in ADisplaySettings) then
|
|
num := Num + (1 shl 4);
|
|
|
|
gtkCalendarDisplayOptions := TGtkCalendarDisplayOptions(num);
|
|
gtk_Calendar_Display_options(GetCalendar(ACalendar), gtkCalendarDisplayOptions);
|
|
end;
|
|
|
|
end.
|