haiku/headers/os/locale/Language.h

75 lines
1.5 KiB
C
Raw Normal View History

/*
* Copyright 2003-2011, Haiku, Inc.
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
* Distributed under the terms of the MIT License.
*/
#ifndef _LANGUAGE_H_
#define _LANGUAGE_H_
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
#include <LocaleStrings.h>
#include <String.h>
#include <SupportDefs.h>
class BBitmap;
// We must not include the icu headers in there as it could mess up binary
// compatibility.
#ifndef U_ICU_NAMESPACE
#define U_ICU_NAMESPACE icu
#endif
namespace U_ICU_NAMESPACE {
class Locale;
}
enum script_direction {
B_LEFT_TO_RIGHT = 0,
B_RIGHT_TO_LEFT,
B_TOP_TO_BOTTOM, // seems not to be supported anywhere else?
};
class BLanguage {
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
public:
BLanguage();
BLanguage(const char* language);
BLanguage(const BLanguage& other);
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
~BLanguage();
status_t SetTo(const char* language);
status_t GetNativeName(BString& name) const;
status_t GetName(BString& name,
const BLanguage* displayLanguage = NULL
) const;
const char* GetString(uint32 id) const;
status_t GetIcon(BBitmap* result) const;
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
const char* Code() const;
// ISO-639-1
const char* CountryCode() const;
// ISO-3166
const char* ScriptCode() const;
// ISO-15924
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
const char* Variant() const;
const char* ID() const;
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
bool IsCountrySpecific() const;
bool IsVariant() const;
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
uint8 Direction() const;
BLanguage& operator=(const BLanguage& source);
class Private;
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
private:
friend class Private;
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
uint8 fDirection;
U_ICU_NAMESPACE::Locale* fICULocale;
};
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
#endif // _LANGUAGE_H_