void PrintGpsText() { if (*g_TimeMs < gGpsTextTimer + GPS_TEXT_TIME) { std::wstring text; if (gCurrentGpsMode == III_RADAR_SPRITE_CENTRE) { text = L"GPS Mode: Disabled"; } else { short legendtext[128]; AsciiToUnicode((char*)BlipsGxtTableIII[gCurrentGpsMode], legendtext); //GetText(TheText, ); text = L"GPS Mode: "; text += (wchar_t*)legendtext; } unsigned int color = 0xFFFFFFFF; SetFontStyle(0); SetScale(0.7f, 1.0f); SetColor(&color); SetJustifyOn(); SetDropShadowPosition(1); SetPropOn(); CVector2D point; point.x = -1.0; point.y = -1.0; TransformRadarPointToScreenSpaceIII(point, point); PrintString(point.x, point.y + 10.0f, (short*)text.c_str()); SetDropShadowPosition(0); SetFontStyle(0); } }
void PrintGpsText() { unsigned int color; CVector2D point; short text[128]; if(*g_TimeMs < gGpsTextTimer + GPS_TEXT_TIME) { switch(gCurrentGpsMode) { case GPS_MODE_DISABLED: AsciiToUnicode("GPS Mode: Disabled", text); break; case GPS_MODE_DEFAULT: AsciiToUnicode("GPS Mode: Default", text); break; case GPS_MODE_AMMUNATION: if(*gCurrLevel != LEVEL_SHORESIDE) AsciiToUnicode("GPS Mode: Ammu-Nation", text); else AsciiToUnicode("GPS Error: can't find Ammu-Nation", text); break; case GPS_MODE_BOMBSHOP: AsciiToUnicode("GPS Mode: Bomb Shop", text); break; case GPS_MODE_FIRESTATION: AsciiToUnicode("GPS Mode: Fire Station", text); break; case GPS_MODE_HOSPITAL: AsciiToUnicode("GPS Mode: Hospital", text); break; case GPS_MODE_PAYNSPRAY: AsciiToUnicode("GPS Mode: Pay'N'Spray", text); break; case GPS_MODE_POLICE: AsciiToUnicode("GPS Mode: Police", text); break; case GPS_MODE_SAFEHOUSE: AsciiToUnicode("GPS Mode: Safehouse", text); break; default: AsciiToUnicode("GPS Error: Unknown command", text); } color = 0xFFFFFFFF; SetFontStyle(0); SetScale(0.7f, 1.0f); SetColor(&color); SetJustifyOn(); SetDropShadowPosition(1); SetPropOn(); point.x = -1.0f; point.y = -1.0f; TransformRadarPointToScreenSpace(point, point); PrintString(point.x, point.y + 10.0f, text); SetDropShadowPosition(0); SetFontStyle(0); } }
void CBFileNameDisplay::UpdateDisplay ( const JBoolean hasFocus ) { itsCBHasFocusFlag = hasFocus; if (!hasFocus && itsDiskModFlag) { SetFontStyle(GetColormap()->GetDarkRedColor()); } else if (!hasFocus) { SetFontStyle(GetColormap()->GetBlackColor()); } }
void CFontStatic::SetFontStatic(CString szFont, int nSize, DWORD dwColor, DWORD dwStyle) { // Set the font, size and color. m_szFont = szFont; m_nSize = nSize; m_dwColor = dwColor; // Set the style SetFontStyle(dwStyle); }
/* * WxCheckBoxUnderlineClick */ void MadHighlightingDialog::WxCheckBoxUnderlineClick(wxCommandEvent& event) { wxFont font=GetItemFont(WxListCtrlKeyword, g_Index); if(event.IsChecked()) { g_KeywordInfoTable[g_Index].attr->style |= fsUnderline; } else { g_KeywordInfoTable[g_Index].attr->style &= (~fsUnderline); } SetFontStyle(font, g_KeywordInfoTable[g_Index].attr->style); SetItemFont(WxListCtrlKeyword, g_Index, font); WxListCtrlKeyword->SetColumnWidth(0, WxListCtrlKeyword->GetClientSize().x - 4); SetToModifiedSyntax(g_Syntax); }
void MadHighlightingDialog::RepaintKeyword() { vector<KeywordInfo>::iterator it=g_KeywordInfoTable.begin(); vector<KeywordInfo>::iterator itend=g_KeywordInfoTable.end(); long idx=0; wxFont font; wxColour &fc0=it->attr->color; wxColour &bc0=it->attr->bgcolor; wxColour fc, bc; WxListCtrlKeyword->Freeze(); do { switch(it->kind) { case kindSysAttr1: case kindSysAttr2: case kindKeyword: fc=it->attr->color; bc=it->attr->bgcolor; font=GetItemFont(WxListCtrlKeyword, idx); SetFontStyle(font, it->attr->style); SetItemFont(WxListCtrlKeyword, idx, font); break; case kindRange: fc=wxNullColour; bc=*it->range_bgcolor; break; } if(fc==wxNullColour) fc=fc0; if(bc==wxNullColour) bc=bc0; SetItemColour(WxListCtrlKeyword, idx, fc, bc); ++idx; } while(++it != itend); WxListCtrlKeyword->SetColumnWidth(0, WxListCtrlKeyword->GetClientSize().x - 4); WxListCtrlKeyword->Thaw(); }
void MadHighlightingDialog::WxListBoxSyntaxSelected(wxCommandEvent& event) { wxString title=WxListBoxSyntax->GetString(event.GetSelection()); g_Syntax=GetSyntax(title); // build keyword list WxListCtrlKeyword->Freeze(); WxListCtrlKeyword->DeleteAllItems(); g_KeywordInfoTable.clear(); int index=0; // system attributes for(int ae=aeText; ae<aeNone; ++ae) { long item = WxListCtrlKeyword->InsertItem(index++, MadSyntax::GetAttributeName((MadAttributeElement)ae)); MadAttributes *attr = g_Syntax->GetAttributes((MadAttributeElement)ae); int kind=kindSysAttr1; if(ae==aeActiveLine || ae==aeBookmark) kind=kindSysAttr2; g_KeywordInfoTable.push_back(KeywordInfo(kind, attr, NULL)); if(ae==aeText) { WxListCtrlKeyword->SetBackgroundColour(attr->bgcolor); } SetItemColour(WxListCtrlKeyword, item, attr->color, attr->bgcolor); wxFont font=GetItemFont(WxListCtrlKeyword, item); SetFontStyle(font, attr->style); SetItemFont(WxListCtrlKeyword, item, font); } // custom ranges size_t i; for(i=0; i<g_Syntax->m_CustomRange.size(); ++i) { wxString text; text.Printf(wxT("Range %s %s"), g_Syntax->m_CustomRange[i].begin.c_str(), g_Syntax->m_CustomRange[i].end.c_str()); long item = WxListCtrlKeyword->InsertItem(index++, text); wxColour *bg = &(g_Syntax->m_CustomRange[i].bgcolor); g_KeywordInfoTable.push_back( KeywordInfo(kindRange, NULL, bg) ); SetItemColour(WxListCtrlKeyword, item, g_KeywordInfoTable[0].attr->color, *bg); } // custom keywords for(i=0; i<g_Syntax->m_CustomKeyword.size(); ++i) { long item = WxListCtrlKeyword->InsertItem(index++, g_Syntax->m_CustomKeyword[i].m_Name); MadAttributes *attr = &(g_Syntax->m_CustomKeyword[i].m_Attr); g_KeywordInfoTable.push_back(KeywordInfo(kindKeyword, attr, NULL)); SetItemColour(WxListCtrlKeyword, item, attr->color, attr->bgcolor); wxFont font=GetItemFont(WxListCtrlKeyword, item); SetFontStyle(font, attr->style); SetItemFont(WxListCtrlKeyword, item, font); } WxListCtrlKeyword->SetColumnWidth( 0, WxListCtrlKeyword->GetClientSize().x - 4); WxListCtrlKeyword->Thaw(); g_Index=-1; wxListEvent e; e.m_itemIndex=0; WxListCtrlKeywordSelected(e); }
/****************************************************************************** RejectChange: Reject the current changed text. ******************************************************************************/ BOOL RejectChange(PTERWND w, long line, int col) { int i,font,CurCfmt,RevId; long l,BegLine,EndLine; int BegCol,EndCol,StartPos,EndPos; LPWORD fmt; CurCfmt=GetCurCfmt(w,line,col); if (!IsTrackChangeFont(w,CurCfmt)) return false; // ** reject deletion ** if (TerFont[CurCfmt].DelRev>0) { BegLine=EndLine=line; BegCol=EndCol=col; if (!GetDelBeginPos(w,&BegLine, &BegCol)) return false; // 20060929: since deletion happens after insertion, reject deletion including any previous insertion if (!TerLocateChangedChar(hTerWnd,-1,TerFont[CurCfmt].DelRev,false,&EndLine,&EndCol,true)) return false; // Save undo for insertion SaveUndo(w,BegLine,BegCol,EndLine,EndCol,'F'); // save font ids // Reset reviewer ids for (l=BegLine;l<=EndLine;l++) { StartPos=(l==BegLine)?BegCol:0; EndPos=(l==EndLine)?EndCol:LineLen(l); // exclusive // scan each character in the line to perform indicated delete operation (regular delete or track-delete) fmt=OpenCfmt(w,l); for (i=StartPos;i<EndPos;i++) { font=fmt[i]; RevId=TerFont[font].DelRev; font=SetTrackingFont(w,font,TRACK_NO_DEL); // 20060929: turn-off deletion if (false && reviewer[RevId].DelColor==TerFont[font].TextColor) { // 20060908: commented out - reset color font=(int)GetNewColor(w,(WORD)font,(DWORD)CLR_AUTO,0L,l,i); } if (True(reviewer[RevId].DelStyle&TerFont[font].style)) { // reset style font=SetFontStyle(w,font,reviewer[RevId].DelStyle,false); // reset the reviewer style } fmt[i]=font; } CloseCfmt(w,l); } TerArg.modified++; return true; } // ** reject font change, 20080626 if (TerFont[CurCfmt].FmtRev>0) { BegLine=EndLine=line; BegCol=EndCol=col; if (!GetChangeBeginPos(w,&BegLine, &BegCol)) return false; if (!TerLocateChangedChar2(hTerWnd,-1,-1,TerFont[CurCfmt].FmtRev,false,&EndLine,&EndCol,true)) return false; // Save undo for insertion SaveUndo(w,BegLine,BegCol,EndLine,EndCol,'F'); // save font ids // Reset to original font id for (l=BegLine;l<=EndLine;l++) { StartPos=(l==BegLine)?BegCol:0; EndPos=(l==EndLine)?EndCol:LineLen(l); // exclusive // scan each character in the line to perform indicated delete operation (regular delete or track-delete) fmt=OpenCfmt(w,l); for (i=StartPos;i<EndPos;i++) { font=fmt[i]; if (TerFont[font].FmtRev==0) continue; // this can happen when rejecting a formatted string within an inserted text font=TerFont[font].FmtOrigFont; // reset to original font RevId=TerFont[font].FmtRev; if (RevId>0) { // this should not happen since the orig-font would be a normal font font=SetTrackingFont(w,font,TRACK_NO_FMT); //inase the original font if (True(reviewer[RevId].FmtStyle&TerFont[font].style)) { // reset style font=SetFontStyle(w,font,reviewer[RevId].FmtStyle,false); // reset the reviewer style } } fmt[i]=font; } CloseCfmt(w,l); } TerArg.modified++; return true; } // ** Reject insertion ** if (TerFont[CurCfmt].InsRev>0) { BOOL SaveUnprotDel=True(TerFlags&TFLAG_UNPROTECTED_DEL); BegLine=EndLine=line; BegCol=EndCol=col; if (!GetChangeBeginPos(w,&BegLine, &BegCol)) return false; if (!TerLocateChangedChar(hTerWnd,TerFont[CurCfmt].InsRev,TerFont[CurCfmt].DelRev,false,&EndLine,&EndCol,true)) return false; HilightBegRow=BegLine; HilightBegCol=BegCol; HilightEndRow=EndLine; HilightEndCol=EndCol; StretchHilight=false; HilightType=HILIGHT_CHAR; TerFlags|=TFLAG_UNPROTECTED_DEL; TerDeleteBlock(hTerWnd,false); if (!SaveUnprotDel) ResetUintFlag(TerFlags,TFLAG_UNPROTECTED_DEL); return true; } return true; }
/****************************************************************************** AcceptChange: Accept the current changed text. ******************************************************************************/ BOOL AcceptChange(PTERWND w, long line, int col) { int i,font,CurCfmt,RevId; long l,BegLine,EndLine; int BegCol,EndCol,StartPos,EndPos; LPWORD fmt; CurCfmt=GetCurCfmt(w,line,col); if (!IsTrackChangeFont(w,CurCfmt)) return false; BegLine=EndLine=line; BegCol=EndCol=col; if (!GetChangeBeginPos(w,&BegLine, &BegCol)) return false; if (!TerLocateChangedChar2(hTerWnd,TerFont[CurCfmt].InsRev,TerFont[CurCfmt].DelRev,TerFont[CurCfmt].FmtRev,false,&EndLine,&EndCol,true)) return false; // 20080626 // ** Accept deletion ** if (TerFont[CurCfmt].DelRev>0) { BOOL SaveUnprotDel=True(TerFlags&TFLAG_UNPROTECTED_DEL); HilightBegRow=BegLine; HilightBegCol=BegCol; HilightEndRow=EndLine; HilightEndCol=EndCol; StretchHilight=false; HilightType=HILIGHT_CHAR; TerFlags|=TFLAG_UNPROTECTED_DEL; TerDeleteBlock(hTerWnd,false); if (!SaveUnprotDel) ResetUintFlag(TerFlags,TFLAG_UNPROTECTED_DEL); return true; } // ** Accept insertion ** // Save undo for insertion SaveUndo(w,BegLine,BegCol,EndLine,EndCol,'F'); // save font ids // Reset reviewer ids for (l=BegLine;l<=EndLine;l++) { StartPos=(l==BegLine)?BegCol:0; EndPos=(l==EndLine)?EndCol:LineLen(l); // exclusive // scan each character in the line to perform indicated delete operation (regular delete or track-delete) fmt=OpenCfmt(w,l); for (i=StartPos;i<EndPos;i++) { font=fmt[i]; RevId=TerFont[font].InsRev; font=SetTrackingFont(w,font,TRACK_NONE); if (reviewer[RevId].InsColor==TerFont[font].TextColor) { // reset color font=(int)GetNewColor(w,(WORD)font,(DWORD)CLR_AUTO,0L,l,i); } if (True(reviewer[RevId].InsStyle&TerFont[font].style)) { // reset style font=SetFontStyle(w,font,reviewer[RevId].InsStyle,false); // reset the reviewer style } fmt[i]=font; } CloseCfmt(w,l); } TerArg.modified++; return true; }
void BYdpMainWindow::MessageReceived(BMessage *Message) { int item; this->DisableUpdates(); switch (Message->what) { case MSG_MODIFIED_INPUT: HandleModifiedInput(false); break; case MSG_LIST_INVOKED: item = dictList->CurrentSelection(0); wordInput->SetText(((BStringItem*)dictList->ItemAt(item))->Text()); break; case MSG_LIST_SELECTED: item = dictList->CurrentSelection(0); if (item>dictList->CountItems()) item = dictList->CountItems(); if (item>=0) myDict->GetDefinition(myDict->wordPairs[item+dictList->topIndex]); break; case MSG_LISTUP: case MSG_LISTDOWN: // printf("got listup\n"); myDict->GetDefinition(myDict->wordPairs[dictList->topIndex+dictList->CurrentSelection(0)]); break; // case MSG_LISTDOWN: // printf("got listdown\n"); // myDict->GetDefinition(myDict->wordPairs[dictList->topIndex+dictList->CurrentSelection(0)]); // break; case MSG_CLEAR_INPUT: wordInput->SetText(""); wordInput->MakeFocus(); break; case MENU_ENG2POL: UpdateLanguages(true); break; case MENU_POL2ENG: UpdateLanguages(false); break; case MENU_SWITCH: UpdateLanguages(!config->toPolish); break; case MENU_FUZZY: config->searchmode = SEARCH_FUZZY; config->save(); HandleModifiedInput(true); UpdateMenus(); break; case MENU_PLAIN: config->searchmode = SEARCH_BEGINS; config->save(); HandleModifiedInput(true); UpdateMenus(); break; /* case MENU_ENGINESQ2: SwitchEngine(DICTIONARY_SQ2); break; */ case MENU_ENGINESAP: SwitchEngine(DICTIONARY_SAP); break; case MENU_ENGINEYDP: SwitchEngine(DICTIONARY_YDP); break; case MENU_PATH: ConfigPath(); break; case MENU_COLOR0: ConfigColour(0); break; case MENU_COLOR1: ConfigColour(1); break; case MENU_COLOR2: ConfigColour(2); break; case MENU_COLOR3: ConfigColour(3); break; case MENU_CLIP: config->clipboardTracking = !config->clipboardTracking; config->save(); UpdateMenus(); break; case MENU_FOCUS: config->setFocusOnSelf = !config->setFocusOnSelf; config->save(); UpdateMenus(); break; case MENU_DISTANCE: ConfigDistance(); break; /* case MENU_SQL: ConfigSQLTables(); break; */ case MENU_ABOUT: { BString about; about = "\n\n" APP_NAME " " APP_VERSION "\n"; about += "English-Polish, Polish-English dictionary\n"; about += "\n\nBeOS version:\n"; about += "Maciej Witkowiak <*****@*****.**>"; about += "\n\nSAP engine based on sap v0.2b\n"; about += "(c) 1998 Bohdan R. Rau,\n(c) 2001 Daniel Mealha Cabrita"; about += "\nYDP and SQL engines by Maciej Witkowiak\n"; about += "\n\nSoftware released under GNU/GPL license"; about += "\n\nvisit:\n"; about += "http://home.elysium.pl/ytm/html/beos.html\n"; about += "\nDevelopment has been encouraged by:\n"; about += "http://www.haiku-os.pl"; outputView->SetText(about.String()); } break; case FONT_SIZE: { float fontSize; Message->FindFloat("size",&fontSize); SetFontSize(fontSize); } break; case FONT_FAMILY: { const char * fontFamily = 0, * fontStyle = 0; void * ptr; if (Message->FindPointer("source",&ptr) == B_OK) { currentFontItem = static_cast<BMenuItem*>(ptr); fontFamily = currentFontItem->Label(); } SetFontStyle(fontFamily, fontStyle); } case FONT_STYLE: { const char * fontFamily = 0, * fontStyle = 0; void * ptr; if (Message->FindPointer("source",&ptr) == B_OK) { BMenuItem * item = static_cast<BMenuItem*>(ptr); fontStyle = item->Label(); BMenu * menu = item->Menu(); if (menu != 0) { currentFontItem = menu->Superitem(); if (currentFontItem != 0) { fontFamily = currentFontItem->Label(); } } } SetFontStyle(fontFamily, fontStyle); } case MSG_SCROLL: // printf("scroll value changed\n"); if (scrollBar->Value() != dictList->topIndex) { dictList->ListScrolled(scrollBar->Value()); myDict->GetDefinition(myDict->wordPairs[dictList->topIndex+dictList->CurrentSelection(0)]); } break; case MSG_COLOURUPDATE: // printf("colour update\n"); myDict->ReGetDefinition(); break; case MSG_FUZZYUPDATE: // printf("fuzzy update\n"); if (config->searchmode == SEARCH_FUZZY) HandleModifiedInput(true); break; /* case MSG_SQLTABLESUPDATE: // printf("sql tables updated\n"); myDict->FlushCache(); SwitchEngine(config->dictionarymode); break; */ case B_CLIPBOARD_CHANGED: NewClipData(); break; case B_REFS_RECEIVED: RefsReceived(Message); break; case B_CANCEL: // printf("canceled\n"); if (firstStart) { config->dictionarymode = DICTIONARY_SAP; // will be saved in QuitRequested below BAlert *alert = new BAlert(APP_NAME, "Couldn't open dictionary. Dictionary engine has been reset to SAP.", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->Go(); QuitRequested(); } else delete myPanel; // break; default: BWindow::MessageReceived(Message); break; } this->EnableUpdates(); }