1
/* Dali Clock - a melting digital clock for the Palm Pilot.
2
* Copyright (c) 1991-1999 Jamie Zawinski <jwz@jwz.org>
1
/* Dali Clock - a melting digital clock for PalmOS.
2
* Copyright (c) 1991-2002 Jamie Zawinski <jwz@jwz.org>
4
4
* Permission to use, copy, modify, distribute, and sell this software and its
5
5
* documentation for any purpose is hereby granted without fee, provided that
15
15
# include "config.h"
18
#ifdef HACK_FRAMEBUFFER
19
/* needed to access WinHandle->displayAddrV20 for ROMs earlier than 3.5 */
20
# define ALLOW_ACCESS_TO_INTERNALS_OF_WINDOWS
18
23
#include "daliclock.h"
20
/* Define this so that we get `hwrDisplayWidth' from <Hardware.h>.
21
(We only use that value (which is 160, BTW) with <3.0 ROMs.) */
24
26
/* Make sure Err*Display* are not no-ops. */
25
27
#define ERROR_CHECK_LEVEL ERROR_CHECK_FULL
30
/*#include <Hardware.h>*/
29
31
#include <FeatureMgr.h> /* for FtrGet() */
31
33
#ifndef HAVE_APPLAUNCHWITHCOMMAND
362
366
: state->test_hack - '0');
363
367
state->test_hack = 0;
365
else if (state->show_date_p == 0)
369
else if (state->display_date == DTime ||
370
state->display_date == DDash)
367
372
Boolean twelve_hour_time_p = state->twelve_hour_time_p;
374
if (state->display_date == DDash)
375
state->display_date = DTime;
369
377
if (twelve_hour_time_p && date.hour > 12) date.hour -= 12;
370
378
if (twelve_hour_time_p && date.hour == 0) date.hour = 12;
371
379
state->target_digits [0] = (date.hour - (date.hour % 10)) / 10;
389
397
y0 = (y0 - (y0 % 10)) / 10;
390
398
y1 = date.year % 10;
392
if (state->show_date_p == 2)
393
state->show_date_p = 0;
400
if (state->display_date == DDateIn)
401
state->display_date = DDate;
402
if (state->display_date == DDateOut)
403
state->display_date = DDateOut2;
404
else if (state->display_date == DDateOut2)
405
state->display_date = DDash;
395
407
switch (state->date_format)
439
451
cache_frame_buffer (void)
441
# ifdef HAVE_SCRDISPLAYMODE
442
static int mono_p = -1;
444
if (mono_p == 0) /* meaning we know we're not in 1-bit-mode; bail. */
446
else if (mono_p == -1) /* meaning we haven't checked yet */
448
DWord rom_version = 0;
449
FtrGet (sysFtrCreator, sysFtrNumROMVersion, &rom_version);
451
if (rom_version < ROM_30) /* ROM earlier than 3.0 -- assume. */
454
frame_buffer_bytes_per_line = hwrDisplayWidth/8;
458
DWord w = 0, h = 0, d = 0;
459
Boolean color = false;
460
ScrDisplayMode (scrDisplayModeGet, &w, &h, &d, &color);
463
if (w > 0 && h > 0 && d == 1 && color == false)
466
frame_buffer_bytes_per_line = (w+7) / 8;
470
# else /* !HAVE_SCRDISPLAYMODE */
472
/* Didn't have a 3.0-level library at compile-time -- assume. */
473
frame_buffer_bytes_per_line = hwrDisplayWidth/8;
475
# endif /* !HAVE_SCRDISPLAYMODE */
477
/* If we got here, then we believe we're running on a monochrome system,
478
and know how to access the frame buffer directly. */
480
frame_buffer = (unsigned char *) WinGetDisplayWindow()->displayAddr;
453
static int initted_p = 0;
455
if (initted_p) return;
459
UInt32 rom_version = 0;
460
FtrGet (sysFtrCreator, sysFtrNumROMVersion, &rom_version);
462
frame_buffer_bytes_per_line = 0;
465
if (rom_version < ROM_30) /* ROM earlier than 3.0 -- assume. */
467
# ifndef hwrDisplayWidth
468
# define hwrDisplayWidth 160
470
frame_buffer_bytes_per_line = hwrDisplayWidth/8;
474
UInt32 w = 0, h = 0, d = 0;
475
Boolean color = false;
476
WinScreenMode (winScreenModeGet, &w, &h, &d, &color);
477
if (w > 0 && h > 0 && d == 1 && color == false)
478
frame_buffer_bytes_per_line = (w+7) / 8;
481
if (frame_buffer_bytes_per_line > 0)
483
WinHandle w = WinGetDisplayWindow();
487
else if (rom_version < ROM_35)
488
frame_buffer = (unsigned char *) w->displayAddrV20;
490
{ /* functions from "3.5 New Feature Set" */
491
BitmapPtr b = WinGetBitmap (w);
492
frame_buffer = (unsigned char *) (b ? BmpGetBits (b) : 0);
482
497
#endif /* HACK_FRAMEBUFFER */
486
draw_horizontal_line (SWord x1, SWord x2, SWord y, Boolean black_p)
501
draw_horizontal_line (Int16 x1, Int16 x2, Int16 y, Boolean black_p)
490
505
else if (x1 > x2)
776
ntext = (Handle) MemHandleNew (StrLen(buf)+1);
777
s = (char *) MemHandleLock ((VoidHand) ntext);
792
ntext = (MemHandle) MemHandleNew (StrLen(buf)+1);
793
s = (char *) MemHandleLock ((MemHandle) ntext);
778
794
StrCopy (s, buf);
779
MemHandleUnlock ((VoidHand) ntext);
795
MemHandleUnlock ((MemHandle) ntext);
781
797
otext = FldGetTextHandle (field);
782
798
FldSetTextHandle (field, ntext);
783
799
/* FldDrawField (field); */
786
MemHandleFree ((VoidHand) otext);
802
MemHandleFree ((MemHandle) otext);
788
804
/* Write into the checkboxes.
1141
1160
to another safe one. The sysFileCDefaultApp is considered "safe"
1143
1162
if (rom_version < ROM_20)
1145
Err err; /* ignored, but referenced by AppLaunchWithCommand! */
1146
AppLaunchWithCommand (sysFileCDefaultApp,
1147
sysAppLaunchCmdNormalLaunch, 0);
1163
AppLaunchWithCommand (sysFileCDefaultApp,
1164
sysAppLaunchCmdNormalLaunch, 0);
1149
1165
# endif /* HAVE_APPLAUNCHWITHCOMMAND */