Mercurial > dwindows
comparison mac/dw.c @ 443:e99cd6e45c0b
Need to have a application package directory for binaries to properly run
under MacOS. So added necessary files and a script to generate the
package directory on MacOS.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 30 May 2003 19:50:18 +0000 |
parents | b559c06a76c2 |
children | d9a5f98a1127 |
comparison
equal
deleted
inserted
replaced
442:7c8bd3bc6c27 | 443:e99cd6e45c0b |
---|---|
29 | 29 |
30 } SignalList; | 30 } SignalList; |
31 | 31 |
32 const Rect CreationRect = { 0, 0, 2000, 1000 }; | 32 const Rect CreationRect = { 0, 0, 2000, 1000 }; |
33 WindowRef CreationWindow = 0; | 33 WindowRef CreationWindow = 0; |
34 ControlRef RootControl = 0; | |
34 | 35 |
35 /* List of signals and their equivilent MacOS event */ | 36 /* List of signals and their equivilent MacOS event */ |
36 #define SIGNALMAX 15 | 37 #define SIGNALMAX 15 |
37 | 38 |
38 SignalList SignalTranslate[SIGNALMAX] = { | 39 SignalList SignalTranslate[SIGNALMAX] = { |
588 * newthread: True if this is the only thread. | 589 * newthread: True if this is the only thread. |
589 * False if there is already a message loop running. | 590 * False if there is already a message loop running. |
590 */ | 591 */ |
591 int API dw_init(int newthread, int argc, char *argv[]) | 592 int API dw_init(int newthread, int argc, char *argv[]) |
592 { | 593 { |
594 CreateNewWindow (kDocumentWindowClass, 0, | |
595 &CreationRect, &CreationWindow); | |
596 CreateRootControl(CreationWindow, &RootControl); | |
597 HideWindow(CreationWindow); | |
593 return 0; | 598 return 0; |
594 } | 599 } |
595 | 600 |
596 /* | 601 /* |
597 * Runs a message loop for Dynamic Windows. | 602 * Runs a message loop for Dynamic Windows. |
773 * Parameters: | 778 * Parameters: |
774 * handle: The window handle to make topmost. | 779 * handle: The window handle to make topmost. |
775 */ | 780 */ |
776 int API dw_window_raise(HWND handle) | 781 int API dw_window_raise(HWND handle) |
777 { | 782 { |
783 BringToFront((WindowRef)handle); | |
778 return 0; | 784 return 0; |
779 } | 785 } |
780 | 786 |
781 /* | 787 /* |
782 * Makes the window bottommost. | 788 * Makes the window bottommost. |
793 * Parameters: | 799 * Parameters: |
794 * handle: The window handle to make visible. | 800 * handle: The window handle to make visible. |
795 */ | 801 */ |
796 int API dw_window_show(HWND handle) | 802 int API dw_window_show(HWND handle) |
797 { | 803 { |
804 ShowWindow((WindowRef)handle); | |
798 return 0; | 805 return 0; |
799 } | 806 } |
800 | 807 |
801 /* | 808 /* |
802 * Minimizes or Iconifies a top-level window. | 809 * Minimizes or Iconifies a top-level window. |
813 * Parameters: | 820 * Parameters: |
814 * handle: The window handle to make visible. | 821 * handle: The window handle to make visible. |
815 */ | 822 */ |
816 int API dw_window_hide(HWND handle) | 823 int API dw_window_hide(HWND handle) |
817 { | 824 { |
825 HideWindow((WindowRef)handle); | |
818 return 0; | 826 return 0; |
819 } | 827 } |
820 | 828 |
821 /* | 829 /* |
822 * Destroys a window and all of it's children. | 830 * Destroys a window and all of it's children. |
823 * Parameters: | 831 * Parameters: |
824 * handle: The window handle to destroy. | 832 * handle: The window handle to destroy. |
825 */ | 833 */ |
826 int API dw_window_destroy(HWND handle) | 834 int API dw_window_destroy(HWND handle) |
827 { | 835 { |
836 DisposeWindow((WindowRef)handle); | |
828 return 0; | 837 return 0; |
829 } | 838 } |
830 | 839 |
831 /* Causes entire window to be invalidated and redrawn. | 840 /* Causes entire window to be invalidated and redrawn. |
832 * Parameters: | 841 * Parameters: |
924 * flStyle: Style flags, see the PM reference. | 933 * flStyle: Style flags, see the PM reference. |
925 */ | 934 */ |
926 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) | 935 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) |
927 { | 936 { |
928 WindowRef hwnd = 0; | 937 WindowRef hwnd = 0; |
938 ControlRef rootcontrol = 0; | |
939 | |
929 CreateNewWindow (kDocumentWindowClass, flStyle, | 940 CreateNewWindow (kDocumentWindowClass, flStyle, |
930 &CreationRect, &hwnd); | 941 &CreationRect, &hwnd); |
931 return (HWND)hwnd; | 942 CreateRootControl(hwnd, &rootcontrol); |
943 dw_window_set_text((HWND)hwnd, title); | |
944 return (HWND)hwnd; | |
932 } | 945 } |
933 | 946 |
934 /* | 947 /* |
935 * Create a new Box to be packed. | 948 * Create a new Box to be packed. |
936 * Parameters: | 949 * Parameters: |
1362 * text: The text associsated with a given window. | 1375 * text: The text associsated with a given window. |
1363 */ | 1376 */ |
1364 void API dw_window_set_text(HWND handle, char *text) | 1377 void API dw_window_set_text(HWND handle, char *text) |
1365 { | 1378 { |
1366 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); | 1379 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); |
1367 SetControlTitleWithCFString(handle, cftext); | 1380 if(IsValidWindowRef((WindowRef)handle)) |
1381 SetWindowTitleWithCFString((WindowRef)handle, cftext); | |
1382 else | |
1383 SetControlTitleWithCFString(handle, cftext); | |
1368 CFRelease(cftext); | 1384 CFRelease(cftext); |
1369 } | 1385 } |
1370 | 1386 |
1371 /* | 1387 /* |
1372 * Gets the text used for a given window. | 1388 * Gets the text used for a given window. |
1375 * Returns: | 1391 * Returns: |
1376 * text: The text associsated with a given window. | 1392 * text: The text associsated with a given window. |
1377 */ | 1393 */ |
1378 char * API dw_window_get_text(HWND handle) | 1394 char * API dw_window_get_text(HWND handle) |
1379 { | 1395 { |
1380 return NULL; | 1396 CFStringRef cftext; |
1397 char *ret = NULL; | |
1398 | |
1399 if(IsValidWindowRef((WindowRef)handle)) | |
1400 CopyWindowTitleAsCFString((WindowRef)handle, &cftext); | |
1401 else | |
1402 { | |
1403 Str255 str; | |
1404 | |
1405 GetControlTitle(handle, str); | |
1406 cftext = CFStringCreateWithPascalString(NULL, str, CFStringGetSystemEncoding()); | |
1407 } | |
1408 | |
1409 if(cftext) | |
1410 { | |
1411 int length = CFStringGetLength(cftext) + 1; | |
1412 char *ret = malloc(length); | |
1413 CFStringGetCString(cftext, ret, length, kCFStringEncodingDOSLatinUS); | |
1414 CFRelease(cftext); | |
1415 } | |
1416 return ret; | |
1381 } | 1417 } |
1382 | 1418 |
1383 /* | 1419 /* |
1384 * Disables given window (widget). | 1420 * Disables given window (widget). |
1385 * Parameters: | 1421 * Parameters: |
1439 * width: New width in pixels. | 1475 * width: New width in pixels. |
1440 * height: New height in pixels. | 1476 * height: New height in pixels. |
1441 */ | 1477 */ |
1442 void API dw_window_set_usize(HWND handle, ULONG width, ULONG height) | 1478 void API dw_window_set_usize(HWND handle, ULONG width, ULONG height) |
1443 { | 1479 { |
1480 SizeWindow((WindowRef)handle, (short)width, (short)height, TRUE); | |
1444 } | 1481 } |
1445 | 1482 |
1446 /* | 1483 /* |
1447 * Returns the width of the screen. | 1484 * Returns the width of the screen. |
1448 */ | 1485 */ |
1473 * x: X location from the bottom left. | 1510 * x: X location from the bottom left. |
1474 * y: Y location from the bottom left. | 1511 * y: Y location from the bottom left. |
1475 */ | 1512 */ |
1476 void API dw_window_set_pos(HWND handle, ULONG x, ULONG y) | 1513 void API dw_window_set_pos(HWND handle, ULONG x, ULONG y) |
1477 { | 1514 { |
1515 MoveWindow((WindowRef)handle, (short)x, (short)y, FALSE); | |
1478 } | 1516 } |
1479 | 1517 |
1480 /* | 1518 /* |
1481 * Sets the position and size of a given window (widget). | 1519 * Sets the position and size of a given window (widget). |
1482 * Parameters: | 1520 * Parameters: |
1486 * width: Width of the widget. | 1524 * width: Width of the widget. |
1487 * height: Height of the widget. | 1525 * height: Height of the widget. |
1488 */ | 1526 */ |
1489 void API dw_window_set_pos_size(HWND handle, ULONG x, ULONG y, ULONG width, ULONG height) | 1527 void API dw_window_set_pos_size(HWND handle, ULONG x, ULONG y, ULONG width, ULONG height) |
1490 { | 1528 { |
1529 dw_window_set_pos(handle, x, y); | |
1530 dw_window_set_usize(handle, width, height); | |
1491 } | 1531 } |
1492 | 1532 |
1493 /* | 1533 /* |
1494 * Gets the position and size of a given window (widget). | 1534 * Gets the position and size of a given window (widget). |
1495 * Parameters: | 1535 * Parameters: |