⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 date.c

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 C
字号:
#include <stdio.h>#include <time.h>#include <sys/time.h>#include <nano-X.h>#include "nanowm.h"#include "applets.h"static GR_WINDOW_ID wid;static GR_FONT_ID fontid;static int g_w = 0, g_h = 0;static int dtoggle = 0;static int applet_id;static void draw_date(void) {  char buffer[256];  time_t t = time(0);  struct tm *tv = localtime(&t);  GR_GC_ID gc = GrNewGC();  if (!fontid) fontid = GrCreateFont(GR_FONT_GUI_VAR, 0, NULL);  GrSetGCForeground(gc, wm_getColor(WM_TASKBAR));  GrFillRect(wid, gc, 0, 0, g_w, g_h);  if (dtoggle)    strftime(buffer, sizeof(buffer) - 1, "%m/%d/%y", tv);  else    strftime(buffer, sizeof(buffer) - 1, "%I:%M %p\n", tv);  GrSetGCBackground(gc, wm_getColor(WM_TASKBAR));  GrSetGCForeground(gc, wm_getColor(WM_BGCOLOR));  GrSetGCFont(gc, fontid);    GrText(wid, gc, 0, 0, buffer, -1, GR_TFTOP);  GrDestroyGC(gc);}static void event_callback(GR_WINDOW_ID wid, GR_EVENT *event) {  switch(event->type) {  case GR_EVENT_TYPE_BUTTON_DOWN:    dtoggle = 1;    break;  case GR_EVENT_TYPE_BUTTON_UP:    dtoggle = 0;    break;  }  draw_date();}static void timeout_callback(void) {  draw_date();}int applet_init(int id, int *x, int y, int h) {  int tid;  applet_id = id;  wid = GrNewWindowEx(GR_WM_PROPS_NODECORATE, 0, GR_ROOT_WINDOW_ID,		      *x, y, 50, h, wm_getColor(WM_TASKBAR));  if (!wid) return -1;  wm_applet_register(id, wid, 		     GR_EVENT_MASK_BUTTON_DOWN | GR_EVENT_MASK_BUTTON_UP | 		     GR_EVENT_MASK_EXPOSURE, event_callback);  tid = wm_applet_add_timer(id, APPLET_TIMER_PERIODIC, 1000, 			    timeout_callback);    GrMapWindow(wid);  g_w = 50;  g_h = h;    *x += 50;  return 0;}int applet_close(void) {  wm_applet_del_timer(applet_id, 0);  return 0;}  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -