00001
00008 #include <PalmTypes.h>
00009 #include <FeatureMgr.h>
00010 #include <ErrorBase.h>
00011 #include <ErrorMgr.h>
00012 #include <SystemMgr.h>
00013
00014
00015
00016
00017 #include <PenInputMgr.h>
00018 #include <NotifyMgr.h>
00019 #include <SysEvtMgr.h>
00020 #include <logging.h>
00021 #include <simcity.h>
00022
00023 #define _HIRESSOURCE_
00024 #include <resCompat.h>
00025 #include <palmutils.h>
00026
00027 #if defined(HRSUPPORT)
00028
00030 Coord sWidth;
00032 Coord sHeight;
00034 static UInt32 hdfs = ~0UL;
00035
00036 #define SetBits(B,L) (((1U << ((L) - 1)) - 1U + (1U << ((L) - 1))) << (B))
00037 #define pinMaxConstraintSize SetBits(0, (sizeof (Coord) * 8) - 1)
00038
00047 void
00048 setScreenRes(void)
00049 {
00050 switch(highDensityFeatureSet()) {
00051 case kDensityQuadruple:
00052 WriteLog("Quadruple Density\n");
00053 case kDensityTriple:
00054 WriteLog("Triple Density\n");
00055 case kDensityDouble:
00056 WriteLog("Double Density\n");
00057 SETWIDTH(BASEWIDTH * 2);
00058 SETHEIGHT(BASEHEIGHT * 2);
00059 break;
00060 case kDensityOneAndAHalf:
00061 WriteLog("One And A Half Density\n");
00062 SETWIDTH(BASEWIDTH * 1.5);
00063 SETHEIGHT(BASEHEIGHT * 1.5);
00064 break;
00065 case kDensityLow:
00066 WriteLog("Single Density\n");
00067 SETWIDTH(BASEWIDTH);
00068 SETHEIGHT(BASEHEIGHT);
00069 default:
00070 if (sonyHires()) {
00071 WriteLog("Sony High Density\n");
00072 SETWIDTH(BASEWIDTH * 2);
00073 SETHEIGHT(BASEHEIGHT * 2);
00074 } else {
00075 WriteLog("Fallthru - Single Density (%d)\n",
00076 (int)highDensityFeatureSet());
00077 SETWIDTH(BASEWIDTH);
00078 SETHEIGHT(BASEHEIGHT);
00079
00080 }
00081 break;
00082 }
00083 }
00084
00093 UInt32
00094 highDensityFeatureSet(void)
00095 {
00096 UInt32 tval;
00097
00098 if (hdfs != ~0UL)
00099 return (hdfs);
00100
00101 hdfs = 0;
00102
00103 if (0 != FtrGet(sysFtrCreator, sysFtrNumWinVersion, &tval))
00104 goto out;
00105 if (tval < 4)
00106 goto out;
00107 if (0 != WinScreenGetAttribute(winScreenDensity, &tval))
00108 goto out;
00109 hdfs = tval;
00110 if (hdfs == kDensityLow)
00111 hdfs = 0;
00112 out:
00113 return (hdfs);
00114 }
00115
00123 Boolean
00124 isDoubleOrMoreResolution()
00125 {
00126 if (hdfs >= kDensityDouble || sonyHires())
00127 return (1);
00128 return (0);
00129 }
00130
00139 void
00140 StartHiresDraw(void)
00141 {
00142 if (hdfs) WinSetCoordinateSystem(hdfs);
00143 StartHiresFontDraw();
00144 }
00145
00152 void
00153 EndHiresDraw(void)
00154 {
00155 EndHiresFontDraw();
00156 if (hdfs) WinSetCoordinateSystem(kCoordinatesStandard);
00157 }
00158
00165 void
00166 StartHiresFontDraw(void)
00167 {
00168 if (hdfs) {
00169 if (IsScaleModes())
00170 WinSetScalingMode(kBitmapScalingOff | kTextScalingOff |
00171 kTextPaddingOff);
00172 else
00173 BmpSetDensity(WinGetBitmap(WinGetDrawWindow()),
00174 kDensityLow);
00175 }
00176 }
00177
00184 void
00185 EndHiresFontDraw(void)
00186 {
00187 if (hdfs) {
00188 if (IsScaleModes())
00189 WinSetScalingMode(0);
00190 else
00191 BmpSetDensity(WinGetBitmap(WinGetDrawWindow()), hdfs);
00192 }
00193 }
00194
00202 Boolean
00203 canHires(void)
00204 {
00205 return (highDensityFeatureSet() || sonyCanHires());
00206 }
00207
00214 Boolean
00215 isHires(void)
00216 {
00217 return (highDensityFeatureSet() || sonyHires());
00218 }
00219
00226 void
00227 scaleEvent(EventPtr event)
00228 {
00229 UInt32 mul;
00230 if (isHires()) {
00231 if (sonyHires())
00232 mul = kDensityDouble;
00233 else
00234 mul = hdfs ? hdfs : kDensityLow;
00235 event->screenX = (Coord)((UInt32)event->screenX * mul /
00236 kDensityLow);
00237 event->screenY = (Coord)((UInt32)event->screenY * mul /
00238 kDensityLow);
00239 }
00240 }
00241
00247 Coord
00248 scaleCoord(Coord x)
00249 {
00250 Int32 mul = sonyHires() ? kDensityDouble :
00251 ( hdfs ? hdfs : kDensityLow );
00252 return ((Coord)((Int32)x * mul / kDensityLow));
00253 }
00254
00260 Coord
00261 normalizeCoord(Coord x)
00262 {
00263 Int32 mul = sonyHires() ? kDensityDouble : (hdfs ? hdfs : kDensityLow);
00264 return ((Coord)((Int32)x * kDensityLow / mul));
00265 }
00266
00267 static Int16 has_silk = -1;
00268
00269 Int16
00270 hasVirtualSilk(void)
00271 {
00272 return (has_silk);
00273 }
00274
00279 void
00280 StartSilk(void)
00281 {
00282 Err err;
00283 UInt32 version;
00284
00285 if (has_silk != -1)
00286 return;
00287
00288 WriteLog("StartSilk(");
00289
00290 err = FtrGet(pinCreator, pinFtrAPIVersion, &version);
00291 if (!err && version) {
00292 if (pinAPIVersion1_0 == version)
00293 has_silk = 1;
00294 else
00295 has_silk = 2;
00296 WriteLog("%d)\n", has_silk);
00297 return;
00298 }
00299
00300 if (SonySilk()) {
00301 has_silk = 1;
00302 WriteLog("%d)\n", has_silk);
00303 return;
00304 }
00305
00306 has_silk = 0;
00307 WriteLog("%d)\n", has_silk);
00308
00309 return;
00310 }
00311
00315 void
00316 EndSilk(void)
00317 {
00318 WriteLog("Endsilk\n");
00319 has_silk = 0;
00320 SonyEndSilk();
00321 }
00322
00326 void
00327 SetSilkResizable(FormPtr form, UInt8 resizeable)
00328 {
00329 if (SonySilk()) {
00330 SonySetSilkResizable(resizeable);
00331 } else if (hasVirtualSilk()) {
00332 UInt16 state;
00333
00334 if (resizeable)
00335 state = pinInputTriggerEnabled;
00336 else
00337 state = pinInputTriggerDisabled;
00338 if (resizeable) {
00339 RectangleType bnds;
00340 Coord x, y;
00341
00342 FrmGetFormBounds(form, &bnds);
00343 x = bnds.extent.x;
00344 y = bnds.extent.y;
00345 WinSetConstraintsSize(WinGetWindowHandle(form), y,
00346 pinMaxConstraintSize, pinMaxConstraintSize, x, x,
00347 pinMaxConstraintSize);
00348 FrmSetDIAPolicyAttr(form, frmDIAPolicyCustom);
00349 PINSetInputTriggerState(pinInputTriggerEnabled);
00350 PINSetInputAreaState(pinInputAreaUser);
00351 } else {
00352 PINSetInputTriggerState(state);
00353 }
00354 }
00355 }
00356
00357 Boolean
00358 collapseMove(FormPtr form, UInt8 stretchy, Int16 *roffsetX, Int16 *roffsetY)
00359 {
00360 Coord dispHeight, dispWidth;
00361 RectangleType dwRect;
00362 Int16 offX, offY;
00363 WinHandle frmH;
00364
00365 if (!hasVirtualSilk()) {
00366 return (false);
00367 }
00368
00369 WinGetDisplayExtent(&dispWidth, &dispHeight);
00370 WriteLog("extent = %d, %d\n", (int)dispWidth, (int)dispHeight);
00371
00372 frmH = WinGetWindowHandle(form);
00373 WinGetBounds(frmH, &dwRect);
00374 offX = dispWidth - dwRect.extent.x - dwRect.topLeft.x;
00375 offY = dispHeight - dwRect.extent.y - dwRect.topLeft.y;
00376
00377 WriteLog("offX = %d, offY = %d\n", (int)offX, (int)offY);
00378
00379 if (stretchy && CM_MODAL) {
00380 offX -= 2;
00381 offY -= 2;
00382 }
00383 if (roffsetX != NULL) *roffsetX = offX;
00384 if (roffsetY != NULL) *roffsetY = offY;
00385
00386 if (offX || offY) {
00387 if (stretchy && CM_MOVEX)
00388 dwRect.topLeft.x += offX;
00389 else
00390 dwRect.extent.x += offX;
00391 if (stretchy && CM_MOVEY)
00392 dwRect.topLeft.y += offY;
00393 else
00394 dwRect.extent.y += offY;
00395 WinSetBounds(frmH, &dwRect);
00396 return (true);
00397 }
00398 return (false);
00399 }
00400
00401 void
00402 collapsePreRedraw(FormPtr form
00403 #if !defined(SONY_CLIE)
00404 __attribute__((unused))
00405 #endif
00406 )
00407 {
00408 SonyCollapsePreRedraw(form);
00409 }
00410
00411 #endif