Mercurial > hg > openttd
changeset 2596:f605403f6746 draft
(svn r3133) - static, const
- remove long unused stuff and bogus comments
- complement struct typedefs
- remove read-only (_demo_mode) and unused (_fix_mouse_at) global variables
author | tron <tron@openttd.org> |
---|---|
date | Fri, 04 Nov 2005 14:01:44 +0000 |
parents | b1a76457091a |
children | 582ede5d1a6b |
files | window.c window.h |
diffstat | 2 files changed, 22 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/window.c +++ b/window.c @@ -23,7 +23,8 @@ InvalidateWidget(w, widget); } -void DispatchLeftClickEvent(Window *w, int x, int y) { +static void DispatchLeftClickEvent(Window* w, int x, int y) +{ WindowEvent e; const Widget *wi; @@ -83,7 +84,8 @@ w->wndproc(w, &e); } -void DispatchRightClickEvent(Window *w, int x, int y) { +static void DispatchRightClickEvent(Window* w, int x, int y) +{ WindowEvent e; /* default tooltips handler? */ @@ -110,7 +112,7 @@ * @param widget the widget where the scrollwheel was used * @param wheel scroll up or down */ -void DispatchMouseWheelEvent(Window *w, int widget, int wheel) +static void DispatchMouseWheelEvent(Window* w, int widget, int wheel) { const Widget *wi1, *wi2; Scrollbar *sb; @@ -373,7 +375,7 @@ } } -bool IsWindowOfPrototype(Window *w, const Widget *widget) +bool IsWindowOfPrototype(const Window* w, const Widget* widget) { return (w->original_widget == widget); } @@ -872,6 +874,9 @@ return true; } + +static bool _dragging_window; + static bool HandleWindowDragging(void) { Window *w; @@ -1291,7 +1296,7 @@ * @param wparam Specifies additional message-specific information * @param lparam Specifies additional message-specific information */ -void SendWindowMessageW(Window *w, uint msg, uint wparam, uint lparam) +static void SendWindowMessageW(Window* w, uint msg, uint wparam, uint lparam) { WindowEvent e; @@ -1557,7 +1562,7 @@ } } -void InvalidateWidget(Window *w, byte widget_index) +void InvalidateWidget(const Window* w, byte widget_index) { const Widget *wi = &w->widget[widget_index];
--- a/window.h +++ b/window.h @@ -5,8 +5,6 @@ typedef union WindowEvent WindowEvent; -//typedef void WindowProc(Window *w, int event, int wparam, long lparam); - typedef void WindowProc(Window *w, WindowEvent *e); /* How the resize system works: @@ -210,10 +208,6 @@ // 0-9 are mapped to 48-57 // A-Z are mapped to 65-90 // a-z are mapped to 97-122 - - - //WKC_UNKNOWN = 0xFF, - }; typedef struct WindowDesc { @@ -250,7 +244,7 @@ uint16 caretxoffs; /* the current position of the caret in pixels */ } Textbuf; -typedef struct { +typedef struct querystr_d { StringID caption; WindowClass wnd_class; WindowNumber wnd_num; @@ -259,18 +253,18 @@ } querystr_d; #define WP(ptr,str) (*(str*)(ptr)->custom) -// querystr_d is the bigest struct that comes in w->custom +// querystr_d is the largest struct that comes in w->custom // because 64-bit systems use 64-bit pointers, it is bigger on a 64-bit system // than on a 32-bit system. Therefore, the size is calculated from querystr_d // instead of a hardcoded number. // if any struct becomes bigger the querystr_d, it should be replaced. #define WINDOW_CUSTOM_SIZE sizeof(querystr_d) -typedef struct { +typedef struct Scrollbar { uint16 count, cap, pos; } Scrollbar; -typedef struct { +typedef struct ResizeInfo { uint width; /* Minimum width and height */ uint height; @@ -278,7 +272,7 @@ uint step_height; } ResizeInfo; -typedef struct { +typedef struct Message { int msg; int wparam; int lparam; @@ -302,7 +296,6 @@ ViewPort *viewport; const Widget *original_widget; Widget *widget; - //const WindowDesc *desc; uint32 desc_flags; Message message; @@ -323,7 +316,7 @@ typedef struct { int16 data_1, data_2, data_3; int16 data_4, data_5; - bool close; /* scrollpos_y */ + bool close; byte byte_1; } def_d; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(def_d)); @@ -334,13 +327,13 @@ assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(void_d)); typedef struct { - uint16 base; /* follow_vehicle */ - uint16 count;/* scrollpos_x */ + uint16 base; + uint16 count; } tree_d; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tree_d)); typedef struct { - byte refresh_counter; /* follow_vehicle */ + byte refresh_counter; } plstations_d; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(plstations_d)); @@ -544,17 +537,11 @@ WF_SCROLL2 = 1 << 13, }; - -void DispatchLeftClickEvent(Window *w, int x, int y); -void DispatchRightClickEvent(Window *w, int x, int y); -void DispatchMouseWheelEvent(Window *w, int widget, int wheel); - /* window.c */ void DrawOverlappedWindow(Window *w, int left, int top, int right, int bottom); void CallWindowEventNP(Window *w, int event); void CallWindowTickEvent(void); void SetWindowDirty(const Window* w); -void SendWindowMessageW(Window *w, uint msg, uint wparam, uint lparam); void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, uint msg, uint wparam, uint lparam); Window *FindWindowById(WindowClass cls, WindowNumber number); @@ -565,10 +552,8 @@ Window *StartWindowSizing(Window *w); Window *FindWindowFromPt(int x, int y); -bool IsWindowOfPrototype(Window *w, const Widget *widget); +bool IsWindowOfPrototype(const Window* w, const Widget* widget); void AssignWidgetToWindow(Window *w, const Widget *widget); -/* Use this function to save the current widget to be the global default */ -void MakeWindowWidgetDefault(Window *w); Window *AllocateWindow( int x, int y, @@ -605,7 +590,7 @@ int GetMenuItemIndex(const Window *w, int x, int y); void InputLoop(void); void UpdateWindows(void); -void InvalidateWidget(Window *w, byte widget_index); +void InvalidateWidget(const Window* w, byte widget_index); void GuiShowTooltips(StringID string_id); @@ -643,16 +628,11 @@ VARDEF int _scrollbar_start_pos; VARDEF int _scrollbar_size; -VARDEF bool _demo_mode; VARDEF byte _scroller_click_timeout; -VARDEF bool _dragging_window; VARDEF bool _scrolling_scrollbar; VARDEF bool _scrolling_viewport; VARDEF bool _popup_menu_active; -//VARDEF bool _dragdrop_active; - -VARDEF Point _fix_mouse_at; VARDEF byte _special_mouse_mode; enum SpecialMouseMode {