comparison window/widget.cc @ 65:4416cfac86ae

Convert EUC-JP files to UTF8
author Thibaut Girka <thib@sitedethib.com>
date Fri, 26 Nov 2010 10:53:15 +0100
parents ddbcbd000206
children
comparison
equal deleted inserted replaced
64:045ca45f9610 65:4416cfac86ae
140 container.DeleteGlobalMotionFunc(&Motionfunc, (void*)this); 140 container.DeleteGlobalMotionFunc(&Motionfunc, (void*)this);
141 } 141 }
142 142
143 bool MouseCursor::Motionfunc(int x, int y, void* pointer) { 143 bool MouseCursor::Motionfunc(int x, int y, void* pointer) {
144 MouseCursor* _this = (MouseCursor*)pointer; 144 MouseCursor* _this = (MouseCursor*)pointer;
145 // 左上がカーソルポイントの場合 145 // 綏筝若純ゃ潟翫
146 // _this->Pic()->Move(x,y); 146 // _this->Pic()->Move(x,y);
147 // 左下がカーソルポイントの場合 147 // 綏筝若純ゃ潟翫
148 _this->Pic()->Move(x,y-_this->Pic()->Height()); 148 _this->Pic()->Move(x,y-_this->Pic()->Height());
149 return true; 149 return true;
150 } 150 }
151 151
152 Button::Button(Event::Container& container, PicContainer* parent, const char* s, int _sx, int _sy, int _sdx, int _sdy, int _nptn, const Rect& r, int _z) : sx(_sx), sy(_sy), sdx(_sdx), sdy(_sdy), nptn(_nptn) ,Event::Video(container,r, _z) { 152 Button::Button(Event::Container& container, PicContainer* parent, const char* s, int _sx, int _sy, int _sdx, int _sdy, int _nptn, const Rect& r, int _z) : sx(_sx), sy(_sy), sdx(_sdx), sdy(_sdy), nptn(_nptn) ,Event::Video(container,r, _z) {
194 void Button::Toggle(bool new_toggle) { 194 void Button::Toggle(bool new_toggle) {
195 if (is_toggled == new_toggle) { 195 if (is_toggled == new_toggle) {
196 return; 196 return;
197 } 197 }
198 is_toggled = new_toggle; 198 is_toggled = new_toggle;
199 // if (is_in) return; // is_in に関わらずウィジットの表示を変更することにする 199 // if (is_in) return; // is_in ≪c吾茵腓冴紊眼
200 if (is_toggled) { 200 if (is_toggled) {
201 if (nptn > 2) 201 if (nptn > 2)
202 Pic()->SetSurfacePos(sx+sdx*2, sy+sdy*2); 202 Pic()->SetSurfacePos(sx+sdx*2, sy+sdy*2);
203 else if (nptn > 1) 203 else if (nptn > 1)
204 Pic()->SetSurfacePos(sx+sdx, sy+sdy); 204 Pic()->SetSurfacePos(sx+sdx, sy+sdy);
250 extern char* create_button(int number, int& width, int& height, int r, int g, int b); 250 extern char* create_button(int number, int& width, int& height, int r, int g, int b);
251 extern char* create_box(int& width, int& height, int r, int g, int b); 251 extern char* create_box(int& width, int& height, int r, int g, int b);
252 252
253 void Scale::Init(Rect r_orig) { 253 void Scale::Init(Rect r_orig) {
254 int r=cursor_color.r, g=cursor_color.g, b=cursor_color.b; 254 int r=cursor_color.r, g=cursor_color.g, b=cursor_color.b;
255 // 矢印 255 // √
256 int arrow_width = -1; 256 int arrow_width = -1;
257 cursor_width = -1; 257 cursor_width = -1;
258 char* button1; 258 char* button1;
259 char* button2; 259 char* button2;
260 if (is_vertical) { 260 if (is_vertical) {
261 // 矢印に必要な領域確保 261 // √違綽荀腆坂
262 int arrow_height = r_orig.width(); 262 int arrow_height = r_orig.width();
263 button1 = create_button(2, arrow_height, arrow_width, r, g, b); 263 button1 = create_button(2, arrow_height, arrow_width, r, g, b);
264 button2 = create_button(3, arrow_height, arrow_width, r, g, b); 264 button2 = create_button(3, arrow_height, arrow_width, r, g, b);
265 if (r_orig.height() < arrow_width*4) { 265 if (r_orig.height() < arrow_width*4) {
266 if (r_orig.height() < 8) r_orig.by = r_orig.ty + 8; // 小さすぎる場合は強制変更 266 if (r_orig.height() < 8) r_orig.by = r_orig.ty + 8; // 絨翫綣桁九
267 free( (void*)button1); 267 free( (void*)button1);
268 free( (void*)button2); 268 free( (void*)button2);
269 arrow_width = r_orig.height()/4; 269 arrow_width = r_orig.height()/4;
270 // 再割り当て 270 // 蚊綵
271 button1 = create_button(2, arrow_height, arrow_width, r, g, b); 271 button1 = create_button(2, arrow_height, arrow_width, r, g, b);
272 button2 = create_button(3, arrow_height, arrow_width, r, g, b); 272 button2 = create_button(3, arrow_height, arrow_width, r, g, b);
273 } 273 }
274 // 矢印ボタンの作成 274 // √違帥潟篏
275 Surface* a1s = parent->Root().NewSurfaceFromRGBAData(arrow_height, arrow_width*3, button1, ALPHA_MASK); 275 Surface* a1s = parent->Root().NewSurfaceFromRGBAData(arrow_height, arrow_width*3, button1, ALPHA_MASK);
276 int x = r_orig.lx; int y = r_orig.ty; 276 int x = r_orig.lx; int y = r_orig.ty;
277 arrow_up = new Button(container, parent, a1s, 0, 0, 0, arrow_width, 3, Rect(x,y,x+arrow_height,y+arrow_width),1); 277 arrow_up = new Button(container, parent, a1s, 0, 0, 0, arrow_width, 3, Rect(x,y,x+arrow_height,y+arrow_width),1);
278 arrow_up->Pic()->SetSurfaceFreeFlag(); 278 arrow_up->Pic()->SetSurfaceFreeFlag();
279 Surface* a2s = parent->Root().NewSurfaceFromRGBAData(arrow_height, arrow_width*3, button2, ALPHA_MASK); 279 Surface* a2s = parent->Root().NewSurfaceFromRGBAData(arrow_height, arrow_width*3, button2, ALPHA_MASK);
280 x = r_orig.rx - arrow_height; y = r_orig.by - arrow_width; 280 x = r_orig.rx - arrow_height; y = r_orig.by - arrow_width;
281 arrow_down = new Button(container, parent, a2s, 0, 0, 0, arrow_width, 3, Rect(x,y,x+arrow_height,y+arrow_width),1); 281 arrow_down = new Button(container, parent, a2s, 0, 0, 0, arrow_width, 3, Rect(x,y,x+arrow_height,y+arrow_width),1);
282 arrow_down->Pic()->SetSurfaceFreeFlag(); 282 arrow_down->Pic()->SetSurfaceFreeFlag();
283 // picture作成(ボタンの動く領域) 283 // picture篏鐚帥潟鐚
284 Rect r = r_orig; 284 Rect r = r_orig;
285 r.ty += arrow_width; 285 r.ty += arrow_width;
286 r.by -= arrow_width; 286 r.by -= arrow_width;
287 panel = parent->create_node(r, 0); 287 panel = parent->create_node(r, 0);
288 SetPic(panel); 288 SetPic(panel);
289 // ボタンの中心線を描画、設定 289 // 帥潟筝綽膩祉荐絎
290 Surface* s = parent->Root().NewSurface(r.width()/2, r.height(), ALPHA_MASK); 290 Surface* s = parent->Root().NewSurface(r.width()/2, r.height(), ALPHA_MASK);
291 DSurfaceFill(s, Rect(0,0,r.width()/2,r.height()), 0, 0, 0, 0xff); 291 DSurfaceFill(s, Rect(0,0,r.width()/2,r.height()), 0, 0, 0, 0xff);
292 Pic()->SetSurface(s, -r.width()/4, 0, 0); 292 Pic()->SetSurface(s, -r.width()/4, 0, 0);
293 Pic()->SetSurfaceFreeFlag(); 293 Pic()->SetSurfaceFreeFlag();
294 } else { 294 } else {
295 // 矢印に必要な領域確保 295 // √違綽荀腆坂
296 int arrow_height = r_orig.height(); 296 int arrow_height = r_orig.height();
297 button1 = create_button(0, arrow_width, arrow_height, r, g, b); 297 button1 = create_button(0, arrow_width, arrow_height, r, g, b);
298 button2 = create_button(1, arrow_width, arrow_height, r, g, b); 298 button2 = create_button(1, arrow_width, arrow_height, r, g, b);
299 if (r_orig.width() < arrow_width*4) { 299 if (r_orig.width() < arrow_width*4) {
300 if (r_orig.width() < 8) r_orig.rx = r_orig.lx + 8; // 小さすぎる場合は強制変更 300 if (r_orig.width() < 8) r_orig.rx = r_orig.lx + 8; // 絨翫綣桁九
301 free( (void*)button1); 301 free( (void*)button1);
302 free( (void*)button2); 302 free( (void*)button2);
303 arrow_width = r_orig.width()/4; 303 arrow_width = r_orig.width()/4;
304 // 再割り当て 304 // 蚊綵
305 button1 = create_button(2, arrow_width, arrow_height, r, g, b); 305 button1 = create_button(2, arrow_width, arrow_height, r, g, b);
306 button2 = create_button(3, arrow_width, arrow_height, r, g, b); 306 button2 = create_button(3, arrow_width, arrow_height, r, g, b);
307 } 307 }
308 // 矢印ボタンの作成 308 // √違帥潟篏
309 Surface* a1s = parent->Root().NewSurfaceFromRGBAData(arrow_width, arrow_height*3, button1, ALPHA_MASK); 309 Surface* a1s = parent->Root().NewSurfaceFromRGBAData(arrow_width, arrow_height*3, button1, ALPHA_MASK);
310 int x = r_orig.lx; int y = r_orig.ty; 310 int x = r_orig.lx; int y = r_orig.ty;
311 arrow_up = new Button(container, parent, a1s, 0, 0, 0, arrow_height, 3, Rect(x,y,x+arrow_width,y+arrow_height),1); 311 arrow_up = new Button(container, parent, a1s, 0, 0, 0, arrow_height, 3, Rect(x,y,x+arrow_width,y+arrow_height),1);
312 arrow_up->Pic()->SetSurfaceFreeFlag(); 312 arrow_up->Pic()->SetSurfaceFreeFlag();
313 Surface* a2s = parent->Root().NewSurfaceFromRGBAData(arrow_width, arrow_height*3, button2, ALPHA_MASK); 313 Surface* a2s = parent->Root().NewSurfaceFromRGBAData(arrow_width, arrow_height*3, button2, ALPHA_MASK);
314 x = r_orig.rx - arrow_width; y = r_orig.by - arrow_height; 314 x = r_orig.rx - arrow_width; y = r_orig.by - arrow_height;
315 arrow_down = new Button(container, parent, a2s, 0, 0, 0, arrow_height, 3, Rect(x,y,x+arrow_width,y+arrow_height),1); 315 arrow_down = new Button(container, parent, a2s, 0, 0, 0, arrow_height, 3, Rect(x,y,x+arrow_width,y+arrow_height),1);
316 arrow_down->Pic()->SetSurfaceFreeFlag(); 316 arrow_down->Pic()->SetSurfaceFreeFlag();
317 // picture作成(ボタンの動く領域) 317 // picture篏鐚帥潟鐚
318 Rect r = r_orig; 318 Rect r = r_orig;
319 r.lx += arrow_width; 319 r.lx += arrow_width;
320 r.rx -= arrow_width; 320 r.rx -= arrow_width;
321 panel = parent->create_node(r, 0); 321 panel = parent->create_node(r, 0);
322 SetPic(panel); 322 SetPic(panel);
323 // ボタンの中心線を描画、設定 323 // 帥潟筝綽膩祉荐絎
324 Surface* s = parent->Root().NewSurface(r.width(), r.height()/2, ALPHA_MASK); 324 Surface* s = parent->Root().NewSurface(r.width(), r.height()/2, ALPHA_MASK);
325 DSurfaceFill(s, Rect(0,0,r.width(),r.height()/2), 0, 0, 0, 0xff); 325 DSurfaceFill(s, Rect(0,0,r.width(),r.height()/2), 0, 0, 0, 0xff);
326 Pic()->SetSurface(s, 0, -r.height()/4, 0); 326 Pic()->SetSurface(s, 0, -r.height()/4, 0);
327 Pic()->SetSurfaceFreeFlag(); 327 Pic()->SetSurfaceFreeFlag();
328 } 328 }
342 cursor = NULL; 342 cursor = NULL;
343 Rect region(0,0); 343 Rect region(0,0);
344 if (width_ratio < 0) width_ratio = 0; 344 if (width_ratio < 0) width_ratio = 0;
345 else if (width_ratio > 1024) width_ratio = 1024; 345 else if (width_ratio > 1024) width_ratio = 1024;
346 if (is_vertical) { 346 if (is_vertical) {
347 if (width_ratio == 0) cursor_width = Pic()->Width() * 3 / 2; // 幅の1.5倍 347 if (width_ratio == 0) cursor_width = Pic()->Width() * 3 / 2; // 綛1.5
348 else cursor_width = Pic()->Height()*width_ratio/1024; 348 else cursor_width = Pic()->Height()*width_ratio/1024;
349 if (cursor_width <= 0) return; // カーソルなし(いいのか?) 349 if (cursor_width <= 0) return; // 若純鐚鐚鐚
350 region = Rect(0, 0, Pic()->Width(), cursor_width); 350 region = Rect(0, 0, Pic()->Width(), cursor_width);
351 } else { // horizontal 351 } else { // horizontal
352 if (width_ratio == 0) cursor_width = Pic()->Height() * 3 / 2; // 高さの1.5倍 352 if (width_ratio == 0) cursor_width = Pic()->Height() * 3 / 2; // 蕭1.5
353 else cursor_width = Pic()->Width()*width_ratio/1024; 353 else cursor_width = Pic()->Width()*width_ratio/1024;
354 if (cursor_width <= 0) return; // カーソルなし(いいのか?) 354 if (cursor_width <= 0) return; // 若純鐚鐚鐚
355 region = Rect(0, 0, cursor_width, Pic()->Height()); 355 region = Rect(0, 0, cursor_width, Pic()->Height());
356 } 356 }
357 357
358 int height = region.height(); 358 int height = region.height();
359 int width = region.width(); 359 int width = region.width();
366 cursor->press_pointer = (void*)this; 366 cursor->press_pointer = (void*)this;
367 cursor->drag_func = &Scale::DragCursor; 367 cursor->drag_func = &Scale::DragCursor;
368 cursor->drag_pointer = (void*)this; 368 cursor->drag_pointer = (void*)this;
369 cursor->show(); 369 cursor->show();
370 370
371 // 矢印等をクリックしたときの移動量計算 371 // √亥腱糸頥膊
372 int bar_width; 372 int bar_width;
373 if (is_vertical) bar_width = Pic()->Height(); 373 if (is_vertical) bar_width = Pic()->Height();
374 else bar_width = Pic()->Width(); 374 else bar_width = Pic()->Width();
375 if (bar_width <= 0) value_add = max-min; 375 if (bar_width <= 0) value_add = max-min;
376 else if (cursor_width == 0) value_add = 2; 376 else if (cursor_width == 0) value_add = 2;
477 Button(container, parent, (Surface*)0, 0, 0, 0, 0, 0, r_orig, _z), 477 Button(container, parent, (Surface*)0, 0, 0, 0, 0, 0, r_orig, _z),
478 root(parent->Root()), surface(0), attribute(attr), text_size(_text_size), 478 root(parent->Root()), surface(0), attribute(attr), text_size(_text_size),
479 fore(_fore), pressed(_pressed), back(_back) 479 fore(_fore), pressed(_pressed), back(_back)
480 { 480 {
481 bool rect_changed = false; 481 bool rect_changed = false;
482 // まず、テキスト領域の広さを得る 482 // 障鴻綺緇
483 Rect r(r_orig); 483 Rect r(r_orig);
484 484
485 if (text == NULL) text = ""; 485 if (text == NULL) text = "";
486 int width = r.width(); int height = r.height(); 486 int width = r.width(); int height = r.height();
487 if (width == 0) width = parent->Width() - r.lx; 487 if (width == 0) width = parent->Width() - r.lx;
488 488
489 TextStream ts = TextStream::ParseMoji(text, _fore.r , _fore.g, _fore.b, text_size); 489 TextStream ts = TextStream::ParseMoji(text, _fore.r , _fore.g, _fore.b, text_size);
490 TextGlyphStream gs = DefaultLayout(text_size)->Layout(ts, width); 490 TextGlyphStream gs = DefaultLayout(text_size)->Layout(ts, width);
491 491
492 if (r.width() == 0) { // 文字に合わせてウィジット作成 492 if (r.width() == 0) { // 絖c吾篏
493 rect_changed = true; 493 rect_changed = true;
494 width = gs.width() + text_size; 494 width = gs.width() + text_size;
495 r.rx = r.lx + gs.width(); 495 r.rx = r.lx + gs.width();
496 attribute = Attribute(attribute | CENTER); 496 attribute = Attribute(attribute | CENTER);
497 } 497 }
500 if (attribute & NOPADDING) r.by = r.ty + gs.height(); 500 if (attribute & NOPADDING) r.by = r.ty + gs.height();
501 else r.by = r.ty + gs.height() + text_size/2; 501 else r.by = r.ty + gs.height() + text_size/2;
502 } 502 }
503 503
504 if (rect_changed) { 504 if (rect_changed) {
505 // 大きさ変更 505 // 紊с紊
506 Pic()->SetSurfaceRect(r); 506 Pic()->SetSurfaceRect(r);
507 } 507 }
508 508
509 sx = 0; sy = 0; sdx = 0; 509 sx = 0; sy = 0; sdx = 0;
510 sdy = r.height(); 510 sdy = r.height();
513 if (attribute & CENTER) 513 if (attribute & CENTER)
514 x = (Pic()->Width() - gs.width()) / 2; 514 x = (Pic()->Width() - gs.width()) / 2;
515 y = (Pic()->Height() - gs.height()) / 2; 515 y = (Pic()->Height() - gs.height()) / 2;
516 516
517 //FIXME: (back.a == NULL ?) 517 //FIXME: (back.a == NULL ?)
518 if (back.a == 0) { // 背景なし、もしくはボタン押の状態のみ背景あり 518 if (back.a == 0) { // 帥恰若倶粋
519 surface = root.NewSurface(r.width(), r.height()*2, ALPHA_MASK); 519 surface = root.NewSurface(r.width(), r.height()*2, ALPHA_MASK);
520 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0); 520 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0);
521 if (attribute & REVERSE) { 521 if (attribute & REVERSE) {
522 DSurfaceFill(surface, Rect(0,r.height(),r.width(),r.height()*2), pressed.r, pressed.g, pressed.b, 0xff); 522 DSurfaceFill(surface, Rect(0,r.height(),r.width(),r.height()*2), pressed.r, pressed.g, pressed.b, 0xff);
523 } 523 }
530 gs.SetReverse(false); 530 gs.SetReverse(false);
531 } else { 531 } else {
532 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0,0,gs.width(),gs.height()), surface, Rect(x,y+r.height())); 532 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0,0,gs.width(),gs.height()), surface, Rect(x,y+r.height()));
533 } 533 }
534 nptn = 2; 534 nptn = 2;
535 } else { // ボタン型の背景あり 535 } else { // 帥喝
536 /* ラベル用の Surface を作る */ 536 /* Surface 篏 */
537 width = r.width(); height = r.height(); 537 width = r.width(); height = r.height();
538 char* box = create_box(width, height, back.r, back.g, back.b); 538 char* box = create_box(width, height, back.r, back.g, back.b);
539 surface = root.NewSurfaceFromRGBAData(r.width(), r.height()*3, box, ALPHA_MASK); 539 surface = root.NewSurfaceFromRGBAData(r.width(), r.height()*3, box, ALPHA_MASK);
540 540
541 Surface* text_surface = root.NewSurface(r.width(), r.height(), ALPHA_MASK); 541 Surface* text_surface = root.NewSurface(r.width(), r.height(), ALPHA_MASK);
556 } 556 }
557 557
558 void TextButton::SetText(const char* text, const Color& _fore, const Color& _pressed, const Color& _back) 558 void TextButton::SetText(const char* text, const Color& _fore, const Color& _pressed, const Color& _back)
559 { 559 {
560 int width = Pic()->Width(); int height = Pic()->Height(); 560 int width = Pic()->Width(); int height = Pic()->Height();
561 // まず、テキスト領域の広さを得る 561 // 障鴻綺緇
562 if (text == NULL) text = ""; 562 if (text == NULL) text = "";
563 563
564 TextGlyphStream gs = DefaultLayout(text_size)->Layout(text, width); 564 TextGlyphStream gs = DefaultLayout(text_size)->Layout(text, width);
565 565
566 int x = 0, y = 0; 566 int x = 0, y = 0;
573 Pic()->SetSurface( (Surface*)0,0,0); 573 Pic()->SetSurface( (Surface*)0,0,0);
574 root.DeleteSurface(surface); 574 root.DeleteSurface(surface);
575 surface = NULL; 575 surface = NULL;
576 576
577 //FIXME: (back.a == NULL) ? 577 //FIXME: (back.a == NULL) ?
578 if (back.a == 0) { // 背景なし 578 if (back.a == 0) { //
579 surface = root.NewSurface(width, height*2, ALPHA_MASK); 579 surface = root.NewSurface(width, height*2, ALPHA_MASK);
580 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0); 580 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0);
581 if (attribute & REVERSE) { 581 if (attribute & REVERSE) {
582 DSurfaceFill(surface, Rect(0,height,width,height*2), pressed.r, pressed.g, pressed.b, 0xff); 582 DSurfaceFill(surface, Rect(0,height,width,height*2), pressed.r, pressed.g, pressed.b, 0xff);
583 } 583 }
587 gs.SetReverse(true); 587 gs.SetReverse(true);
588 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0,0,gs.width(),gs.height()), surface, Rect(x,y+height)); 588 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0,0,gs.width(),gs.height()), surface, Rect(x,y+height));
589 gs.SetReverse(false); 589 gs.SetReverse(false);
590 nptn = 2; 590 nptn = 2;
591 } else { 591 } else {
592 /* ラベル用の Surface を作る */ 592 /* Surface 篏 */
593 char* box = create_box(width, height, _back.r, _back.g, _back.b); 593 char* box = create_box(width, height, _back.r, _back.g, _back.b);
594 surface = root.NewSurfaceFromRGBAData(width, height*3, box, ALPHA_MASK); 594 surface = root.NewSurfaceFromRGBAData(width, height*3, box, ALPHA_MASK);
595 595
596 Surface* text_surface = root.NewSurface(width, height, ALPHA_MASK); 596 Surface* text_surface = root.NewSurface(width, height, ALPHA_MASK);
597 DSurfaceFill(text_surface, Rect(*text_surface), 0, 0, 0, 0); 597 DSurfaceFill(text_surface, Rect(*text_surface), 0, 0, 0, 0);
699 press_count = 0; 699 press_count = 0;
700 nChar = 0; 700 nChar = 0;
701 cursor_activated = false; 701 cursor_activated = false;
702 if (cursor) cursor->hide(); 702 if (cursor) cursor->hide();
703 while(cur_pos != gstream.end()) { 703 while(cur_pos != gstream.end()) {
704 // スクロールしては次行描画、を繰り返す 704 // 鴻若罨∴祉膵違菴
705 for (scroll_height = CalcScrollHeight(); scroll_height > 0; scroll_height--) { 705 for (scroll_height = CalcScrollHeight(); scroll_height > 0; scroll_height--) {
706 status = SCROLL; 706 status = SCROLL;
707 label_scroll: 707 label_scroll:
708 if (press_count) break; 708 if (press_count) break;
709 Scrollup(nChar); 709 Scrollup(nChar);
761 void Text::Start(void) { 761 void Text::Start(void) {
762 gstream.clear(); 762 gstream.clear();
763 bottom_pos.clear(); 763 bottom_pos.clear();
764 layout.Layout(stream, gstream, bottom_pos, pictext->Width()-fontsize/2); 764 layout.Layout(stream, gstream, bottom_pos, pictext->Width()-fontsize/2);
765 765
766 // height の積算値として bottom_pos を計算 766 // height 腥膊ゃ bottom_pos 荐膊
767 std::vector<int>::iterator it; 767 std::vector<int>::iterator it;
768 int pos = 0; 768 int pos = 0;
769 for (it = bottom_pos.begin(); it != bottom_pos.end(); it++) { 769 for (it = bottom_pos.begin(); it != bottom_pos.end(); it++) {
770 pos += *it; 770 pos += *it;
771 *it = pos; 771 *it = pos;
781 cursor_activated = false; 781 cursor_activated = false;
782 if (cursor) cursor->hide(); 782 if (cursor) cursor->hide();
783 } 783 }
784 784
785 void Text::DrawText(int& nChar) { 785 void Text::DrawText(int& nChar) {
786 // 描画範囲を得る 786 // 紫蚊緇
787 iterator end = gstream.end(); 787 iterator end = gstream.end();
788 iterator it = cur_pos; 788 iterator it = cur_pos;
789 while(nChar && it != end) { // nChar < 0 なら出来るだけの文字を描画 789 while(nChar && it != end) { // nChar < 0 堺ャ絖
790 if (! (it->flag & TextGlyph::Group)) nChar--; 790 if (! (it->flag & TextGlyph::Group)) nChar--;
791 if (it->flag & TextGlyph::LineEnd) { 791 if (it->flag & TextGlyph::LineEnd) {
792 if (bottom_pos[line_number+1] > srcrect.by) { //改行すると画面から出てしまう 792 if (bottom_pos[line_number+1] > srcrect.by) { //壕脂≪冴障
793 it++; 793 it++;
794 if (nChar == 0) nChar = 1; 794 if (nChar == 0) nChar = 1;
795 break; 795 break;
796 } 796 }
797 line_number++; 797 line_number++;
798 } 798 }
799 it++; 799 it++;
800 } 800 }
801 // 描画する 801 // 祉
802 Rect r = DSurfaceRenderText(cur_pos, it, srcrect, surface, Rect(0,0,0,0)); 802 Rect r = DSurfaceRenderText(cur_pos, it, srcrect, surface, Rect(0,0,0,0));
803 pictext->ReBlit(r); 803 pictext->ReBlit(r);
804 cur_pos = it; 804 cur_pos = it;
805 } 805 }
806 806
807 void Text::Scrollup(int& nChar) { 807 void Text::Scrollup(int& nChar) {
808 if (nChar < 0) { // 一画面分スクロールする 808 if (nChar < 0) { // 筝脂√鴻若
809 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0); 809 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0);
810 pictext->ReBlit(); 810 pictext->ReBlit();
811 srcrect = Rect(*surface); 811 srcrect = Rect(*surface);
812 srcrect.rmove(0, bottom_pos[line_number]); 812 srcrect.rmove(0, bottom_pos[line_number]);
813 line_number++; 813 line_number++;
814 scrolled_count = 0; 814 scrolled_count = 0;
815 return; 815 return;
816 } 816 }
817 // スクロール幅を求める 817 // 鴻若綛羆
818 const int max_scroll_count = 8; 818 const int max_scroll_count = 8;
819 int dy = bottom_pos[line_number+1] - bottom_pos[line_number]; 819 int dy = bottom_pos[line_number+1] - bottom_pos[line_number];
820 int cur_dy; 820 int cur_dy;
821 if (scrolled_count+nChar >= max_scroll_count) { 821 if (scrolled_count+nChar >= max_scroll_count) {
822 cur_dy = dy - (scrolled_count*dy/max_scroll_count); 822 cur_dy = dy - (scrolled_count*dy/max_scroll_count);
871 int height = r.height(); 871 int height = r.height();
872 if (width == 0) width = parent->Width() - r.lx; 872 if (width == 0) width = parent->Width() - r.lx;
873 873
874 TextGlyphStream gs = DefaultLayout(text_size)->Layout(text, width); 874 TextGlyphStream gs = DefaultLayout(text_size)->Layout(text, width);
875 875
876 if (r.width() == 0) { // 文字に合わせてウィジット作成 876 if (r.width() == 0) { // 絖c吾篏
877 width = gs.width(); 877 width = gs.width();
878 r.rx = r.lx + gs.width(); 878 r.rx = r.lx + gs.width();
879 } 879 }
880 if (r.height() == 0) { 880 if (r.height() == 0) {
881 r.by = r.ty + gs.height(); 881 r.by = r.ty + gs.height();
882 } 882 }
883 883
884 SetPic(parent->create_leaf(r, 0)); 884 SetPic(parent->create_leaf(r, 0));
885 885
886 /* ラベル用の Surface を作る */ 886 /* Surface 篏 */
887 surface = parent->Root().NewSurface(r.width(), r.height(), ALPHA_MASK); 887 surface = parent->Root().NewSurface(r.width(), r.height(), ALPHA_MASK);
888 888
889 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0); 889 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0);
890 int x = 0, y = 0; 890 int x = 0, y = 0;
891 if (is_center) { 891 if (is_center) {
925 set_func = NULL; 925 set_func = NULL;
926 set_pointer = NULL; 926 set_pointer = NULL;
927 927
928 XKFont::HorizLayout& layout = *DefaultLayout(26); 928 XKFont::HorizLayout& layout = *DefaultLayout(26);
929 int dialog_width = parent->Width() / 2; 929 int dialog_width = parent->Width() / 2;
930 TextGlyphStream s_ok = layout.Layout("OK", dialog_width); 930 TextGlyphStream s_ok = layout.Layout("鐚鐚", dialog_width);
931 TextGlyphStream s_cancel = layout.Layout("取消", dialog_width); 931 TextGlyphStream s_cancel = layout.Layout("羔", dialog_width);
932 TextGlyphStream s_text = layout.Layout(text, dialog_width); 932 TextGlyphStream s_text = layout.Layout(text, dialog_width);
933 933
934 Rect r_text(0, 0, s_text.width(), s_text.height()); 934 Rect r_text(0, 0, s_text.width(), s_text.height());
935 Rect r_ok(0, 0, s_ok.width(), s_ok.height()); 935 Rect r_ok(0, 0, s_ok.width(), s_ok.height());
936 Rect r_cancel(0, 0, s_cancel.width(), s_cancel.height()); 936 Rect r_cancel(0, 0, s_cancel.width(), s_cancel.height());
937 937
938 /* ダイアログボックスの Surface を作る */ 938 /* ゃ≪違鴻 Surface 篏 */
939 int dwidth = r_text.width() + (r_text.width()/10)*2 + 6; 939 int dwidth = r_text.width() + (r_text.width()/10)*2 + 6;
940 int dheight = r_text.height() + r_ok.height() + r_cancel.height()*3 + 4; 940 int dheight = r_text.height() + r_ok.height() + r_cancel.height()*3 + 4;
941 surface_diag = parent->Root().NewSurface(dwidth, dheight, NO_MASK); // alpha なし 941 surface_diag = parent->Root().NewSurface(dwidth, dheight, NO_MASK); // alpha
942 DSurfaceFill(surface_diag, Rect(*surface_diag), 0xf0, 0xd0, 0xa0); 942 DSurfaceFill(surface_diag, Rect(*surface_diag), 0xf0, 0xd0, 0xa0);
943 DrawBox(surface_diag, Rect(0,0,dwidth,dheight)); 943 DrawBox(surface_diag, Rect(0,0,dwidth,dheight));
944 944
945 Surface* surface_text = parent->Root().NewSurface(r_text.width(), r_text.height(), ALPHA_MASK); 945 Surface* surface_text = parent->Root().NewSurface(r_text.width(), r_text.height(), ALPHA_MASK);
946 s_text.SetColor(0x38, 0x20, 0x18); 946 s_text.SetColor(0x38, 0x20, 0x18);
948 x = r_text.width()/10 + 3; 948 x = r_text.width()/10 + 3;
949 y = r_cancel.height()+2; 949 y = r_cancel.height()+2;
950 parent->Root().BlitSurface(surface_text, r_text, surface_diag, Rect(x, y, x+r_text.width(), y+r_text.height())); 950 parent->Root().BlitSurface(surface_text, r_text, surface_diag, Rect(x, y, x+r_text.width(), y+r_text.height()));
951 parent->Root().DeleteSurface(surface_text); 951 parent->Root().DeleteSurface(surface_text);
952 952
953 /* panel をつくる */ 953 /* panel ゃ */
954 x = (parent->Width()-dwidth)/2; 954 x = (parent->Width()-dwidth)/2;
955 y = (parent->Height()-dheight)/2; 955 y = (parent->Height()-dheight)/2;
956 SetPic(parent->create_node(Rect(x, y, x+dwidth, y+dheight), 0)); 956 SetPic(parent->create_node(Rect(x, y, x+dwidth, y+dheight), 0));
957 957
958 /* ボタンを作成する */ 958 /* 帥潟篏 */
959 /* f8d8c8 背景(明)*/ 959 /* f8d8c8 ()*/
960 /* f0d0a0 背景*/ 960 /* f0d0a0 */
961 /* b08040 枠(明)*/ 961 /* b08040 鐚)*/
962 /* 805010 枠*/ 962 /* 805010 */
963 /* 382018 黒*/ 963 /* 382018 藥*/
964 /* 9890f8 青*/ 964 /* 9890f8 */
965 /* dc6448 赤*/ 965 /* dc6448 莎*/
966 /* 各ボタンは左右にボタン幅の 1/4, 上下にボタン幅の 1/4 のマージンを持つ */ 966 /* 帥潟綏劻帥喝 1/4, 筝筝帥喝 1/4 若吾潟 */
967 Rect r_btn(r_ok); r_btn.join(r_cancel); 967 Rect r_btn(r_ok); r_btn.join(r_cancel);
968 int btn_width = r_btn.width() * 3 / 2; 968 int btn_width = r_btn.width() * 3 / 2;
969 int btn_height = r_btn.height() * 3 / 2; 969 int btn_height = r_btn.height() * 3 / 2;
970 surface_btn = parent->Root().NewSurface(btn_width, btn_height*4, ALPHA_MASK); 970 surface_btn = parent->Root().NewSurface(btn_width, btn_height*4, ALPHA_MASK);
971 DSurfaceFill(surface_btn, Rect(*surface_btn), 0, 0, 0, 0); 971 DSurfaceFill(surface_btn, Rect(*surface_btn), 0, 0, 0, 0);
1182 1182
1183 void AnmAlphaMove::Exec(int count) { 1183 void AnmAlphaMove::Exec(int count) {
1184 if (ptns.empty()) return; 1184 if (ptns.empty()) return;
1185 if (cur_count != 0 && ptns[cur_count].next_tick > count) return; 1185 if (cur_count != 0 && ptns[cur_count].next_tick > count) return;
1186 if (cur_count >= ptns.size()) return; 1186 if (cur_count >= ptns.size()) return;
1187 // 次のパターンを探す 1187 // 罨<帥若潟「
1188 // count <= it->next_tick なる条件を満たす最後の it を探す 1188 // count <= it->next_tick >散羣緇 it 「
1189 std::vector<Ptn>::iterator it; 1189 std::vector<Ptn>::iterator it;
1190 for (it=ptns.begin()+cur_count; it != ptns.end(); it++) { 1190 for (it=ptns.begin()+cur_count; it != ptns.end(); it++) {
1191 if (count <= it->next_tick) break; 1191 if (count <= it->next_tick) break;
1192 } 1192 }
1193 if (it == ptns.end()) { 1193 if (it == ptns.end()) {
1210 1210
1211 void AnmAlphaMove::Finish(void) { 1211 void AnmAlphaMove::Finish(void) {
1212 if (ptns.empty()) return; 1212 if (ptns.empty()) return;
1213 if (cur_count >= ptns.size() - 1) return; 1213 if (cur_count >= ptns.size() - 1) return;
1214 cur_count = ptns.size() - 1; 1214 cur_count = ptns.size() - 1;
1215 Exec(ptns[cur_count].next_tick); // 最後の pattern の状態にする 1215 Exec(ptns[cur_count].next_tick); // 緇 pattern 倶
1216 } 1216 }
1217 1217
1218 AnmPtnSolid::AnmPtnSolid(Event::Container& container, PicBase* _pic, const unsigned char* _ptn, const Rect& _alpha_r, int total_time) : 1218 AnmPtnSolid::AnmPtnSolid(Event::Container& container, PicBase* _pic, const unsigned char* _ptn, const Rect& _alpha_r, int total_time) :
1219 AnmTime(container, _pic, total_time), 1219 AnmTime(container, _pic, total_time),
1220 ptn(_ptn), alpha_r(_alpha_r) 1220 ptn(_ptn), alpha_r(_alpha_r)
1286 for (it=pic.begin(); it!=pic.end(); it++) (*it)->SetSurfaceAlpha(0, Rect(0,0)); 1286 for (it=pic.begin(); it!=pic.end(); it++) (*it)->SetSurfaceAlpha(0, Rect(0,0));
1287 } 1287 }
1288 1288
1289 /* 1289 /*
1290 1290
1291 Widget の種類 1291 Widget 腮蕁
1292 Mouse: マウス位置に連動する。Surface と origin が必須 1292 Mouse: 剛臀eSurface origin 綽
1293 Panel : なにも存在しないところに張りつけていく 1293 Panel : 絖綣泣ゃ
1294 背景張りつけも可能 1294 綣泣ゃ
1295 ButtonPanel : 無効化可能。Group の Button がカーソルに入ったら、全Button / Label が「カーソル下」状態になる 1295 ButtonPanel : ≦劫純Group Button 若純ャcButton / Label 若純筝倶
1296 同一変数を扱うボタンは原則、同一ButtonPanel の下に入ること(同期する。高速化可能) 1296 筝紊違宴帥潟筝ButtonPanel 筝ャ鐚蕭緒
1297 そうでない場合、ボタンの GlobalVariable フラグを立てる必要がある 1297 с翫帥潟 GlobalVariable 違腴綽荀
1298 背景種類:Window 1298 腮蕁鐚Window
1299 内部の透明度と枠形を別々に指定可能。枠形は全枠、部分枠どちらの形でも可能 1299 綺綵≪ャ絎純綵≪<綵≪с
1300 (部分枠なら、内部的には上枠、下枠、左右枠と別 Surface で管理する) 1300 鐚筝筝綏勄 Surface х∞鐚
1301 DragButton 1301 DragButton
1302 Panel 全体をドラッグし、場所変更できるボタン。 1302 Panel 篏違贋紊眼с帥潟
1303 Button: 無効化>通常>カーソル下>ボタン押下 のpicture / animation 1303 Button: ≦劫鐚絽醐若純筝鐚帥恰寂 picture / animation
1304 Toggle Button にできる(Group化すればRadioButtonにもできる) 1304 Toggle Button с(GroupRadioButtonс)
1305 Label : 無効化>通常>カーソル下 のanimation 1305 Label : ≦劫鐚絽醐若純筝animation
1306 animation は 1306 animation
1307 ・上への変化 1307 私吾紊
1308 ・下への変化 1308 私吾紊
1309 ・常時変形 1309 糸幻紊綵
1310 の3つの形式をもつ。 1310 鐚ゃ綵√ゃ
1311 形式は 1311 綵√
1312 ・x / y increment による(全領域と x,y の大きさを指定すると左上から右上、左下、という方へ勝手に領域を変更していく) 1312 x / y increment 鐚 x,y 紊с絎綏筝劽綏筝鴻後紊眼鐚
1313 ・色変化(明度変化)。色テーブルを指定する。Surface は alpha のみとする 1313 肢峨鐚綺紊鐚蚊若絎Surface alpha 帥
1314 どちらも、一つのラベルに使う時間の長さを指定する 1314 <筝ゃ篏帥激絎
1315 ・callback による。指定した一定時間以上が立つとCallBack が呼び出され、新たなSurface , origin を指定する。 1315 callback 絎筝絎篁ヤ腴ゃCallBack 若喝冴違Surface , origin 絎
1316 1316
1317 ・Surface は 1317 Surface
1318 普通の画像 1318
1319 文字列(適当に仮想化) 1319 絖鐚綵篁喝鐚
1320 画像数値列 1320 糸医ゅ
1321 のいずれか 1321
1322 Cursor 1322 Cursor
1323 リターンカーソル。Label の一種。 1323 帥若潟若純Label 筝腮
1324 Number 1324 Number
1325 数字を表示する。フォントの大きさ、もしくは画像数値列 1325 医茵腓冴潟紊с糸医ゅ
1326 Text 1326 Text
1327 テキストを表示する 1327 鴻茵腓冴
1328 パネルの大きさだけ指定すると適当にやってくれる 1328 紊с絎綵c
1329 カーソルの位置(文字の次/最終)を指定すること 1329 若純篏臀鐚絖罨/腟鐚絎
1330 機能:文字送り速度設定、読み飛ばし設定(常に最高速で押しっぱなし) 1330 罘緒絖綺荐絎茯翠違荐絎鐚絽吾蕭ф若c宴鐚
1331 ProgressBar など 1331 ProgressBar
1332 バーの長さ、あるいは位置で変数の大きさを示す。 1332 若激篏臀у違紊с腓冴
1333 Tick, Max を指定、変数の変化には適当に対応できるようにする 1333 Tick, Max 絎紊違紊綵絲上с
1334 バーの方向として縦/横。Surface は繰り返しで使う(速度上、32pixel くらいあったほうがいいかも?) 1334 若劫膰/罔Surface 膵違菴т戎鐚綺筝32pixel c祉鐚鐚
1335 バーの代わりにボタンも使える。Surface 指定のメソッドが違うだけ。 1335 若篁c帥潟篏帥Surface 絎<純
1336 オプション:バーのどこかをクリックされたとき、そこに移動するかそこに向かって移動するか 1336 激с鰹若腱糸c腱糸
1337 オプション?:矢印ボタン(いらないか) 1337 激с鰹鐚√違帥鰹鐚
1338 ScrollBar 1338 ScrollBar
1339 横/縦。Panel と連動する(専用, ProgressBar の一種として実装) 1339 罔/膰Panel e(絨, ProgressBar 筝腮絎茖)
1340 (Panel 側で「見えない部分はdelete, 見える部分は自動で作成」機能をつける?:バックログ) 1340 (Panel 眼с荀delete, 荀т罘純ゃ鐚鐚逸
1341 1341
1342 1342
1343 1343
1344 メニューの出し方 1344 <ャ若冴
1345 右クリック 1345
1346 ボタンを押す 1346 帥潟若
1347 上の方、右の方など領域に行くとヌっと出てくる 1347 筝鴻劻鴻茵c冴
1348 メニューモード内 1348 <ャ若≪若
1349 ボタンを押して終了 1349 帥潟若腟篋
1350 マップを作っておき、各メニューに名前を割り振ると二次元に広がったメニューになる 1350 篏c<ャ若蚊篋罨≦綺c<ャ若
1351 名前を割り振ると上に名前リストがでてくる 1351 蚊筝鴻с
1352 名前を割り振ると横に名前リストが出てくる 1352 蚊罔鴻冴
1353 1353
1354 */ 1354 */
1355 // } 1355 // }