summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-02-09 01:06:23 +0000
committerrubidium <rubidium@openttd.org>2009-02-09 01:06:23 +0000
commit9907742a0f73bdbbf578cd2b6c424b80d254fed1 (patch)
tree3fb8cd8b4041aa509972f5b01531eb874e6c113d
parent7b8c13fa5c7cdaac1342fd7c8244721739e2354c (diff)
downloadopenttd-9907742a0f73bdbbf578cd2b6c424b80d254fed1.tar.xz
(svn r15423) -Codechange: split widget related types to their own header and add a bit of type strictness.
-rw-r--r--projects/langs_vs80.vcproj15
-rw-r--r--projects/langs_vs90.vcproj15
-rw-r--r--projects/openttd_vs80.vcproj4
-rw-r--r--projects/openttd_vs90.vcproj4
-rw-r--r--source.list1
-rw-r--r--src/autoreplace_gui.cpp4
-rw-r--r--src/company_cmd.cpp4
-rw-r--r--src/company_func.h3
-rw-r--r--src/graph_gui.cpp2
-rw-r--r--src/misc_cmd.cpp2
-rw-r--r--src/osk_gui.cpp2
-rw-r--r--src/saveload/company_sl.cpp2
-rw-r--r--src/saveload/oldloader_sl.cpp2
-rw-r--r--src/station_gui.cpp2
-rw-r--r--src/widget.cpp92
-rw-r--r--src/widget_type.h126
-rw-r--r--src/widgets/dropdown.cpp8
-rw-r--r--src/window.cpp1
-rw-r--r--src/window_gui.h121
19 files changed, 229 insertions, 181 deletions
diff --git a/projects/langs_vs80.vcproj b/projects/langs_vs80.vcproj
index 02af65f0c..5f7c4295f 100644
--- a/projects/langs_vs80.vcproj
+++ b/projects/langs_vs80.vcproj
@@ -302,6 +302,21 @@
</FileConfiguration>
</File>
<File
+ RelativePath="..\src\lang\hebrew.txt"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating hebrew language file"
+ CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+ AdditionalDependencies=""
+ Outputs="..\bin\lang\hebrew.lng"
+ />
+ </FileConfiguration>
+ </File>
+ <File
RelativePath="..\src\lang\hungarian.txt"
>
<FileConfiguration
diff --git a/projects/langs_vs90.vcproj b/projects/langs_vs90.vcproj
index d861b4235..9dff4c271 100644
--- a/projects/langs_vs90.vcproj
+++ b/projects/langs_vs90.vcproj
@@ -303,6 +303,21 @@
</FileConfiguration>
</File>
<File
+ RelativePath="..\src\lang\hebrew.txt"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating hebrew language file"
+ CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+ AdditionalDependencies=""
+ Outputs="..\bin\lang\hebrew.lng"
+ />
+ </FileConfiguration>
+ </File>
+ <File
RelativePath="..\src\lang\hungarian.txt"
>
<FileConfiguration
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
index 90e69274b..206574930 100644
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -1592,6 +1592,10 @@
>
</File>
<File
+ RelativePath=".\..\src\widget_type.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\win32.h"
>
</File>
diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj
index 0e0484a52..09ce2dd23 100644
--- a/projects/openttd_vs90.vcproj
+++ b/projects/openttd_vs90.vcproj
@@ -1589,6 +1589,10 @@
>
</File>
<File
+ RelativePath=".\..\src\widget_type.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\win32.h"
>
</File>
diff --git a/source.list b/source.list
index 07ecd7607..a4eb8dca4 100644
--- a/source.list
+++ b/source.list
@@ -328,6 +328,7 @@ viewport_type.h
water.h
waypoint.h
waypoint_type.h
+widget_type.h
win32.h
music/win32_m.h
sound/win32_s.h
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index fd09cfc03..6e40abe9a 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -282,8 +282,8 @@ public:
SetDParam(2, this->wagon_btnstate ? STR_ENGINES : STR_WAGONS);
/* sets the colour of that art thing */
- this->widget[RVW_WIDGET_TRAIN_FLUFF_LEFT].color = _company_colours[_local_company];
- this->widget[RVW_WIDGET_TRAIN_FLUFF_RIGHT].color = _company_colours[_local_company];
+ this->widget[RVW_WIDGET_TRAIN_FLUFF_LEFT].colour = _company_colours[_local_company];
+ this->widget[RVW_WIDGET_TRAIN_FLUFF_RIGHT].colour = _company_colours[_local_company];
}
if (this->window_number == VEH_TRAIN) {
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index ec20b45ce..3ef64862a 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -37,7 +37,7 @@
CompanyByte _local_company;
CompanyByte _current_company;
/* NOSAVE: can be determined from company structs */
-byte _company_colours[MAX_COMPANIES];
+Colours _company_colours[MAX_COMPANIES];
CompanyManagerFace _company_manager_face; ///< for company manager face storage in openttd.cfg
DEFINE_OLD_POOL_GENERIC(Company, Company)
@@ -434,7 +434,7 @@ Company *DoStartupNewCompany(bool is_ai)
c->colour = colour;
ResetCompanyLivery(c);
- _company_colours[c->index] = c->colour;
+ _company_colours[c->index] = (Colours)c->colour;
c->money = c->current_loan = 100000;
diff --git a/src/company_func.h b/src/company_func.h
index fe19e6439..78dcd9eab 100644
--- a/src/company_func.h
+++ b/src/company_func.h
@@ -9,6 +9,7 @@
#include "company_type.h"
#include "tile_type.h"
#include "strings_type.h"
+#include "gfx_type.h"
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner);
void GetNameOfOwner(Owner owner, TileIndex tile);
@@ -17,7 +18,7 @@ void SetLocalCompany(CompanyID new_company);
extern CompanyByte _local_company;
extern CompanyByte _current_company;
-extern byte _company_colours[MAX_COMPANIES]; ///< NOSAVE: can be determined from company structs
+extern Colours _company_colours[MAX_COMPANIES]; ///< NOSAVE: can be determined from company structs
extern CompanyManagerFace _company_manager_face; ///< for company manager face storage in openttd.cfg
bool IsHumanCompany(CompanyID company);
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index acd220a2e..d5707ed16 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -634,7 +634,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
Widget *wi = &this->widget[3 + i];
wi->type = WWT_PANEL;
wi->display_flags = RESIZE_NONE;
- wi->color = COLOUR_ORANGE;
+ wi->colour = COLOUR_ORANGE;
wi->left = 493;
wi->right = 562;
wi->top = 24 + i * 8;
diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp
index 6a3077230..ce7407c01 100644
--- a/src/misc_cmd.cpp
+++ b/src/misc_cmd.cpp
@@ -53,7 +53,7 @@ CommandCost CmdSetCompanyColor(TileIndex tile, uint32 flags, uint32 p1, uint32 p
{
if (p2 >= 16) return CMD_ERROR; // max 16 colours
- byte colour = p2;
+ Colours colour = (Colours)p2;
LiveryScheme scheme = (LiveryScheme)GB(p1, 0, 8);
byte state = GB(p1, 8, 2);
diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp
index a3fa2f95a..a4906c1ed 100644
--- a/src/osk_gui.cpp
+++ b/src/osk_gui.cpp
@@ -124,7 +124,7 @@ struct OskWindow : public Window {
if (HasBit(_keystate, KEYS_SHIFT)) {
ToggleBit(_keystate, KEYS_SHIFT);
- this->widget[OSK_WIDGET_SHIFT].color = HasBit(_keystate, KEYS_SHIFT) ? COLOUR_WHITE : COLOUR_GREY;
+ this->widget[OSK_WIDGET_SHIFT].colour = HasBit(_keystate, KEYS_SHIFT) ? COLOUR_WHITE : COLOUR_GREY;
this->SetDirty();
}
return;
diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp
index 22930f765..69892890e 100644
--- a/src/saveload/company_sl.cpp
+++ b/src/saveload/company_sl.cpp
@@ -272,7 +272,7 @@ static void Load_PLYR()
while ((index = SlIterateArray()) != -1) {
Company *c = new (index) Company();
SaveLoad_PLYR(c);
- _company_colours[index] = c->colour;
+ _company_colours[index] = (Colours)c->colour;
}
}
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index 6052312b0..9319dfcf5 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -1051,7 +1051,7 @@ static bool LoadOldCompany(LoadgameState *ls, int num)
if (c->money == 893288) c->money = c->current_loan = 100000;
}
- _company_colours[num] = c->colour;
+ _company_colours[num] = (Colours)c->colour;
c->inaugurated_year -= ORIGINAL_BASE_YEAR;
return true;
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index c2a536ca0..6e2f6a87b 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -255,7 +255,7 @@ public:
Widget *wi = &this->widget[SLW_CARGOSTART + i];
wi->type = WWT_PANEL;
wi->display_flags = RESIZE_NONE;
- wi->color = COLOUR_GREY;
+ wi->colour = COLOUR_GREY;
wi->left = 89 + i * 14;
wi->right = wi->left + 13;
wi->top = 14;
diff --git a/src/widget.cpp b/src/widget.cpp
index dfab0c9b3..285fc9920 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -163,15 +163,15 @@ int GetWidgetFromPos(const Window *w, int x, int y)
* @param top Top edge of the frame
* @param right Right edge of the frame
* @param bottom Bottom edge of the frame
- * @param color Colour table to use. @see _colour_gradient
+ * @param colour Colour table to use. @see _colour_gradient
* @param flags Flags controlling how to draw the frame. @see FrameFlags
*/
-void DrawFrameRect(int left, int top, int right, int bottom, int color, FrameFlags flags)
+void DrawFrameRect(int left, int top, int right, int bottom, int colour, FrameFlags flags)
{
- uint dark = _colour_gradient[color][3];
- uint medium_dark = _colour_gradient[color][5];
- uint medium_light = _colour_gradient[color][6];
- uint light = _colour_gradient[color][7];
+ uint dark = _colour_gradient[colour][3];
+ uint medium_dark = _colour_gradient[colour][5];
+ uint medium_light = _colour_gradient[colour][6];
+ uint light = _colour_gradient[colour][7];
if (flags & FR_TRANSPARENT) {
GfxFillRect(left, top, right, bottom, PALETTE_TO_TRANSPARENT, FILLRECT_RECOLOR);
@@ -223,7 +223,7 @@ void Window::DrawWidgets() const
case WWT_IMGBTN_2: {
SpriteID img = wi->data;
assert(img != 0);
- DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->colour, (clicked) ? FR_LOWERED : FR_NONE);
/* show different image when clicked for WWT_IMGBTN_2 */
if ((wi->type & WWT_MASK) == WWT_IMGBTN_2 && clicked) img++;
@@ -233,16 +233,16 @@ void Window::DrawWidgets() const
case WWT_PANEL:
assert(wi->data == 0);
- DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->colour, (clicked) ? FR_LOWERED : FR_NONE);
break;
case WWT_EDITBOX:
- DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_LOWERED | FR_DARKENED);
+ DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->colour, FR_LOWERED | FR_DARKENED);
break;
case WWT_TEXTBTN:
case WWT_TEXTBTN_2:
- DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->colour, (clicked) ? FR_LOWERED : FR_NONE);
/* FALL THROUGH */
case WWT_LABEL: {
@@ -257,20 +257,20 @@ void Window::DrawWidgets() const
case WWT_TEXT: {
const StringID str = wi->data;
- if (str != STR_NULL) DrawStringTruncated(r.left, r.top, str, wi->color, r.right - r.left);
+ if (str != STR_NULL) DrawStringTruncated(r.left, r.top, str, wi->colour, r.right - r.left);
break;
}
case WWT_INSET: {
const StringID str = wi->data;
- DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_LOWERED | FR_DARKENED);
+ DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->colour, FR_LOWERED | FR_DARKENED);
if (str != STR_NULL) DrawStringTruncated(r.left + 2, r.top + 1, str, TC_FROMSTRING, r.right - r.left - 10);
break;
}
case WWT_MATRIX: {
- DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->colour, (clicked) ? FR_LOWERED : FR_NONE);
int c = GB(wi->data, 0, 8);
int amt1 = (wi->right - wi->left + 1) / c;
@@ -278,32 +278,32 @@ void Window::DrawWidgets() const
int d = GB(wi->data, 8, 8);
int amt2 = (wi->bottom - wi->top + 1) / d;
- int color = _colour_gradient[wi->color & 0xF][6];
+ int colour = _colour_gradient[wi->colour & 0xF][6];
int x = r.left;
for (int ctr = c; ctr > 1; ctr--) {
x += amt1;
- GfxFillRect(x, r.top + 1, x, r.bottom - 1, color);
+ GfxFillRect(x, r.top + 1, x, r.bottom - 1, colour);
}
x = r.top;
for (int ctr = d; ctr > 1; ctr--) {
x += amt2;
- GfxFillRect(r.left + 1, x, r.right - 1, x, color);
+ GfxFillRect(r.left + 1, x, r.right - 1, x, colour);
}
- color = _colour_gradient[wi->color & 0xF][4];
+ colour = _colour_gradient[wi->colour & 0xF][4];
x = r.left - 1;
for (int ctr = c; ctr > 1; ctr--) {
x += amt1;
- GfxFillRect(x, r.top + 1, x, r.bottom - 1, color);
+ GfxFillRect(x, r.top + 1, x, r.bottom - 1, colour);
}
x = r.top - 1;
for (int ctr = d; ctr > 1; ctr--) {
x += amt2;
- GfxFillRect(r.left + 1, x, r.right - 1, x, color);
+ GfxFillRect(r.left + 1, x, r.right - 1, x, colour);
}
break;
@@ -316,15 +316,15 @@ void Window::DrawWidgets() const
/* draw up/down buttons */
clicked = ((this->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_UP);
- DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->colour, (clicked) ? FR_LOWERED : FR_NONE);
DoDrawString(UPARROW, r.left + 2 + clicked, r.top + clicked, TC_BLACK);
clicked = (((this->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_DOWN));
- DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->colour, (clicked) ? FR_LOWERED : FR_NONE);
DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, TC_BLACK);
- int c1 = _colour_gradient[wi->color & 0xF][3];
- int c2 = _colour_gradient[wi->color & 0xF][7];
+ int c1 = _colour_gradient[wi->colour & 0xF][3];
+ int c2 = _colour_gradient[wi->colour & 0xF][7];
/* draw "shaded" background */
GfxFillRect(r.left, r.top + 10, r.right, r.bottom - 10, c2);
@@ -337,7 +337,7 @@ void Window::DrawWidgets() const
GfxFillRect(r.left + 8, r.top + 10, r.left + 8, r.bottom - 10, c2);
Point pt = HandleScrollbarHittest(&this->vscroll, r.top, r.bottom);
- DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (this->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_MIDDLE ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->colour, (this->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_MIDDLE ? FR_LOWERED : FR_NONE);
break;
}
@@ -347,15 +347,15 @@ void Window::DrawWidgets() const
/* draw up/down buttons */
clicked = ((this->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_UP | WF_SCROLL2));
- DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->colour, (clicked) ? FR_LOWERED : FR_NONE);
DoDrawString(UPARROW, r.left + 2 + clicked, r.top + clicked, TC_BLACK);
clicked = ((this->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_DOWN | WF_SCROLL2));
- DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->colour, (clicked) ? FR_LOWERED : FR_NONE);
DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, TC_BLACK);
- int c1 = _colour_gradient[wi->color & 0xF][3];
- int c2 = _colour_gradient[wi->color & 0xF][7];
+ int c1 = _colour_gradient[wi->colour & 0xF][3];
+ int c2 = _colour_gradient[wi->colour & 0xF][7];
/* draw "shaded" background */
GfxFillRect(r.left, r.top + 10, r.right, r.bottom - 10, c2);
@@ -368,7 +368,7 @@ void Window::DrawWidgets() const
GfxFillRect(r.left + 8, r.top + 10, r.left + 8, r.bottom - 10, c2);
Point pt = HandleScrollbarHittest(&this->vscroll2, r.top, r.bottom);
- DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (this->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_MIDDLE | WF_SCROLL2) ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->colour, (this->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_MIDDLE | WF_SCROLL2) ? FR_LOWERED : FR_NONE);
break;
}
@@ -378,15 +378,15 @@ void Window::DrawWidgets() const
assert(r.bottom - r.top == 11); // To ensure the same sizes are used everywhere!
clicked = ((this->flags4 & (WF_SCROLL_UP | WF_HSCROLL)) == (WF_SCROLL_UP | WF_HSCROLL));
- DrawFrameRect(r.left, r.top, r.left + 9, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(r.left, r.top, r.left + 9, r.bottom, wi->colour, (clicked) ? FR_LOWERED : FR_NONE);
DrawSprite(SPR_ARROW_LEFT, PAL_NONE, r.left + 1 + clicked, r.top + 1 + clicked);
clicked = ((this->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL)) == (WF_SCROLL_DOWN | WF_HSCROLL));
- DrawFrameRect(r.right - 9, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(r.right - 9, r.top, r.right, r.bottom, wi->colour, (clicked) ? FR_LOWERED : FR_NONE);
DrawSprite(SPR_ARROW_RIGHT, PAL_NONE, r.right - 8 + clicked, r.top + 1 + clicked);
- int c1 = _colour_gradient[wi->color & 0xF][3];
- int c2 = _colour_gradient[wi->color & 0xF][7];
+ int c1 = _colour_gradient[wi->colour & 0xF][3];
+ int c2 = _colour_gradient[wi->colour & 0xF][7];
/* draw "shaded" background */
GfxFillRect(r.left + 10, r.top, r.right - 10, r.bottom, c2);
@@ -400,7 +400,7 @@ void Window::DrawWidgets() const
/* draw actual scrollbar */
Point pt = HandleScrollbarHittest(&this->hscroll, r.left, r.right);
- DrawFrameRect(pt.x, r.top, pt.y, r.bottom, wi->color, (this->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL)) == (WF_SCROLL_MIDDLE | WF_HSCROLL) ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(pt.x, r.top, pt.y, r.bottom, wi->colour, (this->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL)) == (WF_SCROLL_MIDDLE | WF_HSCROLL) ? FR_LOWERED : FR_NONE);
break;
}
@@ -411,8 +411,8 @@ void Window::DrawWidgets() const
if (str != STR_NULL) x2 = DrawString(r.left + 6, r.top, str, TC_FROMSTRING);
- int c1 = _colour_gradient[wi->color][3];
- int c2 = _colour_gradient[wi->color][7];
+ int c1 = _colour_gradient[wi->colour][3];
+ int c2 = _colour_gradient[wi->colour][7];
/* Line from upper left corner to start of text */
GfxFillRect(r.left, r.top + 4, r.left + 4, r.top + 4, c1);
@@ -441,7 +441,7 @@ void Window::DrawWidgets() const
assert(r.right - r.left == 11); // To ensure the same sizes are used everywhere!
clicked = !!(this->flags4 & WF_STICKY);
- DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->colour, (clicked) ? FR_LOWERED : FR_NONE);
DrawSprite((clicked) ? SPR_PIN_UP : SPR_PIN_DOWN, PAL_NONE, r.left + 2 + clicked, r.top + 3 + clicked);
break;
@@ -450,7 +450,7 @@ void Window::DrawWidgets() const
assert(r.right - r.left == 11); // To ensure the same sizes are used everywhere!
clicked = !!(this->flags4 & WF_SIZING);
- DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->colour, (clicked) ? FR_LOWERED : FR_NONE);
DrawSprite(SPR_WINDOW_RESIZE, PAL_NONE, r.left + 3 + clicked, r.top + 3 + clicked);
break;
@@ -460,15 +460,15 @@ void Window::DrawWidgets() const
assert(str == STR_00C5 || str == STR_00C6); // black or silver cross
assert(r.right - r.left == 10); // To ensure the same sizes are used everywhere
- DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_NONE);
+ DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->colour, FR_NONE);
DrawString(r.left + 2, r.top + 2, str, TC_FROMSTRING);
break;
}
case WWT_CAPTION:
assert(r.bottom - r.top == 13); // To ensure the same sizes are used everywhere!
- DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_BORDERONLY);
- DrawFrameRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, wi->color, (this->caption_color == 0xFF) ? FR_LOWERED | FR_DARKENED : FR_LOWERED | FR_DARKENED | FR_BORDERONLY);
+ DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->colour, FR_BORDERONLY);
+ DrawFrameRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, wi->colour, (this->caption_color == 0xFF) ? FR_LOWERED | FR_DARKENED : FR_LOWERED | FR_DARKENED | FR_BORDERONLY);
if (this->caption_color != 0xFF) {
GfxFillRect(r.left + 2, r.top + 2, r.right - 2, r.bottom - 2, _colour_gradient[_company_colours[this->caption_color]][4]);
@@ -481,8 +481,8 @@ void Window::DrawWidgets() const
assert(r.bottom - r.top == 11); // ensure consistent size
StringID str = wi->data;
- DrawFrameRect(r.left, r.top, r.right - 12, r.bottom, wi->color, FR_NONE);
- DrawFrameRect(r.right - 11, r.top, r.right, r.bottom, wi->color, clicked ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(r.left, r.top, r.right - 12, r.bottom, wi->colour, FR_NONE);
+ DrawFrameRect(r.right - 11, r.top, r.right, r.bottom, wi->colour, clicked ? FR_LOWERED : FR_NONE);
DrawString(r.right - (clicked ? 8 : 9), r.top + (clicked ? 2 : 1), STR_0225, TC_BLACK);
if (str != STR_NULL) DrawStringTruncated(r.left + 2, r.top + 1, str, TC_BLACK, r.right - r.left - 12);
break;
@@ -492,8 +492,8 @@ void Window::DrawWidgets() const
assert(r.bottom - r.top == 11); // ensure consistent size
StringID str = wi->data;
- DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_LOWERED | FR_DARKENED);
- DrawFrameRect(r.right - 11, r.top + 1, r.right - 1, r.bottom - 1, wi->color, clicked ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->colour, FR_LOWERED | FR_DARKENED);
+ DrawFrameRect(r.right - 11, r.top + 1, r.right - 1, r.bottom - 1, wi->colour, clicked ? FR_LOWERED : FR_NONE);
DrawString(r.right - (clicked ? 8 : 9), r.top + (clicked ? 2 : 1), STR_0225, TC_BLACK);
if (str != STR_NULL) DrawStringTruncated(r.left + 2, r.top + 2, str, TC_BLACK, r.right - r.left - 12);
break;
@@ -501,7 +501,7 @@ void Window::DrawWidgets() const
}
if (this->IsWidgetDisabled(i)) {
- GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, _colour_gradient[wi->color & 0xF][2], FILLRECT_CHECKER);
+ GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, _colour_gradient[wi->colour & 0xF][2], FILLRECT_CHECKER);
}
}
diff --git a/src/widget_type.h b/src/widget_type.h
new file mode 100644
index 000000000..e3d2fec94
--- /dev/null
+++ b/src/widget_type.h
@@ -0,0 +1,126 @@
+/* $Id$ */
+
+/** @file widget_type.h Definitions about widgets. */
+
+#ifndef WIDGET_TYPE_H
+#define WIDGET_TYPE_H
+
+#include "core/bitmath_func.hpp"
+#include "strings_type.h"
+#include "gfx_type.h"
+
+/* How the resize system works:
+ First, you need to add a WWT_RESIZEBOX to the widgets, and you need
+ to add the flag WDF_RESIZABLE to the window. Now the window is ready
+ to resize itself.
+ As you may have noticed, all widgets have a RESIZE_XXX in their line.
+ This lines controls how the widgets behave on resize. RESIZE_NONE means
+ it doesn't do anything. Any other option let's one of the borders
+ move with the changed width/height. So if a widget has
+ RESIZE_RIGHT, and the window is made 5 pixels wider by the user,
+ the right of the window will also be made 5 pixels wider.
+ Now, what if you want to clamp a widget to the bottom? Give it the flag
+ RESIZE_TB. This is RESIZE_TOP + RESIZE_BOTTOM. Now if the window gets
+ 5 pixels bigger, both the top and bottom gets 5 bigger, so the whole
+ widgets moves downwards without resizing, and appears to be clamped
+ to the bottom. Nice aint it?
+ You should know one more thing about this system. Most windows can't
+ handle an increase of 1 pixel. So there is a step function, which
+ let the windowsize only be changed by X pixels. You configure this
+ after making the window, like this:
+ w->resize.step_height = 10;
+ Now the window will only change in height in steps of 10.
+ You can also give a minimum width and height. The default value is
+ the default height/width of the window itself. You can change this
+ AFTER window - creation, with:
+ w->resize.width or w->resize.height.
+ That was all.. good luck, and enjoy :) -- TrueLight */
+
+enum DisplayFlags {
+ RESIZE_NONE = 0, ///< no resize required
+
+ RESIZE_LEFT = 1, ///< left resize flag
+ RESIZE_RIGHT = 2, ///< rigth resize flag
+ RESIZE_TOP = 4, ///< top resize flag
+ RESIZE_BOTTOM = 8, ///< bottom resize flag
+
+ RESIZE_LR = RESIZE_LEFT | RESIZE_RIGHT, ///< combination of left and right resize flags
+ RESIZE_RB = RESIZE_RIGHT | RESIZE_BOTTOM, ///< combination of right and bottom resize flags
+ RESIZE_TB = RESIZE_TOP | RESIZE_BOTTOM, ///< combination of top and bottom resize flags
+ RESIZE_LRB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_BOTTOM, ///< combination of left, right and bottom resize flags
+ RESIZE_LRTB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM, ///< combination of all resize flags
+ RESIZE_RTB = RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM, ///< combination of right, top and bottom resize flag
+
+ /* The following flags are used by the system to specify what is disabled, hidden, or clicked
+ * They are used in the same place as the above RESIZE_x flags, Widget visual_flags.
+ * These states are used in exceptions. If nothing is specified, they will indicate
+ * Enabled, visible or unclicked widgets*/
+ WIDG_DISABLED = 4, ///< widget is greyed out, not available
+ WIDG_HIDDEN = 5, ///< widget is made invisible
+ WIDG_LOWERED = 6, ///< widget is paint lowered, a pressed button in fact
+};
+DECLARE_ENUM_AS_BIT_SET(DisplayFlags);
+
+enum {
+ WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions
+};
+
+/**
+ * Window widget types
+ */
+enum WidgetType {
+ WWT_EMPTY, ///< Empty widget, place holder to reserve space in widget array
+
+ WWT_PANEL, ///< Simple depressed panel
+ WWT_INSET, ///< Pressed (inset) panel, most commonly used as combo box _text_ area
+ WWT_IMGBTN, ///< Button with image
+ WWT_IMGBTN_2, ///< Button with diff image when clicked
+
+ WWT_TEXTBTN, ///< Button with text
+ WWT_TEXTBTN_2, ///< Button with diff text when clicked
+ WWT_LABEL, ///< Centered label
+ WWT_TEXT, ///< Pure simple text
+ WWT_MATRIX, ///< List of items underneath each other
+ WWT_SCROLLBAR, ///< Vertical scrollbar
+ WWT_FRAME, ///< Frame
+ WWT_CAPTION, ///< Window caption (window title between closebox and stickybox)
+
+ WWT_HSCROLLBAR, ///< Horizontal scrollbar
+ WWT_STICKYBOX, ///< Sticky box (normally at top-right of a window)
+ WWT_SCROLL2BAR, ///< 2nd vertical scrollbar
+ WWT_RESIZEBOX, ///< Resize box (normally at bottom-right of a window)
+ WWT_CLOSEBOX, ///< Close box (at top-left of a window)
+ WWT_DROPDOWN, ///< Raised drop down list (regular)
+ WWT_DROPDOWNIN, ///< Inset drop down list (used on game options only)
+ WWT_EDITBOX, ///< a textbox for typing
+ WWT_LAST, ///< Last Item. use WIDGETS_END to fill up padding!!
+
+ WWT_MASK = 0x1F,
+
+ WWB_PUSHBUTTON = 1 << 5,
+ WWB_MASK = 0xE0,
+
+ WWT_PUSHBTN = WWT_PANEL | WWB_PUSHBUTTON,
+ WWT_PUSHTXTBTN = WWT_TEXTBTN | WWB_PUSHBUTTON,
+ WWT_PUSHIMGBTN = WWT_IMGBTN | WWB_PUSHBUTTON,
+};
+
+/** Marker for the "end of widgets" in a Window(Desc) widget table. */
+#define WIDGETS_END WWT_LAST, RESIZE_NONE, INVALID_COLOUR, 0, 0, 0, 0, 0, STR_NULL
+
+/**
+ * Window widget data structure
+ */
+struct Widget {
+ WidgetType type; ///< Widget type
+ DisplayFlags display_flags; ///< Resize direction, alignment, etc. during resizing
+ Colours colour; ///< Widget colour, see docs/ottd-colourtext-palette.png
+ int16 left; ///< The left edge of the widget
+ int16 right; ///< The right edge of the widget
+ int16 top; ///< The top edge of the widget
+ int16 bottom; ///< The bottom edge of the widget
+ uint16 data; ///< The String/Image or special code (list-matrixes) of a widget
+ StringID tooltips; ///< Tooltips that are shown when rightclicking on a widget
+};
+
+#endif /* WIDGET_TYPE_H */
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp
index 986d051d5..88d31ab7a 100644
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -148,11 +148,11 @@ struct DropdownWindow : Window {
if (y + item_height < height) {
if (sel == item->result) GfxFillRect(x + 1, y, x + width - 1, y + item_height - 1, 0);
- item->Draw(x, y, width, height, sel == item->result, (TextColour)this->widget[0].color);
+ item->Draw(x, y, width, height, sel == item->result, (TextColour)this->widget[0].colour);
if (item->masked) {
GfxFillRect(x, y, x + width - 1, y + item_height - 1,
- _colour_gradient[this->widget[0].color][5], FILLRECT_CHECKER
+ _colour_gradient[this->widget[0].colour][5], FILLRECT_CHECKER
);
}
}
@@ -307,7 +307,7 @@ void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, u
height + 4,
_dropdown_menu_widgets);
- dw->widget[0].color = wi->color;
+ dw->widget[0].colour = wi->colour;
dw->widget[0].right = width - 1;
dw->widget[0].bottom = height + 3;
@@ -316,7 +316,7 @@ void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, u
if (scroll) {
/* We're scrolling, so enable the scroll bar and shrink the list by
* the scrollbar's width */
- dw->widget[1].color = wi->color;
+ dw->widget[1].colour = wi->colour;
dw->widget[1].right = dw->widget[0].right;
dw->widget[1].left = dw->widget[1].right - 11;
dw->widget[1].bottom = dw->widget[0].bottom;
diff --git a/src/window.cpp b/src/window.cpp
index 5161bea4f..c8d15245a 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -172,6 +172,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, bool double_click)
if (wi->type & WWB_MASK) {
/* special widget handling for buttons*/
switch (wi->type) {
+ default: NOT_REACHED();
case WWT_PANEL | WWB_PUSHBUTTON: /* WWT_PUSHBTN */
case WWT_IMGBTN | WWB_PUSHBUTTON: /* WWT_PUSHIMGBTN */
case WWT_TEXTBTN | WWB_PUSHBUTTON: /* WWT_PUSHTXTBTN */
diff --git a/src/window_gui.h b/src/window_gui.h
index 85e4bce3b..abf10c237 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -5,85 +5,14 @@
#ifndef WINDOW_GUI_H
#define WINDOW_GUI_H
-#include "core/bitmath_func.hpp"
#include "core/geometry_type.hpp"
#include "vehicle_type.h"
#include "viewport_type.h"
#include "company_type.h"
-#include "strings_type.h"
#include "core/alloc_type.hpp"
#include "window_type.h"
#include "tile_type.h"
-
-/* How the resize system works:
- First, you need to add a WWT_RESIZEBOX to the widgets, and you need
- to add the flag WDF_RESIZABLE to the window. Now the window is ready
- to resize itself.
- As you may have noticed, all widgets have a RESIZE_XXX in their line.
- This lines controls how the widgets behave on resize. RESIZE_NONE means
- it doesn't do anything. Any other option let's one of the borders
- move with the changed width/height. So if a widget has
- RESIZE_RIGHT, and the window is made 5 pixels wider by the user,
- the right of the window will also be made 5 pixels wider.
- Now, what if you want to clamp a widget to the bottom? Give it the flag
- RESIZE_TB. This is RESIZE_TOP + RESIZE_BOTTOM. Now if the window gets
- 5 pixels bigger, both the top and bottom gets 5 bigger, so the whole
- widgets moves downwards without resizing, and appears to be clamped
- to the bottom. Nice aint it?
- You should know one more thing about this system. Most windows can't
- handle an increase of 1 pixel. So there is a step function, which
- let the windowsize only be changed by X pixels. You configure this
- after making the window, like this:
- w->resize.step_height = 10;
- Now the window will only change in height in steps of 10.
- You can also give a minimum width and height. The default value is
- the default height/width of the window itself. You can change this
- AFTER window - creation, with:
- w->resize.width or w->resize.height.
- That was all.. good luck, and enjoy :) -- TrueLight */
-
-enum ResizeFlag {
- RESIZE_NONE = 0, ///< no resize required
-
- RESIZE_LEFT = 1, ///< left resize flag
- RESIZE_RIGHT = 2, ///< rigth resize flag
- RESIZE_TOP = 4, ///< top resize flag
- RESIZE_BOTTOM = 8, ///< bottom resize flag
-
- RESIZE_LR = RESIZE_LEFT | RESIZE_RIGHT, ///< combination of left and right resize flags
- RESIZE_RB = RESIZE_RIGHT | RESIZE_BOTTOM, ///< combination of right and bottom resize flags
- RESIZE_TB = RESIZE_TOP | RESIZE_BOTTOM, ///< combination of top and bottom resize flags
- RESIZE_LRB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_BOTTOM, ///< combination of left, right and bottom resize flags
- RESIZE_LRTB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM, ///< combination of all resize flags
- RESIZE_RTB = RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM, ///< combination of right, top and bottom resize flag
-
- /* The following flags are used by the system to specify what is disabled, hidden, or clicked
- * They are used in the same place as the above RESIZE_x flags, Widget visual_flags.
- * These states are used in exceptions. If nothing is specified, they will indicate
- * Enabled, visible or unclicked widgets*/
- WIDG_DISABLED = 4, ///< widget is greyed out, not available
- WIDG_HIDDEN = 5, ///< widget is made invisible
- WIDG_LOWERED = 6, ///< widget is paint lowered, a pressed button in fact
-};
-
-enum {
- WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions
-};
-
-/**
- * Window widget data structure
- */
-struct Widget {
- byte type; ///< Widget type, see WindowWidgetTypes
- byte display_flags; ///< Resize direction, alignment, etc. during resizing. @see ResizeFlags
- byte color; ///< Widget colour, see docs/ottd-colourtext-palette.png
- int16 left; ///< The left edge of the widget
- int16 right; ///< The right edge of the widget
- int16 top; ///< The top edge of the widget
- int16 bottom; ///< The bottom edge of the widget
- uint16 data; ///< The String/Image or special code (list-matrixes) of a widget
- StringID tooltips; ///< Tooltips that are shown when rightclicking on a widget
-};
+#include "widget_type.h"
/**
* Flags to describe the look of the frame
@@ -445,54 +374,6 @@ public:
virtual ~PickerWindowBase();
};
-/****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
-enum WindowWidgetBehaviours {
- WWB_PUSHBUTTON = 1 << 5,
-
- WWB_MASK = 0xE0,
-};
-
-
-/**
- * Window widget types
- */
-enum WindowWidgetTypes {
- WWT_EMPTY, ///< Empty widget, place holder to reserve space in widget array
-
- WWT_PANEL, ///< Simple depressed panel
- WWT_INSET, ///< Pressed (inset) panel, most commonly used as combo box _text_ area
- WWT_IMGBTN, ///< Button with image
- WWT_IMGBTN_2, ///< Button with diff image when clicked
-
- WWT_TEXTBTN, ///< Button with text
- WWT_TEXTBTN_2, ///< Button with diff text when clicked
- WWT_LABEL, ///< Centered label
- WWT_TEXT, ///< Pure simple text
- WWT_MATRIX, ///< List of items underneath each other
- WWT_SCROLLBAR, ///< Vertical scrollbar
- WWT_FRAME, ///< Frame
- WWT_CAPTION, ///< Window caption (window title between closebox and stickybox)
-
- WWT_HSCROLLBAR, ///< Horizontal scrollbar
- WWT_STICKYBOX, ///< Sticky box (normally at top-right of a window)
- WWT_SCROLL2BAR, ///< 2nd vertical scrollbar
- WWT_RESIZEBOX, ///< Resize box (normally at bottom-right of a window)
- WWT_CLOSEBOX, ///< Close box (at top-left of a window)
- WWT_DROPDOWN, ///< Raised drop down list (regular)
- WWT_DROPDOWNIN, ///< Inset drop down list (used on game options only)
- WWT_EDITBOX, ///< a textbox for typing
- WWT_LAST, ///< Last Item. use WIDGETS_END to fill up padding!!
-
- WWT_MASK = 0x1F,
-
- WWT_PUSHBTN = WWT_PANEL | WWB_PUSHBUTTON,
- WWT_PUSHTXTBTN = WWT_TEXTBTN | WWB_PUSHBUTTON,
- WWT_PUSHIMGBTN = WWT_IMGBTN | WWB_PUSHBUTTON,
-};
-
-/** Marker for the "end of widgets" in a Window(Desc) widget table. */
-#define WIDGETS_END WWT_LAST, RESIZE_NONE, 0, 0, 0, 0, 0, 0, STR_NULL
-
/**
* Window flags
*/