Exemplo n.º 1
0
void
FlightStatusPanel::Refresh()
{
  const NMEAInfo &basic = CommonInterface::Basic();
  const DerivedInfo &calculated = CommonInterface::Calculated();

  if (basic.location_available)
    SetText(Location, FormatGeoPoint(basic.location));
  else
    ClearText(Location);

  if (basic.gps_altitude_available)
    SetText(Altitude, FormatUserAltitude(basic.gps_altitude));
  else
    ClearText(Altitude);

  SetText(MaxHeightGain, FormatUserAltitude(calculated.max_height_gain));

  if (nearest_waypoint) {
    GeoVector vec(basic.location,
                  nearest_waypoint->location);

    SetText(Near, nearest_waypoint->name.c_str());

    SetText(Bearing, FormatBearing(vec.bearing).c_str());

    SetText(Distance, FormatUserDistanceSmart(vec.distance));
  } else {
    SetText(Near, _T("-"));
    SetText(Bearing, _T("-"));
    SetText(Distance, _T("-"));
  }
}
Exemplo n.º 2
0
static void clearPageText(void)
{
	ClearText(0x2610);
	ClearText(0x2630);
	ClearText(0x2640);
	
	DspNum(0x2603, 0, 2);
	DspNum(0x2604, 0, 2);
	DspNum(0x2605, 0, 2);
	
	//显示当前校准值
	DspNum(0x2609, S_AdjustLedPageBuffer->systemSetData.testLedLightIntensity, 2);
}
void ScreenRecoveryUI::ShowFile(FILE* fp) {
    std::vector<long> offsets;
    offsets.push_back(ftell(fp));
    ClearText();

    struct stat sb;
    fstat(fileno(fp), &sb);

    bool show_prompt = false;
    while (true) {
        if (show_prompt) {
            PrintOnScreenOnly("--(%d%% of %d bytes)--",
                  static_cast<int>(100 * (double(ftell(fp)) / double(sb.st_size))),
                  static_cast<int>(sb.st_size));
            Redraw();
            while (show_prompt) {
                show_prompt = false;
                int key = WaitKey();
                if (key == KEY_POWER || key == KEY_ENTER) {
                    return;
                } else if (key == KEY_UP || key == KEY_VOLUMEUP) {
                    if (offsets.size() <= 1) {
                        show_prompt = true;
                    } else {
                        offsets.pop_back();
                        fseek(fp, offsets.back(), SEEK_SET);
                    }
                } else {
                    if (feof(fp)) {
                        return;
                    }
                    offsets.push_back(ftell(fp));
                }
            }
            ClearText();
        }

        int ch = getc(fp);
        if (ch == EOF) {
            while (text_row_ < text_rows_ - 1) PutChar('\n');
            show_prompt = true;
        } else {
            PutChar(ch);
            if (text_col_ == 0 && text_row_ >= text_rows_ - 1) {
                show_prompt = true;
            }
        }
    }
}
Exemplo n.º 4
0
static void
RemoveSource( JSDContext* jsdc, JSDSourceText* jsdsrc )
{
    PR_REMOVE_LINK(&jsdsrc->links);
    ClearText( jsdc, jsdsrc );
    DestroySource( jsdc, jsdsrc );
}
Exemplo n.º 5
0
void dlgTextEntryKeyboardShowModal(TCHAR *text, int width, const TCHAR* szFile, const TCHAR* szResource)
{

  first = true;
  wf = NULL;
  if (width==0) {
    width = MAX_TEXTENTRY;
  }
  max_width = min(MAX_TEXTENTRY, width);
  char filename[MAX_PATH];
    LocalPathS(filename, szFile);
    wf = dlgLoadFromXML(CallBackTable,
			filename,
			hWndMainWindow,
			szResource);
  if (!wf) return;

  cursor = 0;
  ClearText();

  if (_tcslen(text)>0) {
    _tcsupr(text);
    LK_tcsncpy(edittext, text, max_width-1);
    // show previous test.
    // this text is replaced by first key down
    // but used if "OK" is clicked first for don't reset current value.
  }

  UpdateTextboxProp();
  wf->SetKeyDownNotify(FormKeyDown);
  wf->ShowModal();
  LK_tcsncpy(text, edittext, max_width-1);
  delete wf;
  wf=NULL;
}
Exemplo n.º 6
0
void CPrefabTrackerDlg::FillEditText()
{
	CWaitCursor WaitCursor;
	ClearText();

	//now we need to fill in the text into the window
	CString sFinalText;

	bool bShowReferences = IsShowReferences();

	for(uint32 nCurrPrefab = 0; nCurrPrefab < m_Prefabs.GetSize(); nCurrPrefab++)
	{
		CString sText;
		sText.Format("%s: %d\r\n", m_Prefabs[nCurrPrefab].m_sFilename, m_Prefabs[nCurrPrefab].m_nTotalRefCount);
		sFinalText += sText;

		if(bShowReferences)
		{
			for(uint32 nCurrRef = 0; nCurrRef < m_Prefabs[nCurrPrefab].m_References.GetSize(); nCurrRef++)
			{
				sText.Format("%s: %d\r\n", m_Prefabs[nCurrPrefab].m_References[nCurrRef].m_sFile, m_Prefabs[nCurrPrefab].m_References[nCurrRef].m_nRefCount);
				sFinalText += sText;
			}

			sFinalText += "\r\n";
		}
	}	
	AddString(sFinalText);
}
Exemplo n.º 7
0
void dlgTextEntryKeyboardShowModal(TCHAR *text, int width, unsigned ResID)
{
  wf = NULL;
  if (width==0) {
    width = MAX_TEXTENTRY;
  }
  max_width = min(MAX_TEXTENTRY, width);
  wf = dlgLoadFromXML(CallBackTable, ResID);
  if (!wf) return;

 // cursor = _tcslen(text);
  ClearText();

  if (_tcslen(text)>0) {
    CharUpper(text);
    LK_tcsncpy(edittext, text, max_width-1);
    // show previous test.
    // this text is replaced by first key down
    // but used if "OK" is clicked first for don't reset current value.
  }
  cursor = _tcslen(edittext);
  UpdateTextboxProp();

  WindowControl* pBtHelp = wf->FindByName(TEXT("cmdHelp"));
  if(pBtHelp) {
     pBtHelp->SetVisible(wKeyboardPopupWndProperty && wKeyboardPopupWndProperty->HasHelpText());
  }

  wf->SetKeyDownNotify(FormKeyDown);
  wf->ShowModal();
  LK_tcsncpy(text, edittext, max_width-1);
 // cursor = _tcslen(text);
  delete wf;
  wf=NULL;
}
Exemplo n.º 8
0
static void OnClear(WindowControl * Sender)
{
  #ifndef DISABLEAUDIO
  if (EnableSoundModes) PlayResource(TEXT("IDR_WAV_CLICK"));
  #endif
  ClearText();
}
Exemplo n.º 9
0
void dlgTextEntryKeyboardShowModal(TCHAR *text, int width, const TCHAR* szFile, const TCHAR* szResource)
{
	first = true;
  wf = NULL;
  if (width==0) {
    width = MAX_TEXTENTRY;
  }
  max_width = min(MAX_TEXTENTRY, width);
  char filename[MAX_PATH];
    LocalPathS(filename, szFile);
    wf = dlgLoadFromXML(CallBackTable, 
			filename, 
			hWndMainWindow,			  
			szResource);
  if (!wf) return;

  cursor = 0;
  ClearText();

  if (_tcslen(text)>0) {
    _tcsupr(text);
    LK_tcsncpy(edittext, text, max_width-1);
    // position cursor at the end of imported text
    cursor=_tcslen(text); 
  }

  UpdateTextboxProp();
  wf->SetKeyDownNotify(FormKeyDown);
  wf->ShowModal();
  LK_tcsncpy(text, edittext, max_width-1);
  delete wf;
  wf=NULL;
}
Exemplo n.º 10
0
void  CUICustomEdit::Init( u32 max_char_count, bool number_only_mode, bool read_mode, bool fn_mode )
{
	if ( read_mode )
	{
		m_editor_control->init( max_char_count, text_editor::im_read_only );
		m_editor_control->set_selected_mode( true );
		m_read_mode = true;
	}
	else
	{
		if ( number_only_mode )
		{
			m_editor_control->init( max_char_count, text_editor::im_number_only );
		}
		else if ( fn_mode )
		{
			m_editor_control->init( max_char_count, text_editor::im_file_name_mode );
		}
		else
		{
			m_editor_control->init( max_char_count );
		}
		m_editor_control->set_selected_mode( false );
		m_read_mode = false;
	}
	
	Register_callbacks();
	ClearText();

	m_bInputFocus = false;
}
Exemplo n.º 11
0
static void
MoveSourceToRemovedList( JSDContext* jsdc, JSDSourceText* jsdsrc )
{
    ClearText(jsdc, jsdsrc);
    PR_REMOVE_LINK(&jsdsrc->links);
    PR_INSERT_LINK(&jsdsrc->links, &jsd_removed_source_list);
}
Exemplo n.º 12
0
wxShapeRegion::wxShapeRegion(wxShapeRegion &region)
{
	m_regionText = region.m_regionText;
	m_regionName = region.m_regionName;
	m_textColour = region.m_textColour;

	m_font = region.m_font;
	m_minHeight = region.m_minHeight;
	m_minWidth = region.m_minWidth;
	m_width = region.m_width;
	m_height = region.m_height;
	m_x = region.m_x;
	m_y = region.m_y;

	m_regionProportionX = region.m_regionProportionX;
	m_regionProportionY = region.m_regionProportionY;
	m_formatMode = region.m_formatMode;
	m_actualColourObject = region.GetActualColourObject();
	m_actualPenObject = NULL;
	m_penStyle = region.m_penStyle;
	m_penColour = region.m_penColour;

	ClearText();
	wxNode *node = region.m_formattedText.GetFirst();
	while (node)
	{
		wxShapeTextLine *line = (wxShapeTextLine *)node->GetData();
		wxShapeTextLine *new_line =
		    new wxShapeTextLine(line->GetX(), line->GetY(), line->GetText());
		m_formattedText.Append(new_line);
		node = node->GetNext();
	}
}
Exemplo n.º 13
0
void
jsd_ClearSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc)
{
    if( JSD_SOURCE_INITED  != jsdsrc->status &&
        JSD_SOURCE_PARTIAL != jsdsrc->status )
    {
        ClearText(jsdc, jsdsrc);
    }
}
void ReadThread::run()
{
    // new connect class
    // clear info struct
    // fill reader name
    // connect function
    // success
    //    emit empty string signal to GUI
    //    read
    //    emit string signal to GUI
    //    delete class
    // fail
    //    delete class
    //    return

    if (NULL == serial)
        return;

    Connecter *card = new Connecter;
    //card->ReaderName = Reader;
    //card->SetHSC(hSC);
    if(card->TestConnect() == SCARD_S_SUCCESS) {
        // send Clear info text signal;
        // blablabla
        emit ShowStatus(QString::fromLocal8Bit
                        ("已检测到银行卡,正在读取!请不要移开银行卡..."),
                        STATUS_LEVEL_WARNING);
        QTime time;
        time.start();
        card->StartReadInfo();
        qDebug()<<"Reader Time: " << time.elapsed()/1000.0 << "s";

        emit ClearText();
        // send Clear info text signal;
        // blablabla
        time.start();
        PrintAllInfo(card);
        qDebug()<<"Printer Time: " << time.elapsed()/1000.0 << "s";
        emit ShowStatus(QString::fromLocal8Bit
                        ("读取完毕!若需读取新银行卡信息可直接更换银行卡,若需重复读取本次银行卡保持银行卡不动即可!"),
                        STATUS_LEVEL_NORMAL);
        Sleep(2000);
    }


    // send all info into info text signal;
    // blablabla
    delete card;
    return;
}
Exemplo n.º 15
0
static void OnKey(WndButton* pWnd) {
    LKASSERT(pWnd);
    if(!pWnd) return;

    if (first) {
        ClearText();
        first = false;
    }
    PlayResource(TEXT("IDR_WAV_CLICK"));
    const TCHAR *Caption = pWnd->GetWndText();
    if (cursor < max_width - 1) {
        edittext[cursor++] = toupper(Caption[0]);
    }
    UpdateTextboxProp();
}
Exemplo n.º 16
0
void dlgNumberEntryKeyboardShowModal(int *value, int width) 
{
  wf = NULL;
  wGrid = NULL;
  if (width==0) {
    width = MAX_TEXTENTRY;
  }
  max_width = min(MAX_TEXTENTRY, width);
  char filename[MAX_PATH];
  if (InfoBoxLayout::landscape) 
    {
      LocalPathS(filename, TEXT("frmNumberEntry_Keyboard_L.xml"));
      wf = dlgLoadFromXML(CallBackTable, 
			  filename, 
			  hWndMainWindow,			  
			  TEXT("IDR_XML_NUMBERENTRY_KEYBOARD_L"));
      if (!wf) return;
    }
  else
    {
      LocalPathS(filename, TEXT("frmNumberEntry_Keyboard.xml"));
      wf = dlgLoadFromXML(CallBackTable, 
			  filename, 
			  hWndMainWindow,			  
			  TEXT("IDR_XML_NUMBERENTRY_KEYBOARD"));
      if (!wf) return;
    }
  wGrid = (WndOwnerDrawFrame*)wf->FindByName(TEXT("frmGrid"));
  cursor = 0;
  ClearText();
  TCHAR text[20];
  _stprintf(text, TEXT("%ld"), *value);
  if (_tcslen(text)>0) {
    _tcsupr(text);
    _tcsncpy(edittext, text, max_width-1);
    edittext[max_width-1]= 0;
  }
  UpdateTextboxProp();
  wf->SetKeyDownNotify(FormKeyDown);
  wf->ShowModal();
  _tcsncpy(text, edittext, max_width);
  text[max_width-1]=0;
  *value = _wtoi(text);
  delete wf;
  wf=NULL; //@ 101027 just to be sure
}
Exemplo n.º 17
0
scContUnit* scContUnit::Split( long& offset )
{
	scContUnit* p2;

	p2 = CopyText( offset, GetContentSize() );

	ClearText( offset, GetContentSize() );
	if ( offset == 0 )
		SetFirstline( NULL );
	
	PostInsert( p2 );

	Mark( scREBREAK );
	p2->Mark( scREBREAK );
	offset = 0;
	return p2;
}
Exemplo n.º 18
0
static void OnKey(WindowControl * Sender)
{
if(first)
{
    ClearText();
    first = false;
}
  TCHAR *Caption = Sender->GetCaption();
  #ifndef DISABLEAUDIO
  if (EnableSoundModes) PlayResource(TEXT("IDR_WAV_CLICK"));
  #endif
  if (cursor < max_width-1)
    {
      edittext[cursor++] = Caption[0];
    }
  UpdateTextboxProp();
}
Exemplo n.º 19
0
static JSBool
AppendText( JSDContext* jsdc, JSDSourceText* jsdsrc, 
            const char* text, size_t length )
{
#define MEMBUF_GROW 1000

    PRUintn neededSize = jsdsrc->textLength + length;

    if( neededSize > jsdsrc->textSpace )
    {
        MY_XP_HUGE_CHAR_PTR pBuf;
        PRUintn iNewSize;

        /* if this is the first alloc, the req might be all that's needed*/
        if( ! jsdsrc->textSpace )
             iNewSize = length;
        else
             iNewSize = (neededSize * 5 / 4) + MEMBUF_GROW;

        pBuf = (MY_XP_HUGE_CHAR_PTR) MY_XP_HUGE_ALLOC(iNewSize);
        if( pBuf )
        {
            if( jsdsrc->text )
            {
                MY_XP_HUGE_MEMCPY(pBuf, jsdsrc->text, jsdsrc->textLength);
                MY_XP_HUGE_FREE(jsdsrc->text);
            }
            jsdsrc->text = pBuf;
            jsdsrc->textSpace = iNewSize;
        }
        else 
        {
            /* LTNOTE: throw an out of memory exception */
            ClearText( jsdc, jsdsrc );
            jsdsrc->status = JSD_SOURCE_FAILED;
            return JS_FALSE;
        }
    }

    MY_XP_HUGE_MEMCPY( &jsdsrc->text[jsdsrc->textLength], text, length );
    jsdsrc->textLength += length;
    return JS_TRUE;
}
void ScreenRecoveryUI::ShowFile(const char* filename) {
    FILE* fp = fopen_path(filename, "re");
    if (fp == nullptr) {
        Print("  Unable to open %s: %s\n", filename, strerror(errno));
        return;
    }

    char** old_text = text_;
    size_t old_text_col = text_col_;
    size_t old_text_row = text_row_;
    size_t old_text_top = text_top_;

    // Swap in the alternate screen and clear it.
    text_ = file_viewer_text_;
    ClearText();

    ShowFile(fp);
    fclose(fp);

    text_ = old_text;
    text_col_ = old_text_col;
    text_row_ = old_text_row;
    text_top_ = old_text_top;
}
Exemplo n.º 21
0
/* ----------------------------------------------------------------------
   TtaSetAttributeText

   Changes the value of an attribute of type text.
   Parameters:
   attribute: the attribute to be modified.
   buffer: character string representing the new value of the attribute.
   element: the element with which the attribute is associated,
   NULL if the attribute is not yet associated with an element.
   document: the document to which the element belongs.
   Must be 0 if element is NULL.
   ---------------------------------------------------------------------- */
void TtaSetAttributeText (Attribute attribute, const char* buffer,
                          Element element, Document document)
{
  int                 lg;
  PtrAttribute        pAttr;
#ifndef NODISPLAY
  PtrAttribute        pPrevAttr, pA;
#endif /* NODISPLAY */
  Language	      lang;

  UserErrorCode = 0;
  pAttr = (PtrAttribute) attribute;
  if (pAttr == NULL)
    TtaError (ERR_invalid_parameter);
  else if (pAttr->AeAttrType != AtTextAttr)
    TtaError (ERR_invalid_attribute_type);
  else if (AttrOfElement (attribute, element))
    {
#ifndef NODISPLAY
      if (element != NULL)
        {
          /* detach temporarily attribute from element */
          pPrevAttr = NULL;
          pA = ((PtrElement) element)->ElFirstAttr;
          while (pA && pA != pAttr)
            {
              pPrevAttr = pA;
              pA = pA->AeNext;
            }
          if (pA)
            {
              if (pPrevAttr)
                pPrevAttr->AeNext = pA->AeNext;
              else
                ((PtrElement) element)->ElFirstAttr = pA->AeNext;
            }
          /* de-apply all presentation rules related to the attribute */
          UndisplayInheritedAttributes ((PtrElement) element, pAttr, document,
                                        TRUE);
          /* reattach attribute to element */
          if (pA)
            {
              if (pPrevAttr)
                pPrevAttr->AeNext = pAttr;
              else
                ((PtrElement) element)->ElFirstAttr = pAttr;
            }
        }
#endif
      if (pAttr->AeAttrText == NULL)
        GetTextBuffer (&pAttr->AeAttrText);
      else
        ClearText (pAttr->AeAttrText);
      /* Sets the new value */
      CopyStringToBuffer ((unsigned char *)buffer, pAttr->AeAttrText, &lg);
      if (pAttr->AeAttrNum == 1)
        /* language attribute */
        {
          lang = TtaGetLanguageIdFromName (buffer);
#ifdef NODISPLAY
          ChangeLanguageLeaves((PtrElement) element, lang);
#else
          ChangeLanguage (LoadedDocument[document - 1],
                          (PtrElement) element, lang, FALSE);
#endif
        }
#ifndef NODISPLAY
      if (element != NULL)
        DisplayAttribute ((PtrElement) element, pAttr, document);
#endif
    }
}
Exemplo n.º 22
0
void
TaskStatusPanel::Refresh()
{
  if (protected_task_manager == nullptr)
    return;

  const DerivedInfo &calculated = CommonInterface::Calculated();
  const TaskStats &task_stats = calculated.ordered_task_stats;

  SetRowVisible(TaskTime, task_stats.has_targets);
  if (task_stats.has_targets)
    SetText(TaskTime,
            FormatSignedTimeHHMM((int)protected_task_manager->GetOrderedTaskSettings().aat_min_time));

  SetText(ETETime,
          FormatSignedTimeHHMM((int)task_stats.GetEstimatedTotalTime()));

  SetText(RemainingTime,
          FormatSignedTimeHHMM((int)task_stats.total.time_remaining_now));

  if (task_stats.total.planned.IsDefined())
    SetText(TaskDistance,
            FormatUserDistanceSmart(task_stats.total.planned.GetDistance()));
  else
    ClearText(TaskDistance);

  if (task_stats.total.remaining.IsDefined())
    SetText(RemainingDistance,
            FormatUserDistanceSmart(task_stats.total.remaining.GetDistance()));

  if (task_stats.total.planned.IsDefined())
    SetText(EstimatedSpeed,
            FormatUserTaskSpeed(task_stats.total.planned.GetSpeed()));
  else
    ClearText(EstimatedSpeed);

  if (task_stats.total.travelled.IsDefined())
    SetText(AverageSpeed,
            FormatUserTaskSpeed(task_stats.total.travelled.GetSpeed()));
  else
    ClearText(AverageSpeed);

  LoadValue(MC,
            CommonInterface::GetComputerSettings().polar.glide_polar_task.GetMC(),
            UnitGroup::VERTICAL_SPEED);

  if (task_stats.total.planned.IsDefined()) {
    auto rMax = task_stats.distance_max;
    auto rMin = task_stats.distance_min;

    if (rMin < rMax) {
      auto range = 2 * (task_stats.total.planned.GetDistance() - rMin) / (rMax - rMin) - 1;
      LoadValue(RANGE, range * 100);
    } else
      ClearValue(RANGE);
  } else
    ClearValue(RANGE);

  if (task_stats.total.remaining_effective.IsDefined())
    LoadValue(SPEED_REMAINING, task_stats.total.remaining_effective.GetSpeed(),
              UnitGroup::TASK_SPEED);
  else
    ClearValue(SPEED_REMAINING);

  LoadValue(EFFECTIVE_MC, task_stats.effective_mc, UnitGroup::VERTICAL_SPEED);

  if (task_stats.total.travelled.IsDefined())
    LoadValue(SPEED_ACHIEVED, task_stats.total.travelled.GetSpeed(),
              UnitGroup::TASK_SPEED);
  else
    ClearValue(SPEED_ACHIEVED);

  LoadValue(CRUISE_EFFICIENCY, task_stats.cruise_efficiency * 100);
}
Exemplo n.º 23
0
static void OnClear(WndButton* pWnd)
{
  PlayResource(TEXT("IDR_WAV_CLICK"));
  ClearText();
}
Exemplo n.º 24
0
int MyMeshText::CreateString(bool concat, float fontheight, float x, float y, float z, float rotz, unsigned char justificationflags, ColorByte color, Vector2 size, const char* text, ...)
{
    assert( m_pFont && m_pFont->m_pFont );

    if( strlen( text ) == 0 )
        return 0;

    const char* stringtodraw = text;
    if( g_pLanguageTable != 0 && text[0] == '.' )
        stringtodraw = g_pLanguageTable->LookUp( text );

    int numlines = 0;

    if( concat == false )
    {
        ClearText();
    }

    bool moretexttocome = true;
    const char* stringpos = stringtodraw;

    while( moretexttocome )
    {
        numlines++;

        char singlelinebuffer[300];
        singlelinebuffer[0] = 0;
        char* singlelinebufferpos = singlelinebuffer;

        // word wrap if width of text is not 0.
        if( size.x != 0 )
        {
            float linewidth = -1;// = GetStringSize( fontheight, Vector2(0,0), singlelinebuffer ).x;
            while( linewidth < size.x &&
                    *stringpos != 0 )
            {
                *singlelinebufferpos = *stringpos;
                singlelinebufferpos++;
                *singlelinebufferpos = 0;
                stringpos++;

                linewidth = GetStringSize( fontheight, Vector2(0,0), singlelinebuffer ).x;

                assert( singlelinebufferpos < singlelinebuffer + 300 );
            }

            int numcharswewentback = 0;
            while( ( *(singlelinebufferpos-1) != ' ' && *stringpos != 0 ) &&
                    singlelinebufferpos > singlelinebuffer )
            {
                singlelinebufferpos--;
                numcharswewentback++;
            }

            if( singlelinebufferpos != singlelinebuffer )
            {
                *singlelinebufferpos = 0;
                stringpos -= numcharswewentback;
            }

            if( *stringpos == 0 )
                moretexttocome = false;

            stringtodraw = singlelinebuffer;
        }
        else
        {
            moretexttocome = false;
        }
            
        //// don't bother drawing if fontheight is zero... still doing logic above so the currect number of lines will be returned.
        //if( g_pRTQGlobals->m_WordWrapCountLinesOnly )
        //    continue;

        Vertex_XYZUV_RGBA* pVertsToDraw = (Vertex_XYZUV_RGBA*)GetVerts( true );

        int newverts = (int)strlen( stringtodraw ) * 4;
#if _DEBUG
        m_MostLettersAttemptedToDrawThisFrame += newverts/4;
        if( m_MostLettersAttemptedToDrawThisFrame > m_MostLettersAttemptedToDrawEver )
            m_MostLettersAttemptedToDrawEver = m_MostLettersAttemptedToDrawThisFrame;
#endif

        if( m_NumVertsToDraw + newverts > GetNumVerts() )
        {
#if _DEBUG
            LOGInfo( LOGTag, "TextMesh buffer isn't big enough for string (%s) - %d of %d letters used - most letters needed (%d)\n", stringtodraw, m_NumVertsToDraw/4, GetNumVerts()/4, m_MostLettersAttemptedToDrawEver );
#endif
            //assert( false ); // drawing more than we have room for.
            return 0;
        }

        pVertsToDraw += m_NumVertsToDraw;

        unsigned int textstrlen = m_pFont->m_pFont->GenerateVerts( stringtodraw, true, pVertsToDraw, fontheight, GL_TRIANGLES, justificationflags, color );

        m_NumVertsToDraw += (unsigned short)(textstrlen * 4);
        m_NumIndicesToDraw += textstrlen * 6;

        MyMatrix position;
        position.SetIdentity();
        position.Rotate( rotz, 0, 0, 1 );
        position.SetPosition( x, y - (numlines-1)*fontheight, z );
        //position.SetPosition( x, y - (numlines-1)*g_pRTQGlobals->m_WordWrapLineIncSize, z );
        //position.SetPosition( x, y, z );

        for( unsigned int i=0; i<textstrlen*4; i++ )
        {
            Vector3 out = position.TransformVector3( *(Vector3*)&pVertsToDraw[i].x );
            pVertsToDraw[i].x = out.x;
            pVertsToDraw[i].y = out.y;
            pVertsToDraw[i].z = out.z;
        }
    }

    return numlines;
}
Exemplo n.º 25
0
bool
dlgTextEntryKeyboardShowModal(TCHAR *text, size_t width,
                              const TCHAR* caption,
                              AllowedCharacters accb)
{
  if (width == 0)
    width = MAX_TEXTENTRY;

  max_width = std::min(MAX_TEXTENTRY, width);

  const DialogLook &look = UIGlobals::GetDialogLook();
  WndForm form(look);
  form.Create(UIGlobals::GetMainWindow(), caption);
  form.SetKeyDownFunction(FormKeyDown);
  form.SetCharacterFunction(FormCharacter);

  ContainerWindow &client_area = form.GetClientAreaWindow();
  const PixelRect rc = client_area.GetClientRect();

  const PixelScalar client_height = rc.bottom - rc.top;

  const PixelScalar padding = Layout::Scale(2);
  const PixelScalar backspace_width = Layout::Scale(36);
  const PixelScalar backspace_left = rc.right - padding - backspace_width;
  const PixelScalar editor_height = Layout::Scale(22);
  const PixelScalar editor_bottom = padding + editor_height;
  const PixelScalar button_height = Layout::Scale(40);
  constexpr unsigned keyboard_rows = 5;
  const PixelScalar keyboard_top = editor_bottom + padding;
  const PixelScalar keyboard_height = keyboard_rows * button_height;
  const PixelScalar keyboard_bottom = keyboard_top + keyboard_height;

  const bool vertical = client_height >= keyboard_bottom + button_height;

  const PixelScalar button_top = vertical
    ? rc.bottom - button_height
    : keyboard_bottom - button_height;
  const PixelScalar button_bottom = vertical
    ? rc.bottom
    : keyboard_bottom;

  const PixelScalar ok_left = vertical ? 0 : padding;
  const PixelScalar ok_right = vertical
    ? rc.right / 3
    : ok_left + Layout::Scale(80);

  const PixelScalar cancel_left = vertical
    ? ok_right
    : Layout::Scale(175);
  const PixelScalar cancel_right = vertical
    ? rc.right * 2 / 3
    : cancel_left + Layout::Scale(60);

  const PixelScalar clear_left = vertical
    ? cancel_right
    : Layout::Scale(235);
  const PixelScalar clear_right = vertical
    ? rc.right
    : clear_left + Layout::Scale(50);

  WndProperty _editor(client_area, look, _T(""),
                      { 0, padding, backspace_left - padding, editor_bottom },
                      0, WindowStyle());
  _editor.SetReadOnly();
  editor = &_editor;

  ButtonWindowStyle button_style;
  button_style.TabStop();

  WndButton backspace_button(client_area, look, _T("<-"),
                             { backspace_left, padding, rc.right - padding,
                                 editor_bottom },
                             button_style, OnBackspace);

  WndButton ok_button(client_area, look, _("OK"),
                      { ok_left, button_top, ok_right, button_bottom },
                      button_style, form, mrOK);

  WndButton cancel_button(client_area, look, _("Cancel"),
                          { cancel_left, button_top,
                              cancel_right, button_bottom },
                          button_style, form, mrCancel);

  WndButton clear_button(client_area, look, _("Clear"),
                         { clear_left, button_top,
                             clear_right, button_bottom },
                         button_style, ClearText);

  KeyboardControl keyboard(client_area, look,
                           { padding, keyboard_top,
                              rc.right - padding,
                              keyboard_bottom },
                           OnCharacter);
  kb = &keyboard;

  AllowedCharactersCallback = accb;

  cursor = 0;
  ClearText();

  if (!StringIsEmpty(text)) {
    CopyString(edittext, text, width);
    cursor = _tcslen(text);
  }

  UpdateTextboxProp();
  bool result = form.ShowModal() == mrOK;

  if (result) {
    CopyString(text, edittext, width);
  }

  return result;
}
Exemplo n.º 26
0
wxShapeRegion::~wxShapeRegion()
{
	ClearText();
}
Exemplo n.º 27
0
/******************************************************************************\
* Text message decoder (for receiver)                                          *
\******************************************************************************/
void CTextMessageDecoder::Decode(CVector<_BINARY>& pData)
{
	int			i, j;
	_BOOLEAN	bBeginningFound;

	/* Reset binary vector function. Always four bytes of data */
	pData.ResetBitAccess();

	/* Identify the beginning of a segment, all four bytes are 0xFF, otherwise
	   store total new buffer in internal intermediate buffer. This buffer is
	   read, when a beginning was found */
	bBeginningFound = TRUE;
	for (i = 0; i < NUM_BYTES_TEXT_MESS_IN_AUD_STR; i++)
	{
		if (pData.Separate(SIZEOF__BYTE) != 0xFF)
			bBeginningFound = FALSE;
	}

	if (bBeginningFound)
	{
		/* Analyse old stream buffer, which should be completed now --------- */
		/* Get header information. This function separates 16 bits from
		   stream */
		biStreamBuffer.ResetBitAccess();
		ReadHeader();

		/* Check CRC */
		biStreamBuffer.ResetBitAccess();
		CRCObject.Reset(16);

		/* "byLengthBody" was defined in the header */
		for (i = 0; i < byLengthBody + 2 /* Header */; i++)
			CRCObject.AddByte(biStreamBuffer.Separate(SIZEOF__BYTE));

		if (CRCObject.CheckCRC(biStreamBuffer.Separate(16)) == TRUE)
		{
			if (biCommandFlag == 1)
			{
				switch (byCommand)
				{
				case 1: /* 0001 */
					/* The message shall be removed from the display */
					ClearText();
					break;
				}
			}
			else
			{
				/* Body ----------------------------------------------------- */
				/* Evaluate toggle bit */
				if (biToggleBit != biOldToggleBit)
				{
					/* A new message is sent, clear all old segments */
					ResetSegments();

					biOldToggleBit = biToggleBit;
				}


				/* Read all bytes in stream buffer -------------------------- */
				/* First, check if segment was already OK and if new data has
				   the same content or not. If the content is different, a new
				   message is being send, clear all other segments */
				if (Segment[bySegmentID].bIsOK == TRUE)
				{
					/* Reset bit access and skip header bits to go directly to
					   the body bytes */
					biStreamBuffer.ResetBitAccess();
					biStreamBuffer.Separate(16);

					_BOOLEAN bIsSame = TRUE;
					for (i = 0; i < byLengthBody; i++)
					{
						if (Segment[bySegmentID].byData[i] !=
							biStreamBuffer.Separate(SIZEOF__BYTE))
						{
							bIsSame = FALSE;
						}
					}

					/* If a new message is sent, clear all old segments */
					if (bIsSame == FALSE)
						ResetSegments();
				}

				/* Reset bit access and skip header bits to go directly to the
				   body bytes */
				biStreamBuffer.ResetBitAccess();
				biStreamBuffer.Separate(16);

				/* Get all body bytes */
				for (i = 0; i < byLengthBody; i++)
				{
					Segment[bySegmentID].byData[i] =
						biStreamBuffer.Separate(SIZEOF__BYTE);
				}

				/* Set length of this segment and OK flag */
				Segment[bySegmentID].iNumBytes = byLengthBody;
				Segment[bySegmentID].bIsOK = TRUE;

				/* Check length of text message */
				if (biLastFlag == 1)
					iNumSegments = bySegmentID + 1;

				/* Set text to display */
				SetText();
			}
		}

		/* Reset bit count */
		iBitCount = 0;
	}
	else
	{
		for (i = 0; i < NUM_BYTES_TEXT_MESS_IN_AUD_STR; i++)
		{
			/* Check, if number of bytes is not too big */
			if (iBitCount < TOT_NUM_BITS_PER_PIECE)
			{
				for (j = 0; j < SIZEOF__BYTE; j++)
					biStreamBuffer[iBitCount + j] = pData[i * SIZEOF__BYTE + j];

				iBitCount += SIZEOF__BYTE;
			}
		}
	}
}
Exemplo n.º 28
0
void
TimesStatusPanel::Refresh()
{
  const NMEAInfo &basic = CommonInterface::Basic();
  const FlyingState &flight = CommonInterface::Calculated().flight;
  const ComputerSettings &settings = CommonInterface::GetComputerSettings();

  StaticString<64> temp;

  if (basic.location_available && basic.date_time_utc.IsDatePlausible()) {
    SunEphemeris::Result sun =
      SunEphemeris::CalcSunTimes(basic.location, basic.date_time_utc,
                                 settings.utc_offset);

    const unsigned sunrisehours = (int)sun.time_of_sunrise;
    const unsigned sunrisemins = (int)((sun.time_of_sunrise - double(sunrisehours)) * 60);
    const unsigned sunsethours = (int)sun.time_of_sunset;
    const unsigned sunsetmins = (int)((sun.time_of_sunset - double(sunsethours)) * 60);

    temp.Format(_T("%02u:%02u - %02u:%02u"), sunrisehours, sunrisemins, sunsethours, sunsetmins);
    SetText(Daylight, temp);
  } else {
    ClearText(Daylight);
  }

  if (basic.time_available) {
    SetText(LocalTime,
            FormatLocalTimeHHMM((int)basic.time, settings.utc_offset));
    SetText(UTCTime, FormatSignedTimeHHMM((int)basic.time));
  } else {
    ClearText(LocalTime);
    ClearText(UTCTime);
  }

  if (basic.date_time_utc.IsDatePlausible()) {
    temp.Format(_T("%04d-%02d-%02d"), basic.date_time_utc.year,
                basic.date_time_utc.month, basic.date_time_utc.day);
    SetText(UTCDate, temp);
  } else {
    ClearText(UTCDate);
  }

  if (flight.flying) {
    SetText(TakeoffTime,
            FormatLocalTimeHHMM((int)flight.takeoff_time,
                                settings.utc_offset));
  } else {
    ClearText(TakeoffTime);
  }

  if (flight.landing_time >= 0) {
    SetText(LandingTime,
            FormatLocalTimeHHMM(int(flight.landing_time),
                                settings.utc_offset));
  } else {
    ClearText(LandingTime);
  }

  if (flight.flight_time > 0) {
    SetText(FlightTime, FormatSignedTimeHHMM((int)flight.flight_time));
  } else {
    ClearText(FlightTime);
  }
}
Exemplo n.º 29
0
void CPrefabTrackerDlg::OnButtonGenerate()
{
	CWaitCursor WaitCursor;

	//first off clear out any existing window text, and any old data
	m_Prefabs.SetSize(0);
	ClearText();

	//alright, now we need to get the prefab directory and the world directory
	CDirDialog PrefabDir;
	PrefabDir.m_hwndOwner = m_hWnd;
	PrefabDir.m_strInitDir = GetProject()->m_BaseProjectDir;
	PrefabDir.m_strTitle = "Select Prefab Directory";
	if(!PrefabDir.DoBrowse())
		return;

	CDirDialog WorldDir;
	WorldDir.m_hwndOwner = m_hWnd;
	WorldDir.m_strInitDir = GetProject()->m_BaseProjectDir;
	WorldDir.m_strTitle = "Select World Directory";
	if(!WorldDir.DoBrowse())
		return;

	//alright, we now have both directories. Now build up a list of all the prefabs and worlds under
	//that directory
	CMoArray<CString>	sPrefabs;
	CFileUtils::GetAllWorldFiles(PrefabDir.m_strPath, sPrefabs);

	CMoArray<CString>	sWorlds;
	CFileUtils::GetAllWorldFiles(WorldDir.m_strPath, sWorlds);

	//alright, we now need to convert the prefab file list over to structures we can use
	m_Prefabs.SetSize(sPrefabs.GetSize());

	uint32 nCurrPrefab;
	for(nCurrPrefab = 0; nCurrPrefab < sPrefabs.GetSize(); nCurrPrefab++)
	{
		m_Prefabs[nCurrPrefab].m_sFilename		= RemoveProjectPath(sPrefabs[nCurrPrefab]);
		m_Prefabs[nCurrPrefab].m_nTotalRefCount = 0;

		m_Prefabs[nCurrPrefab].m_References.SetSize(0);
	}

	//alright, now we run through every level, open it, and look for prefabs
	for(uint32 nCurrWorld = 0; nCurrWorld < sWorlds.GetSize(); nCurrWorld++)
	{
		CString sWorld = sWorlds[nCurrWorld];
		CString sRelativeWorld = RemoveProjectPath(sWorld);

		//load up the LTA if it is a world
		CLTALoadOnlyAlloc Allocator(512 * 1024);

		//open up the file
		CLTAReader File;
		if(!File.Open(sWorld, CLTAUtil::IsFileCompressed(sWorld)))
		{
			continue;
		}

		//load up the world node
		CLTANode* pWorld = CLTANodeReader::LoadNode(&File, "world", &Allocator);

		//clean up the file
		File.Close();

		//if there is no world node, then this was not a world
		if(pWorld == NULL)
		{
			Allocator.FreeNode(pWorld);
			Allocator.FreeAllMemory();
			continue;
		}

		//now find any matching prefabs
		CLTANodeIterator Iter(pWorld);
		CLTANode* pPrefabName;

		while((pPrefabName = Iter.FindNextList("prefabfile")) != NULL)
		{
			//sanity checks
			ASSERT(pPrefabName->IsList());
			
			if(pPrefabName->GetNumElements() < 2)
				continue;

			CLTANode* pValue = pPrefabName->GetElement(1);

			if(pValue->IsList())
				continue;

			//valid, now see if we have a match
			for(uint32 nCurrPrefab = 0; nCurrPrefab < m_Prefabs.GetSize(); nCurrPrefab++)
			{
				if(m_Prefabs[nCurrPrefab].m_sFilename.CompareNoCase(pValue->GetValue()) == 0)
				{
					//we have a match, add this reference
					bool bFoundRef = false;
					for(uint32 nCurrRef = 0; nCurrRef < m_Prefabs[nCurrPrefab].m_References.GetSize(); nCurrRef++)
					{
						if(m_Prefabs[nCurrPrefab].m_References[nCurrRef].m_sFile.CompareNoCase(sRelativeWorld) == 0)
						{
							//found a reference
							m_Prefabs[nCurrPrefab].m_References[nCurrRef].m_nRefCount++;
							bFoundRef = true;
							break;
						}
					}

					//no luck finding an existing one, make a new one
					if(!bFoundRef)
					{
						SPrefabInfo::SPrefabRef NewRef;
						NewRef.m_sFile = sRelativeWorld;
						NewRef.m_nRefCount = 1;

						m_Prefabs[nCurrPrefab].m_References.Append(NewRef);
					}

					m_Prefabs[nCurrPrefab].m_nTotalRefCount++;
				}
			}		
		}

		//now clean up the world and the memory
		Allocator.FreeNode(pWorld);
		Allocator.FreeAllMemory();
	}

	FillEditText();
}
Exemplo n.º 30
0
static void OnClear(WindowControl * Sender)
{	
  ClearText();
}