Mercurial > otakunoraifu
diff window/widget.h @ 52:15a18fbe6f21
* Known bugs added to the README
* Code cleaning (0 -> NULL when needed, indentation, spaces, ...)
author | thib |
---|---|
date | Sat, 18 Apr 2009 18:35:39 +0000 |
parents | 5ae5533b3a9a |
children | 4416cfac86ae |
line wrap: on
line diff
--- a/window/widget.h +++ b/window/widget.h @@ -28,11 +28,11 @@ #ifndef __WIDGET_H__ #define __WIDGET_H__ -#include<vector> -#include"font/font.h" -#include"font/text.h" -#include"event.h" -#include"picture.h" +#include <vector> +#include "font/font.h" +#include "font/text.h" +#include "event.h" +#include "picture.h" #define TimeCursor WidTimeCursor #define MouseCursor WidMouseCursor @@ -51,7 +51,7 @@ // namespace Widget { struct TimeCursor : public Event::Time, PicWidget { - int x,y,dx,dy, nptn; + int x, y, dx, dy, nptn; int old_time, count, interval; TimeCursor(Event::Container& container, int _interval, PicContainer* parent, const char* fname, int sx, int sy, int sdx, int sdy, int nptn, const Rect& r); void Elapsed(unsigned int current_time); @@ -93,52 +93,52 @@ struct Button : public Event::Video, Pic void SetRegion(const Rect& new_rect) { Event::Video::SetRegion(new_rect);} }; struct Scale : Event::Video, PicWidget { -private: - Button* arrow_down, *arrow_up; - Button* cursor; - PicContainer* panel; - Event::Container& container; - PicContainer* parent; - Color cursor_color; + private: + Button* arrow_down, *arrow_up; + Button* cursor; + PicContainer* panel; + Event::Container& container; + PicContainer* parent; + Color cursor_color; - int mouse_x, mouse_y; - enum {scale_max = 65536}; - int min, max; - int value; - int value_add; - int value_dragstart; - int cursor_width; - bool is_vertical; - -public: + int mouse_x, mouse_y; + enum {scale_max = 65536}; + int min, max; + int value; + int value_add; + int value_dragstart; + int cursor_width; + bool is_vertical; - Scale(Event::Container& container, PicContainer* parent, const Rect& r_orig, const Color& cursor_color, bool _is_vertical); - void InitCursor(int cursor_width_ratio); // 1024=max - void SetRange(int min, int max); - void SetValue(int value); - int GetValue(void) const; - typedef void (*ChangeFunc)(void* pointer, Scale* from); - ChangeFunc change_func; - void* change_pointer; -private: - void Init(Rect r_orig); - int CalcValue(void); - void SetScaleValue(int value); + public: + Scale(Event::Container& container, PicContainer* parent, const Rect& r_orig, const Color& cursor_color, bool _is_vertical); + void InitCursor(int cursor_width_ratio); // 1024=max + void SetRange(int min, int max); + void SetValue(int value); + int GetValue(void) const; + typedef void (*ChangeFunc)(void* pointer, Scale* from); + ChangeFunc change_func; + void* change_pointer; + + private: + void Init(Rect r_orig); + int CalcValue(void); + void SetScaleValue(int value); - // callback - static void PressArrowDown(void* pointer, Button* from); - static void PressArrowUp(void* pointer, Button* from); - static void PressCursor(void* pointer, Button* from); - static void DragCursor(int x_from, int y_from,int x, int y, void* pointer, Button* from); + // callback + static void PressArrowDown(void* pointer, Button* from); + static void PressArrowUp(void* pointer, Button* from); + static void PressCursor(void* pointer, Button* from); + static void DragCursor(int x_from, int y_from,int x, int y, void* pointer, Button* from); - // 费镜¨Event::Video - void Press(void); - void Motion(int x, int y); + // 费镜¨Event::Video + void Press(void); + void Motion(int x, int y); - /* 费镜 : PicWidget */ - void activate(void) { Event::Video::activate();} - void deactivate(void) { Event::Video::deactivate();} - void SetRegion(const Rect& new_rect) { Event::Video::SetRegion(new_rect);} + /* 费镜 : PicWidget */ + void activate(void) { Event::Video::activate();} + void deactivate(void) { Event::Video::deactivate();} + void SetRegion(const Rect& new_rect) { Event::Video::SetRegion(new_rect);} }; struct TextButton : public Button { @@ -159,83 +159,86 @@ struct TextButton : public Button { struct Text : public Event::Video, Event::Time, PicWidget { typedef TextGlyphStream::iterator iterator; -private: - Event::Container& event; -public: - PicBase* pictext; -private: - TimeCursor* cursor; - Surface* surface; - TextGlyphStream gstream; - std::vector<int> bottom_pos; // 乖光さ(height)の芜纷猛 - XKFont::HorizLayout layout; - int fontsize; + private: + Event::Container& event; + public: + PicBase* pictext; + private: + TimeCursor* cursor; + Surface* surface; + TextGlyphStream gstream; + std::vector<int> bottom_pos; // 乖光さ(height)の芜纷猛 + XKFont::HorizLayout layout; + int fontsize; - iterator cur_pos; - int line_number; - Rect srcrect; - int press_count; - int scrolled_count; - int scroll_height; - bool window_activated; - bool cursor_activated; + iterator cur_pos; + int line_number; + Rect srcrect; + int press_count; + int scrolled_count; + int scroll_height; + bool window_activated; + bool cursor_activated; - int speed; // chars / sec or -1 - int wait_delay; // msec - int old_time; - int wait_starttime; + int speed; // chars / sec or -1 + int wait_delay; // msec + int old_time; + int wait_starttime; - int CalcScrollHeight(void); - void DrawText(int& nChar); - void Scrollup(int& nChar); -public: - Text(Event::Container& container, PicContainer* parent, const Rect& r, const Rect& text_r, int fontsize); - ~Text(); + int CalcScrollHeight(void); + void DrawText(int& nChar); + void Scrollup(int& nChar); + + public: + Text(Event::Container& container, PicContainer* parent, const Rect& r, const Rect& text_r, int fontsize); + ~Text(); - TextStream stream; - enum {PREPARE, DRAW, WAIT, SCROLL, DRAW2, WAIT2} status; + TextStream stream; + enum {PREPARE, DRAW, WAIT, SCROLL, DRAW2, WAIT2} status; - void Clear(void); - void Start(void); - void Flush(void); + void Clear(void); + void Start(void); + void Flush(void); - void Elapsed(unsigned int current_time); - static bool Pressed(int x, int y, void* pointer); - void activate(void); - void deactivate(void); - void SetSpeed(int new_speed); - void SetWait(int new_wait); + void Elapsed(unsigned int current_time); + static bool Pressed(int x, int y, void* pointer); + void activate(void); + void deactivate(void); + void SetSpeed(int new_speed); + void SetWait(int new_wait); - void SetCursor(TimeCursor* cursor); + void SetCursor(TimeCursor* cursor); }; extern void SetFont(const char* fontname); struct Label : PicWidget{ -private: - Surface* surface; - bool is_center; - PicRoot& root; - int text_size; -public: - Label(PicContainer* parent, const Rect& r_orig, bool is_center=true, const char* text=0, int textsize = 26); - ~Label(); - void SetText(const char* text); + private: + Surface* surface; + bool is_center; + PicRoot& root; + int text_size; + public: + Label(PicContainer* parent, const Rect& r_orig, bool is_center=true, const char* text=0, int textsize = 26); + ~Label(); + void SetText(const char* text); }; class Dialog : public Event::Video, PicWidget { - Surface* surface_btn; - Surface* surface_diag; -public: - enum { WAIT, OK, CANCEL} status; - Dialog(Event::Container& container, PicContainer* parent, const char* text, bool with_cancel); - ~Dialog(); - static void press_ok(void* pointer, Button* btn); - static void press_cancel(void* pointer, Button* btn); - static void DrawBox(Surface* s, const Rect& r); - typedef void (*SetFunc)(void* pointer, Dialog* from); - SetFunc set_func; - void* set_pointer; + private: + Surface* surface_btn; + Surface* surface_diag; + + public: + enum { WAIT, OK, CANCEL} status; + Dialog(Event::Container& container, PicContainer* parent, const char* text, bool with_cancel); + ~Dialog(); + static void press_ok(void* pointer, Button* btn); + static void press_cancel(void* pointer, Button* btn); + static void DrawBox(Surface* s, const Rect& r); + typedef void (*SetFunc)(void* pointer, Dialog* from); + SetFunc set_func; + void* set_pointer; }; struct AnmTime : public Event::Time, PicAnm { @@ -267,6 +270,7 @@ struct AnmMove : public AnmTime { AnmMove(Event::Container& container, PicBase* _pic, const Rect& to, int total_time); void Exec(int count); }; + #define ALPHA_MAX 255 struct AnmAlpha : public AnmTime { int from, to; @@ -277,6 +281,7 @@ struct AnmAlpha : public AnmTime { void Exec(int count); void Finish(void); }; + struct AnmAlphaMove : public AnmTime { struct Ptn { Rect pos; @@ -293,6 +298,7 @@ struct AnmAlphaMove : public AnmTime { void Exec(int count); void Finish(void); }; + struct AnmPtnSolid : public AnmTime { AnmPtnSolid(Event::Container& container, PicBase* _pic, const unsigned char* ptn, const Rect& alpha_r, int total_time); ~AnmPtnSolid() { delete[] alpha; } @@ -305,6 +311,7 @@ struct AnmPtnSolid : public AnmTime { void Exec(int count); void Finish(void); }; + struct AnmPtnAlpha : public AnmTime { AnmPtnAlpha(Event::Container& container, PicBase* _pic, const unsigned char* ptn, const Rect& alpha_r, int alpha_bandwidth, int total_time); ~AnmPtnAlpha() { delete[] alpha; }