home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / p2demo21.exe / PEL / STATBAR.PEL < prev    next >
Text File  |  1995-02-22  |  16KB  |  558 lines

  1. # $Header:   P:\source\wmacros\statbar.pev   1.16   22 Feb 1995 14:04:10   PFHJXM0  $
  2. ## $Tabs:4 7$
  3.  
  4. ##############################################################################
  5. #
  6. #       Compuware Corporation
  7. #         31440 Northwestern Highway
  8. #           Farmington Hills, Michigan 48334-2564
  9. #
  10. #   This source code listing contains information that is
  11. #   proprietary to Compuware Corporation and may not be copied
  12. #   duplicated, translated, transmitted, stored, retrieved
  13. #   or in any manner or by any method conveyed or disclosed
  14. #   to a third party or parties without express written
  15. #   permission from Compuware Corporation.
  16. #
  17. #  
  18. ##############################################################################
  19.  
  20. #### $Workfile:   statbar.pel  $
  21.  
  22. #########################################################################
  23. ## Status Bar flags (STB) are different bits in a long:
  24. ##
  25. ## The top word is currently unused.
  26. ##
  27. ##  The next word is shown below.  Note that a Status bar flag of 0 
  28. ##  implies that no element of the status bar is visible.  Therefore it
  29. ##  is not drawn.  In all other cases it appears. 
  30. ##
  31. ## 0xN000         0x0N00                    0x00N0            0x000N
  32. ## |_8_|_4_|_2_|_1_| |_8_|_4_|_2_|_1_| |_8_|_4_|_2_|_1_| |_8_|_4_|_2_|_1_|
  33. ## |    unused     | |un1 pau  B   # | | *  ind|cur pos| |  clock items  |
  34. ##
  35. ##  The message flag (*) indicates whether popups or the status bar is used
  36. ##  for messages; the prompt flag (#) indicates whether popups or the status
  37. ##  bar is used for prompts and confirms.
  38. ##
  39.  
  40. global STB_TIME12       =  0x00001
  41. global STB_TIME24       =  0x00002
  42. global STB_DATE         =  0x00004
  43. global STB_DAYOFWEEK    =  0x00008    
  44. global STB_CLOCK        =  STB_TIME24 + STB_TIME12+STB_DATE+STB_DAYOFWEEK
  45. global STB_TIME         =  STB_TIME24 + STB_TIME12
  46.  
  47. global STB_LINE         =  0x00010
  48. global STB_COLUMN       =  0x00020
  49. global STB_LAST_LINE    =  0x00040   
  50. global STB_PAUSEONERR   =  0x00080
  51.  
  52. global STB_PROMPTS      =  0x00100   # prompts displays on status bar
  53. global STB_MESSAGES     =  0x00200   # messages display on status bar
  54. global STB_INDICATORS   =  0x00400
  55. global STB_BUSY         =  0x00800
  56.  
  57. global STB_MESSAGELEV0  =  0x01000
  58. global STB_MESSAGELEV1  =  0x02000
  59. global STB_EMULATION    =  0x04000
  60. global STB_DYNA_SIZE    =  0x08000
  61. global STB_OFFSET       =  0x10000
  62.  
  63. global STB_LINE_COLUMN  =  STB_LINE + STB_COLUMN
  64. global STB_POSITION     =  STB_LINE + STB_COLUMN + STB_LAST_LINE + STB_OFFSET
  65.  
  66. global STB_TOTAL_INDS   = STB_INDICATORS + STB_EMULATION
  67. global STB_LEVELS       = STB_MESSAGELEV0 + STB_MESSAGELEV1
  68.  
  69. # useful combinations
  70. global  STB_DEFAULT         = STB_TIME12 + STB_DAYOFWEEK + STB_DATE+ \
  71.                               STB_COLUMN + STB_LINE + STB_MESSAGES+ \
  72.                               STB_INDICATORS + STB_PAUSEONERR
  73.  
  74. global  STB_DEFAULT_PROMPTS = STB_DEFAULT + STB_PROMPTS
  75.  
  76. global STB_VISIBLE          = STB_CLOCK + STB_POSITION + \
  77.                               STB_MESSAGES+ STB_INDICATORS
  78.  
  79. local statusBarOn = STB_DEFAULT
  80. local prevStatusBarFlags
  81.  
  82. ### status bar functions
  83. #
  84.  
  85. function toggle_status_bar( enable, flags )
  86. {
  87. #   local menu = menu_info(0, 0x2000)
  88. #   local action
  89.    local count = argcount();
  90.  
  91.    enable += 0;
  92.  
  93.    if(count < 1 )
  94.       enable = !status_bar_flags
  95.  
  96.    if(enable)
  97.    {
  98.       if(count == 2)            #  flags specified, so set status_bar_flags
  99.       {
  100.          status_bar_flags = flags;
  101.          if(flags)              #  not 0, so save them for later
  102.             statusBarOn = flags
  103.       }
  104.       else if(status_bar_flags) #  already on, save them
  105.          statusBarOn = status_bar_flags;
  106.       else                      #  not on, change them to the flags last used
  107.          status_bar_flags = statusBarOn;
  108.    }
  109.    else                         #  turn them off
  110.       status_bar_flags = 0
  111.  
  112. #   action = !!status_bar_flags ? MI_CHECKED : MI_UNCHECKED
  113. #   if ( menu )
  114. #      modify_menuitem( menu, IDM_STATUSBAR, action)
  115. }
  116.  
  117. # Change the value of status_bar_flags, while saving a copy of the previous
  118. # settings so that they may later be restored.
  119. #
  120. global function save_status_bar_flags()
  121. {
  122.    prevStatusBarFlags = status_bar_flags
  123. }
  124.  
  125. global function set_status_bar_flags( newFlags )
  126. {
  127.    prevStatusBarFlags = status_bar_flags
  128.    status_bar_flags = newFlags
  129. }
  130.  
  131. # Enable the message bit in status_bar_flags, saving the previous value
  132. # so that it may later be restored.
  133. #
  134. global function enable_status_bar_messages()
  135. {
  136.    prevStatusBarFlags = status_bar_flags
  137.    status_bar_flags   = or(status_bar_flags, STB_MESSAGES)
  138. }
  139.  
  140. # Disable the message bit in status_bar_flags, saving the previous value
  141. # so that it may later be restored.
  142. #
  143. global function disable_status_bar_messages()
  144. {
  145.    prevStatusBarFlags = status_bar_flags
  146.    status_bar_flags   = and(status_bar_flags, not(STB_MESSAGES))
  147. }
  148.  
  149. # Enable the prompt bit in status_bar_flags, saving the previous value
  150. # so that it may later be restored.
  151. #
  152. global function enable_status_bar_prompts()
  153. {
  154.    prevStatusBarFlags = status_bar_flags
  155.    status_bar_flags   = or(status_bar_flags, STB_PROMPTS)
  156. }
  157.  
  158. # Disable the prompt bit in status_bar_flags, saving the previous value
  159. # so that it may later be restored.
  160. #
  161. global function disable_status_bar_prompts()
  162. {
  163.    prevStatusBarFlags = status_bar_flags
  164.    status_bar_flags   = and(status_bar_flags, not(STB_PROMPTS))
  165. }
  166.  
  167. # Restore status_bar_flags to a prior value.
  168. #
  169. global function restore_status_bar()
  170. {
  171.    status_bar_flags = prevStatusBarFlags
  172. }
  173.  
  174. function default_status_bar( prompt_on_bar )
  175. {
  176.    prevStatusBarFlags = status_bar_flags
  177.    if ( prompt_on_bar )
  178.       status_bar_flags = STB_DEFAULT_PROMPTS
  179.    else
  180.       status_bar_flags = STB_DEFAULT
  181. }
  182.  
  183. global function toggle_stb_flags(mask, value)
  184. {
  185.    local msg, suffix = "disabled.";
  186.  
  187.    #  If no value supplied, toggle the old value;
  188.    if(argcount() < 2)
  189.       value = xor(mask, and(status_bar_flags, mask));
  190.  
  191.    if ( value )
  192.    {
  193.       status_bar_flags = or( status_bar_flags, mask )
  194.       suffix = "enabled.";
  195.    }
  196.    else
  197.       status_bar_flags = and( status_bar_flags, not(mask) )
  198.  
  199.    if(mask == STB_COLUMN)
  200.       msg = "Columns on status bar " suffix;
  201.    else if(mask == STB_DATE)
  202.       msg = "Date on status bar " suffix;
  203.    else if(mask == STB_DAYOFWEEK)
  204.       msg = "Day of week on status bar " suffix;
  205.    else if(mask == STB_DYNA_SIZE)
  206.       msg = "Dynamic resizing of status bar " suffix;
  207.    else if(mask == STB_EMULATION)
  208.       msg = "Emulaton on status bar " suffix;
  209.    else if(mask == STB_INDICATORS)
  210.       msg = "Other indicators on status bar " suffix;
  211.    else if(mask == STB_LAST_LINE)
  212.       msg = "Last line on status bar " suffix;
  213.    else if(mask == STB_LINE)
  214.       msg = "Current line on status bar " suffix;
  215.    else if(mask == STB_MESSAGES)
  216.       msg = "Messages on status bar " suffix;
  217.    else if(mask == STB_PROMPTS)
  218.       msg = "Prompts on status bar " suffix;
  219.    else if(mask == STB_TIME12)
  220.       msg = "12 hour time on status bar " suffix;
  221.    else if(mask == STB_TIME24)
  222.       msg = "24 hour time on status bar " suffix;
  223.    else if(mask == STB_TIME)
  224.       msg = "Time on status bar " suffix;
  225.    else
  226.       msg = "Status bar feature " suffix;
  227.  
  228.    message(msg);
  229.  
  230.    return value;
  231. }
  232.  
  233. #
  234. # toggle the display of messages and notifys on the status bar
  235. #
  236. #function toggle_stb_message( on )                        #PUBLIC #INT
  237. #{
  238. #   if ( argcount() < 1 )
  239. #      on = !and( status_bar_flags, STB_MESSAGES )
  240. #   else
  241. #      on = 0+on
  242. #
  243. #   #
  244. #   # toggle the setting
  245. #   #
  246. #   if ( on )
  247. #      status_bar_flags = or( status_bar_flags, STB_MESSAGES )
  248. #   else
  249. #      status_bar_flags = and( status_bar_flags, not( STB_MESSAGES ))
  250. #
  251. #   message( "Status bar messages %s.", on ? "on" : "off" )
  252. #   return on
  253. #}
  254.  
  255. #
  256. # toggle the display of prompts and confirms on the status bar
  257. #
  258. #function toggle_stb_prompt( on )                        #PUBLIC #INT
  259. #{
  260. #   if ( argcount() < 1 )
  261. #      on = !and( status_bar_flags, STB_PROMPTS )
  262. #   else
  263. #      on = 0+on
  264. #
  265. #   #
  266. #   # toggle the setting
  267. #   #
  268. #   if ( on )
  269. #      status_bar_flags = or( status_bar_flags, STB_PROMPTS )
  270. #   else
  271. #      status_bar_flags = and( status_bar_flags, not( STB_PROMPTS ))
  272. #
  273. #   message( "Status bar prompts %s.", on ? "on" : "off" )
  274. #   return on
  275. #}
  276.  
  277. #
  278. # toggle the display of current line position on the status bar
  279. #
  280. #function toggle_stb_line( on )                        #PUBLIC #INT
  281. #{
  282. #   if ( argcount() < 1 )
  283. #      on = !and( status_bar_flags, STB_LINE )
  284. #   else
  285. #      on = 0+on
  286. #
  287. #   #
  288. #   # toggle the setting
  289. #   #
  290. #   if ( on )
  291. #      status_bar_flags = or( status_bar_flags, STB_LINE )
  292. #   else
  293. #      status_bar_flags = and( status_bar_flags, not( STB_LINE ))
  294. #
  295. #   message( "Status bar line display %s.", on ? "on" : "off" )
  296. #   return on
  297. #}
  298.  
  299. #
  300. # toggle the display of current column position on the status bar
  301. #
  302. #function toggle_stb_column( on )                        #PUBLIC #INT
  303. #{
  304. #   if ( argcount() < 1 )
  305. #      on = !and( status_bar_flags, STB_COLUMN )
  306. #   else
  307. #      on = 0+on
  308. #
  309. #   #
  310. #   # toggle the setting
  311. #   #
  312. #   if ( on )
  313. #      status_bar_flags = or( status_bar_flags, STB_COLUMN )
  314. #   else
  315. #      status_bar_flags = and( status_bar_flags, not( STB_COLUMN ))
  316. #
  317. #   message( "Status bar column display %s.", on ? "on" : "off" )
  318. #   return on
  319. #}
  320.  
  321. #
  322. # toggle the display of indicators on the status bar
  323. #
  324. #function toggle_stb_indicators( on )                        #PUBLIC #INT
  325. #{
  326. #   if ( argcount() < 1 )
  327. #      on = !and( status_bar_flags, STB_INDICATORS )
  328. #   else
  329. #      on = 0+on
  330. #
  331. #   #
  332. #   # toggle the setting
  333. #   #
  334. #   if ( on )
  335. #      status_bar_flags = or( status_bar_flags, STB_INDICATORS )
  336. #   else
  337. #      status_bar_flags = and( status_bar_flags, not( STB_INDICATORS ))
  338. #
  339. #   message( "Status bar indicators %s.", on ? "on" : "off" )
  340. #   return on
  341. #}
  342.  
  343. #
  344. # toggle the display of the day of the week on the status bar
  345. #
  346. #function toggle_stb_dow( on )                        #PUBLIC #INT
  347. #{
  348. #   if ( argcount() < 1 )
  349. #      on = !and( status_bar_flags, STB_DAYOFWEEK )
  350. #   else
  351. #      on = 0+on
  352. #
  353. #   #
  354. #   # toggle the setting
  355. #   #
  356. #   if ( on )
  357. #      status_bar_flags = or( status_bar_flags, STB_DAYOFWEEK )
  358. #   else
  359. #   {
  360. #      oldClock = and( status_bar_flags,  STB_CLOCK )
  361. #      status_bar_flags = and( status_bar_flags, not( STB_DAYOFWEEK ))
  362. #   }
  363. #   message( "Status bar day of week display %s.", on ? "on" : "off" )
  364. #   return on
  365. #}
  366.  
  367. #
  368. # toggle the display of date on the status bar
  369. #
  370. #function toggle_stb_date( on )                        #PUBLIC #INT
  371. #{
  372. #   if ( argcount() < 1 )
  373. #      on = !and( status_bar_flags, STB_DATE )
  374. #   else
  375. #      on = 0+on
  376. #
  377. #   #
  378. #   # toggle the setting
  379. #   #
  380. #   if ( on )
  381. #      status_bar_flags = or( status_bar_flags, STB_DATE )
  382. #   else {
  383. #      oldClock = and( status_bar_flags,  STB_CLOCK )
  384. #      status_bar_flags = and( status_bar_flags, not( STB_DATE ))
  385. #   }
  386. #   message( "Status bar date display %s.", on ? "on" : "off" )
  387. #   return on
  388. #}
  389.  
  390. #
  391. # toggle the display of 12 hour format time on the status bar
  392. #
  393. #function toggle_stb_time12( on )                        #PUBLIC #INT
  394. #{
  395. #   if ( argcount() < 1 )
  396. #      on = !and( status_bar_flags, STB_TIME12 )
  397. #   else
  398. #      on = 0+on
  399. #      
  400. #   # turn 24 hour time off
  401. #   #
  402. #   status_bar_flags = and( status_bar_flags, not( STB_TIME24 ))
  403. #
  404. #   #
  405. #   # toggle the setting
  406. #   #
  407. #   if ( on )
  408. #      status_bar_flags = or( status_bar_flags, STB_TIME12 )
  409. #   else {
  410. #      oldClock = and( status_bar_flags,  STB_CLOCK )
  411. #      status_bar_flags = and( status_bar_flags, not( STB_TIME12 ))
  412. #   }
  413. #   message( "Status bar 12 hour time display %s.", on ? "on" : "off" )
  414. #   return on
  415. #}
  416.  
  417.  
  418. #
  419. # toggle the display of 24 hour format time on the status bar
  420. #
  421. #function toggle_stb_time24( on )                        #PUBLIC #INT
  422. #{
  423. #   if ( argcount() < 1 )
  424. #      on = !and( status_bar_flags, STB_TIME24 )
  425. #   else
  426. #      on = 0+on
  427. #      
  428. #   # turn 12 hour time off
  429. #   #
  430. #   status_bar_flags = and( status_bar_flags, not( STB_TIME12 ))
  431. #
  432. #   #
  433. #   # toggle the setting
  434. #   #
  435. #   if ( on )
  436. #      status_bar_flags = or( status_bar_flags, STB_TIME24 )
  437. #   else {
  438. #      oldClock = and( status_bar_flags,  STB_CLOCK )
  439. #      status_bar_flags = and( status_bar_flags, not( STB_TIME24 ))
  440. #   }
  441. #   
  442. #   message( "Status bar 24 hour time display %s.", on ? "on" : "off" )
  443. #   return on
  444. #}
  445.  
  446. #  local oldClock = and( status_bar_flags,  STB_CLOCK )
  447. #
  448. # toggle the display of date, day and time on the status bar
  449. #
  450. #function toggle_stb_clock( on )                        #PUBLIC #INT
  451. #{
  452. #   if ( argcount() < 1 )
  453. #      on = !and( status_bar_flags, STB_CLOCK )
  454. #   else
  455. #      on = 0+on
  456. #      
  457. #   #
  458. #   # toggle the setting
  459. #   #
  460. #   if ( on )
  461. #      status_bar_flags = or( status_bar_flags, oldClock )
  462. #   else {
  463. #      oldClock = and( status_bar_flags,  STB_CLOCK )
  464. #      status_bar_flags = and( status_bar_flags, not( STB_CLOCK ))
  465. #   }
  466. #
  467. #   message( "Status bar clock display %s.", on ? "on" : "off" )
  468. #   return on
  469. #}
  470.  
  471. #
  472. # toggle the display of the emulation mode on the status bar
  473. #
  474. #function toggle_stb_emulation( on )                        #PUBLIC #INT
  475. #{
  476. #   if ( argcount() < 1 )
  477. #      on = !and( status_bar_flags, STB_EMULATION )
  478. #   else
  479. #      on = 0+on
  480. #
  481. #   #
  482. #   # toggle the setting
  483. #   #
  484. #   if ( on )
  485. #      status_bar_flags = or( status_bar_flags, STB_EMULATION )
  486. #   else 
  487. #      status_bar_flags = and( status_bar_flags, not( STB_EMULATION ))
  488. #
  489. #   message( "Status bar emulation mode display %s.", on ? "on" : "off" )
  490. #   return on
  491. #}
  492.  
  493. #
  494. # toggle the display of the last line on the status bar
  495. #
  496. #function toggle_stb_lastline( on )                        #PUBLIC #INT
  497. #{
  498. #   if ( argcount() < 1 )
  499. #      on = !and( status_bar_flags, STB_LAST_LINE)
  500. #   else
  501. #      on = 0+on
  502. #
  503. #   #
  504. #   # toggle the setting
  505. #   #
  506. #   if ( on )
  507. #      status_bar_flags = or( status_bar_flags, STB_LAST_LINE)
  508. #   else 
  509. #      status_bar_flags = and( status_bar_flags, not( STB_LAST_LINE))
  510. #
  511. #   message( "Status bar last line display %s.", on ? "on" : "off" )
  512. #   return on
  513. #}
  514.  
  515. #
  516. # toggle the display of the dynamic sizing on the status bar
  517. #
  518. #function toggle_stb_dynasize( on )                        #PUBLIC #INT
  519. #{
  520. #   if ( argcount() < 1 )
  521. #      on = !and( status_bar_flags, STB_DYNA_SIZE )
  522. #   else
  523. #      on = 0+on
  524. #
  525. #   #
  526. #   # toggle the setting
  527. #   #
  528. #   if ( on )
  529. #      status_bar_flags = or( status_bar_flags, STB_DYNA_SIZE )
  530. #   else 
  531. #      status_bar_flags = and( status_bar_flags, not( STB_DYNA_SIZE ))
  532. #
  533. #   message( "Status bar dynamic sizing display %s.", on ? "on" : "off" )
  534. #   return on
  535. #}
  536.  
  537. #
  538. # toggle the display of the dynamic sizing on the status bar
  539. #
  540. #function toggle_stb_offset( on )                        #PUBLIC #INT
  541. #{
  542. #   if ( argcount() < 1 )
  543. #      on = !and( status_bar_flags, STB_OFFSET )
  544. #   else
  545. #      on = 0+on
  546. #
  547. #   #
  548. #   # toggle the setting
  549. #   #
  550. #   if ( on )
  551. #      status_bar_flags = or( status_bar_flags, STB_OFFSET )
  552. #   else 
  553. #      status_bar_flags = and( status_bar_flags, not( STB_OFFSET ))
  554. #
  555. #   message( "Status bar offset display %s.", on ? "on" : "off" )
  556. #   return on
  557. #}
  558.