Example #1
0
    std::string ToolchainItem::colorStr(std::string const& _var) const
    {
      if (!library()) return std::string();

      if (!valid())
      {
        std::string _path(std::string("invalid_") + _var);
        if (!pathExists(_path))
        { 
          return (_var != "light") ? "#e74c3c" : "#6b2018"; 
        } else
        {
          return library()->config().get<std::string>(tbd::ConfigPath("colorset") / tbd::ConfigPath(_path));
        }
      }

      auto& _cfg = library()->config();
      tbd::ConfigPath _toolsetId(elementId().toolset().str());
      tbd::ConfigPath _typeId(elementId().typeId().str());
      tbd::ConfigPath _path = _toolsetId / _typeId / tbd::ConfigPath(_var);

      std::cout << _path.dump() << std::endl;
      if (pathExists(_path.dump()))
      {
        return _cfg.get<std::string>(ConfigPath("colorset") /_path);
      } 
      _path =  _toolsetId / tbd::ConfigPath(_var); 
      if (pathExists(_path.dump()))
      {
        return _cfg.get<std::string>(ConfigPath("colorset") /_path);
      }
      return (_var != "light") ? "#405959" : "#9ed8db"; 
    }
Example #2
0
void BYdpMainWindow::TryToOpenDict(void) {
//		printf("about to reopen dict\n");
	switch (config->dictionarymode) {
/*		case DICTIONARY_SQ2:
			myDict = sq2Dict;
			myConverter = sq2Conv;
			break; */
		case DICTIONARY_YDP:
			myDict = ydpDict;
			myConverter = ydpConv;
			break;
		case DICTIONARY_SAP:
		default:
			myDict = sapDict;
			myConverter = sapConv;
			break;
	}
	if (myDict->OpenDictionary() < 0) {
//		printf("failed\n");
		ConfigPath();
	} else {
//		printf("success\n");
		firstStart = false;
		dictList->SetConverter(myConverter);
		wordInput->SetText("A");
		HandleModifiedInput(true);
		UpdateMenus();
		this->MoveTo(BPoint(config->position.left, config->position.top));
//		XXX if this is enabled - menubar is lost
//		this->ResizeTo(config->position.Width(),config->position.Height());

		this->Show();
	}
}
Example #3
0
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();
}
Example #4
0
 bool ToolchainItem::pathExists(std::string const& _path) const
 {
   if (!library()) return false;
   return library()->config().exists(ConfigPath("colorset") / ConfigPath(_path)); 
 }