void SpliceAsteroids::Init() { Asteroids::Init(); auto topPostSpawn = TopPostSpawn(); PushPeriod([this] { if (active) { return spawnPeriodActive; } else { return spawnPeriodPassive; } }); // use some generated data from Super and modify for our task PushPostSpawn([this, topPostSpawn] (Asteroid & created) { // call old callback topPostSpawn(created); // change some settings created.SetPos(Rand(- GetFieldWidth() * 0.5f, 0.0f, 0.1f), Rand(GetFieldHeight() * 0.5f, GetFieldHeight() * 1.5f, 0.1f)); created.SetVel(GetFieldWidth() * 0.25, - GetFieldHeight() * 0.125); if (leftToRight) { created.IncPosX(GetFieldWidth() * 2.0f); created.DecVelX(- created.GetVelX()); } }); }
void AwtChoice::Reshape(int x, int y, int w, int h) { // Choice component height is fixed (when rolled up) // so vertically center the choice in it's bounding box JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); jobject target = GetTarget(env); jobject parent = env->GetObjectField(target, AwtComponent::parentID); RECT rc; int fieldHeight = GetFieldHeight(); if ((parent != NULL && env->GetObjectField(parent, AwtContainer::layoutMgrID) != NULL) && fieldHeight > 0 && fieldHeight < h) { y += (h - fieldHeight) / 2; } int totalHeight = GetTotalHeight(); AwtComponent::Reshape(x, y, w, totalHeight); /* Bug 4255631 Solaris: Size returned by Choice.getSize() does not match * actual size * Fix: Set the Choice to its actual size in the component. */ ::GetClientRect(GetHWnd(), &rc); env->SetIntField(target, AwtComponent::widthID, (jint)rc.right); env->SetIntField(target, AwtComponent::heightID, (jint)rc.bottom); env->DeleteLocalRef(target); env->DeleteLocalRef(parent); }
// gets the total height of the combobox, including drop down int AwtChoice::GetTotalHeight() { int dropHeight = GetDropDownHeight(); int fieldHeight = GetFieldHeight(); int totalHeight; // border on drop-down portion is always non-3d (so don't use SM_CYEDGE) int borderHeight = ::GetSystemMetrics(SM_CYBORDER); // total height = drop down height + field height + top+bottom drop down border lines totalHeight = dropHeight + fieldHeight +borderHeight*2; return totalHeight; }
void AwtChoice::Reshape( int x, int y, int w, int h ) { // Choice component height is fixed (when rolled up) // so vertically center the choice in it's bounding box int fieldHeight = GetFieldHeight(); if ( fieldHeight > 0 && fieldHeight < h ) { y += (h - fieldHeight) / 2; } AwtComponent::Reshape( x, y, w, GetTotalHeight() ); return; }
void AwtChoice::Reshape(int x, int y, int w, int h) { // Choice component height is fixed (when rolled up) // so vertically center the choice in it's bounding box JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); jobject target = GetTarget(env); jobject parent = env->GetObjectField(target, AwtComponent::parentID); RECT rc; int fieldHeight = GetFieldHeight(); if ((parent != NULL && env->GetObjectField(parent, AwtContainer::layoutMgrID) != NULL) && fieldHeight > 0 && fieldHeight < h) { y += (h - fieldHeight) / 2; } /* Fix for 4783342 * Choice should ignore reshape on height changes, * as height is dependent on Font size only. */ AwtComponent* awtParent = GetParent(); BOOL bReshape = true; if (awtParent != NULL) { ::GetWindowRect(GetHWnd(), &rc); int oldW = rc.right - rc.left; RECT parentRc; ::GetWindowRect(awtParent->GetHWnd(), &parentRc); int oldX = rc.left - parentRc.left; int oldY = rc.top - parentRc.top; bReshape = (x != oldX || y != oldY || w != oldW); } if (bReshape) { int totalHeight = GetTotalHeight(); AwtComponent::Reshape(x, y, w, totalHeight); } /* Bug 4255631 Solaris: Size returned by Choice.getSize() does not match * actual size * Fix: Set the Choice to its actual size in the component. */ ::GetClientRect(GetHWnd(), &rc); env->SetIntField(target, AwtComponent::widthID, (jint)rc.right); env->SetIntField(target, AwtComponent::heightID, (jint)rc.bottom); env->DeleteLocalRef(target); env->DeleteLocalRef(parent); }