Permalink
Browse files

widget: Remove unused and useless W_TABFORM.

  • Loading branch information...
1 parent 685e77c commit 1240e7c96c5ecdb8415a1726438475f8ee7d719b @Cyp Cyp committed Mar 12, 2013
Showing with 40 additions and 482 deletions.
  1. +2 −291 lib/widget/form.cpp
  2. +0 −55 lib/widget/form.h
  3. +3 −7 lib/widget/widget.cpp
  4. +1 −40 lib/widget/widget.h
  5. +4 −7 src/design.cpp
  6. +4 −7 src/display3d.cpp
  7. +1 −3 src/hci.cpp
  8. +0 −36 src/intdisplay.cpp
  9. +0 −2 src/intdisplay.h
  10. +23 −28 src/intelmap.cpp
  11. +2 −6 src/transporter.cpp
View
@@ -32,34 +32,17 @@
#include "lib/ivis_opengl/pieblitfunc.h"
#include "lib/ivis_opengl/piepalette.h"
-/* Control whether single tabs are displayed */
-#define NO_DISPLAY_SINGLE_TABS 1
-
W_FORMINIT::W_FORMINIT()
: disableChildren(false)
- , majorPos(0)
- , majorSize(0)
- , majorOffset(0)
- , tabVertOffset(0)
- , tabHorzOffset(0)
- , tabMajorThickness(0)
- , tabMajorGap(0)
- , numStats(0)
- , numButtons(0)
- , numMajor(0)
- , maxTabsShown(MAX_TAB_SMALL_SHOWN - 1) // Equal to TAB_SEVEN, which is equal to 7.
, pTip(NULL)
- , pTabDisplay(NULL)
-{
-}
+{}
W_FORM::W_FORM(W_FORMINIT const *init)
: WIDGET(init, WIDG_FORM)
, disableChildren(init->disableChildren)
{
- ASSERT((init->style & ~(WFORM_TABBED | WFORM_INVISIBLE | WFORM_CLICKABLE | WFORM_NOCLICKMOVE | WFORM_NOPRIMARY | WFORM_SECONDARY | WIDG_HIDDEN)) == 0, "Unknown style bit");
- ASSERT((init->style & WFORM_TABBED) == 0 || (init->style & (WFORM_INVISIBLE | WFORM_CLICKABLE)) == 0, "Tabbed form cannot be invisible or clickable");
+ ASSERT((init->style & ~(WFORM_INVISIBLE | WFORM_CLICKABLE | WFORM_NOCLICKMOVE | WFORM_NOPRIMARY | WFORM_SECONDARY | WIDG_HIDDEN)) == 0, "Unknown style bit");
ASSERT((init->style & WFORM_INVISIBLE) == 0 || (init->style & WFORM_CLICKABLE) == 0, "Cannot have an invisible clickable form");
ASSERT((init->style & WFORM_CLICKABLE) != 0 || (init->style & (WFORM_NOPRIMARY | WFORM_SECONDARY)) == 0, "Cannot set keys if the form isn't clickable");
}
@@ -86,75 +69,6 @@ W_CLICKFORM::W_CLICKFORM(WIDGET *parent)
, AudioCallback(WidgGetAudioCallback())
{}
-W_TABFORM::W_TABFORM(W_FORMINIT const *init)
- : W_FORM(init)
- , majorPos(init->majorPos)
- , majorSize(init->majorSize)
- , tabMajorThickness(init->tabMajorThickness)
- , tabMajorGap(init->tabMajorGap)
- , tabVertOffset(init->tabVertOffset)
- , tabHorzOffset(init->tabHorzOffset)
- , majorOffset(init->majorOffset)
- , state(0)
- , tabHiLite(~0)
- , maxTabsShown(init->maxTabsShown)
- , numStats(init->numStats)
- , numButtons(init->numButtons)
- , pTabDisplay(init->pTabDisplay)
- , currentTab(0)
-{
- setNumTabs(init->numMajor);
-}
-
-bool W_TABFORM::setTab(int newTab)
-{
- if (currentTab < childTabs.size())
- {
- childTabs[currentTab]->hide();
- }
- currentTab = clip(newTab, 0, childTabs.size() - 1);
- childTabs[currentTab]->show();
- return currentTab == (unsigned)newTab;
-}
-
-void W_TABFORM::setNumTabs(int numTabs)
-{
- ASSERT(numTabs >= 1, "Must have at least one major tab on a tabbed form");
-
- unsigned prevNumTabs = childTabs.size();
- for (unsigned n = numTabs; n < prevNumTabs; ++n)
- {
- delete childTabs[n];
- }
- childTabs.resize(numTabs);
- for (unsigned n = prevNumTabs; n < childTabs.size(); ++n)
- {
- childTabs[n] = new WIDGET(this);
- childTabs[n]->show(n == currentTab);
- }
- setTab(currentTab); // Ensure that currentTab is still valid.
- fixChildGeometry();
-}
-
-/* Add a widget to a form */
-bool formAddWidget(W_FORM *psForm, WIDGET *psWidget, W_INIT const *psInit)
-{
- ASSERT_OR_RETURN(false, psWidget != NULL && psForm != NULL, "Invalid pointer");
-
- if (psForm->style & WFORM_TABBED)
- {
- W_TABFORM *psTabForm = (W_TABFORM *)psForm;
- ASSERT_OR_RETURN(false, psInit->majorID < psTabForm->childTabs.size(), "Major tab does not exist");
- psTabForm->childTabs[psInit->majorID]->attach(psWidget);
- }
- else
- {
- psForm->attach(psWidget);
- }
-
- return true;
-}
-
unsigned W_CLICKFORM::getState()
{
return state & (WBUT_DISABLE | WBUT_LOCK | WBUT_CLICKLOCK | WBUT_FLASH | WBUT_DOWN | WBUT_HIGHLIGHT);
@@ -168,129 +82,6 @@ void W_CLICKFORM::setState(unsigned newState)
state = (state & ~mask) | (newState & mask);
}
-static W_TABFORM *widgGetTabbedFormById(W_SCREEN *const psScreen, const UDWORD id)
-{
- W_TABFORM *const psForm = (W_TABFORM *)widgGetFromID(psScreen, id);
-
- if (psForm == NULL
- || psForm->type != WIDG_FORM
- || !(psForm->style & WFORM_TABBED))
- {
- return NULL;
- }
-
- return psForm;
-}
-
-
-/* Set the current tabs for a tab form */
-void widgSetTabs(W_SCREEN *psScreen, UDWORD id, UWORD major)
-{
- W_TABFORM *const psForm = widgGetTabbedFormById(psScreen, id);
-
- ASSERT(psForm != NULL, "widgSetTabs: Invalid tab form pointer");
-
- if (psForm == NULL)
- {
- return; /* make us work fine in no assert compiles */
- }
-
- ASSERT(major < widgGetNumTabMajor(psScreen, id), "widgSetTabs id=%u: invalid major id %u >= max %u", id,
- major, widgGetNumTabMajor(psScreen, id));
-
- // Make sure to bail out when we've been passed out-of-bounds major or minor numbers
- if (major >= widgGetNumTabMajor(psScreen, id))
- {
- return;
- }
-
- psForm->setTab(major);
-}
-
-int widgGetNumTabMajor(W_SCREEN *psScreen, UDWORD id)
-{
- W_TABFORM *const psForm = widgGetTabbedFormById(psScreen, id);
-
- ASSERT_OR_RETURN(0, psForm != NULL, "Couldn't find a tabbed form with ID %u", id);
-
- return psForm->numTabs();
-}
-
-/* Get the current tabs for a tab form */
-void widgGetTabs(W_SCREEN *psScreen, UDWORD id, UWORD *pMajor)
-{
- W_TABFORM *const psForm = widgGetTabbedFormById(psScreen, id);
- ASSERT_OR_RETURN(, psForm != NULL, "Couldn't find a tabbed form with ID %u", id);
-
- *pMajor = psForm->tab();
-}
-
-void W_TABFORM::fixChildGeometry()
-{
- bool horizontal = majorPos == WFORM_TABTOP || majorPos == WFORM_TABBOTTOM;
- bool leftOrTop = majorPos == WFORM_TABLEFT || majorPos == WFORM_TABTOP;
-
- int dw = horizontal? 0 : -tabMajorThickness;
- int dh = horizontal? -tabMajorThickness : 0;
- int dx = -dw*leftOrTop;
- int dy = -dh*leftOrTop;
-
- for (Children::iterator i = childTabs.begin(); i != childTabs.end(); ++i)
- {
- (*i)->setGeometry(dx, dy, width() + dw, height() + dh);
- }
-}
-
-QRect W_TABFORM::tabPos(int index)
-{
- if (NO_DISPLAY_SINGLE_TABS && numTabs() == 1)
- {
- return QRect(); // Don't display single tabs.
- }
-
- int n = index - tabPage()*maxTabsShown;
- if (n < 0 || (unsigned)n >= maxTabsShown)
- {
- return QRect(); // Tab icon is not currently visible.
- }
-
- int pos = majorOffset + n*(majorSize + tabMajorGap);
-
- switch (majorPos)
- {
- case WFORM_TABTOP: return QRect(pos, 0, majorSize, tabMajorThickness);
- case WFORM_TABBOTTOM: return QRect(pos, height() - tabMajorThickness, majorSize, tabMajorThickness);
- case WFORM_TABLEFT: return QRect(0, pos, tabMajorThickness, majorSize);
- case WFORM_TABRIGHT: return QRect(width() - tabMajorThickness, pos, tabMajorThickness, majorSize);
- }
- ASSERT(false, "Cannot have a tabbed form with no major tabs");
- return QRect();
-}
-
-int W_TABFORM::pickTab(int clickX, int clickY)
-{
- for (int i = 0; i < numTabs(); ++i)
- {
- QRect r = tabPos(i);
- if (r.isNull())
- {
- continue;
- }
-
- if (r.contains(clickX, clickY))
- {
- return i;
- }
- }
- return -1;
-}
-
-void W_TABFORM::run(W_CONTEXT *psContext)
-{
- // If the mouse is over the form, see if any tabs need to be highlighted.
- tabHiLite = pickTab(psContext->mx, psContext->my);
-}
-
void W_CLICKFORM::setFlash(bool enable)
{
if (enable)
@@ -332,19 +123,6 @@ void W_CLICKFORM::clicked(W_CONTEXT *psContext, WIDGET_KEY key)
}
}
-
-/* Respond to a mouse form up */
-void W_TABFORM::released(W_CONTEXT *psContext, WIDGET_KEY)
-{
- int newTab = pickTab(psContext->mx, psContext->my);
- if (newTab >= 0)
- {
- // Clicked on a tab.
- setTab(newTab);
- screenPointer->setReturn(this);
- }
-}
-
void W_CLICKFORM::released(W_CONTEXT *, WIDGET_KEY key)
{
if ((state & WBUT_DOWN) != 0)
@@ -385,13 +163,6 @@ void W_FORM::highlightLost()
tipStop(this);
}
-void W_TABFORM::highlightLost()
-{
- W_FORM::highlightLost();
-
- tabHiLite = (UWORD)(-1);
-}
-
void W_CLICKFORM::highlightLost()
{
W_FORM::highlightLost();
@@ -442,66 +213,6 @@ void W_CLICKFORM::display(int xOffset, int yOffset)
}
}
-void W_TABFORM::display(int xOffset, int yOffset)
-{
- if (displayFunction != NULL)
- {
- displayFunction(this, xOffset, yOffset);
- return;
- }
-
- int x0 = x() + xOffset;
- int y0 = y() + yOffset;
-
- for (int i = 0; i < numTabs(); ++i)
- {
- QRect r = tabPos(i);
- if (r.isNull())
- {
- continue;
- }
-
- bool isCurrent = (unsigned)i == currentTab;
- bool isHighlighted = (unsigned)i == tabHiLite;
- if (pTabDisplay)
- {
- pTabDisplay(this, majorPos, i - tabPage()*maxTabsShown, isCurrent, isHighlighted, x0 + r.x(), y0 + r.y(), r.width(), r.height());
- }
- else
- {
- int x = x0 + r.x();
- int y = y0 + r.y();
- int x1 = x + r.width();
- int y1 = y + r.height();
- if (isCurrent)
- {
- /* Fill in the tab */
- pie_BoxFill(x + 1, y + 1, x1 - 1, y1, WZCOL_FORM_BACKGROUND);
- /* Draw the outline */
- iV_Line(x, y + 2, x, y1 - 1, WZCOL_FORM_LIGHT);
- iV_Line(x, y + 2, x + 2, y, WZCOL_FORM_LIGHT);
- iV_Line(x + 2, y, x1 - 1, y, WZCOL_FORM_LIGHT);
- iV_Line(x1, y + 1, x1, y1, WZCOL_FORM_DARK);
- }
- else
- {
- /* Fill in the tab */
- pie_BoxFill(x + 1, y + 2, x1 - 1, y1 - 1, WZCOL_FORM_BACKGROUND);
- /* Draw the outline */
- iV_Line(x, y + 3, x, y1 - 1, WZCOL_FORM_LIGHT);
- iV_Line(x, y + 3, x + 2, y + 1, WZCOL_FORM_LIGHT);
- iV_Line(x + 2, y + 1, x1 - 1, y + 1, WZCOL_FORM_LIGHT);
- iV_Line(x1, y + 2, x1, y1 - 1, WZCOL_FORM_DARK);
- }
- if (isHighlighted)
- {
- /* Draw the highlight box */
- iV_Box(x + 2, y + 4, x1 - 3, y1 - 3, WZCOL_FORM_HILITE);
- }
- }
- }
-}
-
void W_CLICKFORM::setTip(QString string)
{
pTip = string;
Oops, something went wrong.

0 comments on commit 1240e7c

Please sign in to comment.