PoorMan: use BMessageFormat.

This commit is contained in:
Adrien Destugues 2014-10-08 13:38:32 +02:00
parent be93029899
commit 0e7fcd84af
4 changed files with 14 additions and 15 deletions

View File

@ -8,22 +8,21 @@
#include "StatusSlider.h"
#include <stdio.h>
#include <MessageFormat.h>
StatusSlider::StatusSlider(const char* name, const char* label,
char* statusPrefix, BMessage* message, int32 minValue, int32 maxValue)
const char* statusPrefix, BMessage* message, int32 minValue, int32 maxValue)
:
BSlider(name, label, message, minValue, maxValue, B_HORIZONTAL),
BSlider(name, label, message, minValue, maxValue, B_HORIZONTAL),
fStatusPrefix(statusPrefix)
{
fTemp = fStr;
}
const char*
StatusSlider::UpdateText() const
{
sprintf(fTemp, "%" B_PRId32 " %s", Value(), fStatusPrefix);
return fTemp;
BMessageFormat().Format(fStr, fStatusPrefix, Value());
return fStr.String();
}

View File

@ -11,13 +11,14 @@
//#define BEOS_R5_COMPATIBLE
#include <Slider.h>
#include <String.h>
class StatusSlider: public BSlider {
public:
StatusSlider(const char* name,
const char* label,
char* statusPrefix,
const char* statusPrefix,
BMessage* message,
int32 minValue,
int32 maxValue);
@ -25,9 +26,8 @@ public:
virtual const char* UpdateText() const;
private:
char* fStatusPrefix;
char* fTemp;
char fStr[128];
const char* fStatusPrefix;
mutable BString fStr;
};
#endif

View File

@ -115,8 +115,8 @@ const char* STR_BBX_CONNECTION
= B_TRANSLATE("Connections");
const char* STR_SLD_LABEL
= B_TRANSLATE("Max. simultaneous connections:");
char* STR_SLD_STATUS_LABEL
= (char*)B_TRANSLATE("connections");
const char* STR_SLD_STATUS_LABEL
= B_TRANSLATE("{0, plural, one{# connection} other{# connections}}");
const char CMD_FILE_SAVE_AS
= 'S';

View File

@ -94,7 +94,7 @@ extern const char* STR_FILEPANEL_CREATE_LOG_FILE;
extern const char* STR_TAB_ADVANCED;
extern const char* STR_BBX_CONNECTION;
extern const char* STR_SLD_LABEL;
extern char* STR_SLD_STATUS_LABEL;
extern const char* STR_SLD_STATUS_LABEL;
extern const char CMD_FILE_SAVE_AS;
extern const char CMD_FILE_QUIT;