Table of Contents
CalendarSet in a plugin Window
Using CalendarSet in a plugin Window
Warning: this feature is only available in 32-bit mode, as 4D is unable to create an external window in 64-bit mode.
You can display CalendarSet in an independent, resizable window.
This type of window is created using the 4D Open external window command.
The syntax of the command is as follows:
Open external window (left;top;right;bottom;type;title;plugInArea) → AreaRef
Parameter | Type | Description |
---|---|---|
→ left | longint | global left coordinate of window contents area |
→ top | longint | global top coordinate of window contents area |
→ right | longint | global right coordinate of window contents area |
→ bottom | longint | global bottom coordinate of window contents area |
→ type | longint | window type |
→ title | text | title of window |
→ plugInArea | text | plugin object name: use “_CS_Area” for CalendarSet |
← AreaRef | longint | area reference of plugin area, used by CalendarSet commands |
After opening the plugin window, you then issue CalendarSet commands to configure the format and events you wish to display.
You can detect user actions on the CalendarSet object, but since there is no object method or form method, a callback method is used.
This is a method you specify with CS_SetCallback, which CalendarSet will execute when the user clicks or does a drag action on the object.
Example
// display all items for this month from the appointments file C_DATE(vDay1ThisMth;vDay1NextMth) vDay1ThisMth:= Add to date(!00/00/0000!;Year of(Current date);Month of(Current date);1) vDay1NextMth:= Add to date(vDay1ThisMth;0;1;0) QUERY([Appts];[Appts]Appt Date>=vDay1ThisMth;*) // find the appointments for this month QUERY([Appts]; & ;[Appts]Appt Date<vDay1NextMth) // now load the appointment data into arrays // Note that each appointment item has a field for the date, item text, font, size, style, and color //This makes loading the data and displaying it very easy to accomplish SELECTION TO ARRAY([Appts]Appt Date;aDates;[Appts]Item;aItems;[Appts]Item Font;\ aFonts;[Appts]Size;aSizes;[Appts]Styles;aStyles;[Appts]Color; aColors) // and display the data in the CalendarSet plugin area named "eMonth" // open a CalendarSet plugin window eMonth:=Open external window(10;50;400;450;4;"plugin Window Example";"_CS_Area") // setup the CalendarSet area CS_SetArray (eMonth;"aDates";"aItems";"aFonts";"aSizes";"aStyles";"aColors") // highlight number only, multiple cells (contiguous), grayed cells with info, // month prefix, Sunday start, extend frame CS_Options (eMonth;CS_Highlight_Number;CS_DaySelect_Multiple;CS_Unused_GrayedNumBan;\ CS_MonthOnFirstOn;CS_FirstDaySun;CS_Frame_Extended) // allow event selection, word-wrap event text, mark events with bullet CS_SetEventOpts(eMonth;CS_EventSelect_Single;CS_WordWrap_On;CS_Marker_Bullet) // allow banner selection, allow banner resizing CS_SetBanrOpts(eMonth;CS_Banner_Select;CS_Banner_Resize) // grid color blue, background color very light gray CS_SetCalColor(eMonth;CS_Color_Blue;241) CS_SetCallback(eMonth;"HandleCalClick") // Project method HandleCalClick C_LONGINT($1;$CalArea) // CalendarSet object reference C_INTEGER($2;$Action) // type of user action $CalArea:=$1 // reassign received parameters for better readability $Action:=$2 Case of :($Action=CS_Action_ClickOnDay) // user click on a day CS_GetSelect ($CalArea;vDateSt;vDateEn;vContig;aDays) ModDayInfo ($CalArea;vDateSt) // add/modify the info for that day :($Action=CS_Action_WindowClosed) // user click in plugin window close box or the hosting form is closed SaveCalendar // save any changes :($Action=CS_Action_ClickOnEventBanner) // clicked on an event or bannerv :($Action=CS_Action_BannerResize) // resized a banner :($Action=CS_Action_Drop) // dropped an event or banner (or a non-CalendarSet object) // handle the drag and drop here :($Action=CS_Action_DragOver) //dragging a non CalendarSet/AreaList Pro object over the area $0:=1 //allow drop End case