Add Date/Time control panel application.
authorEric Kohl <eric.kohl@reactos.org>
Sat, 30 Oct 2004 19:16:20 +0000 (19:16 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 30 Oct 2004 19:16:20 +0000 (19:16 +0000)
svn path=/trunk/; revision=11482

reactos/lib/cpl/Makefile
reactos/lib/cpl/timedate/.cvsignore [new file with mode: 0644]
reactos/lib/cpl/timedate/makefile [new file with mode: 0644]
reactos/lib/cpl/timedate/resource.h [new file with mode: 0644]
reactos/lib/cpl/timedate/resources/applet.ico [new file with mode: 0644]
reactos/lib/cpl/timedate/timedate.c [new file with mode: 0644]
reactos/lib/cpl/timedate/timedate.def [new file with mode: 0644]
reactos/lib/cpl/timedate/timedate.h [new file with mode: 0644]
reactos/lib/cpl/timedate/timedate.rc [new file with mode: 0644]

index 6ee6ef7..0e0bdaa 100644 (file)
@@ -6,7 +6,7 @@ PATH_TO_TOP = ../..
 
 include $(PATH_TO_TOP)/rules.mak
 
-CONTROL_PANELS = access appwiz desk intl main ncpa sysdm control
+CONTROL_PANELS = access appwiz desk intl main ncpa sysdm timedate control
 
 all: $(CONTROL_PANELS)
 
diff --git a/reactos/lib/cpl/timedate/.cvsignore b/reactos/lib/cpl/timedate/.cvsignore
new file mode 100644 (file)
index 0000000..ee6046a
--- /dev/null
@@ -0,0 +1,8 @@
+*.coff
+*.cpl
+*.d
+*.a
+*.o
+*.sym
+*.map
+*.tmp
diff --git a/reactos/lib/cpl/timedate/makefile b/reactos/lib/cpl/timedate/makefile
new file mode 100644 (file)
index 0000000..690dc49
--- /dev/null
@@ -0,0 +1,50 @@
+# $Id: makefile,v 1.1 2004/10/30 19:15:31 ekohl Exp $
+
+PATH_TO_TOP = ../../..
+
+TARGET_TYPE = dynlink
+
+TARGET_EXTENSION = .cpl
+
+TARGET_NAME = timedate
+
+TARGET_INSTALLDIR = system32
+
+TARGET_BASE = 0x75970000
+
+TARGET_CFLAGS = \
+ -D_WIN32_IE=0x0600 \
+ -D_WIN32_WINNT=0x0501 \
+ -D__USE_W32API \
+ -I./include \
+ -DUNICODE \
+ -D_UNICODE \
+ -D__REACTOS__ \
+ -Wall \
+ -Werror \
+ -fno-builtin
+
+TARGET_LFLAGS = -nostartfiles
+
+TARGET_SDKLIBS = kernel32.a user32.a comctl32.a
+
+TARGET_GCCLIBS = gcc
+
+TARGET_PCH = 
+
+TARGET_CLEAN = 
+
+TARGET_OBJECTS = timedate.o
+
+DEP_OBJECTS = $(TARGET_OBJECTS)
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk
+
+include $(TOOLS_PATH)/depend.mk
+
+%/TAGS:
+       etags -o $(@D)/TAGS $(@D)/\*.c
+
+etags: ./TAGS
diff --git a/reactos/lib/cpl/timedate/resource.h b/reactos/lib/cpl/timedate/resource.h
new file mode 100644 (file)
index 0000000..c26fb1c
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef __CPL_RESOURCE_H
+#define __CPL_RESOURCE_H
+
+
+#define IDC_CPLICON            1
+
+#define IDD_DATETIMEPAGE       100
+#define IDC_TIMEZONE           106
+
+#define IDD_TIMEZONEPAGE       110
+#define IDC_TIMEZONELIST       111
+#define IDC_AUTOADJUST         113
+
+#define IDS_CPLNAME            1001
+#define IDS_CPLDESCRIPTION     2001
+
+#endif /* __CPL_RESOURCE_H */
+
+/* EOF */
diff --git a/reactos/lib/cpl/timedate/resources/applet.ico b/reactos/lib/cpl/timedate/resources/applet.ico
new file mode 100644 (file)
index 0000000..3eae16d
Binary files /dev/null and b/reactos/lib/cpl/timedate/resources/applet.ico differ
diff --git a/reactos/lib/cpl/timedate/timedate.c b/reactos/lib/cpl/timedate/timedate.c
new file mode 100644 (file)
index 0000000..888f795
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+ *  ReactOS
+ *  Copyright (C) 2004 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  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.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/* $Id: timedate.c,v 1.1 2004/10/30 19:15:31 ekohl Exp $
+ *
+ * PROJECT:         ReactOS Timedate Control Panel
+ * FILE:            lib/cpl/timedate/timedate.c
+ * PURPOSE:         ReactOS Timedate Control Panel
+ * PROGRAMMER:      Eric Kohl
+ */
+
+#include <windows.h>
+#include <commctrl.h>
+#include <cpl.h>
+
+#include "resource.h"
+#include "timedate.h"
+
+
+#define NUM_APPLETS    (1)
+
+LONG APIENTRY
+Applet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam);
+
+
+HINSTANCE hApplet = 0;
+
+
+/* Applets */
+APPLET Applets[NUM_APPLETS] = 
+{
+  {IDC_CPLICON, IDS_CPLNAME, IDS_CPLDESCRIPTION, Applet}
+};
+
+
+/* Property page dialog callback */
+INT_PTR CALLBACK
+DateTimePageProc(HWND hwndDlg,
+                UINT uMsg,
+                WPARAM wParam,
+                LPARAM lParam)
+{
+  switch (uMsg)
+  {
+    case WM_INITDIALOG:
+      break;
+  }
+
+  return FALSE;
+}
+
+
+/* Property page dialog callback */
+INT_PTR CALLBACK
+TimeZonePageProc(HWND hwndDlg,
+                UINT uMsg,
+                WPARAM wParam,
+                LPARAM lParam)
+{
+  switch (uMsg)
+  {
+    case WM_INITDIALOG:
+      break;
+  }
+
+  return FALSE;
+}
+
+
+static VOID
+InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
+{
+  ZeroMemory(psp, sizeof(PROPSHEETPAGE));
+  psp->dwSize = sizeof(PROPSHEETPAGE);
+  psp->dwFlags = PSP_DEFAULT;
+  psp->hInstance = hApplet;
+  psp->pszTemplate = MAKEINTRESOURCE(idDlg);
+  psp->pfnDlgProc = DlgProc;
+}
+
+
+LONG APIENTRY
+Applet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam)
+{
+  PROPSHEETHEADER psh;
+  PROPSHEETPAGE psp[3];
+  TCHAR Caption[256];
+
+  LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
+
+  ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
+  psh.dwSize = sizeof(PROPSHEETHEADER);
+  psh.dwFlags =  PSH_PROPSHEETPAGE | PSH_PROPTITLE;
+  psh.hwndParent = NULL;
+  psh.hInstance = hApplet;
+  psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON));
+  psh.pszCaption = Caption;
+  psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
+  psh.nStartPage = 0;
+  psh.ppsp = psp;
+
+  InitPropSheetPage(&psp[0], IDD_DATETIMEPAGE, DateTimePageProc);
+  InitPropSheetPage(&psp[1], IDD_TIMEZONEPAGE, TimeZonePageProc);
+
+  return (LONG)(PropertySheet(&psh) != -1);
+}
+
+
+/* Control Panel Callback */
+LONG CALLBACK
+CPlApplet(HWND hwndCpl,
+         UINT uMsg,
+         LPARAM lParam1,
+         LPARAM lParam2)
+{
+  int i = (int)lParam1;
+  
+  switch (uMsg)
+  {
+    case CPL_INIT:
+      return TRUE;
+
+    case CPL_GETCOUNT:
+      return NUM_APPLETS;
+
+    case CPL_INQUIRE:
+    {
+      CPLINFO *CPlInfo = (CPLINFO*)lParam2;
+      CPlInfo->lData = 0;
+      CPlInfo->idIcon = Applets[i].idIcon;
+      CPlInfo->idName = Applets[i].idName;
+      CPlInfo->idInfo = Applets[i].idDescription;
+      break;
+    }
+
+    case CPL_DBLCLK:
+    {
+      Applets[i].AppletProc(hwndCpl, uMsg, lParam1, lParam2);
+      break;
+    }
+  }
+  return FALSE;
+}
+
+
+BOOL STDCALL
+DllMain(HINSTANCE hinstDLL,
+       DWORD dwReason,
+       LPVOID lpReserved)
+{
+  switch (dwReason)
+  {
+    case DLL_PROCESS_ATTACH:
+    case DLL_THREAD_ATTACH:
+      hApplet = hinstDLL;
+      break;
+  }
+
+  return TRUE;
+}
+
+/* EOF */
diff --git a/reactos/lib/cpl/timedate/timedate.def b/reactos/lib/cpl/timedate/timedate.def
new file mode 100644 (file)
index 0000000..8d67834
--- /dev/null
@@ -0,0 +1,6 @@
+LIBRARY timedate.cpl
+
+EXPORTS
+CPlApplet@16
+
+; EOF
diff --git a/reactos/lib/cpl/timedate/timedate.h b/reactos/lib/cpl/timedate/timedate.h
new file mode 100644 (file)
index 0000000..817bd4f
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef __CPL_SAMPLE_H
+#define __CPL_SAMPLE_H
+
+typedef struct
+{
+  int idIcon;
+  int idName;
+  int idDescription;
+  APPLET_PROC AppletProc;
+} APPLET, *PAPPLET;
+
+extern HINSTANCE hApplet;
+
+#endif /* __CPL_SAMPLE_H */
+
+/* EOF */
diff --git a/reactos/lib/cpl/timedate/timedate.rc b/reactos/lib/cpl/timedate/timedate.rc
new file mode 100644 (file)
index 0000000..bfb749b
--- /dev/null
@@ -0,0 +1,44 @@
+/* $Id: timedate.rc,v 1.1 2004/10/30 19:15:31 ekohl Exp $ */
+
+#include <defines.h>
+#include "resource.h"
+
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION   "ReactOS Control Panel\0"
+#define REACTOS_STR_INTERNAL_NAME      "timedate\0"
+#define REACTOS_STR_ORIGINAL_FILENAME  "timedate.cpl\0"
+#include <reactos/version.rc>
+
+IDC_CPLICON ICON "resources/applet.ico"
+
+
+LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
+
+IDD_DATETIMEPAGE DIALOGEX 0, 0, 252, 146
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
+CAPTION "Date && Time"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+  GROUPBOX "&Date", -1, 4, 2, 122, 125
+  GROUPBOX "&Time", -1, 132, 2, 113, 125
+  LTEXT "Current time zone: %s", IDC_TIMEZONE, 4, 136, 241, 8
+END
+
+
+IDD_TIMEZONEPAGE DIALOGEX 0, 0, 252, 146
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
+CAPTION "Time Zone"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+  COMBOBOX IDC_TIMEZONELIST, 5, 4, 241, 136,
+           CBS_DROPDOWNLIST | WS_VSCROLL | WS_VISIBLE | WS_TABSTOP
+  AUTOCHECKBOX "Automatically adjust clock for &daylight saving changes",
+               IDC_AUTOADJUST, 5, 139, 241, 10, WS_VISIBLE | WS_GROUP | WS_TABSTOP
+END
+
+
+STRINGTABLE
+BEGIN
+  IDS_CPLNAME "Date/Time"
+  IDS_CPLDESCRIPTION "Changes date, time and time zone information."
+END