Changeset 18
- Timestamp:
- 06/14/06 14:42:53 (6 years ago)
- Location:
- trunk
- Files:
-
- 18 added
- 8 edited
-
COPYING (added)
-
rsc/bitmaps/appicons/appicon_small_x1_1.bmp (modified) (previous)
-
rsc/bitmaps/appicons/appicon_small_x1_2.bmp (modified) (previous)
-
rsc/bitmaps/appicons/appicon_small_x1_8.bmp (modified) (previous)
-
rsc/bitmaps/appicons/appicon_small_x2_1.bmp (added)
-
rsc/bitmaps/appicons/appicon_small_x2_2.bmp (added)
-
rsc/bitmaps/appicons/appicon_small_x2_8.bmp (added)
-
rsc/resources.xrd (modified) (20 diffs)
-
src/common.c (added)
-
src/common.h (added)
-
src/form (added)
-
src/form/beat.c (added)
-
src/form/beat.h (added)
-
src/form/main.c (added)
-
src/form/main.h (added)
-
src/form/preferences.c (added)
-
src/form/preferences.h (added)
-
src/form/tap.c (added)
-
src/form/tap.h (added)
-
src/form/volume.c (added)
-
src/form/volume.h (added)
-
src/main.c (modified) (10 diffs)
-
src/main.h (added)
-
src/metropro.h (modified) (3 diffs)
-
src/mtprtypes.h (modified) (3 diffs)
-
src/resources.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/rsc/resources.xrd
r16 r18 3 3 <PALMOS_RESOURCE_FILE> 4 4 5 <ALERT_RESOURCE RESOURCE_ID="1000" >5 <ALERT_RESOURCE RESOURCE_ID="1000" COMMENT="AlertInvalidTapTempo"> 6 6 <ALERT_TYPE> WARNING_ALERT </ALERT_TYPE> 7 7 <HELP_ID> 0 </HELP_ID> … … 16 16 </ALERT_RESOURCE> 17 17 18 <ALERT_RESOURCE RESOURCE_ID="1001" >18 <ALERT_RESOURCE RESOURCE_ID="1001" COMMENT="InvalidBeatNumeratorAlert"> 19 19 <ALERT_TYPE> ERROR_ALERT </ALERT_TYPE> 20 20 <HELP_ID> 0 </HELP_ID> … … 29 29 </ALERT_RESOURCE> 30 30 31 <ALERT_RESOURCE RESOURCE_ID="1100"> 31 <ALERT_RESOURCE RESOURCE_ID="1002" COMMENT="AlertInvalidNumericValue"> 32 <ALERT_TYPE> ERROR_ALERT </ALERT_TYPE> 33 <HELP_ID> 0 </HELP_ID> 34 <DEFAULT_BUTTON> 0 </DEFAULT_BUTTON> 35 <TITLE> "Invalid Numeric Value" </TITLE> 36 <MESSAGE> "Please enter a numeric value between ^1 and ^2 for ^3." </MESSAGE> 37 <BUTTONS> 38 <TEXT> "OK" </TEXT> 39 </BUTTONS> 40 </ALERT_RESOURCE> 41 42 <ALERT_RESOURCE RESOURCE_ID="1003" COMMENT="AlertPreferencesTempo"> 43 <ALERT_TYPE> ERROR_ALERT </ALERT_TYPE> 44 <HELP_ID> 0 </HELP_ID> 45 <DEFAULT_BUTTON> 0 </DEFAULT_BUTTON> 46 <TITLE> "Invalid Tempo Values" </TITLE> 47 <MESSAGE> "The mininum tempo has to be lower than the maximum tempo." </MESSAGE> 48 <BUTTONS> 49 <TEXT> "OK" </TEXT> 50 </BUTTONS> 51 </ALERT_RESOURCE> 52 53 <ALERT_RESOURCE RESOURCE_ID="1100" COMMENT="DebugAlert"> 32 54 <ALERT_TYPE> INFORMATION_ALERT </ALERT_TYPE> 33 55 <HELP_ID> 0 </HELP_ID> … … 146 168 <HAS_COLOR_TABLE> FALSE </HAS_COLOR_TABLE> 147 169 <BITMAP_FILE> "./bitmaps/appicons/appicon_small_x1_8.bmp" </BITMAP_FILE> 170 </BITMAP> 171 <BITMAP> 172 <BITMAP_DENSITY> 144 </BITMAP_DENSITY> 173 <WIDTH> 30 </WIDTH> 174 <HEIGHT> 18 </HEIGHT> 175 <BIT_DEPTH> 1 </BIT_DEPTH> 176 <BITMAP_COMPRESSION> BEST </BITMAP_COMPRESSION> 177 <HAS_TRANSPARENCY> FALSE </HAS_TRANSPARENCY> 178 <HAS_COLOR_TABLE> FALSE </HAS_COLOR_TABLE> 179 <BITMAP_FILE> "./bitmaps/appicons/appicon_small_x2_1.bmp" </BITMAP_FILE> 180 </BITMAP> 181 <BITMAP> 182 <BITMAP_DENSITY> 144 </BITMAP_DENSITY> 183 <WIDTH> 30 </WIDTH> 184 <HEIGHT> 18 </HEIGHT> 185 <BIT_DEPTH> 2 </BIT_DEPTH> 186 <BITMAP_COMPRESSION> BEST </BITMAP_COMPRESSION> 187 <HAS_TRANSPARENCY> FALSE </HAS_TRANSPARENCY> 188 <HAS_COLOR_TABLE> FALSE </HAS_COLOR_TABLE> 189 <BITMAP_FILE> "./bitmaps/appicons/appicon_small_x2_2.bmp" </BITMAP_FILE> 190 </BITMAP> 191 <BITMAP> 192 <BITMAP_DENSITY> 144 </BITMAP_DENSITY> 193 <WIDTH> 30 </WIDTH> 194 <HEIGHT> 18 </HEIGHT> 195 <BIT_DEPTH> 8 </BIT_DEPTH> 196 <BITMAP_COMPRESSION> BEST </BITMAP_COMPRESSION> 197 <HAS_TRANSPARENCY> FALSE </HAS_TRANSPARENCY> 198 <HAS_COLOR_TABLE> FALSE </HAS_COLOR_TABLE> 199 <BITMAP_FILE> "./bitmaps/appicons/appicon_small_x2_8.bmp" </BITMAP_FILE> 148 200 </BITMAP> 149 201 </BITMAPS> … … 1140 1192 <HELP_ID> 0 </HELP_ID> 1141 1193 <MENU_ID> 1000 </MENU_ID> 1142 <DEFAULT_BUTTON> 0</DEFAULT_BUTTON>1194 <DEFAULT_BUTTON> 1008 </DEFAULT_BUTTON> 1143 1195 <TITLE_ICON> FALSE </TITLE_ICON> 1144 1196 <TITLE_BAR_FOCUSABLE> FALSE </TITLE_BAR_FOCUSABLE> … … 1322 1374 <MODAL> TRUE </MODAL> 1323 1375 <SAVE_BEHIND> TRUE </SAVE_BEHIND> 1324 <HELP_ID> 0</HELP_ID>1376 <HELP_ID> 2005 </HELP_ID> 1325 1377 <MENU_ID> 0 </MENU_ID> 1326 <DEFAULT_BUTTON> 0</DEFAULT_BUTTON>1378 <DEFAULT_BUTTON> 1108 </DEFAULT_BUTTON> 1327 1379 <TITLE_ICON> FALSE </TITLE_ICON> 1328 1380 <TITLE_BAR_FOCUSABLE> FALSE </TITLE_BAR_FOCUSABLE> … … 1334 1386 <ID> 1101 </ID> 1335 1387 <LOCATION> 1336 <X> 6</X>1388 <X> 2 </X> 1337 1389 <Y> 22 </Y> 1338 1390 </LOCATION> … … 1344 1396 <ID> 1102 </ID> 1345 1397 <LOCATION> 1346 <X> 6</X>1398 <X> 2 </X> 1347 1399 <Y> 39 </Y> 1348 1400 </LOCATION> … … 1369 1421 <ID> 1105 </ID> 1370 1422 <LOCATION> 1371 <X> 6</X>1423 <X> 2 </X> 1372 1424 <Y> 70 </Y> 1373 1425 </LOCATION> … … 1397 1449 <ID> 1107 </ID> 1398 1450 <LOCATION> 1399 <X> 6</X>1451 <X> 2 </X> 1400 1452 <Y> 109 </Y> 1401 1453 </LOCATION> … … 1403 1455 <FONT_ID> STD_FONT </FONT_ID> 1404 1456 <TEXT> 1405 "This software is distributed under\nthe terms of the GNU GPL ."1457 "This software is distributed under\nthe terms of the GNU GPL, Version 2." 1406 1458 </TEXT> 1407 1459 </FORM_LABEL> … … 1409 1461 <ID> 1104 </ID> 1410 1462 <LOCATION> 1411 <X> 6</X>1463 <X> 2 </X> 1412 1464 <Y> 52 </Y> 1413 1465 </LOCATION> … … 1419 1471 <ID> 1106 </ID> 1420 1472 <LOCATION> 1421 <X> 6</X>1473 <X> 2 </X> 1422 1474 <Y> 84 </Y> 1423 1475 </LOCATION> 1424 1476 <USABLE> TRUE </USABLE> 1425 1477 <FONT_ID> STD_FONT </FONT_ID> 1426 <TEXT> "Copyright (C) 2005 Nicolai Ehemann\n(en@enlightened.de)." </TEXT> 1478 <TEXT> 1479 "Copyright (c) 2005, 2006\nNicolai Ehemann (en@enlightened.de)" 1480 </TEXT> 1427 1481 </FORM_LABEL> 1428 1482 </FORM_OBJECTS> … … 1443 1497 <HELP_ID> 2001 </HELP_ID> 1444 1498 <MENU_ID> 0 </MENU_ID> 1445 <DEFAULT_BUTTON> 0</DEFAULT_BUTTON>1499 <DEFAULT_BUTTON> 1203 </DEFAULT_BUTTON> 1446 1500 <TITLE_ICON> FALSE </TITLE_ICON> 1447 1501 <TITLE_BAR_FOCUSABLE> FALSE </TITLE_BAR_FOCUSABLE> … … 1529 1583 <MODAL> TRUE </MODAL> 1530 1584 <SAVE_BEHIND> FALSE </SAVE_BEHIND> 1531 <HELP_ID> 0</HELP_ID>1585 <HELP_ID> 2002 </HELP_ID> 1532 1586 <MENU_ID> 0 </MENU_ID> 1533 <DEFAULT_BUTTON> 0</DEFAULT_BUTTON>1587 <DEFAULT_BUTTON> 1302 </DEFAULT_BUTTON> 1534 1588 <TITLE_ICON> FALSE </TITLE_ICON> 1535 1589 <TITLE_BAR_FOCUSABLE> FALSE </TITLE_BAR_FOCUSABLE> … … 1584 1638 <MODAL> TRUE </MODAL> 1585 1639 <SAVE_BEHIND> TRUE </SAVE_BEHIND> 1586 <HELP_ID> 0</HELP_ID>1640 <HELP_ID> 2004 </HELP_ID> 1587 1641 <MENU_ID> 0 </MENU_ID> 1588 <DEFAULT_BUTTON> 0 </DEFAULT_BUTTON>1642 <DEFAULT_BUTTON> 1420 </DEFAULT_BUTTON> 1589 1643 <TITLE_ICON> FALSE </TITLE_ICON> 1590 1644 <TITLE_BAR_FOCUSABLE> FALSE </TITLE_BAR_FOCUSABLE> … … 1593 1647 <TEXT> "Preferences" </TEXT> 1594 1648 </FORM_TITLE> 1595 <FORM_BUTTON >1596 <ID> 1 000 </ID>1597 <BOUNDS> 1598 <LEFT> 4</LEFT>1599 <TOP> 1 40</TOP>1600 <WIDTH> 67</WIDTH>1649 <FORM_BUTTON COMMENT="PreferencesFormButtonOK"> 1650 <ID> 1420 </ID> 1651 <BOUNDS> 1652 <LEFT> 6 </LEFT> 1653 <TOP> 139 </TOP> 1654 <WIDTH> 35 </WIDTH> 1601 1655 <HEIGHT> 12 </HEIGHT> 1602 1656 </BOUNDS> … … 1604 1658 <ENABLED> TRUE </ENABLED> 1605 1659 <TEXT> "OK" </TEXT> 1660 <LEFT_ANCHOR> FALSE </LEFT_ANCHOR> 1661 <FONT_ID> STD_FONT </FONT_ID> 1662 <BUTTON_FRAME> STANDARD_BUTTON_FRAME </BUTTON_FRAME> 1663 </FORM_BUTTON> 1664 <FORM_LABEL COMMENT="PreferencesFormLabelMajorClickFrequency"> 1665 <ID> 1401 </ID> 1666 <LOCATION> 1667 <X> 6 </X> 1668 <Y> 20 </Y> 1669 </LOCATION> 1670 <USABLE> TRUE </USABLE> 1671 <FONT_ID> STD_FONT </FONT_ID> 1672 <TEXT> "Major click frequency:" </TEXT> 1673 </FORM_LABEL> 1674 <FORM_LABEL COMMENT="PreferencesFormLabelMinimumBPS"> 1675 <ID> 1405 </ID> 1676 <LOCATION> 1677 <X> 6 </X> 1678 <Y> 56 </Y> 1679 </LOCATION> 1680 <USABLE> TRUE </USABLE> 1681 <FONT_ID> STD_FONT </FONT_ID> 1682 <TEXT> "Minimum BPS:" </TEXT> 1683 </FORM_LABEL> 1684 <FORM_LABEL COMMENT="PreferencesFormLabelMinorClickFrequency"> 1685 <ID> 1403 </ID> 1686 <LOCATION> 1687 <X> 6 </X> 1688 <Y> 38 </Y> 1689 </LOCATION> 1690 <USABLE> TRUE </USABLE> 1691 <FONT_ID> STD_FONT </FONT_ID> 1692 <TEXT> "Minor click frequency:" </TEXT> 1693 </FORM_LABEL> 1694 <FORM_FIELD COMMENT="PreferencesFormFieldMajorClickFrequency"> 1695 <ID> 1402 </ID> 1696 <BOUNDS> 1697 <LEFT> 118 </LEFT> 1698 <TOP> 20 </TOP> 1699 <WIDTH> 30 </WIDTH> 1700 <HEIGHT> 11 </HEIGHT> 1701 </BOUNDS> 1702 <USABLE> TRUE </USABLE> 1703 <EDITABLE> TRUE </EDITABLE> 1704 <SINGLE_LINE> TRUE </SINGLE_LINE> 1705 <DYNAMIC_SIZE> FALSE </DYNAMIC_SIZE> 1706 <UNDERLINE> GRAY_UNDERLINE </UNDERLINE> 1707 <JUSTIFICATION> RIGHT_ALIGN </JUSTIFICATION> 1708 <AUTO_SHIFT> FALSE </AUTO_SHIFT> 1709 <HAS_SCROLLBAR> FALSE </HAS_SCROLLBAR> 1710 <NUMERIC> TRUE </NUMERIC> 1711 <MAX_CHARS> 5 </MAX_CHARS> 1712 <FONT_ID> STD_FONT </FONT_ID> 1713 <MAX_VISIBLE_LINES> 0 </MAX_VISIBLE_LINES> 1714 </FORM_FIELD> 1715 <FORM_FIELD COMMENT="PreferencesFormFieldMinorClickFrequency"> 1716 <ID> 1404 </ID> 1717 <BOUNDS> 1718 <LEFT> 118 </LEFT> 1719 <TOP> 38 </TOP> 1720 <WIDTH> 30 </WIDTH> 1721 <HEIGHT> 11 </HEIGHT> 1722 </BOUNDS> 1723 <USABLE> TRUE </USABLE> 1724 <EDITABLE> TRUE </EDITABLE> 1725 <SINGLE_LINE> TRUE </SINGLE_LINE> 1726 <DYNAMIC_SIZE> FALSE </DYNAMIC_SIZE> 1727 <UNDERLINE> GRAY_UNDERLINE </UNDERLINE> 1728 <JUSTIFICATION> RIGHT_ALIGN </JUSTIFICATION> 1729 <AUTO_SHIFT> FALSE </AUTO_SHIFT> 1730 <HAS_SCROLLBAR> FALSE </HAS_SCROLLBAR> 1731 <NUMERIC> TRUE </NUMERIC> 1732 <MAX_CHARS> 5 </MAX_CHARS> 1733 <FONT_ID> STD_FONT </FONT_ID> 1734 <MAX_VISIBLE_LINES> 0 </MAX_VISIBLE_LINES> 1735 </FORM_FIELD> 1736 <FORM_FIELD COMMENT="PreferencesFormFieldMinimumBPS"> 1737 <ID> 1406 </ID> 1738 <BOUNDS> 1739 <LEFT> 131 </LEFT> 1740 <TOP> 56 </TOP> 1741 <WIDTH> 17 </WIDTH> 1742 <HEIGHT> 11 </HEIGHT> 1743 </BOUNDS> 1744 <USABLE> TRUE </USABLE> 1745 <EDITABLE> TRUE </EDITABLE> 1746 <SINGLE_LINE> TRUE </SINGLE_LINE> 1747 <DYNAMIC_SIZE> FALSE </DYNAMIC_SIZE> 1748 <UNDERLINE> GRAY_UNDERLINE </UNDERLINE> 1749 <JUSTIFICATION> RIGHT_ALIGN </JUSTIFICATION> 1750 <AUTO_SHIFT> FALSE </AUTO_SHIFT> 1751 <HAS_SCROLLBAR> FALSE </HAS_SCROLLBAR> 1752 <NUMERIC> TRUE </NUMERIC> 1753 <MAX_CHARS> 3 </MAX_CHARS> 1754 <FONT_ID> STD_FONT </FONT_ID> 1755 <MAX_VISIBLE_LINES> 0 </MAX_VISIBLE_LINES> 1756 </FORM_FIELD> 1757 <FORM_LABEL COMMENT="PreferencesFormLabelMaximumBPS"> 1758 <ID> 1407 </ID> 1759 <LOCATION> 1760 <X> 6 </X> 1761 <Y> 74 </Y> 1762 </LOCATION> 1763 <USABLE> TRUE </USABLE> 1764 <FONT_ID> STD_FONT </FONT_ID> 1765 <TEXT> "Maximum BPS:" </TEXT> 1766 </FORM_LABEL> 1767 <FORM_FIELD COMMENT="PreferencesFormFieldMaximumBPS"> 1768 <ID> 1408 </ID> 1769 <BOUNDS> 1770 <LEFT> 131 </LEFT> 1771 <TOP> 74 </TOP> 1772 <WIDTH> 17 </WIDTH> 1773 <HEIGHT> 11 </HEIGHT> 1774 </BOUNDS> 1775 <USABLE> TRUE </USABLE> 1776 <EDITABLE> TRUE </EDITABLE> 1777 <SINGLE_LINE> TRUE </SINGLE_LINE> 1778 <DYNAMIC_SIZE> FALSE </DYNAMIC_SIZE> 1779 <UNDERLINE> GRAY_UNDERLINE </UNDERLINE> 1780 <JUSTIFICATION> RIGHT_ALIGN </JUSTIFICATION> 1781 <AUTO_SHIFT> FALSE </AUTO_SHIFT> 1782 <HAS_SCROLLBAR> FALSE </HAS_SCROLLBAR> 1783 <NUMERIC> TRUE </NUMERIC> 1784 <MAX_CHARS> 3 </MAX_CHARS> 1785 <FONT_ID> STD_FONT </FONT_ID> 1786 <MAX_VISIBLE_LINES> 0 </MAX_VISIBLE_LINES> 1787 </FORM_FIELD> 1788 <FORM_BUTTON COMMENT="PreferencesFormButtonReset"> 1789 <ID> 1421 </ID> 1790 <BOUNDS> 1791 <LEFT> 47 </LEFT> 1792 <TOP> 139 </TOP> 1793 <WIDTH> 35 </WIDTH> 1794 <HEIGHT> 12 </HEIGHT> 1795 </BOUNDS> 1796 <USABLE> TRUE </USABLE> 1797 <ENABLED> TRUE </ENABLED> 1798 <TEXT> "Reset" </TEXT> 1799 <LEFT_ANCHOR> FALSE </LEFT_ANCHOR> 1800 <FONT_ID> STD_FONT </FONT_ID> 1801 <BUTTON_FRAME> STANDARD_BUTTON_FRAME </BUTTON_FRAME> 1802 </FORM_BUTTON> 1803 <FORM_BUTTON COMMENT="PreferencesFormButtonBuildDefaults"> 1804 <ID> 1422 </ID> 1805 <BOUNDS> 1806 <LEFT> 88 </LEFT> 1807 <TOP> 139 </TOP> 1808 <WIDTH> 61 </WIDTH> 1809 <HEIGHT> 12 </HEIGHT> 1810 </BOUNDS> 1811 <USABLE> TRUE </USABLE> 1812 <ENABLED> TRUE </ENABLED> 1813 <TEXT> "Build Defaults" </TEXT> 1606 1814 <LEFT_ANCHOR> FALSE </LEFT_ANCHOR> 1607 1815 <FONT_ID> STD_FONT </FONT_ID> … … 1622 1830 <MODAL> TRUE </MODAL> 1623 1831 <SAVE_BEHIND> FALSE </SAVE_BEHIND> 1624 <HELP_ID> 0</HELP_ID>1832 <HELP_ID> 2003 </HELP_ID> 1625 1833 <MENU_ID> 0 </MENU_ID> 1626 <DEFAULT_BUTTON> 0</DEFAULT_BUTTON>1834 <DEFAULT_BUTTON> 1506 </DEFAULT_BUTTON> 1627 1835 <TITLE_ICON> FALSE </TITLE_ICON> 1628 1836 <TITLE_BAR_FOCUSABLE> FALSE </TITLE_BAR_FOCUSABLE> … … 1809 2017 1810 2018 <STRING_RESOURCE RESOURCE_ID="2002" COMMENT="StringFormVolumeHelp"> 1811 <TEXT> " With" </TEXT>2019 <TEXT> "Here, you can adjust the volume of the clicks." </TEXT> 1812 2020 </STRING_RESOURCE> 1813 2021 2022 <STRING_RESOURCE RESOURCE_ID="2003" COMMENT="StringFormBeatHelp"> 2023 <TEXT> 2024 "Beat settings\n\nCurrently, only basic beats are implemented. Select a nominator and a denominator, and click ok. Some combinations are known to cause problems or malfunction." 2025 </TEXT> 2026 </STRING_RESOURCE> 2027 2028 <STRING_RESOURCE RESOURCE_ID="2004" COMMENT="StringFormPreferencesHelp"> 2029 <TEXT> 2030 "Set application preferences\n\nWith major and minor click frequency, you can adjust the click sounds.\nMinimum and maximum BPS (= beats per second) are the bps constraints enforced by MetroPro.\n\nClick OK to save defaults or Reset to restore your old preferences. Click Build Defaults to restore buildtime default values." 2031 </TEXT> 2032 </STRING_RESOURCE> 2033 2034 <STRING_RESOURCE RESOURCE_ID="2005" COMMENT="StringHelp"> 2035 <TEXT> 2036 "MetroPro is a simple metronome application. It should be pretty straightforward to use:\n\n- Adjust tempo (beats per minute, bpm) using the slider at the bottom\n- Select a beat by clicking the Main Beat button\n- Start / Stop the metronome by tapping the screen\n- Tap a temo using the tap button\n- Save and load presets using the hard buttons\n\nPreferences can be adjusted through the preferences dialog.\n\nUsing presets requires a long press for saving and a short press for loading the preset.\n" 2037 </TEXT> 2038 </STRING_RESOURCE> 2039 1814 2040 </PALMOS_RESOURCE_FILE> -
trunk/src/main.c
r17 r18 1 /****************************************************************************** 2 * 3 * Copyright (c) 1999-2004 PalmSource, Inc. All rights reserved. 4 * 5 * File: AppMain.c 6 * 7 *****************************************************************************/ 8 9 #include <PalmOS.h> 10 //#include <KeyMgr.h> 11 #include <Libraries/PalmOSGlue/PalmOSGlue.h> 12 13 #include "resources.h" 14 #include "metropro.h" 15 #include "mtprtypes.h" 1 /******************************************************************************* 2 * 3 * File: main.c - metronome core 4 * 5 * Copyright (c) 2005, 2006 Nicolai Ehemann 6 * 7 * This file is part of MetroPro. 8 * 9 * MetroPro is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License Version 2 as 11 * published by the Free Software Foundation; you may not use other 12 * versions of the license. 13 * 14 * MetroPro is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with MetroPro; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 * 23 ******************************************************************************/ 24 25 #include "main.h" 16 26 17 27 /*********************************************************************** … … 21 31 ***********************************************************************/ 22 32 /** internal constants */ 23 // graphical 'equalizer' proportions24 //static const float Proportions[] = {0.00,0.00,0.01,0.02,0.03,0.04,0.06,0.09,0.12,0.17,0.22,0.27,0.34,0.42,0.51,0.61,0.73,0.86,1.00};25 // 1 1 1 2 2 2 3 3 4 5 6 7 8 9 10 11 12 1326 static const float Proportions[] = {0.00,0.01,0.02,0.03,0.05,0.07,0.09,0.12,0.15,0.19,0.24,0.30,0.37,0.45,0.54,0.64,0.75,0.87,1.00};27 #define BarNum 3828 29 // colors30 static const RGBColorType colorBar = {0, 160, 160, 160};31 static const RGBColorType colorMidBar = {0, 80, 80, 80};32 static const RGBColorType colorActBar = {0, 255, 0, 0};33 33 34 34 /** saved variables */ 35 static AppStateTypeAppState;36 static AppPrefTypeAppPrefs;35 AppStateType AppState; 36 AppPrefType AppPrefs; 37 37 38 38 /** runtime variables */ 39 static Boolean HighDensity = false; 40 41 static UInt16 NextClick = 0; 42 static UInt16 ClickLength = 0; 43 static Boolean Running = false; 44 static UInt16 CurrentBeat = 0; 45 static UInt16 CurrentBar = 0; 46 static Boolean MoveRight = true; 47 static UInt16 AutoOffTime = 0; 48 49 static UInt16 Tapped = 0; 50 static UInt16 TappedTempo = 0; 51 static UInt16 LastTappedTick = 0; 52 // IDEA: static UInt16 TapDiff[6]; 39 Boolean HighDensity = false; 40 41 UInt16 NextClick = 0; 42 UInt16 ClickLength = 0; 43 Boolean Running = false; 44 UInt16 CurrentBeat = 0; 45 UInt16 CurrentBar = 0; 46 Boolean MoveRight = true; 47 UInt16 AutoOffTime = 0; 53 48 54 49 static MemHandle customFontH; 55 static RectangleType BarRectangle[BarNum];56 50 57 51 /** … … 65 59 */ 66 60 67 static ControlType *GetObjectPtr(UInt16 objectID, FormType* pForm) 68 { 69 return (ControlType*)(FrmGetObjectPtr(pForm,FrmGetObjectIndex(pForm,objectID))); 70 } 71 72 static void CalculateTickLength() 61 void CalculateTickLength() 73 62 { 74 63 ClickLength = ( ( ( SysTicksPerSecond() * SECONDS_PER_MINUTE ) … … 105 94 } 106 95 107 static void PaintBars(UInt16 bar, RGBColorType rgbColor)108 {109 IndexedColorType icolor, icolorPrev;110 111 icolor = WinRGBToIndex(&rgbColor);112 icolorPrev = WinSetForeColor(icolor);113 WinDrawRectangle(&BarRectangle[bar], 0);114 WinDrawRectangle(&BarRectangle[bar + 1], 0);115 WinDrawRectangle(&BarRectangle[bar + 2], 0);116 WinSetForeColor(icolorPrev);117 }118 119 static void SetRunning(Boolean set)120 {121 if (Running != set)122 {123 FormType* pForm = FrmGetFormPtr(MainForm);124 ControlType* pCtl = GetObjectPtr(MainFormPlayButton, pForm);125 126 if (set)127 {128 NextClick = TimGetTicks();129 CurrentBeat = 0;130 CurrentBar = 0;131 MoveRight = false;132 Running = true;133 FrmCopyLabel(pForm, MainFormRunningLabel, "On");134 CtlSetGraphics(pCtl, BitmapButtonPlayOn, BitmapButtonPlayOnPressed);135 AutoOffTime = SysSetAutoOffTime(0);136 }137 else138 {139 PaintBars(CurrentBar, colorBar);140 Running = false;141 FrmCopyLabel(pForm, MainFormRunningLabel, "Off");142 CtlSetGraphics(pCtl, BitmapButtonPlayOff, BitmapButtonPlayOffPressed);143 AutoOffTime = SysSetAutoOffTime(AutoOffTime);144 }145 }146 }147 148 static void ToggleRunning()149 {150 SetRunning(!Running);151 }152 153 static void SetMute(Boolean Mute)154 {155 ControlType* pCtl = GetObjectPtr(MainFormMuteButton, FrmGetFormPtr(MainForm));156 157 AppState.Mute = Mute;158 if (Mute)159 {160 CtlSetGraphics(pCtl, BitmapButtonMuteOn, BitmapButtonMuteOnPressed);161 }162 else163 {164 CtlSetGraphics(pCtl, BitmapButtonMuteOff, BitmapButtonMuteOffPressed);165 }166 }167 168 static void ToggleMute()169 {170 SetMute(!AppState.Mute);171 }172 96 /* 173 97 static void ChangeVolume(UInt16 Volume) … … 189 113 }*/ 190 114 191 static Boolean MainFormDoCommand(UInt16 command) 192 { 193 Boolean handled = false; 194 FormType* pForm; 195 196 switch (command) 197 { 198 case MainMenuAbout: 199 { 200 UInt16 obj; 201 RectangleType pRect; 202 Char text[13]; 203 204 pForm = FrmInitForm(AboutForm); 205 // update version label 206 obj = FrmGetObjectIndex(pForm, AboutFormLabelVersionNum); 207 FrmGetObjectBounds(pForm, obj, &pRect); 208 FrmHideObject(pForm, obj); 209 FrmRemoveObject(&pForm, obj); 210 211 StrPrintF(text, "%d.%d.%d", appVersionMajor, appVersionMinor, appVersionPatch); 212 FrmNewLabel(&pForm, AboutFormLabelVersionNum, 213 text, pRect.topLeft.x, pRect.topLeft.y, 214 boldFont); 215 obj = FrmGetObjectIndex(pForm, AboutFormLabelVersionNum); 216 FrmSetObjectPosition(pForm, obj, pRect.topLeft.x, pRect.topLeft.y); 217 FrmShowObject(pForm, obj); 218 //update date label 219 obj = FrmGetObjectIndex(pForm, AboutFormLabelDate); 220 FrmGetObjectBounds(pForm, obj, &pRect); 221 FrmHideObject(pForm, obj); 222 FrmRemoveObject(&pForm, obj); 223 224 StrPrintF(text, "(%s)", appVersionDate); 225 FrmNewLabel(&pForm, AboutFormLabelDate, 226 text, pRect.topLeft.x, pRect.topLeft.y, 227 stdFont); 228 obj = FrmGetObjectIndex(pForm, AboutFormLabelDate); 229 FrmSetObjectPosition(pForm, obj, pRect.topLeft.x, pRect.topLeft.y); 230 FrmShowObject(pForm, obj); 231 232 FrmDoDialog(pForm); 233 FrmDeleteForm(pForm); 234 handled = true; 235 } 236 break; 237 case MainMenuPreferences: 238 pForm = FrmInitForm(PreferencesForm); 239 240 FrmDoDialog(pForm); 241 FrmDeleteForm(pForm); 242 handled = true; 243 break; 244 } 245 246 return handled; 247 } 248 249 static Char* getTempoDescription(UInt16 bpm) 250 { 251 // TODO 252 //Char *s = MemPtrNew(6 * sizeof(Char)); 253 //StrCopy(s, "Largo"); 254 //return s; 255 if (bpm < 60) 256 { 257 return "Largo"; 258 } 259 else if (59 < bpm && bpm < 66) 260 { 261 return "Larghetto"; 262 } 263 else if (65 < bpm && bpm < 76) 264 { 265 return "Adagio"; 266 } 267 else if (75 < bpm && bpm < 108) 268 { 269 return "Andante"; 270 } 271 else if (107 < bpm && bpm < 120) 272 { 273 return "Moderato"; 274 } 275 else if (119 < bpm && bpm < 168) 276 { 277 return "Allegro"; 278 } 279 else if (167 < bpm && bpm < 208) 280 { 281 return "Presto"; 282 } 283 else 284 { 285 return "Prestissimo"; 286 } 287 } 288 289 static void MainFormUpdateTempoFromSlider(UInt16 value) 290 { 291 FormType* pForm = FrmGetFormPtr(MainForm); 292 UInt16 obj = FrmGetObjectIndex(pForm, MainFormTempoLabelNo); 293 char tempo[4], num[4]; 294 Coord width; 295 RectangleType pRect; 296 297 StrIToA(num, value); 298 if (100 > value) 299 { 300 StrCopy(tempo, "0"); 301 } 302 else 303 { 304 StrCopy(tempo, ""); 305 } 306 StrCat(tempo, num); 307 308 // change actual tempo 309 AppState.Tempo = value; 310 CalculateTickLength(); 311 312 // get the form width 313 FrmGetFormBounds(pForm, &pRect); 314 width = pRect.extent.x; 315 316 // update the numerical tempo label 317 FrmHideObject(pForm, obj); 318 FrmCopyLabel(pForm, MainFormTempoLabelNo, tempo); 319 FrmShowObject(pForm, obj); 320 321 // get the position of the old textual tempo label and remove it 322 obj = FrmGetObjectIndex(pForm, MainFormTempoLabelString); 323 FrmGetObjectBounds(pForm, obj, &pRect); 324 FrmHideObject(pForm, obj); 325 FrmRemoveObject(&pForm, obj); 326 327 FrmNewLabel(&pForm, MainFormTempoLabelString, 328 getTempoDescription(value), pRect.topLeft.x, pRect.topLeft.y, 329 stdFont); 330 obj = FrmGetObjectIndex(pForm, MainFormTempoLabelString); 331 332 // calculate centered position and move label to this position 333 FrmGetObjectBounds(pForm, obj, &pRect); 334 width = (width - pRect.extent.x) / 2; 335 FrmSetObjectPosition(pForm, obj, width, pRect.topLeft.y); 336 FrmShowObject(pForm, obj); 337 } 338 339 static void MainFormUpdateTempo(UInt16 value) 340 { 341 FormType* pForm = FrmGetFormPtr(MainForm); 342 UInt16 slider = FrmGetObjectIndex(pForm, MainFormTempoSlider); 343 344 if (AppPrefs.TempoMinValue > value) 345 { 346 value = AppPrefs.TempoMinValue; 347 } 348 else if (AppPrefs.TempoMaxValue < value) 349 { 350 value = AppPrefs.TempoMaxValue; 351 } 352 353 MainFormUpdateTempoFromSlider(value); 354 FrmHideObject(pForm, slider); 355 CtlSetValue(GetObjectPtr(MainFormTempoSlider, pForm), value); 356 FrmShowObject(pForm, slider); 357 } 358 359 static void MainFormUpdateBeat(UInt16 num, NoteValueType denom) 360 { 361 FormType* pForm = FrmGetFormPtr(MainForm); 362 UInt16 obj = FrmGetObjectIndex(pForm, MainFormButtonMainBeat); 363 RectangleType pRect; 364 Char sBeat[17]; 365 366 AppState.BeatNumerator = num; 367 AppState.BeatDenominator = denom; 368 369 FrmGetObjectBounds(pForm, obj, &pRect); 370 FrmHideObject(pForm, obj); 371 FrmRemoveObject(&pForm, obj); 372 pForm = FrmGetFormPtr(MainForm); 373 StrPrintF(sBeat, "Main Beat: %d/%d", AppState.BeatNumerator, AppState.BeatDenominator); 374 CtlNewControl ((void**)&pForm, MainFormButtonMainBeat, buttonCtl, 375 sBeat, pRect.topLeft.x, pRect.topLeft.y, pRect.extent.x, 376 pRect.extent.y, stdFont, 0, false); 377 obj = FrmGetObjectIndex(pForm, MainFormButtonMainBeat); 378 FrmShowObject(pForm, obj); 379 380 CalculateTickLength(); 381 } 382 383 Boolean DisplayGadgetHandleEvent(FormGadgetTypeInCallback* pGadget, 384 UInt16 cmd, void* pParam) 385 { 386 Boolean handled = false; 387 388 switch (cmd) 389 { 390 case formGadgetDrawCmd: 391 if (pGadget->data == NULL) 392 { 393 RectangleType pRect; 394 UInt16 propHeight; 395 UInt16 topLeftX; 396 int i; 397 DisplayGadgetData* ndata = (DisplayGadgetData*) MemPtrNew(sizeof(DisplayGadgetData)); 398 399 ErrFatalDisplayIf(0 == ndata, 400 "Could Not allocate gadget data"); 401 ndata->BaseHeight = (pGadget->rect.extent.x * 0.05); 402 ndata->MaxBarHeight = (pGadget->rect.extent.y * 0.9) / 2 - (ndata->BaseHeight / 2); 403 ndata->Step = (pGadget->rect.extent.x * 0.95) / BarNum; 404 ndata->SpaceWidth = ndata->Step / 4; 405 ndata->BarWidth = ndata->SpaceWidth * 3; 406 ndata->MidPoint.x = pGadget->rect.extent.x / 2; 407 ndata->MidPoint.y = pGadget->rect.extent.y / 2; 408 ndata->BarNumHalf = BarNum / 2; 409 pGadget->data = ndata; 410 411 // paint bars 412 topLeftX = pRect.topLeft.x = ndata->MidPoint.x - (ndata->BarNumHalf * (ndata->Step) + ndata->SpaceWidth); 413 pRect.extent.x = ndata->BarWidth; 414 for (i = ndata->BarNumHalf; i >= 1; i--) 415 { 416 propHeight = Proportions[i-1] * ndata->MaxBarHeight; 417 pRect.topLeft.y = ndata->MidPoint.y - (propHeight + ndata->BaseHeight) + pGadget->rect.topLeft.y; 418 pRect.extent.y = 2 * ndata->BaseHeight + 2 * propHeight; 419 BarRectangle[ndata->BarNumHalf-i] = pRect; 420 pRect.topLeft.x = pGadget->rect.extent.x - (topLeftX + ndata->BarWidth); 421 BarRectangle[ndata->BarNumHalf + (i - 1)] = pRect; 422 topLeftX = pRect.topLeft.x = topLeftX + ndata->Step; 423 } 424 425 // paint beat indicators 426 427 } 428 429 //WinDrawRectangleFrame(rectangleFrame, &(pGadget->rect)); 430 { 431 DisplayGadgetData data = *((DisplayGadgetData*) pGadget->data); 432 RectangleType pRect; 433 IndexedColorType icolor, icolorPrev; 434 int i; 435 436 icolor = WinRGBToIndex(&colorBar); 437 icolorPrev = WinSetForeColor(icolor); 438 for (i = 0; i < BarNum; i++) 439 { 440 WinDrawRectangle(&BarRectangle[i], 0); 441 } 442 icolor = WinRGBToIndex(&colorMidBar); 443 WinSetForeColor(icolor); 444 pRect = BarRectangle[data.BarNumHalf - 1]; 445 pRect.topLeft.x = pRect.topLeft.x + data.Step; 446 pRect.extent.x = 2 * data.SpaceWidth; 447 WinDrawRectangle(&pRect, 0); 448 WinSetForeColor(icolorPrev); 449 } 450 handled = true; 451 break; 452 453 case formGadgetHandleEventCmd: 454 { 455 EventType* pEvent = (EventType*) pParam; 456 457 if (pEvent->eType == frmGadgetEnterEvent) 458 { 459 // pen down in gadget 460 ToggleRunning(); 461 handled = true; 462 } 463 else if (pEvent->eType == frmGadgetMiscEvent) 464 { 465 //you can send events into the gadget 466 //handler here 467 //if (pEvent->data.gadgetMisc.selector == gadgetDoSomethingButtonSelector) 468 //{ 469 // //do something here 470 //} 471 } 472 } 473 break; 474 475 case formGadgetEraseCmd: 476 //erase the frame drawn around the gadget 477 //WinEraseRectangleFrame (rectangleFrame, &(pGadget->rect)); 478 handled = false; 479 break; 480 481 case formGadgetDeleteCmd: 482 //free the chunk set to hold the gadget's data 483 MemPtrFree((MemPtr)pGadget->data); 484 handled = true; 485 break; 486 487 default: 488 break; 489 } 490 return handled; 491 } 492 493 Boolean VolumeFormHandleEvent(EventType* pEvent) 494 { 495 Boolean handled = false; 496 497 switch (pEvent->eType) 498 { 499 case ctlRepeatEvent: 500 if (VolumeFormSliderVolume == pEvent->data.ctlRepeat.controlID) 501 { 502 AppState.Volume = pEvent->data.ctlRepeat.value; 503 } 504 // not handled, because of repeating events 505 break; 506 default: 507 break; 508 } 509 return handled; 510 } 511 512 static void StartVolumeForm() 513 { 514 FormType* pForm; 515 516 pForm = FrmInitForm(VolumeForm); 517 FrmSetEventHandler(pForm, VolumeFormHandleEvent); 518 CtlSetValue(GetObjectPtr(VolumeFormSliderVolume, pForm), AppState.Volume); 519 FrmDoDialog(pForm); 520 FrmDeleteForm(pForm); 521 } 522 523 Boolean VolumeGadgetHandleEvent(FormGadgetTypeInCallback* pGadget, 524 UInt16 cmd, void* pParam) 525 { 526 Boolean handled = false; 527 VolumeGadgetData *pData = (VolumeGadgetData*) pGadget->data; 528 529 switch (cmd) 530 { 531 case formGadgetDrawCmd: 532 if (pGadget->data == NULL) 533 { 534 // reserve memory for data 535 pData = (VolumeGadgetData*) MemPtrNew(sizeof(VolumeGadgetData)); 536 // retrieve and lock bitmap ressources 537 pData->hBitmap = DmGetResource(bitmapRsc, BitmapButtonVolume); 538 pData->pBitmap = (BitmapType *)MemHandleLock(pData->hBitmap); 539 pData->hSelectedBitmap = DmGetResource(bitmapRsc, BitmapButtonVolumePressed); 540 pData->pSelectedBitmap = (BitmapType *)MemHandleLock(pData->hSelectedBitmap); 541 pGadget->data = pData; 542 } 543 { 544 FormType *pForm = FrmGetFormPtr(MainForm); 545 UInt16 obj = FrmGetObjectIndex(pForm, MainFormVolumeGadget); 546 RectangleType pRect; 547 UInt16 coordSys = 0, i, start, end, y; 548 549 FrmGetObjectBounds(pForm, obj, &pRect); 550 WinDrawBitmap(pData->pBitmap, pRect.topLeft.x, pRect.topLeft.y); 551 pRect.topLeft.x = pRect.topLeft.x + 2; 552 pRect.topLeft.y = pRect.topLeft.y + 2; 553 pRect.extent.x = pRect.extent.x - 4; 554 pRect.extent.y = pRect.extent.y - 4; 555 if (HighDensity) 556 { 557 coordSys = WinSetCoordinateSystem(kCoordinatesDouble); 558 WinScaleRectangle(&pRect); 559 } 560 end = pRect.extent.x * AppState.Volume / 100; 561 i = 0; 562 for (i = 0, start = pRect.extent.x * i / pRect.extent.y; 563 i < pRect.extent.y && start <= end; i++) 564 { 565 y = pRect.topLeft.y + pRect.extent.y - (i + 1); 566 WinDrawLine(pRect.topLeft.x + start, y, pRect.topLeft.x + end, y); 567 start = pRect.extent.x * (i + 1) / pRect.extent.y; 568 } 569 //WinDrawLine(pRect.topLeft.x, pRect.topLeft.y + pRect.extent.y - 1, 570 // pRect.topLeft.x + end, pRect.topLeft.y + pRect.extent.y - i); 571 if (HighDensity) 572 { 573 WinSetCoordinateSystem(coordSys); 574 } 575 } 576 handled = true; 577 break; 578 579 case formGadgetHandleEventCmd: 580 { 581 EventType* pEvent = (EventType*) pParam; 582 583 if (pEvent->eType == frmGadgetEnterEvent) 584 { 585 // pen down in gadget 586 StartVolumeForm(); 587 handled = true; 588 } 589 } 590 break; 591 592 case formGadgetEraseCmd: 593 { 594 FormType *pForm = FrmGetActiveForm(); 595 RectangleType pRect; 596 UInt16 obj; 597 598 obj = FrmGetObjectIndex(pForm, MainFormVolumeGadget); 599 FrmGetObjectBounds(pForm, obj, &pRect); 600 WinEraseRectangle(&pRect, 0); 601 602 // release and free bitmap ressources 603 MemHandleUnlock(pData->hBitmap); 604 DmReleaseResource(pData->hBitmap); 605 MemHandleUnlock(pData->hSelectedBitmap); 606 DmReleaseResource(pData->hSelectedBitmap); 607 608 // free data 609 MemPtrFree((MemPtr)pGadget->data); 610 } 611 handled = true; 612 break; 613 614 case formGadgetDeleteCmd: 615 handled = true; 616 break; 617 618 default: 619 break; 620 } 621 return handled; 622 } 623 624 static void MainFormInitialize(FormType* pForm) 625 { 626 UInt16 obj; 627 Coord width; 628 RectangleType pRect; 629 630 FrmGlueSetLabelFont(pForm, MainFormTempoLabelNo, LEDFontID); 631 632 // update mute button 633 SetMute(AppState.Mute); 634 635 // update position of the numerical display 636 obj = FrmGetObjectIndex(pForm, MainFormTempoLabelNo); 637 FrmHideObject(pForm, obj); 638 639 // get the form width 640 FrmGetFormBounds(pForm, &pRect); 641 width = pRect.extent.x; 642 643 // calculate centered position and move label to this position 644 FrmGetObjectBounds(pForm, obj, &pRect); 645 width = (width - pRect.extent.x) / 2; 646 FrmSetObjectPosition(pForm, obj, width, pRect.topLeft.y); 647 FrmShowObject(pForm, obj); 648 MainFormUpdateTempo(AppState.Tempo); 649 650 // update the beat display 651 MainFormUpdateBeat(AppState.BeatNumerator, AppState.BeatDenominator); 652 653 // set event handler for the display gadget 654 obj = FrmGetObjectIndex(pForm, MainFormDisplayGadget); 655 FrmSetGadgetHandler(pForm, obj, DisplayGadgetHandleEvent); 656 657 // set event handler for the volume gadget 658 obj = FrmGetObjectIndex(pForm, MainFormVolumeGadget); 659 FrmSetGadgetHandler(pForm, obj, VolumeGadgetHandleEvent); 660 661 } 662 663 static void MainFormFinalize(FormType* pForm) 664 { 665 UInt16 obj = FrmGetObjectIndex(pForm, MainFormVolumeGadget); 666 FrmHideObject(pForm, obj); 667 FrmRemoveObject(&pForm, obj); 115 void UpdatePrefMinTempo(UInt16 value) 116 { 117 AppPrefs.TempoMinValue = value; 118 MainFormUpdateTempoLimits(&value, NULL); 119 } 120 121 void UpdatePrefMaxTempo(UInt16 value) 122 { 123 AppPrefs.TempoMaxValue = value; 124 MainFormUpdateTempoLimits(NULL, &value); 668 125 } 669 126 … … 736 193 } 737 194 738 static void UpdateTapForm(UInt16 tempo)739 {740 ControlType* pCtl;741 FormType* pForm = FrmGetFormPtr(TapForm);742 UInt16 obj = FrmGetObjectIndex(pForm, TapFormLabelTempoNo);743 Char sTempo[3];744 745 if (0 == tempo)746 {747 StrCopy(sTempo, "---");748 }749 else750 {751 StrIToA(sTempo, tempo);752 }753 754 FrmHideObject(pForm, obj);755 FrmCopyLabel(pForm, TapFormLabelTempoNo, sTempo);756 FrmShowObject(pForm, obj);757 pCtl = GetObjectPtr(TapFormButtonTap, pForm);758 CtlSetLabel(pCtl, sTempo);759 }760 761 static void ResetTapForm(Boolean form)762 {763 Tapped = 0;764 TappedTempo = 0;765 766 if (form)767 {768 UpdateTapForm(0);769 }770 }771 772 Boolean TapFormHandleEvent(EventType* pEvent)773 {774 Boolean handled = false;775 776 switch (pEvent->eType)777 {778 case frmLoadEvent:779 /*780 //TODO: Does not work781 Debug("OPEN");782 {783 ControlType* pCtl;784 FormType* pForm = FrmGetActiveForm();785 786 FrmHideObject(pForm, TapFormButtonTap);787 pCtl = getObjectPtr(TapFormButtonTap);788 CtlGlueSetFont(pCtl, LEDFontID);789 FrmShowObject(pForm, TapFormButtonTap);790 }*/791 break;792 case ctlSelectEvent:793 if (TapFormButtonTap == pEvent->data.ctlSelect.controlID)794 {795 UInt16 currentTick = TimGetTicks();796 797 Tapped++;798 if (1 != Tapped)799 {800 UInt16 NewTempo;801 802 TappedTempo = ( (TappedTempo * (Tapped - 2))803 + (currentTick - LastTappedTick) )804 / (Tapped - 1);805 806 if (0 == TappedTempo)807 {808 Char min[3], max[4];809 StrIToA(min, AppPrefs.TempoMinValue);810 StrIToA(max, AppPrefs.TempoMaxValue);811 FrmCustomAlert(TapFormAlert, "fast", min, max);812 ResetTapForm(true);813 }814 else815 {816 NewTempo = (SysTicksPerSecond() * SECONDS_PER_MINUTE) / TappedTempo;817 818 if (NewTempo < 40)819 {820 Char min[3], max[4];821 StrIToA(min, AppPrefs.TempoMinValue);822 StrIToA(max, AppPrefs.TempoMaxValue);823 FrmCustomAlert(TapFormAlert, "slow", min, max);824 ResetTapForm(true);825 }826 else if (240 < NewTempo)827 {828 Char min[3], max[4];829 StrIToA(min, AppPrefs.TempoMinValue);830 StrIToA(max, AppPrefs.TempoMaxValue);831 FrmCustomAlert(TapFormAlert, "fast", min, max);832 ResetTapForm(true);833 }834 else835 {836 UpdateTapForm(NewTempo);837 }838 }839 }840 LastTappedTick = currentTick;841 handled = true;842 }843 break;844 default:845 break;846 }847 return handled;848 }849 850 static void StartTapForm()851 {852 FormType* pForm;853 UInt16 ChangeTempo = TapFormButtonCancel;854 855 ResetTapForm(false);856 SetRunning(false);857 pForm = FrmInitForm(TapForm);858 FrmSetEventHandler(pForm, TapFormHandleEvent);859 ChangeTempo = FrmDoDialog(pForm);860 if (TapFormButtonOK == ChangeTempo && 0 != TappedTempo)861 {862 MainFormUpdateTempo((SysTicksPerSecond() * SECONDS_PER_MINUTE) / TappedTempo);863 }864 FrmDeleteForm(pForm);865 }866 867 Boolean BeatFormHandleEvent(EventType* pEvent)868 {869 Boolean handled = false;870 871 switch (pEvent->eType)872 {873 case ctlSelectEvent:874 if (BeatFormButtonOK == pEvent->data.ctlSelect.controlID)875 {876 UInt16 num, denom;877 FormType* pForm;878 ListType* pList;879 FieldType* pField;880 Char *sValue;881 882 pForm = FrmGetFormPtr(BeatForm);883 pField = (FieldType*) GetObjectPtr(BeatFormFieldNumerator, pForm);884 if (NULL == (sValue = FldGetTextPtr(pField)))885 {886 num = 0;887 }888 else889 {890 num = StrAToI(sValue);891 }892 if (NOTE_VALUE_MIN > num)893 {894 Char s[4];895 StrIToA(s, NOTE_VALUE_MIN);896 FrmCustomAlert(BeatFormNumeratorAlert, s, NULL, NULL);897 handled = true;898 }899 900 pList = (ListType*) GetObjectPtr(BeatFormListDenominator, pForm);901 denom = StrAToI(LstGetSelectionText(pList, LstGetSelection(pList)));902 903 if (!handled)904 {905 MainFormUpdateBeat(num, denom);906 }907 }908 break;909 default:910 break;911 }912 return handled;913 }914 915 static void StartBeatForm()916 {917 FormType* pForm;918 ControlType* pCtl;919 ListType* pList;920 FieldType* pField;921 UInt16 i, items, value;922 Char sNum[4];923 924 pForm = FrmInitForm(BeatForm);925 pList = (ListType*) GetObjectPtr(BeatFormListDenominator, pForm);926 items = LstGetNumberOfItems(pList);927 for (i = 0; i < items; i++)928 {929 value = StrAToI(LstGetSelectionText(pList, i));930 if (AppState.BeatDenominator == value)931 {932 LstSetSelection(pList, i);933 pCtl = GetObjectPtr(BeatFormPopupDenominator, pForm);934 CtlSetLabel(pCtl, LstGetSelectionText(pList, i));935 break;936 }937 }938 939 StrIToA(sNum, AppState.BeatNumerator);940 pField = (FieldType*) GetObjectPtr(BeatFormFieldNumerator, pForm);941 FldInsert(pField, sNum, StrLen(sNum));942 943 FrmSetEventHandler(pForm, BeatFormHandleEvent);944 FrmDoDialog(pForm);945 FrmDeleteForm(pForm);946 }947 948 Boolean MainFormHandleEvent(EventType* pEvent)949 {950 Boolean handled = false;951 FormType* pForm;952 953 switch (pEvent->eType)954 {955 case menuEvent:956 return MainFormDoCommand(pEvent->data.menu.itemID);957 958 case frmOpenEvent:959 pForm = FrmGetActiveForm();960 MainFormInitialize(pForm);961 FrmDrawForm(pForm);962 handled = true;963 break;964 case ctlRepeatEvent:965 if (MainFormTempoSlider == pEvent->data.ctlRepeat.controlID)966 {967 MainFormUpdateTempoFromSlider(pEvent->data.ctlRepeat.value);968 }969 else if (MainFormTempoUpButton == pEvent->data.ctlRepeat.controlID)970 {971 MainFormUpdateTempo(AppState.Tempo + 1);972 }973 else if (MainFormTempoDownButton == pEvent->data.ctlRepeat.controlID)974 {975 MainFormUpdateTempo(AppState.Tempo - 1);976 }977 // not handled, because of repeating events978 break;979 case ctlSelectEvent:980 if (MainFormPlayButton == pEvent->data.ctlSelect.controlID)981 {982 ToggleRunning();983 handled = true;984 }985 else if (MainFormTapButton == pEvent->data.ctlSelect.controlID)986 {987 StartTapForm();988 handled = true;989 }990 else if (MainFormMuteButton == pEvent->data.ctlSelect.controlID)991 {992 ToggleMute();993 handled = true;994 }995 else if (MainFormButtonMainBeat == pEvent->data.ctlSelect.controlID)996 {997 StartBeatForm();998 handled = true;999 }1000 break;1001 case keyDownEvent:1002 switch (pEvent->data.keyDown.chr)1003 {1004 case '0':1005 case '1':1006 case '2':1007 case '3':1008 case '4':1009 case '5':1010 case '6':1011 case '7':1012 case '8':1013 case '9':1014 ErrDisplay("NUMERICAL");1015 handled = true;1016 }1017 break;1018 case frmCloseEvent:1019 pForm = FrmGetActiveForm();1020 MainFormFinalize(pForm);1021 break;1022 default:1023 break;1024 }1025 1026 return handled;1027 }1028 1029 /***********************************************************************1030 *1031 * FUNCTION: AppHandleEvent1032 *1033 * DESCRIPTION: This routine loads form resources and set the event1034 * handler for the form loaded.1035 *1036 * PARAMETERS: event - a pointer to an EventType structure1037 *1038 * RETURNED: true if the event has handle and should not be passed1039 * to a higher level handler.1040 *1041 * REVISION HISTORY:1042 *1043 *1044 ***********************************************************************/1045 195 Boolean AppHandleEvent(EventType* pEvent) 1046 196 { … … 1265 415 EventType event; 1266 416 Boolean hardKeyEvent; 1267 UInt16 currentTick, lastTick ;417 UInt16 currentTick, lastTick = 0; 1268 418 1269 419 do … … 1281 431 lastTick = currentTick; 1282 432 MoveRight = ((MoveRight?false:true)); 1283 PaintBars(CurrentBar, colorBar);433 PaintBars(CurrentBar, false); 1284 434 CurrentBar = (MoveRight?0:(BarNum - 3)); 1285 PaintBars(CurrentBar, colorActBar);435 PaintBars(CurrentBar, true); 1286 436 EvtGetEvent(&event, CalculateTimeout(currentTick)); 1287 437 } 1288 438 else 1289 439 { 1290 PaintBars(CurrentBar, colorBar);440 PaintBars(CurrentBar, false); 1291 441 CurrentBar = ((BarNum - 3) * (ClickLength - (NextClick - currentTick))) / ClickLength; 1292 442 if (!MoveRight) … … 1294 444 CurrentBar = BarNum - (3 + CurrentBar); 1295 445 } 1296 PaintBars(CurrentBar, colorActBar);446 PaintBars(CurrentBar, true); 1297 447 EvtGetEvent(&event, CalculateTimeout(currentTick)); 1298 448 }/* … … 1331 481 } 1332 482 1333 1334 /***********************************************************************1335 *1336 * FUNCTION: PilotMain1337 *1338 * DESCRIPTION: This is the main entry point for the application.1339 *1340 * PARAMETERS: cmd - word value specifying the launch code.1341 * cmdPB - pointer to a structure that is associated with the launch code.1342 * launchFlags - word value providing extra information about the launch.1343 * RETURNED: Result of launch1344 *1345 * REVISION HISTORY:1346 *1347 *1348 ***********************************************************************/1349 483 UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) 1350 484 { -
trunk/src/metropro.h
r14 r18 1 /** 2 * main header file (function declarations, constants, definitions) 1 /******************************************************************************* 2 * 3 * File: metropro.h - constants and definitions 3 4 * 4 */ 5 6 #include "mtprtypes.h" 7 8 Boolean DisplayGadgetHandleEvent(FormGadgetTypeInCallback* pGadget, 9 UInt16 cmd, void* pParam); 10 Boolean VolumeGadgetHandleEvent(FormGadgetTypeInCallback* pGadget, 11 UInt16 cmd, void* pParam); 5 * Copyright (c) 2005, 2006 Nicolai Ehemann 6 * 7 * This file is part of MetroPro. 8 * 9 * MetroPro is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License Version 2 as 11 * published by the Free Software Foundation; you may not use other 12 * versions of the license. 13 * 14 * MetroPro is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with MetroPro; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 * 23 ******************************************************************************/ 12 24 13 25 /** … … 17 29 #define appVersionNum 0x00 18 30 #define appVersionMajor 0 19 #define appVersionMinor 331 #define appVersionMinor 4 20 32 #define appVersionPatch 0 21 #define appVersionDate " 25.10.2005"33 #define appVersionDate "14.06.2006" 22 34 #define appPrefPrefID 0x01 23 35 #define appPrefStateID 0x02 … … 46 58 #define CLICK_DURATION 30 47 59 60 // ui definition 61 #define BarNum 38 62 -
trunk/src/mtprtypes.h
r14 r18 1 /** 2 * MetroPro datatypes 1 /******************************************************************************* 2 * 3 * File: mtprtypes.h - special types 3 4 * 4 */ 5 * Copyright (c) 2005, 2006 Nicolai Ehemann 6 * 7 * This file is part of MetroPro. 8 * 9 * MetroPro is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License Version 2 as 11 * published by the Free Software Foundation; you may not use other 12 * versions of the license. 13 * 14 * MetroPro is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with MetroPro; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 * 23 ******************************************************************************/ 5 24 6 #ifndef MTPR_TYPES 7 #define MTPR_TYPES 1 25 #ifndef _METROPRO_MTPRTYPES_H_ 26 #define _METROPRO_MTPRTYPES_H_ 1 27 28 #include <PalmOS.h> 8 29 9 30 typedef enum … … 65 86 typedef struct 66 87 { 67 UInt16BaseHeight;68 UInt16MaxBarHeight;69 UInt16BarWidth;70 UInt16SpaceWidth;71 UInt16Step;88 double BaseHeight; 89 double MaxBarHeight; 90 double BarWidth; 91 double SpaceWidth; 92 double Step; 72 93 UInt16 BarNumHalf; 73 94 PointType MidPoint; … … 113 134 } AppPrefType; 114 135 115 #endif // MTPR_TYPES136 #endif // _METROPRO_MTPRTYPES_H_ -
trunk/src/resources.h
r11 r18 1 /** 2 * resources.h - id definitions for the resources in rsc/resource.xrd 1 /******************************************************************************* 3 2 * 4 */ 5 3 * File: resources.h - id definitions for the resources in rsc/resource.xrd 4 * 5 * Copyright (c) 2005, 2006 Nicolai Ehemann 6 * 7 * This file is part of MetroPro. 8 * 9 * MetroPro is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License Version 2 as 11 * published by the Free Software Foundation; you may not use other 12 * versions of the license. 13 * 14 * MetroPro is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with MetroPro; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 * 23 ******************************************************************************/ 24 6 25 /** Resource: Main Form */ 7 26 #define MainForm 1000 … … 46 65 /** Resource: Preferences Form */ 47 66 #define PreferencesForm 1400 67 #define PreferencesFormLabelMajorClickFrequency 1401 68 #define PreferencesFormFieldMajorClickFrequency 1402 69 #define PreferencesFormLabelMinorClickFrequency 1403 70 #define PreferencesFormFieldMinorClickFrequency 1404 71 #define PreferencesFormLabelMinimumBPS 1405 72 #define PreferencesFormFieldMinimumBPS 1406 73 #define PreferencesFormLabelMaximumBPS 1407 74 #define PreferencesFormFieldMaximumBPS 1408 75 #define PreferencesFormButtonOK 1420 76 #define PreferencesFormButtonReset 1421 77 #define PreferencesFormButtonBuildDefaults 1422 48 78 49 79 /** Resource: Beat Form */ … … 65 95 #define TapFormAlert 1000 66 96 #define BeatFormNumeratorAlert 1001 97 #define AlertInvalidNumericValue 1002 98 #define AlertPreferencesTempo 1003 67 99 #define DebugAlert 1100 68 100 … … 93 125 #define Smallicons12and8bitsAppIconFamily 1001 94 126 127 // Resource: Strings 128 #define StringHelp 2005 129 95 130 // Resource: LED Font 96 131 #define LEDFont 1000
Note: See TracChangeset
for help on using the changeset viewer.
