Skip to content

Commit

Permalink
widgets: Cleanup, replace remnants of C-style virtual functions calls…
Browse files Browse the repository at this point in the history
… with native C++ virtual functions.
  • Loading branch information
Cyp committed Jan 26, 2013
1 parent bf6daeb commit d285bbf
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 112 deletions.
16 changes: 8 additions & 8 deletions lib/widget/bar.cpp
Expand Up @@ -192,22 +192,22 @@ void widgSetMinorBarSize(W_SCREEN *psScreen, UDWORD id, UDWORD iValue )


/* Respond to a mouse moving over a barGraph */
void barGraphHiLite(W_BARGRAPH *psWidget, W_CONTEXT *psContext)
void W_BARGRAPH::highlight(W_CONTEXT *psContext)
{
if (psWidget->pTip)
if (pTip)
{
tipStart((WIDGET *)psWidget, psWidget->pTip, psContext->psScreen->TipFontID,
psContext->psForm->aColours,
psWidget->x + psContext->xOffset, psWidget->y + psContext->yOffset,
psWidget->width, psWidget->height);
tipStart(this, pTip, psContext->psScreen->TipFontID,
psContext->psForm->aColours,
x + psContext->xOffset, y + psContext->yOffset,
width, height);
}
}


/* Respond to the mouse moving off a barGraph */
void barGraphHiLiteLost(W_BARGRAPH *psWidget)
void W_BARGRAPH::highlightLost(W_CONTEXT *psContext)
{
tipStop((WIDGET *)psWidget);
tipStop(this);
}


Expand Down
10 changes: 2 additions & 8 deletions lib/widget/bar.h
Expand Up @@ -27,18 +27,12 @@
#include "widget.h"


/* Respond to a mouse moving over a barGraph */
void barGraphHiLite(W_BARGRAPH *psWidget, W_CONTEXT *psContext);
/* Respond to the mouse moving off a barGraph */
void barGraphHiLiteLost(W_BARGRAPH *psWidget);


struct W_BARGRAPH : public WIDGET
{
W_BARGRAPH(W_BARINIT const *init);

void highlight(W_CONTEXT *psContext) { barGraphHiLite(this, psContext); }
void highlightLost(W_CONTEXT *) { barGraphHiLiteLost(this); }
void highlight(W_CONTEXT *psContext);
void highlightLost(W_CONTEXT *);

WBAR_ORIENTATION barPos; // Orientation of the bar on the widget
UWORD majorSize; // Percentage of the main bar that is filled
Expand Down
16 changes: 11 additions & 5 deletions lib/widget/button.cpp
Expand Up @@ -179,8 +179,9 @@ void buttonSetState(W_BUTTON *psButton, UDWORD state)


/* Run a button widget */
void buttonRun(W_BUTTON *psButton)
void W_BUTTON::run(W_CONTEXT *)
{
W_BUTTON *psButton = this;
if (psButton->state & WBUTS_FLASH)
{
if (((realTime/250) % 2) == 0) {
Expand All @@ -193,8 +194,9 @@ void buttonRun(W_BUTTON *psButton)


/* Respond to a mouse click */
void buttonClicked(W_BUTTON *psWidget, UDWORD key)
void W_BUTTON::clicked(W_CONTEXT *, WIDGET_KEY key)
{
W_BUTTON *psWidget = this;
/* Can't click a button if it is disabled or locked down */
if (!(psWidget->state & (WBUTS_GREY | WBUTS_LOCKED)))
{
Expand All @@ -219,8 +221,10 @@ void buttonClicked(W_BUTTON *psWidget, UDWORD key)
}

/* Respond to a mouse button up */
void buttonReleased(W_SCREEN* psScreen, W_BUTTON* psWidget, UDWORD key)
void W_BUTTON::released(W_CONTEXT *psContext, WIDGET_KEY key)
{
W_SCREEN *psScreen = psContext->psScreen;
W_BUTTON *psWidget = this;
if (psWidget->state & WBUTS_DOWN)
{
// Check this is the correct key
Expand All @@ -235,8 +239,9 @@ void buttonReleased(W_SCREEN* psScreen, W_BUTTON* psWidget, UDWORD key)


/* Respond to a mouse moving over a button */
void buttonHiLite(W_BUTTON *psWidget, W_CONTEXT *psContext)
void W_BUTTON::highlight(W_CONTEXT *psContext)
{
W_BUTTON *psWidget = this;
psWidget->state |= WBUTS_HILITE;

if(psWidget->AudioCallback) {
Expand All @@ -255,8 +260,9 @@ void buttonHiLite(W_BUTTON *psWidget, W_CONTEXT *psContext)


/* Respond to the mouse moving off a button */
void buttonHiLiteLost(W_BUTTON *psWidget)
void W_BUTTON::highlightLost(W_CONTEXT *)
{
W_BUTTON *psWidget = this;
psWidget->state &= ~(WBUTS_DOWN | WBUTS_HILITE);
if (psWidget->pTip)
{
Expand Down
22 changes: 5 additions & 17 deletions lib/widget/button.h
Expand Up @@ -39,27 +39,15 @@
#define WBUTS_FLASHON 0x0040 // Button is flashing


/* Respond to a mouse click */
void buttonClicked(W_BUTTON *psWidget, UDWORD key);
/* Respond to a mouse button up */
void buttonReleased(W_SCREEN *psScreen, W_BUTTON *psWidget, UDWORD key);
/* Respond to a mouse moving over a button */
void buttonHiLite(W_BUTTON *psWidget, W_CONTEXT *psContext);
/* Respond to the mouse moving off a button */
void buttonHiLiteLost(W_BUTTON *psWidget);
/* Run a button widget */
void buttonRun(W_BUTTON *psWidget);


struct W_BUTTON : public WIDGET
{
W_BUTTON(W_BUTINIT const *init);

void clicked(W_CONTEXT *, WIDGET_KEY key) { buttonClicked(this, key); }
void released(W_CONTEXT *psContext, WIDGET_KEY key) { buttonReleased(psContext->psScreen, this, key); }
void highlight(W_CONTEXT *psContext) { buttonHiLite(this, psContext); }
void highlightLost(W_CONTEXT *) { buttonHiLiteLost(this); }
void run(W_CONTEXT *) { buttonRun(this); }
void clicked(W_CONTEXT *psContext, WIDGET_KEY key);
void released(W_CONTEXT *psContext, WIDGET_KEY key);
void highlight(W_CONTEXT *psContext);
void highlightLost(W_CONTEXT *psContext);
void run(W_CONTEXT *psContext);

UDWORD state; // The current button state
const char *pText; // The text for the button
Expand Down
6 changes: 4 additions & 2 deletions lib/widget/editbox.cpp
Expand Up @@ -516,8 +516,9 @@ void W_EDITBOX::focusLost(W_SCREEN *psScreen)


/* Respond to a mouse moving over an edit box */
void editBoxHiLite(W_EDITBOX *psWidget)
void W_EDITBOX::highlight(W_CONTEXT *)
{
W_EDITBOX *psWidget = this;
if(psWidget->state & WEDBS_DISABLE)
{
return;
Expand All @@ -533,8 +534,9 @@ void editBoxHiLite(W_EDITBOX *psWidget)


/* Respond to the mouse moving off an edit box */
void editBoxHiLiteLost(W_EDITBOX *psWidget)
void W_EDITBOX::highlightLost(W_CONTEXT *)
{
W_EDITBOX *psWidget = this;
if(psWidget->state & WEDBS_DISABLE)
{
return;
Expand Down
12 changes: 3 additions & 9 deletions lib/widget/editbox.h
Expand Up @@ -38,22 +38,16 @@
#define WEDBS_DISABLE 0x0020 // disable button from selection


/* Respond to a mouse moving over an edit box */
void editBoxHiLite(W_EDITBOX *psWidget);
/* Respond to the mouse moving off an edit box */
void editBoxHiLiteLost(W_EDITBOX *psWidget);


struct W_EDITBOX : public WIDGET
{
W_EDITBOX(W_EDBINIT const *init);

void initialise(); // Moves the cursor to the end.
void setString(char const *utf8);

void clicked(W_CONTEXT *psContext, WIDGET_KEY);
void highlight(W_CONTEXT *) { editBoxHiLite(this); }
void highlightLost(W_CONTEXT *) { editBoxHiLiteLost(this); }
void clicked(W_CONTEXT *psContext, WIDGET_KEY key);
void highlight(W_CONTEXT *psContext);
void highlightLost(W_CONTEXT *psContext);
void focusLost(W_SCREEN *psScreen);
void run(W_CONTEXT *psContext);

Expand Down
15 changes: 10 additions & 5 deletions lib/widget/form.cpp
Expand Up @@ -968,8 +968,9 @@ static bool formPickTab(W_TABFORM *psForm, UDWORD fx, UDWORD fy,
extern UDWORD realTime; // FIXME Include a header...

/* Run a form widget */
void formRun(W_FORM *psWidget, W_CONTEXT *psContext)
void W_FORM::run(W_CONTEXT *psContext)
{
W_FORM *psWidget = this;
SDWORD mx,my;
TAB_POS sTabPos;
char *pTip;
Expand Down Expand Up @@ -1057,8 +1058,9 @@ void formClearFlash(W_FORM *psWidget)


/* Respond to a mouse click */
void formClicked(W_FORM *psWidget, UDWORD key)
void W_FORM::clicked(W_CONTEXT *, WIDGET_KEY key)
{
W_FORM *psWidget = this;
W_CLICKFORM *psClickForm;

/* Stop the tip if there is one */
Expand Down Expand Up @@ -1089,8 +1091,9 @@ void formClicked(W_FORM *psWidget, UDWORD key)


/* Respond to a mouse form up */
void formReleased(W_FORM *psWidget, UDWORD key, W_CONTEXT *psContext)
void W_FORM::released(W_CONTEXT *psContext, WIDGET_KEY key)
{
W_FORM *psWidget = this;
W_TABFORM *psTabForm;
W_CLICKFORM *psClickForm;
TAB_POS sTabPos;
Expand Down Expand Up @@ -1137,8 +1140,9 @@ void formReleased(W_FORM *psWidget, UDWORD key, W_CONTEXT *psContext)


/* Respond to a mouse moving over a form */
void formHiLite(W_FORM *psWidget, W_CONTEXT *psContext)
void W_FORM::highlight(W_CONTEXT *psContext)
{
W_FORM *psWidget = this;
W_CLICKFORM *psClickForm;

if (psWidget->style & WFORM_CLICKABLE)
Expand All @@ -1164,8 +1168,9 @@ void formHiLite(W_FORM *psWidget, W_CONTEXT *psContext)


/* Respond to the mouse moving off a form */
void formHiLiteLost(W_FORM *psWidget, W_CONTEXT *psContext)
void W_FORM::highlightLost(W_CONTEXT *psContext)
{
W_FORM *psWidget = this;
/* If one of the widgets were hilited that has to loose it as well */
if (psWidget->psLastHiLite != NULL)
{
Expand Down
22 changes: 5 additions & 17 deletions lib/widget/form.h
Expand Up @@ -27,28 +27,16 @@
#include "lib/widget/widget.h"


/* Respond to a mouse click */
void formClicked(W_FORM *psWidget, UDWORD key);
/* Respond to a mouse form up */
void formReleased(W_FORM *psWidget, UDWORD key, W_CONTEXT *psContext);
/* Respond to a mouse moving over a form */
void formHiLite(W_FORM *psWidget, W_CONTEXT *psContext);
/* Respond to the mouse moving off a form */
void formHiLiteLost(W_FORM *psWidget, W_CONTEXT *psContext);
/* Run a form widget */
void formRun(W_FORM *psWidget, W_CONTEXT *psContext);


/* The standard form */
struct W_FORM : public WIDGET
{
W_FORM(W_FORMINIT const *init);

void clicked(W_CONTEXT *, WIDGET_KEY key) { formClicked(this, key); }
void released(W_CONTEXT *psContext, WIDGET_KEY key) { formReleased(this, key, psContext); }
void highlight(W_CONTEXT *psContext) { formHiLite(this, psContext); }
void highlightLost(W_CONTEXT *psContext) { formHiLiteLost(this, psContext); }
void run(W_CONTEXT *psContext) { formRun(this, psContext); }
void clicked(W_CONTEXT *psContext, WIDGET_KEY key);
void released(W_CONTEXT *psContext, WIDGET_KEY key);
void highlight(W_CONTEXT *psContext);
void highlightLost(W_CONTEXT *psContext);
void run(W_CONTEXT *psContext);

bool disableChildren; ///< Disable all child widgets if true
UWORD Ax0,Ay0,Ax1,Ay1; ///< Working coords for animations.
Expand Down
18 changes: 9 additions & 9 deletions lib/widget/label.cpp
Expand Up @@ -119,24 +119,24 @@ void labelDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pC
}

/* Respond to a mouse moving over a label */
void labelHiLite(W_LABEL *psWidget, W_CONTEXT *psContext)
void W_LABEL::highlight(W_CONTEXT *psContext)
{
/* If there is a tip string start the tool tip */
if (psWidget->pTip)
if (pTip)
{
tipStart((WIDGET *)psWidget, psWidget->pTip, psContext->psScreen->TipFontID,
psContext->psForm->aColours,
psWidget->x + psContext->xOffset, psWidget->y + psContext->yOffset,
psWidget->width,psWidget->height);
tipStart(this, pTip, psContext->psScreen->TipFontID,
psContext->psForm->aColours,
x + psContext->xOffset, y + psContext->yOffset,
width, height);
}
}


/* Respond to the mouse moving off a label */
void labelHiLiteLost(W_LABEL *psWidget)
void W_LABEL::highlightLost(W_CONTEXT *)
{
if (psWidget->pTip)
if (pTip)
{
tipStop((WIDGET *)psWidget);
tipStop(this);
}
}
10 changes: 2 additions & 8 deletions lib/widget/label.h
Expand Up @@ -29,18 +29,12 @@
#include "lib/ivis_opengl/textdraw.h"


/* Respond to a mouse moving over a label */
void labelHiLite(W_LABEL *psWidget, W_CONTEXT *psContext);
/* Respond to the mouse moving off a label */
void labelHiLiteLost(W_LABEL *psWidget);


struct W_LABEL : public WIDGET
{
W_LABEL(W_LABINIT const *init);

void highlight(W_CONTEXT *psContext) { labelHiLite(this, psContext); }
void highlightLost(W_CONTEXT *) { labelHiLiteLost(this); }
void highlight(W_CONTEXT *psContext);
void highlightLost(W_CONTEXT *);

char aText[WIDG_MAXSTR]; // Text on the label
enum iV_fonts FontID;
Expand Down
19 changes: 10 additions & 9 deletions lib/widget/slider.cpp
Expand Up @@ -216,8 +216,9 @@ static void sliderGetBarBox(W_SLIDER *psSlider, SWORD *pX, SWORD *pY,


/* Run a slider widget */
void sliderRun(W_SLIDER *psWidget, W_CONTEXT *psContext)
void W_SLIDER::run(W_CONTEXT *psContext)
{
W_SLIDER *psWidget = this;
SDWORD mx,my;
UDWORD stopSize;

Expand All @@ -228,7 +229,7 @@ void sliderRun(W_SLIDER *psWidget, W_CONTEXT *psContext)
}
else if (!(psWidget->state & SLD_DRAG) && mouseDown(MOUSE_LMB))
{
sliderClicked(psWidget, psContext);
clicked(psContext, WKEY_NONE);
}
if (psWidget->state & SLD_DRAG)
{
Expand Down Expand Up @@ -317,8 +318,9 @@ void sliderRun(W_SLIDER *psWidget, W_CONTEXT *psContext)


/* Respond to a mouse click */
void sliderClicked(W_SLIDER *psWidget, W_CONTEXT *psContext)
void W_SLIDER::clicked(W_CONTEXT *psContext, WIDGET_KEY)
{
W_SLIDER *psWidget = this;
#if 0
SWORD x,y;
UWORD width,height;
Expand All @@ -344,23 +346,22 @@ void sliderClicked(W_SLIDER *psWidget, W_CONTEXT *psContext)


/* Respond to a mouse up */
void sliderReleased(W_SLIDER *psWidget)
void W_SLIDER::released(W_CONTEXT *, WIDGET_KEY)
{
(void)psWidget;
}


/* Respond to a mouse moving over a slider */
void sliderHiLite(W_SLIDER *psWidget)
void W_SLIDER::highlight(W_CONTEXT *)
{
psWidget->state |= SLD_HILITE;
state |= SLD_HILITE;
}


/* Respond to the mouse moving off a slider */
void sliderHiLiteLost(W_SLIDER *psWidget)
void W_SLIDER::highlightLost(W_CONTEXT *)
{
psWidget->state &= ~SLD_HILITE;
state &= ~SLD_HILITE;
}

/* The slider display function */
Expand Down

0 comments on commit d285bbf

Please sign in to comment.