Пример #1
0
nsresult nsCategoryImp::Get( PRUnichar aChar, nsUGenCategory* oResult)
{
   PRUint8 ret = GetCat(aChar);
   if( 0 == ret)
      *oResult = kUGenCategory_Other; // treat it as Cn - Other, Not Assigned
   else 
      *oResult = (nsUGenCategory)ret;
   return NS_OK;
}
Пример #2
0
nsresult nsCategoryImp::Is( PRUnichar aChar, nsUGenCategory aCategory, PRBool* oResult)

{
   nsUGenCategory cat ;
   PRUint8 ret = GetCat(aChar);
   if( 0 == ret)
      cat = kUGenCategory_Other; // treat it as Cn - Other, Not Assigned
   else 
      cat = (nsUGenCategory)ret;
   *oResult = (aCategory == cat );
   return NS_OK;
}
Пример #3
0
void SplitWindow::MessageReceived(BMessage* msg)
{
	switch(msg->what)
	{
		case AddCatMSG:
			AddCat();
		break;
		case AmountModifiedMSG:
		{
			int32 splitSum = SplitSum();
			if (total == 0)
			{
				totalText->SetText(prefs->currencyToString(splitSum).c_str());
			}
			else
			{
				splitSum = total - splitSum;
				diffText->SetText(prefs->currencyToString(splitSum).c_str());
			}
		}
		break;
		case CatPopUpMSG:
		{
			int8 i8;
			const char* str;
			msg->FindInt8("num", &i8);
			msg->FindString("text", &str);
			catTexts[i8]->SetText(str);
		}
		break;
		case SplitEnterMSG:
		{
			#ifdef DEBUG
			printf("SplitWindow::MessageReceived:SplitEnterMSG\n");
			#endif
			if (!(depRadio->Value() || pamRadio->Value()))
			{
				BAlert* alert = new BAlert("Split Error", 
					"Must choose either Payment or Deposit", "OK");
				alert->Go();
				return;
			}

			int32 splitSum = SplitSum();
			if (total < 0)
			{
				BAlert* alert = new BAlert("Split Error",
					"Total Amount is Negative.",
					"Change Payment/Deposit & Continue", "Cancel");
				if (alert->Go() == 1)
					return;
				else
					pamRadio->SetEnabled(depRadio->Value());
			}
			if (total != 0 && splitSum != total)
			{
				BAlert* alert = new BAlert("Split Error",
					"Total of Categories does not equal Total Amount given.",
					"Change Total & Continue", "Cancel");
				if (alert->Go() == 1)
					return;
			}

			tcv::iterator iterc = catTexts.begin();
			uint8 i = 1;
			cal* scatlist = new list<Cat*>;
			i32l* amtlist = new list<int32>;
			int32 amt;
			string sumtext;
			for (tcv::iterator itera = amtTexts.begin(); itera != amtTexts.end();
				itera++)
			{
				sumtext = (*itera)->Text();
				amt = prefs->stringToCurrency(sumtext);
				#ifdef DEBUG
				printf("\t%li\n", amt);
				#endif
				string cattext = (*iterc)->Text();
				if (cattext.length() == 0 && amt != 0)
				{
					char buffer[30];
					sprintf(buffer, "Amount but no Category given for Line %i", i);
					BAlert* alert = new BAlert("Split Error", buffer, "OK");
					alert->Go();
					delete scatlist;
					return;
				}
				if (amt != 0)
				{
					Cat* thisCat;
					if ((thisCat = GetCat(cattext)) == 0)
						thisCat = theProxy->AddCat(cattext);
					scatlist->push_back(thisCat);
					amtlist->push_back((splitSum < 0 ? -1 : 1) * amt);
				}
				i++;
				iterc++;
			}
			Cat* sc;
			if (scatlist->size() == 0)
			{
				BAlert* alert = new BAlert("Split Error", "No Valid Categories", "OK");
				alert->Go();
				delete scatlist;
				delete amtlist;
				return;
			}
			else if (scatlist->size() == 1)
			{
				sc = scatlist->front();
			}
			else
			{
				sc = new SplCat(scatlist, amtlist, prefs);
			}
			BMessenger msngr(targetHandler);
			BMessage* msg = new BMessage(SplitMSG);
			msg->AddPointer("cat", sc);
			msg->AddBool("pam", pamRadio->Value());
			msg->AddInt32("amt", splitSum);
			msngr.SendMessage(msg);
			Lock();
			Quit();
		}
		break;
		default:
			BWindow::MessageReceived(msg);
	}
}
Пример #4
0
// This needs vast improvement
static PRBool ucIsAlpha(PRUnichar c)
{
  // XXX we have to fix callers to handle the full Unicode range
  return (5 == GetCat(PRUint32(c)));
}