/***************************************************************************** * Function - CalculateSpecialStringWidths * DESCRIPTION: * ****************************************************************************/ void StringWidthCalculator::CalculateSpecialStringWidths() { mpDisplayCtrl->GetCurrentDisplay()->SetDisplayNumber(""); Label* pLabel = new Label(); pLabel->SetSize(239+1, 15); pLabel->SetStringId( SID_STEP_BY_STEP_INSTALLATION_GUIDE ); pLabel->CalculateStringWidths(true); pLabel->SetSize(78, 15); pLabel->SetStringId( SID_WORK_PERIOD ); pLabel->CalculateStringWidths(true); pLabel->SetStringId( SID_OFF_PERIOD ); pLabel->CalculateStringWidths(true); pLabel->SetStringId( SID_SLEEP_PERIOD ); pLabel->CalculateStringWidths(true); pLabel->SetVisible(false); delete pLabel; CancelOrContinuePopUp* pConfirm = new CancelOrContinuePopUp(); pConfirm->SetQuestionStringId( SID_PASSWORD_TEXT ); pConfirm->CalculateStringWidths(true); pConfirm->SetQuestionStringId( SID_YOU_ARE_ABOUT_TO_CHANGE_PUMP_OPERATION_MODE_ ); pConfirm->CalculateStringWidths(true); pConfirm->SetVisible(false); delete pConfirm; }
/***************************************************************************** * Function - CalculateUnitStringWidths * DESCRIPTION: * ****************************************************************************/ void StringWidthCalculator::CalculateUnitStringWidths() { mpDisplayCtrl->GetCurrentDisplay()->SetDisplayNumber(""); Label* pLabel = new Label(); // use the same size as mLabelErrorUnit in AlarmListItem pLabel->SetSize(225-19+1, 15); pLabel->SetChildPos(240, 0); pLabel->SetVisible(); for(int i = 0; i < DISPLAY_UNIT_STRINGS_CNT; ++i) { pLabel->SetStringId( DISPLAY_UNIT_STRINGS[i].StringId ); //ignore duplicates if (!pLabel->IsValid()) pLabel->CalculateStringWidths(true); } pLabel->SetStringId( SID_UNIT_UNKNOWN ); pLabel->CalculateStringWidths(true); pLabel->SetVisible(false); delete pLabel; }
void MapPanel::AddTitle(const char* name) { char tmp[16]; Q_snprintf(tmp, sizeof(tmp), "separator%i", separCount); Empty *div = new Empty(this, tmp); int w, t; GetSize(w, t); div->SetSize(w / 2, SEPAR_AND_TITLE_HEIGHT); Q_snprintf(tmp, sizeof(tmp), "title%i", titleCount); Label *lab = new Label(this, tmp, name); lab->SetSize(w / 2, SEPAR_AND_TITLE_HEIGHT); AddItem(div, lab); separCount++; titleCount++; }
void TabStrip::AddTab(string name) { Label* label = new Label(); label->SetSize(tabSize); label->SetLayoutMargin(Box(0, 0, 10, 10)); label->SetGravity(GRAVITY_VCENTER | GRAVITY_HCENTER); label->SetText(name); label->SetParentView(this); label->SetRelativePosition(0, 0); label->SetTextSize(18); if (IsInitialized()) { label->Initialize(context); label->CalculateLayout(Size(-1, -1)); } tabs.push_back(label); }
/***************************************************************************** * Function - CalculateAlarmStringWidths * DESCRIPTION: * ****************************************************************************/ void StringWidthCalculator::CalculateAlarmStringWidths() { Label* pLabel = new Label(); // use the same size as mLabelErrorString in AlarmListItem pLabel->SetSize(225-5+1, 15); mpDisplayCtrl->GetCurrentDisplay()->SetDisplayNumber(""); for(int i = 0; i < DISPLAY_ALARM_STRINGS_CNT; ++i) { pLabel->SetStringId( DISPLAY_ALARM_STRINGS[i].StringId ); pLabel->CalculateStringWidths(true); } pLabel->SetStringId( SID_ALARM_UNKNOWN ); pLabel->CalculateStringWidths(true); pLabel->SetVisible(false); delete pLabel; }
//----------------------------------------------------------------------------- // Purpose: sets up the current control to edit //----------------------------------------------------------------------------- void BuildModeDialog::SetActiveControl(Panel *controlToEdit) { if (m_pCurrentPanel == controlToEdit) { // it's already set, so just update the property data and quit if (m_pCurrentPanel) { UpdateControlData(m_pCurrentPanel); } return; } // reset the data m_pCurrentPanel = controlToEdit; RemoveAllControls(); m_pPanelList->m_pControls->MoveScrollBarToTop(); if (!m_pCurrentPanel) { m_pStatusLabel->SetText("[nothing currently selected]"); m_pStatusLabel->SetTextColorState(Label::CS_DULL); RemoveAllControls(); return; } // get the control description string const char *controlDesc = m_pCurrentPanel->GetDescription(); // parse out the control description int tabPosition = 1; while (1) { const char *dataType = ParseTokenFromString(&controlDesc); // finish when we have no more tokens if (*dataType == 0) break; // default the data type to a string int datat = TYPE_STRING; if (!stricmp(dataType, "int")) { datat = TYPE_STRING; //!! just for now } else if (!stricmp(dataType, "alignment")) { datat = TYPE_ALIGNMENT; } else if (!stricmp(dataType, "autoresize")) { datat = TYPE_AUTORESIZE; } else if (!stricmp(dataType, "corner")) { datat = TYPE_CORNER; } else if (!stricmp(dataType, "localize")) { datat = TYPE_LOCALIZEDSTRING; } // get the field name const char *fieldName = ParseTokenFromString(&controlDesc); int itemHeight = 18; // build a control & label Label *label = new Label(this, NULL, fieldName); label->SetSize(96, itemHeight); label->SetContentAlignment(Label::a_east); TextEntry *edit = NULL; ComboBox *editCombo = NULL; Button *editButton = NULL; if (datat == TYPE_ALIGNMENT) { // drop-down combo box editCombo = new ComboBox(this, NULL, 9, false); editCombo->AddItem("north-west", NULL); editCombo->AddItem("north", NULL); editCombo->AddItem("north-east", NULL); editCombo->AddItem("west", NULL); editCombo->AddItem("center", NULL); editCombo->AddItem("east", NULL); editCombo->AddItem("south-west", NULL); editCombo->AddItem("south", NULL); editCombo->AddItem("south-east", NULL); edit = editCombo; } else if (datat == TYPE_AUTORESIZE) { // drop-down combo box editCombo = new ComboBox(this, NULL, 4, false); editCombo->AddItem( "0 - no auto-resize", NULL); editCombo->AddItem( "1 - resize right", NULL); editCombo->AddItem( "2 - resize down", NULL); editCombo->AddItem( "3 - down & right", NULL); edit = editCombo; } else if (datat == TYPE_CORNER) { // drop-down combo box editCombo = new ComboBox(this, NULL, 4, false); editCombo->AddItem("0 - top-left", NULL); editCombo->AddItem("1 - top-right", NULL); editCombo->AddItem("2 - bottom-left", NULL); editCombo->AddItem("3 - bottom-right", NULL); edit = editCombo; } else if (datat == TYPE_LOCALIZEDSTRING) { editButton = new Button(this, NULL, "..."); editButton->SetParent(this); editButton->AddActionSignalTarget(this); editButton->SetTabPosition(tabPosition++); editButton->SetTall( itemHeight ); label->SetAssociatedControl(editButton); } else { // normal string edit edit = new CSmallTextEntry(this, NULL); } if (edit) { edit->SetTall( itemHeight ); edit->SetParent(this); edit->AddActionSignalTarget(this); edit->SetTabPosition(tabPosition++); label->SetAssociatedControl(edit); } HFont smallFont = scheme()->GetIScheme( GetScheme() )->GetFont( "DefaultVerySmall" ); if ( label ) { label->SetFont( smallFont ); } if ( edit ) { edit->SetFont( smallFont ); } if ( editCombo ) { editCombo->SetFont( smallFont ); } if ( editButton ) { editButton->SetFont( smallFont ); } // add to our control list m_pPanelList->AddItem(label, edit, editCombo, editButton, fieldName, datat); if ( edit ) { m_pPanelList->m_pControls->AddItem(label, edit); } else { m_pPanelList->m_pControls->AddItem(label, editButton); } } // check and see if the current panel is a Label // iterate through the class hierarchy if ( controlToEdit->IsBuildModeDeletable() ) { m_pDeleteButton->SetEnabled(true); } else { m_pDeleteButton->SetEnabled(false); } // update the property data in the dialog UpdateControlData(m_pCurrentPanel); // set our title if ( m_pBuildGroup->GetResourceName() ) { m_pFileSelectionCombo->SetText(m_pBuildGroup->GetResourceName()); } else { m_pFileSelectionCombo->SetText("[ no resource file associated with dialog ]"); } m_pApplyButton->SetEnabled(false); InvalidateLayout(); Repaint(); }
/***************************************************************************** * Function - ExportStringWidths * DESCRIPTION: * ****************************************************************************/ void StringWidthCalculator::ExportStringWidthsAdv(StringWidthParameters* parameters) { if (parameters->includeHeader) {//create new file mpStringLengthFile = fopen(parameters->filename, "wb"); } else {//append to file mpStringLengthFile = fopen(parameters->filename, "ab"); } if (mpStringLengthFile == NULL) { TCHAR sz_msg[512]; _stprintf(sz_msg, TEXT("Unable to open file: %s"), parameters->filename); ::MessageBox(NULL,sz_msg,TEXT("Unable to open file."),MB_OK|MB_ICONHAND); return; } strncpy(mpFirstColumnContents, parameters->firstcolumn, MAX_PATH); if (parameters->includeHeader) { Languages* p_lang = Languages::GetInstance(); LANGUAGE_TYPE orig_lang = p_lang->GetLanguage(); p_lang->SetLanguage(DEV_LANGUAGE); // write a simple header DataPointTime* pdt = new DataPointTime(); fprintf(mpStringLengthFile, "\"%s\";\"%s\"\r\n", p_lang->GetLanguageName( orig_lang ), pdt->GetText() ); p_lang->SetLanguage(orig_lang); delete pdt; if (parameters->onlyRelationsInCurrentDisplay) { sHelpStringIdExported.clear(); // write column names fprintf(mpStringLengthFile, "\"%s\";\"%s\";\"%s\";\"%s\";\"%s\"\r\n", "DisplayFilename","DisplayId","Display","StringId","Visible"); } else { // write column names fprintf(mpStringLengthFile, "\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\"\r\n", "DisplayId","Display", "StringId","Visible","String Width","String Height", "ComponentId","Component Width","Component Height", "Max. no of lines", "Wrapped","Fits"); } } sStringIdCompWidth.clear(); if (parameters->onlyRelationsInCurrentDisplay) { // special export for first display if (parameters->includeHeader) { mpDisplayCtrl->GetMenuBar()->CalculateStringWidths(false); } // special export of unreferenced helptexts if (strcmp(mpFirstColumnContents, UNREFERENCED_HELPTEXT) == 0) { for (int i = 0; i < LANG_GEN_HELP_STRING_COUNT; ++i) { int id = Languages::GetInstance()->GetHelpStingId(i); std::map<U16, bool>::iterator itr = sHelpStringIdExported.find(id); if (itr == sHelpStringIdExported.end()) { fprintf(mpStringLengthFile, "\"%s\";\"%d\";\"[%s]\";\"%d\";\"%d\"\r\n", mpFirstColumnContents, 0, "", id, 2); } } } else // normal export { // don't set g_is_calculating_strings, only visible listview rows should be exported PopupBox* popup = mpDisplayCtrl->GetCurrentPopupBox(); if (popup != NULL) { popup->CalculateStringWidths(false); } else { Display* disp = mpDisplayCtrl->GetCurrentDisplay(); g_is_calculating_strings = true; disp->GetRoot()->Invalidate(); disp->GetRoot()->Run(); g_is_calculating_strings = false; disp->CalculateStringWidths(false); //special export for display 2.1 Pump Control. (on/off/auto switch) if (disp->GetId() == 37) { CancelOrContinuePopUp* pConfirm = new CancelOrContinuePopUp(); pConfirm->SetQuestionStringId( SID_YOU_ARE_ABOUT_TO_CHANGE_PUMP_OPERATION_MODE_ ); pConfirm->SetVisible(false); pConfirm->CalculateStringWidths(false); delete pConfirm; } //special export for display 4.5 Alarm settings if (disp->GetId() == 58) { Label* pLabel = new Label(disp->GetRoot()); pLabel->SetSize(230, 15); pLabel->SetStringId(SID_PUMP_ALARMS_GROUP_1); pLabel->CalculateStringWidths(false); pLabel->SetStringId(SID_PUMP_ALARMS_GROUP_2); pLabel->CalculateStringWidths(false); delete pLabel; } //special export for display 4.5.2 Pump Alarms if (disp->GetId() == 60) { Label* pLabel = new Label(disp->GetRoot()); pLabel->SetSize(230, 15); pLabel->SetStringId(SID_PUMP_ALARM_GENIBUS_COM_ERROR_IO111); pLabel->CalculateStringWidths(false); delete pLabel; } //special export for 4.3.4.8 work/off/sleep schedule if (disp->GetId() == 76) { Label* pLabel = new Label(disp->GetRoot()); pLabel->SetSize(78, 15); pLabel->SetVisible(); pLabel->SetStringId( SID_WORK_PERIOD ); pLabel->CalculateStringWidths(false); pLabel->SetStringId( SID_OFF_PERIOD ); pLabel->CalculateStringWidths(false); pLabel->SetStringId( SID_SLEEP_PERIOD ); pLabel->CalculateStringWidths(false); pLabel->SetVisible(false); delete pLabel; } } } } else // calculate widths of all strings { g_is_calculating_strings = true; // calculate menu bars strings mpDisplayCtrl->GetMenuBar()->CalculateStringWidths(true); // calculate strings of all displays int i = 0; while (i++ < MAX_DISPLAY_ID) { Display* p_disp = GetDisplay(i); if(p_disp && p_disp->GetAbleToShow()) { mpDisplayCtrl->Push(p_disp); p_disp->CalculateStringWidths(true); p_disp->Hide(); } } // calculate all alarm strings CalculateAlarmStringWidths(); // calculate all help texts CalculateHelpStringWidths(); // calculate all unit texts CalculateUnitStringWidths(); // calculate all remaining strings CalculateSpecialStringWidths(); i = 0; std::map<U16, U16>::iterator itr; // ensure all string id's are exported while (i++ <= LANG_GEN_STRING_COUNT) { itr = sStringIdCompWidth.find(i); if (itr == sStringIdCompWidth.end()) { fprintf(mpStringLengthFile, "\"%d\";\"%s\";\"%d\";\"%d\";\"%s\";\"%s\";\"%d\";\"%d\";\"%d\";\"%d\";\"%d\";\"%d\"\r\n", 0,"",i, 0,"","", 0,0,0, 0,0,0); } } g_is_calculating_strings = false; mpDisplayCtrl->ResetToHome(); } fclose(mpStringLengthFile); }
//----------------------------------------------------------------------------- // Sets up the shader param editbox //----------------------------------------------------------------------------- void CMaterialEditorPanel::PopulateShaderParameters() { Assert( m_nShaderIndex >= 0 ); m_pEditorPanel->RemoveAll(); int nCount = g_pMaterialSystem->GetNumShaderParams(m_nShaderIndex); for (int i = 0; i < nCount; ++i) { const char *pParamName = g_pMaterialSystem->GetShaderParamName(m_nShaderIndex, i); char tempBuf[512]; Q_strncpy( tempBuf, pParamName, 512 ); Q_strnlwr( tempBuf, 512 ); // build a control & label (strip off '$' prefix) Label *pLabel = new Label( this, NULL, tempBuf + 1 ); pLabel->SetSize(128, 24); // Set up the tooltip for this puppy... pLabel->SetTooltipText( g_pMaterialSystem->GetShaderParamHelp(m_nShaderIndex, i) ); // Get at the material var bool bFound; IMaterialVar *pMaterialVar = m_pMaterial->FindVar( pParamName, &bFound ); Assert( bFound ); Panel *pEditPanel; switch( g_pMaterialSystem->GetShaderParamType(m_nShaderIndex, i) ) { case SHADER_PARAM_TYPE_TEXTURE: pEditPanel = new Label( this, NULL, "texture" ); break; case SHADER_PARAM_TYPE_INTEGER: { TextEntry *pTextEntry = new TextEntry(this, "Shader Param Integer"); Q_snprintf( tempBuf, 512, "%d", pMaterialVar->GetIntValue() ); pTextEntry->SetText( tempBuf ); pTextEntry->SetEditable( true ); pEditPanel = pTextEntry; } break; case SHADER_PARAM_TYPE_COLOR: pEditPanel = new Label( this, NULL, "color" ); break; case SHADER_PARAM_TYPE_VEC2: pEditPanel = new Label( this, NULL, "vec2" ); break; case SHADER_PARAM_TYPE_VEC3: pEditPanel = new Label( this, NULL, "vec3" ); break; case SHADER_PARAM_TYPE_FLOAT: { TextEntry *pTextEntry = new TextEntry(this, "Shader Param Float"); Q_snprintf( tempBuf, 512, "%f", pMaterialVar->GetIntValue() ); pTextEntry->SetText( tempBuf ); pTextEntry->SetEditable( true ); pEditPanel = pTextEntry; } break; default: pEditPanel = new Label( this, NULL, "other" ); break; } pEditPanel->SetSize(128, 24); // pEditPanel->SetContentAlignment( Label::a_east ); m_pEditorPanel->AddItem( pLabel, pEditPanel ); } }