mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
support osx 10.4
This commit is contained in:
parent
920c5eac2b
commit
c4dfa24ca4
@ -17,6 +17,11 @@
|
|||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|
||||||
#include <Carbon/Carbon.h>
|
#include <Carbon/Carbon.h>
|
||||||
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
|
|
||||||
|
#ifndef MAC_OS_X_VERSION_10_5
|
||||||
|
typedef float CGFloat;
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: P3DOsxSplashWindow::Constructor
|
// Function: P3DOsxSplashWindow::Constructor
|
||||||
@ -268,15 +273,19 @@ paint_window() {
|
|||||||
CGContextScaleCTM(context, 1.0, -1.0);
|
CGContextScaleCTM(context, 1.0, -1.0);
|
||||||
|
|
||||||
// Clear the whole region to white before beginning.
|
// Clear the whole region to white before beginning.
|
||||||
CGRect region = { { 0, 0 }, { _win_width, _win_height } };
|
static const CGFloat white_components[] = { 1, 1, 1, 1 };
|
||||||
|
CGColorSpaceRef rgb_space = CGColorSpaceCreateDeviceRGB();
|
||||||
|
CGColorRef white = CGColorCreate(rgb_space, white_components);
|
||||||
|
|
||||||
// Clear the entire progress bar to white.
|
CGRect region = { { 0, 0 }, { _win_width, _win_height } };
|
||||||
CGColorRef white = CGColorGetConstantColor(kCGColorWhite);
|
|
||||||
CGContextBeginPath(context);
|
CGContextBeginPath(context);
|
||||||
CGContextSetFillColorWithColor(context, white);
|
CGContextSetFillColorWithColor(context, white);
|
||||||
CGContextAddRect(context, region);
|
CGContextAddRect(context, region);
|
||||||
CGContextFillPath(context);
|
CGContextFillPath(context);
|
||||||
|
|
||||||
|
CGColorRelease(white);
|
||||||
|
CGColorSpaceRelease(rgb_space);
|
||||||
|
|
||||||
// Now paint in the image(s).
|
// Now paint in the image(s).
|
||||||
paint_image(context, _background_image);
|
paint_image(context, _background_image);
|
||||||
switch (_bstate) {
|
switch (_bstate) {
|
||||||
@ -303,6 +312,7 @@ paint_window() {
|
|||||||
paint_progress_bar(context);
|
paint_progress_bar(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGContextSynchronize(context);
|
||||||
CGContextRelease(context);
|
CGContextRelease(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,6 +444,16 @@ paint_image(CGContextRef context, const OsxImageData &image) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void P3DOsxSplashWindow::
|
void P3DOsxSplashWindow::
|
||||||
paint_progress_bar(CGContextRef context) {
|
paint_progress_bar(CGContextRef context) {
|
||||||
|
// Get some colors we'll need. We can't just use
|
||||||
|
// CGColorGetConstantColor(), since that requires 10.5.
|
||||||
|
static const CGFloat black_components[] = { 0, 0, 0, 1 };
|
||||||
|
static const CGFloat white_components[] = { 1, 1, 1, 1 };
|
||||||
|
static const CGFloat blue_components[] = { 0.424, 0.647, 0.878, 1 };
|
||||||
|
CGColorSpaceRef rgb_space = CGColorSpaceCreateDeviceRGB();
|
||||||
|
CGColorRef black = CGColorCreate(rgb_space, black_components);
|
||||||
|
CGColorRef white = CGColorCreate(rgb_space, white_components);
|
||||||
|
CGColorRef blue = CGColorCreate(rgb_space, blue_components);
|
||||||
|
|
||||||
int bar_x, bar_y, bar_width, bar_height;
|
int bar_x, bar_y, bar_width, bar_height;
|
||||||
get_bar_placement(bar_x, bar_y, bar_width, bar_height);
|
get_bar_placement(bar_x, bar_y, bar_width, bar_height);
|
||||||
|
|
||||||
@ -446,7 +466,6 @@ paint_progress_bar(CGContextRef context) {
|
|||||||
CGRect bar = { { bar_xf, bar_yf }, { bar_width, bar_height } };
|
CGRect bar = { { bar_xf, bar_yf }, { bar_width, bar_height } };
|
||||||
|
|
||||||
// Clear the entire progress bar to white.
|
// Clear the entire progress bar to white.
|
||||||
CGColorRef white = CGColorGetConstantColor(kCGColorWhite);
|
|
||||||
CGContextBeginPath(context);
|
CGContextBeginPath(context);
|
||||||
CGContextSetFillColorWithColor(context, white);
|
CGContextSetFillColorWithColor(context, white);
|
||||||
CGContextAddRect(context, bar);
|
CGContextAddRect(context, bar);
|
||||||
@ -456,16 +475,13 @@ paint_progress_bar(CGContextRef context) {
|
|||||||
int progress_width = (int)((bar_width - 2) * _install_progress);
|
int progress_width = (int)((bar_width - 2) * _install_progress);
|
||||||
if (progress_width != 0) {
|
if (progress_width != 0) {
|
||||||
CGRect prog = { { bar_xf, bar_yf }, { progress_width, bar_height } };
|
CGRect prog = { { bar_xf, bar_yf }, { progress_width, bar_height } };
|
||||||
CGColorRef blue = CGColorCreateGenericRGB(0.424, 0.647, 0.878, 1.0);
|
|
||||||
CGContextBeginPath(context);
|
CGContextBeginPath(context);
|
||||||
CGContextSetFillColorWithColor(context, blue);
|
CGContextSetFillColorWithColor(context, blue);
|
||||||
CGContextAddRect(context, prog);
|
CGContextAddRect(context, prog);
|
||||||
CGContextFillPath(context);
|
CGContextFillPath(context);
|
||||||
CGColorRelease(blue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the black stroke around the progress bar.
|
// Draw the black stroke around the progress bar.
|
||||||
CGColorRef black = CGColorGetConstantColor(kCGColorBlack);
|
|
||||||
CGContextBeginPath(context);
|
CGContextBeginPath(context);
|
||||||
CGContextSetLineWidth(context, 1);
|
CGContextSetLineWidth(context, 1);
|
||||||
CGContextSetStrokeColorWithColor(context, black);
|
CGContextSetStrokeColorWithColor(context, black);
|
||||||
@ -501,12 +517,16 @@ paint_progress_bar(CGContextRef context) {
|
|||||||
|
|
||||||
// And finally, draw the text.
|
// And finally, draw the text.
|
||||||
CGContextSetTextDrawingMode(context, kCGTextFill);
|
CGContextSetTextDrawingMode(context, kCGTextFill);
|
||||||
CGColorRef black = CGColorGetConstantColor(kCGColorBlack);
|
|
||||||
CGContextSetFillColorWithColor(context, black);
|
CGContextSetFillColorWithColor(context, black);
|
||||||
|
|
||||||
CGContextShowTextAtPoint(context, text_x, text_y + text_height,
|
CGContextShowTextAtPoint(context, text_x, text_y + text_height,
|
||||||
_install_label.data(), _install_label.length());
|
_install_label.data(), _install_label.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGColorRelease(blue);
|
||||||
|
CGColorRelease(white);
|
||||||
|
CGColorRelease(black);
|
||||||
|
CGColorSpaceRelease(rgb_space);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -532,7 +552,6 @@ event_callback(EventHandlerCallRef my_handler, EventRef event) {
|
|||||||
WindowRef window = NULL;
|
WindowRef window = NULL;
|
||||||
UInt32 the_class = GetEventClass(event);
|
UInt32 the_class = GetEventClass(event);
|
||||||
UInt32 kind = GetEventKind(event);
|
UInt32 kind = GetEventKind(event);
|
||||||
|
|
||||||
GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL,
|
GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL,
|
||||||
sizeof(WindowRef), NULL, (void*) &window);
|
sizeof(WindowRef), NULL, (void*) &window);
|
||||||
switch (the_class) {
|
switch (the_class) {
|
||||||
@ -564,7 +583,6 @@ event_callback(EventHandlerCallRef my_handler, EventRef event) {
|
|||||||
|
|
||||||
case kEventWindowDrawContent:
|
case kEventWindowDrawContent:
|
||||||
paint_window();
|
paint_window();
|
||||||
result = noErr;
|
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user