Skip to content

Commit

Permalink
fix text for demo
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangjipeng committed Sep 28, 2024
1 parent 0f36faf commit 1862ff8
Show file tree
Hide file tree
Showing 24 changed files with 140 additions and 303 deletions.
42 changes: 12 additions & 30 deletions examples/touchweb/src/about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
About::About(Widget* parent)
: DashLayer(parent)
, m_main(0)
, m_url(0, 0, 0, 0)
, m_conn(0, 0, 0, 0)
, m_email(0, 0, 0, 0)
, m_click(0)
{
setTitle(U("¹ØÓÚ"));
setCommitText(U("·µ»Ø"));
setTitle(U("About"));
setCommitText(U("Back"));
setCancel(false);
}

Expand All @@ -51,8 +50,7 @@ void About::OnCreate(uint32_t flags, int x, int y, int w, int h)
DashLayer::OnCreate(flags, x, y, w, h);

int b = DASH_TITLE_HEIGHT / 30;
m_url = Rect(b * 75, b * 150, b * 135, b * 12);
m_conn = Rect(b * 75, b * 170, b * 140, b * 12);
m_email = Rect(b * 75, b * 150, b * 135, b * 12);
}

void About::OnPaint(ps_context* gc, const Rect* r)
Expand Down Expand Up @@ -83,8 +81,7 @@ void About::OnPaint(ps_context* gc, const Rect* r)
of = ps_set_font(gc, f);
ps_text_out_length(gc, b * 85, b * 100, VERSION_STRING, strlen(VERSION_STRING));

ps_wide_text_out_length(gc, b * 15, b * 150, P16(U("¹Ù·½Ö÷Ò³:")), 5);
ps_wide_text_out_length(gc, b * 15, b * 170, P16(U("ÁªÏµÎÒÃÇ:")), 5);
ps_wide_text_out_length(gc, b * 15, b * 150, P16(U("Email:")), 6);
if (m_click) {
ps_color tc = {1, 0, 0, 1};
ps_set_text_color(gc, &tc);
Expand All @@ -94,13 +91,8 @@ void About::OnPaint(ps_context* gc, const Rect* r)
}

rr = *r;
if (rr.intersect(m_url)) {
ps_wide_text_out_length(gc, b * 75, b * 150, P16(U("http://www.zncsoft.com")), 22);
}

rr = *r;
if (rr.intersect(m_conn)) {
ps_wide_text_out_length(gc, b * 75, b * 170, P16(U("http://conn.zncsoft.com")), 23);
if (rr.intersect(m_email)) {
ps_wide_text_out_length(gc, b * 75, b * 150, P16(U("onecoolx@gmail.com")), 18);
}

ps_set_font(gc, of);
Expand All @@ -113,16 +105,10 @@ void About::link_click(void* p)
int click = (intptr_t)p;

if (click == 1) {
Update(&m_url);
TabPage* p = Application::getInstance()->getMainWindow()->getTabs();
if (!p->newView("http://www.zncsoft.com")) {
p->getActiveView()->loadUrl("http://www.zncsoft.com");
}
} else if (click == 2) {
Update(&m_conn);
Update(&m_email);
TabPage* p = Application::getInstance()->getMainWindow()->getTabs();
if (!p->newView("http://www.zncsoft.com/concent.html")) {
p->getActiveView()->loadUrl("http://www.zncsoft.com/concent.html");
if (!p->newView("MailTo")) {
p->getActiveView()->loadUrl("http://mail.google.com");
}
}
Commit();
Expand All @@ -133,18 +119,14 @@ void About::OnMouseEvent(const MouseEvent* e)
{
DashLayer::OnMouseEvent(e);
if (e->type() == MouseEvent::MouseDown) {
if (m_url.contains(e->x(), e->y())) {
if (m_email.contains(e->x(), e->y())) {
m_click = 1;
} else if (m_conn.contains(e->x(), e->y())) {
m_click = 2;
} else {
m_click = 0;
}

if (m_click == 1) {
Update(&m_url);
} else if (m_click == 2) {
Update(&m_conn);
Update(&m_email);
}
} else if (e->type() == MouseEvent::MouseUp) {
if (m_click) {
Expand Down
3 changes: 1 addition & 2 deletions examples/touchweb/src/about.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class About : public DashLayer
private:
void link_click(void* p);
MainWindow* m_main;
Rect m_url;
Rect m_conn;
Rect m_email;
int m_click;
};

Expand Down
2 changes: 1 addition & 1 deletion examples/touchweb/src/addressbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ AddressBar::AddressBar(Widget* parent)
, m_sy(0)
{
m_btn = new NavButton(this);
m_tip = ustring(U("ÊäÈëÍøÖ·»òËÑË÷¹Ø¼ü×Ö"));
m_tip = ustring(U("Enter url or search keyword"));
}

AddressBar::~AddressBar()
Expand Down
8 changes: 4 additions & 4 deletions examples/touchweb/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
#define GLOBAL_SCALE 1
#endif

#define TOOLBAR_HEIGHT (SETUI(30)*GLOBAL_SCALE)
#define TOOLBAR_HEIGHT (SETUI(48)*GLOBAL_SCALE)

#define TITLE_HEIGHT (SETUI(22)*GLOBAL_SCALE)
#define TITLE_HEIGHT (SETUI(36)*GLOBAL_SCALE)

#define DASH_TITLE_HEIGHT (SETUI(30)*GLOBAL_SCALE)
#define DASH_TITLE_HEIGHT (SETUI(48)*GLOBAL_SCALE)

#define BUTTON_HEIGHT (TITLE_HEIGHT*1.4)

Expand Down Expand Up @@ -69,7 +69,7 @@
#define LINUX 1
typedef unsigned short uchar_t;
typedef std::basic_string<uchar_t> ustring;
#define U(text) ((uchar_t*)(L##text))
#define U(text) ((uchar_t*)(u##text))
#define DATA_PATH(path) path
#define FILENAME_UNICODE 0
#endif
Expand Down
12 changes: 6 additions & 6 deletions examples/touchweb/src/contextmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,18 @@ void ContextMenu::OnPaint(ps_context* gc, const Rect* r)
#endif

if (!m_link.empty()) {
ps_wide_text_out_length(gc, m_open.x + 2 * b, m_open.y + (TOOLBAR_HEIGHT - s) / 2, (ps_uchar16*)U("´ò¿ªÁ¬½Ó"), 4);
ps_wide_text_out_length(gc, m_open.x + 2 * b, m_open.y + (TOOLBAR_HEIGHT - s) / 2, (ps_uchar16*)U("Open Link"), 9);
if (!m_easy) {
ps_wide_text_out_length(gc, m_nwin.x + 2 * b, m_nwin.y + (TOOLBAR_HEIGHT - s) / 2, (ps_uchar16*)U("ÔÚд°¿Ú´ò¿ª"), 6);
ps_wide_text_out_length(gc, m_bopen.x + 2 * b, m_bopen.y + (TOOLBAR_HEIGHT - s) / 2, (ps_uchar16*)U("ÔÚºǫ́´ò¿ª"), 5);
ps_wide_text_out_length(gc, m_nwin.x + 2 * b, m_nwin.y + (TOOLBAR_HEIGHT - s) / 2, (ps_uchar16*)U("Open in new window"), 18);
ps_wide_text_out_length(gc, m_bopen.x + 2 * b, m_bopen.y + (TOOLBAR_HEIGHT - s) / 2, (ps_uchar16*)U("Open in background"), 18);
}
}

if (!m_imglink.empty()) {
ps_wide_text_out_length(gc, m_imgopen.x + 2 * b, m_imgopen.y + (TOOLBAR_HEIGHT - s) / 2, (ps_uchar16*)U("´ò¿ªÍ¼Æ¬"), 4);
ps_wide_text_out_length(gc, m_imgopen.x + 2 * b, m_imgopen.y + (TOOLBAR_HEIGHT - s) / 2, (ps_uchar16*)U("Open Link"), 9);
if (!m_easy) {
ps_wide_text_out_length(gc, m_imgwin.x + 2 * b, m_imgwin.y + (TOOLBAR_HEIGHT - s) / 2, (ps_uchar16*)U("ÔÚд°¿Ú´ò¿ªÍ¼Æ¬"), 8);
ps_wide_text_out_length(gc, m_imgbopen.x + 2 * b, m_imgbopen.y + (TOOLBAR_HEIGHT - s) / 2, (ps_uchar16*)U("ÔÚºǫ́´ò¿ªÍ¼Æ¬"), 7);
ps_wide_text_out_length(gc, m_imgwin.x + 2 * b, m_imgwin.y + (TOOLBAR_HEIGHT - s) / 2, (ps_uchar16*)U("Open in new window"), 18);
ps_wide_text_out_length(gc, m_imgbopen.x + 2 * b, m_imgbopen.y + (TOOLBAR_HEIGHT - s) / 2, (ps_uchar16*)U("Open in background"), 18);
}
}

Expand Down
32 changes: 16 additions & 16 deletions examples/touchweb/src/ctrlpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ CtrlPanel::CtrlPanel(Widget* parent)
, m_main(0)
, m_btn(0)
{
setTitle(U("¹¦ÄÜÃæ°å"));
setTitle(U("Panel"));
}

CtrlPanel::~CtrlPanel()
Expand Down Expand Up @@ -102,8 +102,8 @@ static void draw_history_btn(ps_context* gc, const ps_rect& r)

ps_set_text_color(gc, &c);
ps_set_line_width(gc, br / 2);
ps_wide_text_out_length(gc, r.x + r.w / 2 - DASH_TITLE_HEIGHT / 5 * 2,
r.y + r.h - DASH_TITLE_HEIGHT / 2, (ps_uchar16*)U("ÀúÊ·"), 2);
ps_wide_text_out_length(gc, r.x + r.w / 2 - DASH_TITLE_HEIGHT / 5 * 3.5f,
r.y + r.h - DASH_TITLE_HEIGHT / 2, (ps_uchar16*)U("History"), 7);
}

static void draw_favorite_btn(ps_context* gc, const ps_rect& r)
Expand Down Expand Up @@ -138,8 +138,8 @@ static void draw_favorite_btn(ps_context* gc, const ps_rect& r)
ps_set_gamma(gc, gamma);

ps_set_text_color(gc, &c);
ps_wide_text_out_length(gc, r.x + r.w / 2 - DASH_TITLE_HEIGHT / 5 * 2,
r.y + r.h - DASH_TITLE_HEIGHT / 2, (ps_uchar16*)U("ÊÕ²Ø"), 2);
ps_wide_text_out_length(gc, r.x + r.w / 2 - DASH_TITLE_HEIGHT / 5 * 4,
r.y + r.h - DASH_TITLE_HEIGHT / 2, (ps_uchar16*)U("Favorite"), 8);
}

static void draw_full_btn(ps_context* gc, const ps_rect& r)
Expand All @@ -164,8 +164,8 @@ static void draw_full_btn(ps_context* gc, const ps_rect& r)
ps_fill(gc);

ps_set_text_color(gc, &c);
ps_wide_text_out_length(gc, r.x + r.w / 2 - DASH_TITLE_HEIGHT / 5 * 2,
r.y + r.h - DASH_TITLE_HEIGHT / 2, (ps_uchar16*)U("È«ÆÁ"), 2);
ps_wide_text_out_length(gc, r.x + r.w / 2 - DASH_TITLE_HEIGHT / 5 * 5,
r.y + r.h - DASH_TITLE_HEIGHT / 2, (ps_uchar16*)U("FullScreen"), 10);
}

static void draw_newpage_btn(ps_context* gc, const ps_rect& r)
Expand Down Expand Up @@ -194,8 +194,8 @@ static void draw_newpage_btn(ps_context* gc, const ps_rect& r)

ps_set_line_width(gc, 1);
ps_set_text_color(gc, &c);
ps_wide_text_out_length(gc, r.x + r.w / 2 - DASH_TITLE_HEIGHT / 5 * 3,
r.y + r.h - DASH_TITLE_HEIGHT / 2, (ps_uchar16*)U("ÐÂÒ³Ãæ"), 3);
ps_wide_text_out_length(gc, r.x + r.w / 2 - DASH_TITLE_HEIGHT / 5 * 4.5f,
r.y + r.h - DASH_TITLE_HEIGHT / 2, (ps_uchar16*)U("NewPage"), 7);
}

static void draw_exit_btn(ps_context* gc, const ps_rect& r)
Expand Down Expand Up @@ -223,7 +223,7 @@ static void draw_exit_btn(ps_context* gc, const ps_rect& r)
ps_set_line_width(gc, 1);
ps_set_text_color(gc, &c);
ps_wide_text_out_length(gc, r.x + r.w / 2 - DASH_TITLE_HEIGHT / 5 * 2,
r.y + r.h - DASH_TITLE_HEIGHT / 2, (ps_uchar16*)U("Í˳ö"), 2);
r.y + r.h - DASH_TITLE_HEIGHT / 2, (ps_uchar16*)U("Exit"), 4);
}

static void draw_config_btn(ps_context* gc, const ps_rect& r)
Expand Down Expand Up @@ -270,8 +270,8 @@ static void draw_config_btn(ps_context* gc, const ps_rect& r)
ps_fill(gc);

ps_set_text_color(gc, &c);
ps_wide_text_out_length(gc, r.x + r.w / 2 - DASH_TITLE_HEIGHT / 5 * 2,
r.y + r.h - DASH_TITLE_HEIGHT / 2, (ps_uchar16*)U("ÉèÖÃ"), 2);
ps_wide_text_out_length(gc, r.x + r.w / 2 - DASH_TITLE_HEIGHT / 5 * 3.5f,
r.y + r.h - DASH_TITLE_HEIGHT / 2, (ps_uchar16*)U("Setting"), 7);
}

static void draw_mode_btn(ps_context* gc, const ps_rect& r)
Expand Down Expand Up @@ -331,8 +331,8 @@ static void draw_mode_btn(ps_context* gc, const ps_rect& r)
ps_set_line_width(gc, 1);

ps_set_text_color(gc, &c);
ps_wide_text_out_length(gc, r.x + r.w / 2 - DASH_TITLE_HEIGHT / 5 * 2,
r.y + r.h - DASH_TITLE_HEIGHT / 2, (ps_uchar16*)U("ģʽ"), 2);
ps_wide_text_out_length(gc, r.x + r.w / 2 - DASH_TITLE_HEIGHT / 5 * 5,
r.y + r.h - DASH_TITLE_HEIGHT / 2, (ps_uchar16*)U("ViewMode"), 8);
}

static void draw_search_btn(ps_context* gc, const ps_rect& r)
Expand All @@ -359,8 +359,8 @@ static void draw_search_btn(ps_context* gc, const ps_rect& r)
ps_stroke(gc);

ps_set_text_color(gc, &c);
ps_wide_text_out_length(gc, r.x + r.w / 2 - DASH_TITLE_HEIGHT / 5 * 2,
r.y + r.h - DASH_TITLE_HEIGHT / 2, (ps_uchar16*)U("ËÑË÷"), 2);
ps_wide_text_out_length(gc, r.x + r.w / 2 - DASH_TITLE_HEIGHT / 5 * 3,
r.y + r.h - DASH_TITLE_HEIGHT / 2, (ps_uchar16*)U("Search"), 6);
}

void CtrlPanel::draw_buttons(ps_context* gc, const Rect& r)
Expand Down
4 changes: 2 additions & 2 deletions examples/touchweb/src/dashlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ DashLayer::DashLayer(Widget* parent)
, m_scanbtn(true)
, m_btn(0)
{
setCommitText(U("È·¶¨"));
setCancelText(U("È¡Ïû"));
setCommitText(U("Ok"));
setCancelText(U("Cancel"));
}

DashLayer::~DashLayer()
Expand Down
16 changes: 8 additions & 8 deletions examples/touchweb/src/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ void MsgDialog::draw_btns(ps_context* gc)
ps_gradient_unref(g);
}

draw_btnText(gc, U("È·¶¨"), m_commit);
draw_btnText(gc, U("Ok"), m_commit);
draw_light(gc, m_commit);
}

Expand Down Expand Up @@ -282,7 +282,7 @@ void MsgDialog::draw_btns(ps_context* gc)
ps_gradient_unref(g);
}

draw_btnText(gc, U("È¡Ïû"), m_cancel);
draw_btnText(gc, U("Cancel"), m_cancel);
draw_light(gc, m_cancel);
}
}
Expand Down Expand Up @@ -513,7 +513,7 @@ void InputDialog::draw_btns(ps_context* gc)
ps_gradient_unref(g);
}

draw_btnText(gc, U("È·¶¨"), m_commit);
draw_btnText(gc, U("Ok"), m_commit);
draw_light(gc, m_commit);
}

Expand Down Expand Up @@ -545,7 +545,7 @@ void InputDialog::draw_btns(ps_context* gc)
ps_gradient_unref(g);
}

draw_btnText(gc, U("È¡Ïû"), m_cancel);
draw_btnText(gc, U("Cancel"), m_cancel);
draw_light(gc, m_cancel);
}
}
Expand Down Expand Up @@ -745,7 +745,7 @@ void LoginDialog::draw_btns(ps_context* gc)
ps_gradient_unref(g);
}

draw_btnText(gc, U("È·¶¨"), m_commit);
draw_btnText(gc, U("Ok"), m_commit);
draw_light(gc, m_commit);
}

Expand Down Expand Up @@ -777,7 +777,7 @@ void LoginDialog::draw_btns(ps_context* gc)
ps_gradient_unref(g);
}

draw_btnText(gc, U("È¡Ïû"), m_cancel);
draw_btnText(gc, U("Cancel"), m_cancel);
draw_light(gc, m_cancel);
}
}
Expand All @@ -803,8 +803,8 @@ void LoginDialog::OnPaint(ps_context* gc, const Rect* d)
#endif

int b = TITLE_HEIGHT / 22;
ps_wide_text_out_length(gc, b * 5, titleHeight() + b * 8, (ps_uchar16*)U("̞:"), 4);
ps_wide_text_out_length(gc, b * 5, titleHeight() + b * 16 + TOOLBAR_HEIGHT / 3 * 2, (ps_uchar16*)U("ÃÜ Âë:"), 5);
ps_wide_text_out_length(gc, b * 5, titleHeight() + b * 8, (ps_uchar16*)U("UserName:"), 9);
ps_wide_text_out_length(gc, b * 5, titleHeight() + b * 16 + TOOLBAR_HEIGHT / 3 * 2, (ps_uchar16*)U("PassWord:"), 9);

draw_btns(gc);

Expand Down
Loading

0 comments on commit 1862ff8

Please sign in to comment.