// ---------------------------- init ---------------------------------- void racing_init (void) { CControl *ctrl = Players.GetCtrl (g_game.player_id); if (param.view_mode < 0 || param.view_mode >= NUM_VIEW_MODES) { param.view_mode = ABOVE; } set_view_mode (ctrl, (TViewMode)param.view_mode); left_turn = right_turn = trick_modifier = false; ctrl->turn_fact = 0.0; ctrl->turn_animation = 0.0; ctrl->is_braking = false; ctrl->is_paddling = false; ctrl->jumping = false; ctrl->jump_charging = false; lastsound = -1; newsound = -1; if (g_game.prev_mode != PAUSED) ctrl->Init (); g_game.raceaborted = false; SetSoundVolumes (); Music.PlayTheme (g_game.theme_id, MUS_RACING); g_game.fps = 0; g_game.timesteps = 0; g_game.finish = false; }
// ---------------------------- init ---------------------------------- void CRacing::Enter (void) { CControl *ctrl = Players.GetCtrl (g_game.player_id); if (param.view_mode < 0 || param.view_mode >= NUM_VIEW_MODES) { param.view_mode = ABOVE; } set_view_mode (ctrl, (TViewMode)param.view_mode); left_turn = right_turn = trick_modifier = false; ctrl->turn_fact = 0.0; ctrl->turn_animation = 0.0; ctrl->is_braking = false; ctrl->is_paddling = false; ctrl->jumping = false; ctrl->jump_charging = false; lastsound = -1; newsound = -1; if (State::manager.PreviousState() != &Paused) ctrl->Init (); g_game.raceaborted = false; SetSoundVolumes (); Music.PlayTheme (g_game.theme_id, MUS_RACING); g_game.finish = false; }
//----------------------------------------------------------------------------- static CControl* findControlTag (CViewContainer* parent, int32_t tag, bool reverse = true) { CControl* result = 0; ViewIterator it (parent); while (*it) { CView* view = *it; CControl* control = dynamic_cast<CControl*> (view); if (control) { if (control->getTag () == tag) result = control; } else if (reverse) { CViewContainer* container = dynamic_cast<CViewContainer*> (view); if (container) result = findControlTag (container, tag); } if (result) break; ++it; } if (result == 0 && !reverse) return findControlTag (dynamic_cast<CViewContainer*> (parent->getParentView ()), reverse); return result; }
//----------------------------------------------------------------------------------------------- void CGUI::MousePress (const SMouseEvent& event) { CControl* Ptr = _FindControl(event); if (Ptr != 0) Ptr->MousePress(event.X, event.Y); else _ZeroFocus(); }
//----------------------------------------------------------------------------- void ControlValueAnimation::animationTick (CView* view, IdStringPtr name, float pos) { CControl* control = dynamic_cast<CControl*> (view); if (control) { float value = startValue + (endValue - startValue) * pos; control->setValue (value); } }
void CWindow::EachControlSizeChanged() { TRect aScreenRect = iMainEngine.ScreenRect(); for (TInt i = 0 ; i < iControlArray.Count() ; i++) { CControl* control = iControlArray[i]; control->SizeChanged(aScreenRect); } }
//----------------------------------------------------------------------------- void ControlValueAnimation::animationFinished (CView* view, IdStringPtr name, bool wasCanceled) { CControl* control = dynamic_cast<CControl*> (view); if (control) { if (!wasCanceled || forceEndValueOnFinish) control->setValue (endValue); } }
void CControl::SetLayerId( size_t layerid ) { m_uLayerID = layerid; for ( auto child : GetChildren() ) { CControl* pChild = ( CControl*) child; if ( pChild ) { pChild->SetLayerId( m_uLayerID + 1 ); } } }
void CNumberSelector::Enable(bool enable) { SallyAPI::GUI::CForm::Enable(enable); // Send Timer Event to all Childs std::list<CControl*>::iterator iter = m_GUIControlList.begin(); while (iter != m_GUIControlList.end()) { CControl* control = *iter; control->Enable(enable); ++iter; } }
// ダイアログプロシージャ(形式上) LRESULT CALLBACK CControl::DispatchSubProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { // ダイアログの 32 ビット整数に格納されている // this ポインタを取りだす CControl *pcControl = (CControl *)GetWindowLongPtr(hWnd, GWLP_USERDATA); if(pcControl == NULL) { // たぶんここが実行されることはない return NULL; } // メンバ関数のダイアログプロシージャを呼び出す return pcControl->SubProc(hWnd, uMsg, wParam, lParam); }
void MsgBoxDlgProc(LPWindow pWindow, LPGuiMsgInfo pGuiMsgInfo) { CControl* pControl; switch(pGuiMsgInfo->ID) { case WM_LOAD: pWindow->DrawFunc(pWindow); break; case WM_SHOW: pWindow->DrawFunc(pWindow); break; case WM_CLOSE: if(pWindow->pParentWindow != NULL) { //·µ»Ø¸¸´°¿Ú g_pCurWindow = pWindow->pParentWindow; PostWindowMsg(g_pCurWindow, WM_RETURN, 0, 0); } break; case WM_UPDATECTRL: pControl = (CControl*)(pGuiMsgInfo->wParam); if(pControl != NULL) { pControl->DrawFunc(pControl); } break; case WM_KEYDOWN: switch(pGuiMsgInfo->wParam) { case KEY_BACK: //·µ»Ø PostWindowMsg(pWindow, WM_CLOSE, 0, 0); break; case KEY_OK: //È·¶¨ PostWindowMsg(pWindow, WM_CLOSE, 0, 0); break; default: break; } break; default: break; } }
void CUIViewAgent::OutView() { m_pMainFrame->m_pToolBook->DeleteAllPages(); m_pMainFrame->m_Manager.GetPane(m_pMainFrame->m_pToolPanel).Hide(); m_pMainFrame->m_Manager.Update(); if(m_pMainFrame->m_pSelectedComponentProxy) { CControl *pWindow = dynamic_cast<CControl*>( m_pMainFrame->m_pSelectedComponentProxy->GetHostComponent()); if(pWindow) { pWindow->SetEditorSelect(false); } } }
TBool CWindow::HandleEachControlCommandL(TInt aCommand) { TBool cmdResult = EFalse; //自顶向底处理 for (TInt i = iControlArray.Count() - 1 ; i >= 0 ; i--) { CControl* control = iControlArray[i]; cmdResult = control->HandleCommandL(aCommand); if(cmdResult) { break; //事件已响应,结束处理 } } return cmdResult; }
//出牌 LRESULT CHostView::OnSendMessage(WPARAM wParam, LPARAM lParam) { switch(g_game->GetGameState()) { case PREPARE: case START: switch(g_game->GetWhoSendCard()) { case PLAYER_A: case PLAYER_C: g_kz.ComputerSendCard(g_game); break; } break; } m_clientRect.left=0; m_clientRect.top=0; m_clientRect.right=780; m_clientRect.bottom=620; InvalidateRect(&m_clientRect,false); return 0; }
void CControl::Uninitialize() { super::Uninitialize(); m_bUninitialize = true; CWindowManager::GetInstance()->LogoutControl( this ); // TODO: There is a worse solution, wait for the frame fix // bug describe // If delete the component , the child didn't render again for ( auto child : GetChildren() ) { CControl* control = down_cast<CControl*>(child); if ( control && control->GetRootFlag() ) { CWindowManager::GetInstance()->RemoveFromRoot( control ); } } }
void CControl::SetPercentSize( const CVec2& size ) { if ( m_vec2PercentSize != size ) { m_vec2PercentSize = size; CalcRealSize(); UpdateQuadP(); for ( auto childWnd : GetChildren() ) { if ( childWnd->GetType() == eNT_NodeGUI ) { CControl* child =( CControl*) childWnd; child->OnParentSizeChange( m_vec2Size.x , m_vec2Size.y ); } } } }
void racing_loop (double time_step){ CControl *ctrl = Players.GetCtrl (g_game.player_id); double ycoord = Course.FindYCoord (ctrl->cpos.x, ctrl->cpos.z); bool airborne = (bool) (ctrl->cpos.y > (ycoord + JUMP_MAX_START_HEIGHT)); check_gl_error(); ClearRenderContext (); Env.SetupFog (); Music.Update (); CalcTrickControls (ctrl, time_step, airborne); if (!g_game.finish) CalcSteeringControls (ctrl, time_step); else CalcFinishControls (ctrl, time_step, airborne); PlayTerrainSound (ctrl, airborne); // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ctrl->UpdatePlayerPos (time_step); // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if (g_game.finish) IncCameraDistance (time_step); update_view (ctrl, time_step); UpdateTrackmarks (ctrl); SetupViewFrustum (ctrl); if (sky) Env.DrawSkybox (ctrl->viewpos); if (fog) Env.DrawFog (); void SetupLight (); if (terr) RenderCourse (); DrawTrackmarks (); if (trees) DrawTrees (); if (param.perf_level > 2) { update_particles (time_step); draw_particles (ctrl); } Char.Draw (g_game.char_id); UpdateWind (time_step, ctrl); UpdateSnow (time_step, ctrl); DrawSnow (ctrl); DrawHud (ctrl); Reshape (param.x_resolution, param.y_resolution); Winsys.SwapBuffers (); if (g_game.finish == false) g_game.time += time_step; }
void CControl::SetClip( bool bClip , const CRect& rect ) { m_bIsClip = bClip; m_rectClip = rect; //Y axis is bottom-up in OpenGL CRenderTarget* pTarget= CRenderManager::GetInstance()->GetCurrentRenderTarget(); BEATS_ASSERT(pTarget != NULL); m_rectClip.position.y = pTarget->GetHeight() - m_rectClip.position.y - m_rectClip.size.y; float fScale = pTarget->GetScaleFactor(); m_rectClip.position *= fScale; m_rectClip.size *= fScale; for ( auto child : GetChildren() ) { CControl* pChild = (CControl*)child; pChild->SetClip( bClip, rect ); } }
TBool CWindow::HandleEachControlKeyL(TInt aKeyCode) { iMainEngine.WriteLog16(_L("CWindow::HandleEachControlKeyL")); TBool keyResult = EFalse; //自顶向底处理 for (TInt i = iControlArray.Count() - 1 ; i >= 0 ; i--) { CControl* control = iControlArray[i]; //UtilityTools::InfoPrint(control->GetControlType()); keyResult = control->KeyEventL(aKeyCode); if(keyResult) { break; //事件已响应,结束处理 } } // iMainEngine.WriteLog16(_L("CWindow::HandleEachControlKeyL End")); return keyResult; }
void CUIViewAgent::SelectComponent( CComponentProxy* pComponentInstance ) { if (m_pMainFrame->m_pSelectedComponentProxy) { CControl* pWindow = dynamic_cast<CControl*>(m_pMainFrame->m_pSelectedComponentProxy->GetHostComponent()); if (pWindow != NULL) { pWindow->SetEditorSelect(false); } } if (pComponentInstance != NULL) { CControl* pWindow = dynamic_cast<CControl*>(pComponentInstance->GetHostComponent()); if (pWindow != NULL) { pWindow->SetEditorSelect(true); } } }
LRESULT CXMLKeyFrameValuesDlg::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { CPaintDC dc(m_hWnd); HFONT hOldFont = dc.SelectFont((HFONT)GetStockObject(DEFAULT_GUI_FONT)); dc.SetBkMode(TRANSPARENT); CRect client; GetClientRect(&client); int y = 0; for (int i = 0; i < m_controls.GetSize(); i++) { CControl* pControl = m_controls[i]; if (pControl->m_bVisible) { // CXMLAttribute* pAttr = pControl->m_pAttr; CRect itemrect(0, y, client.right, y+pControl->m_height); CRect trect = itemrect; trect.right = 80; dc.DrawText(pControl->m_name, pControl->m_name.GetLength(), &trect, DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS); CRect vrect = itemrect; vrect.left = 82; pControl->Draw(dc.m_hDC, vrect); y += pControl->m_height; y += 1; // Spacing } } dc.SelectFont(hOldFont); return 0; }
//---------------------------------------------------------------------------------------------------- CView* UIColorChooserController::verifyView (CView* view, const UIAttributes& attributes, const IUIDescription* description) { CControl* control = dynamic_cast<CControl*>(view); if (control && control->getTag () >= 0) { controls.push_back (control); CTextEdit* textEdit = dynamic_cast<CTextEdit*> (control); if (textEdit) { #if VSTGUI_HAS_FUNCTIONAL textEdit->setValueToStringFunction (valueToString); textEdit->setStringToValueFunction (stringToValue); #else textEdit->setValueToStringProc (valueToString, textEdit); textEdit->setStringToValueProc (stringToValue, textEdit); #endif } updateColorSlider (control); } return view; }
void CControl::OnParentSizeChange( float width, float height ) { m_fTargetWidth = width; m_fTargetHeight = height; CVec2 position; CalcRealPosition( position ); SetPosition( position.x, position.y, 0.0f ); CalcRealSize(); UpdateQuadP(); for ( auto childWnd : GetChildren() ) { if( childWnd->GetType() == eNT_NodeGUI ) { CControl* child = down_cast<CControl*>(childWnd); child->OnParentSizeChange( m_vecRealSize.x, m_vecRealSize.y ); } } }
//---------------------------------------------------------------------------------------------------- CView* UIFocusSettingsController::verifyView (CView* view, const UIAttributes& attributes, const IUIDescription* description) { CControl* control = dynamic_cast<CControl*>(view); if (control) { switch (control->getTag ()) { case kEnabledTag: { bool value = false; settings->getBooleanAttribute ("enabled", value); control->setValue (value ? control->getMax () : control->getMin ()); controls[kEnabledTag] = control; break; } case kColorTag: { COptionMenu* menu = dynamic_cast<COptionMenu*>(control); if (menu) { controls[kColorTag] = control; const std::string* current = settings->getAttributeValue ("color"); std::list<const std::string*> names; editDescription->collectColorNames (names); names.sort (UIEditController::std__stringCompare); int32_t index = 0; for (std::list<const std::string*>::const_iterator it = names.begin (); it != names.end (); it++, index++) { menu->addEntry (new CMenuItem ((*it)->c_str ())); if (current && *current == *(*it)) { menu->setValue ((float)index); } } } break; } case kWidthTag: { controls[kWidthTag] = control; CTextEdit* edit = dynamic_cast<CTextEdit*>(control); if (edit) { #if VSTGUI_HAS_FUNCTIONAL edit->setStringToValueFunction (stringToValue); edit->setValueToStringFunction (valueToString); #else edit->setStringToValueProc (stringToValue); edit->setValueToStringProc (valueToString); #endif } double current = 1.; settings->getDoubleAttribute ("width", current); control->setValue ((float)current); break; } } } return view; }
void CHostView::OnRButtonDown(UINT nFlags, CPoint point) { if (g_game->GetGameState()==PREPARE||g_game->GetGameState()==START) { g_kz.RButtonDown(g_game); m_clientRect.left=0; m_clientRect.top=0; m_clientRect.right=780; m_clientRect.bottom=620; InvalidateRect(&m_clientRect,false); } CView::OnRButtonDown(nFlags, point); }
void CControl::SetParentNode( CNode* pParent ) { super::SetParentNode( pParent ); if( pParent ) { if ( GetRootFlag() ) { CWindowManager::GetInstance()->RemoveFromRoot( this ); } if ( pParent->GetType() == eNT_NodeGUI ) { CControl* pControl = (CControl*)pParent; SetLayerId( pControl->GetLayerID() + 1); CVec2 size = pControl->GetRealSize(); OnParentSizeChange( size.x, size.y ); } else { CWindowManager::GetInstance()->AttachToNode( this ); } } else { if ( !m_bUninitialize ) { SetLayerId( GUI_LAYER_ID); CRenderTarget* pMainRenderTarget = CRenderManager::GetInstance()->GetCurrentRenderTarget(); BEATS_ASSERT( pMainRenderTarget ); CWindowManager::GetInstance()->AddToRoot( this ); CWindowManager::GetInstance()->DetachToNode( this ); float fWidth = (float)pMainRenderTarget->GetWidth(); float fHeight = (float)pMainRenderTarget->GetHeight(); OnParentSizeChange( fWidth, fHeight ); } } }
void CHostView::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 if (g_game->GetGameState()==PREPARE||g_game->GetGameState()==START) { g_kz.LButtonUp(g_game,point); m_clientRect.left=0; m_clientRect.top=0; m_clientRect.right=780; m_clientRect.bottom=620; InvalidateRect(&m_clientRect,false); } CView::OnLButtonUp(nFlags, point); }
void CWindow::DrawButton(CGraphic& aGraphic)const { ASSERT(NULL != iControlPaneBmp); TSize screenSize = UtilityTools::ScreenSize(); //temp code TSize size = iControlPaneBmp->SizeInPixels(); TPoint point(0,0); point.iY += screenSize.iHeight; point.iY -= size.iHeight; aGraphic.BitBlt(point,iControlPaneBmp); aGraphic.SetPenColor(KTextColor); TRect controlPaneRect = iMainEngine.ScreenLayout().GetControlPaneRect(); TInt margin = iMainEngine.ScreenLayout().InnerMargin(); TPtrC leftButtonPtr; TPtrC rightButtonPtr; leftButtonPtr.Set(iLeftButtonText); rightButtonPtr.Set(iRightButtonText); if(iControlArray.Count() > 0) { for(TInt controlIndex = iControlArray.Count() - 1 ; controlIndex >= 0 ; controlIndex--) { CControl* lastControl = iControlArray[controlIndex]; if(lastControl->HasButton()) { leftButtonPtr.Set(lastControl->LeftButton()); rightButtonPtr.Set(lastControl->RightButton()); break; } } } aGraphic.DrawText(leftButtonPtr,controlPaneRect,CGraphicsContext::ELeft,margin); aGraphic.DrawText(rightButtonPtr,controlPaneRect,CGraphicsContext::ERight,margin); }
//---------------------------------------------------------------------------------------------------- CView* UIDialogController::verifyView (CView* view, const UIAttributes& attributes, IUIDescription* description) { CControl* control = dynamic_cast<CControl*>(view); if (control) { if (control->getTag () == kButton1Tag) { CTextButton* button = dynamic_cast<CTextButton*>(control); if (button) { button1 = button; button->setTitle (dialogButton1.c_str ()); layoutButtons (); } } else if (control->getTag () == kButton2Tag) { CTextButton* button = dynamic_cast<CTextButton*>(control); if (button) { button2 = button; if (dialogButton2.empty ()) { button->setVisible (false); } else { button->setTitle (dialogButton2.c_str ()); } layoutButtons (); } } else if (control->getTag () == kTitleTag) { CTextLabel* label = dynamic_cast<CTextLabel*>(control); if (label) { label->setText (dialogTitle.c_str ()); } } } const std::string* name = attributes.getAttributeValue ("custom-view-name"); if (name) { if (*name == "view") { IController* controller = dialogController.cast<IController> (); CView* subView = dialogDescription->createView (templateName.c_str (), controller); if (subView) { subView->setAttribute (kCViewControllerAttribute, sizeof (IController*), &controller); sizeDiff.x = subView->getWidth () - view->getWidth (); sizeDiff.y = subView->getHeight () - view->getHeight (); CRect size = view->getViewSize (); size.setWidth (subView->getWidth ()); size.setHeight (subView->getHeight ()); view->setViewSize (size); view->setMouseableArea (size); CViewContainer* container = dynamic_cast<CViewContainer*> (view); if (container) container->addView (subView); } } } return view; }
BOOL CControlsModule::MetaProc(PBMetaStruct *pbMetaStructure, PPBSTRUCT pPBStructure, void *pParam) { INSTANCE_DATA *pdata = (INSTANCE_DATA*) pParam; if (!pdata) { WRITELOG (L"pParam null"); return FALSE; } LPCWSTR pparameter = pbMetaStructure->lpParameter; LPCWSTR pvalue = pbMetaStructure->lpValue; CControlListEntry *plist_entry; // Get CControl which we're operating on from the array in the instance data // Instantiate as necessary CControl *pcontrol = NULL; switch (nControlType) { case CT_QUITBUTTON: if (!pdata->pQuitButton) pdata->pQuitButton = new CQuitButton (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); pcontrol = pdata->pQuitButton; break; case CT_RELOADBUTTON: if (!pdata->pReloadButton) pdata->pReloadButton = new CReloadButton (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); pcontrol = pdata->pReloadButton; break; case CT_ADDRESSBAR: if (!pdata->pAddressBar) { pdata->pAddressBar = new CAddressBar (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); // If there's a go button then pass the address bar to it if (pdata->pGoButton) pdata->pGoButton->SetAddressBar(pdata->pAddressBar); } pcontrol = pdata->pAddressBar; break; case CT_TOPCOMMANDAREA: if (!pdata->pTopCommandArea) { pdata->pTopCommandArea = new CTopCommandArea (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); BringControlsToFront (pdata); } pcontrol = pdata->pTopCommandArea; break; case CT_BOTTOMCOMMANDAREA: if (!pdata->pBottomCommandArea) { pdata->pBottomCommandArea = new CBottomCommandArea (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); BringControlsToFront (pdata); } pcontrol = pdata->pBottomCommandArea; break; case CT_BACKBUTTON: if (!pdata->pBackButton) pdata->pBackButton = new CBackButton (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); pcontrol = pdata->pBackButton; break; case CT_FORWARDBUTTON: if (!pdata->pForwardButton) pdata->pForwardButton = new CForwardButton (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); pcontrol = pdata->pForwardButton; break; case CT_GOBUTTON: if (!pdata->pGoButton) { pdata->pGoButton = new CGoButton (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); // If there's an address bar then pass a pointer to it if (pdata->pAddressBar) pdata->pGoButton->SetAddressBar (pdata->pAddressBar); // If there's a stop button make sure it's under the go button if (pdata->pStopButton) SetWindowPos (pdata->pStopButton->GetWindow (), pdata->pGoButton->GetWindow (), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } pcontrol = pdata->pGoButton; break; case CT_HOMEBUTTON: if (!pdata->pHomeButton) pdata->pHomeButton = new CHomeButton (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); pcontrol = pdata->pHomeButton; break; case CT_MINIMIZEBUTTON: if (!pdata->pMinimizeButton) pdata->pMinimizeButton = new CMinimizeButton (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); pcontrol = pdata->pMinimizeButton; break; case CT_PAGEZOOMINBUTTON: if (!pdata->pPageZoomInButton) pdata->pPageZoomInButton = new CPageZoomInButton (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); pcontrol = pdata->pPageZoomInButton; break; case CT_PAGEZOOMOUTBUTTON: if (!pdata->pPageZoomOutButton) pdata->pPageZoomOutButton = new CPageZoomOutButton (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); pcontrol = pdata->pPageZoomOutButton; break; case CT_SIPBUTTON: if (!pdata->pSIPButton) pdata->pSIPButton = new CSIPButton (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); pcontrol = pdata->pSIPButton; break; case CT_STOPBUTTON: if (!pdata->pStopButton) { pdata->pStopButton = new CStopButton (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); // If there's a go button make sure it's on top of the stop button if (pdata->pGoButton) SetWindowPos (pdata->pStopButton->GetWindow (), pdata->pGoButton->GetWindow (), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } pcontrol = pdata->pStopButton; break; case CT_ZOOMTEXTBUTTON: if (!pdata->pZoomTextButton) pdata->pZoomTextButton = new CZoomTextButton (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); pcontrol = pdata->pZoomTextButton; break; case CT_KEYSTATE: if (!pdata->pKeyState) pdata->pKeyState = new CKeyState (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); pcontrol = pdata->pKeyState; break; case CT_SCROLL: if (!pdata->pScroll) pdata->pScroll = new CScroll (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); pcontrol = pdata->pScroll; break; case CT_BATTERY: if (!pdata->pBattery) pdata->pBattery = new CBattery (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); pcontrol = pdata->pBattery; break; case CT_SIGNAL: if (!pdata->pSignal) { pdata->pSignal = new CSignal (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); // Check WLAN available if (!pdata->pSignal->OpenWLAN ()) { delete pdata->pSignal; pdata->pSignal = NULL; WRITELOG (L"WLAN support not available"); return TRUE; } } pcontrol = pdata->pSignal; break; case CT_CUSTOMBUTTON: // Record custom button ID if (cmp (pparameter, L"id")) WSAFECOPY (pdata->sControlID, pvalue); // Find button list entry for most recent ID plist_entry = pdata->pCustomButtonList->Find (pdata->sControlID); // Use existing control if found if (plist_entry) { pcontrol = plist_entry->pControl; } else { // Create new control if not found and add to list pcontrol = new CCustomButton (pPBStructure->hInstance, pPBStructure->hWnd, pdata->nID); pdata->pCustomButtonList->AddEntry (new CControlListEntry (pcontrol)); } break; } if (!pcontrol) { WRITELOG (L"Control type not available: %d", nControlType); return FALSE; } if (cmp (pparameter, L"visibility")) { if (cmp (pvalue, L"visible")) return pcontrol->Show (); else if (cmp (pvalue, L"hidden")) return pcontrol->Hide (); else { WRITELOG (L"Unknown visibility value: %s", pvalue); return FALSE; } } else if (cmp (pparameter, L"id")) { return pcontrol->SetID (pvalue); } //JMS 5/5/2010 //add check for null values on numeric parameters else if (cmp (pparameter, L"left")) { if(pvalue == NULL || pvalue[0] == NULL) return pcontrol->SetLeft (0); else { // JS can pass in integer values as floats -> check if a string is a float and then transform it to int. if (isFloat(pvalue)) return pcontrol->SetLeft (_wtoi (pvalue)); else { WRITELOG (L"Unknown left value: %s", pvalue); return FALSE; } } } else if (cmp (pparameter, L"right")) { if(pvalue == NULL || pvalue[0] == NULL) return pcontrol->SetRight (0); else { // JS can pass in integer values as floats -> check if a string is a float and then transform it to int. if (isFloat(pvalue)) return pcontrol->SetRight (_wtoi (pvalue)); else { WRITELOG (L"Unknown right value: %s", pvalue); return FALSE; } } } else if (cmp (pparameter, L"top")) { if(pvalue == NULL || pvalue[0] == NULL) return pcontrol->SetTop (0); else { // JS can pass in integer values as floats -> check if a string is a float and then transform it to int. if (isFloat(pvalue)) return pcontrol->SetTop (_wtoi (pvalue)); else { WRITELOG (L"Unknown top value: %s", pvalue); return FALSE; } } } else if (cmp (pparameter, L"width")) { if(pvalue == NULL || pvalue[0] == NULL) return pcontrol->SetWidth (0); else { // JS can pass in integer values as floats -> check if a string is a float and then transform it to int. if (isFloat(pvalue)) return pcontrol->SetWidth (_wtoi (pvalue)); else { WRITELOG (L"Unknown width value: %s", pvalue); return FALSE; } } } else if (cmp (pparameter, L"height")) { if(pvalue == NULL || pvalue[0] == NULL) return pcontrol->SetHeight (0); else { // JS can pass in integer values as floats -> check if a string is a float and then transform it to int. if (isFloat(pvalue)) return pcontrol->SetHeight (_wtoi (pvalue)); else { WRITELOG (L"Unknown height value: %s", pvalue); return FALSE; } } } else if (cmp (pparameter, L"image")) return pcontrol->SetImage (pvalue); else if (cmp (pparameter, L"imageup")) return pcontrol->SetImageUp (pvalue); else if (cmp (pparameter, L"imagedown")) return pcontrol->SetImageDown (pvalue); else if (cmp (pparameter, L"color") || cmp (pparameter, L"colour")) return pcontrol->SetColour (pvalue); else if (cmp (pparameter, L"click")) return pcontrol->SetClick (pvalue); else if (cmp (pparameter, L"border")) { if (cmp (pvalue, L"visible")) return pcontrol->SetBorder (TRUE); else if (cmp (pvalue, L"hidden")) return pcontrol->SetBorder (FALSE); else { WRITELOG (L"Unknown border value: %s", pvalue); return FALSE; } } else { // See if the control wants any non-standard parameter not handled above if (pcontrol->SetMiscValue (pparameter, pvalue)) return TRUE; WRITELOG (L"Unknown parameter: %s", pparameter); return FALSE; } return TRUE; }