Пример #1
0
//! refreshes the position and text on child buttons
void ScrollBar::refreshControls_()
{
  if (_horizontal)
	{
		int h = getHeight();
		if( !_d->upButton )
         _d->upButton = _CreateButton( Rect(0, 0, h, h), alignUpperLeft, alignUpperLeft, alignUpperLeft, alignLowerRight, 2 );

    if (!_d->downButton)
         _d->downButton = _CreateButton( Rect( getWidth()-h, 0, getWidth(), h), 
                                         alignLowerRight, alignLowerRight, alignUpperLeft, alignLowerRight, 3 );
	}
	else
	{
	  //int w = getWidth();
		if (!_d->upButton)
    {
      _d->upButton = _CreateButton( Rect(0,0, 39, 26), alignUpperLeft, alignLowerRight, alignUpperLeft, alignUpperLeft, 0 );
    }

    if (!_d->downButton)
    {
      _d->downButton = _CreateButton( Rect(0, getHeight()-26, 39, getHeight()), 
                                      alignUpperLeft, alignLowerRight, alignLowerRight, alignLowerRight, 1 );
    }
	}
}
void MainTask(void) {
  static GUI_PID_STATE OldState;
  GUI_PID_STATE        CurrentState;
  int                  tEnd;

  GUI_Init();
  BUTTON_SetReactOnLevel();
  //
  // Check if recommended memory for the sample is available
  //
  if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) {
    GUI_ErrorOut("Not enough memory available."); 
    return;
  }
  do {
    WM_HWIN hButton0, hButton1;
    WM_SetCallback(WM_HBKWIN, _cbBkWin);
    hButton0 = _CreateButton(100, 220, 170, 150, 5, 25, "Dashboard"    , &bmDashboard   , GUI_ID_BUTTON0);
    hButton1 = _CreateButton(370, 220, 170, 150, 5, 25, "Cash Terminal", &bmCashTerminal, GUI_ID_BUTTON1);
    WM_SetFocus(hButton0);
    tEnd = GUI_GetTime() + 4000;
    do {
      GUI_PID_GetState(&CurrentState);
      if ((OldState.x != CurrentState.x) || (OldState.y != CurrentState.y)) {
        tEnd = GUI_GetTime() + 10000;
      }
      OldState = CurrentState;
      GUI_Delay(100);
      if (GUI_GetTime() >= tEnd) {
        if (_AppSelectionOld) {
          _AppSelection = ((_AppSelectionOld - 1) ^ 1) + 1;
        } else {
          _AppSelection = APP_DASHBOARD;
        }
      }
    } while (!_AppSelection && !_Break);
    WM_DeleteWindow(hButton0);
    WM_DeleteWindow(hButton1);
    if (!_Break) {
      switch (_AppSelection) {
      case APP_DASHBOARD:
        AppDashBoard();
        break;
      case APP_CASHTERMINAL:
        AppCashTerminal();
        break;
      }
      GUI_CURSOR_Hide();
      _AppSelectionOld = _AppSelection;
      _AppSelection    = 0;
    }
  } while (!_Break);
}
Пример #3
0
void MainTask(void) {
  static GUI_PID_STATE OldState;
  GUI_PID_STATE        CurrentState;
  int                  tEnd;

  GUI_Init();
  do {
    WM_HWIN hButton0, hButton1;
    WM_SetCallback(WM_HBKWIN, _cbBkWin);
    hButton0 = _CreateButton(100, 220, 170, 150, 5, 25, "Dashboard"    , &bmDashboard   , GUI_ID_BUTTON0);
    hButton1 = _CreateButton(370, 220, 170, 150, 5, 25, "Cash Terminal", &bmCashTerminal, GUI_ID_BUTTON1);
    WM_SetFocus(hButton0);
    tEnd = GUI_GetTime() + 4000;
    do {
      GUI_PID_GetState(&CurrentState);
      if ((OldState.x != CurrentState.x) || (OldState.y != CurrentState.y)) {
        tEnd = GUI_GetTime() + 10000;
      }
      OldState = CurrentState;
      GUI_Delay(100);
      if (GUI_GetTime() >= tEnd) {
        if (_AppSelectionOld) {
          _AppSelection = ((_AppSelectionOld - 1) ^ 1) + 1;
        } else {
          _AppSelection = APP_DASHBOARD;
        }
      }
    } while (!_AppSelection && !_Break);
    WM_DeleteWindow(hButton0);
    WM_DeleteWindow(hButton1);
    if (!_Break) {
      switch (_AppSelection) {
      case APP_DASHBOARD:
        AppDashBoard();
        break;
      case APP_CASHTERMINAL:
        AppCashTerminal();
        break;
      }
      GUI_CURSOR_Hide();
      _AppSelectionOld = _AppSelection;
      _AppSelection    = 0;
    }
  } while (!_Break);
}
Пример #4
0
void
BAlert::AddButton(const char* label, char key)
{
	if (label == NULL || label[0] == '\0')
		return;

	BButton* button = _CreateButton(fButtons.size(), label);
	fButtons.push_back(button);
	fKeys.push_back(key);

	SetDefaultButton(button);
	fButtonLayout->AddView(button);
}
Пример #5
0
//! refreshes the position and text on child buttons
void ScrollBar::refreshControls_()
{
  if (_horizontal)
	{
		int h = getHeight();
		if( !_d->upButton )
         _d->upButton = _CreateButton( Rect(0, 0, h, h), alignUpperLeft, alignUpperLeft, alignUpperLeft, alignLowerRight );

    if (!_d->downButton)
         _d->downButton = _CreateButton( Rect( getWidth()-h, 0, getWidth(), h), 
                                         alignLowerRight, alignLowerRight, alignUpperLeft, alignLowerRight );
	}
	else
	{
		int w = getWidth();
		if (!_d->upButton)
            _d->upButton = _CreateButton( Rect(0,0, w, w), alignUpperLeft, alignLowerRight, alignUpperLeft, alignUpperLeft );

        if (!_d->downButton)
            _d->downButton = _CreateButton( Rect(0, getHeight()-w, w, getHeight()), 
                                             alignUpperLeft, alignLowerRight, alignLowerRight, alignLowerRight );
	}
}
CDialogEditGridColours::CDialogEditGridColours(mainFrame *parent) : 
  wxDialog(parent, wxID_ANY, _T("Edit Grid Colors"),
    wxDefaultPosition, wxDefaultSize,
    mainApp::DIALOG_STYLE & ~wxRESIZE_BORDER),
  m_nRowColor(-1),
  m_nRowAttr(-1),
  m_nInSelect(0),
  m_bModified(false)
{
  wxFont fnt;
  wxSize sz;
  wxSize sz2;
  int nw;
  int nw2;

  wxStaticText *pTextTop;
  wxStaticText *pTextAttributes;
  wxButton *pButtonReset;

  wxBoxSizer *pSizerAll;
  wxBoxSizer *pSizerColors;
  wxBoxSizer *pSizerAttributes;
  wxBoxSizer *pSizerWin;
  wxFlexGridSizer *pSizer2x2;
  wxSizer *pSizerButtons;

  pTextTop = new wxStaticText(
    this,wxID_ANY,_T(
    "Select a line in the lists below and use the\n"
    "buttons to modify its colors or attributes\n\nColors"));
  m_pGridColor = new CGridColorGrid(this,wxID_ANY);

    
  m_pTextFG = new wxStaticText(this,wxID_ANY,_T("Foreground Color: "));
  m_pButtonFG = _CreateButton(this,IDbuttonEditFGcolor);
  m_pTextBG = new wxStaticText(this,wxID_ANY,_T("Background Color: "));
  m_pButtonBG = _CreateButton(this,IDbuttonEditBGcolor);
  m_pButtonReverse = new wxButton(this,IDbuttonReverse,_T("Reverse"));

  pSizer2x2 = new wxFlexGridSizer(2,2,ID_BORDER,ID_BORDER);
  pSizer2x2->Add(m_pTextFG,0,wxALIGN_CENTER_VERTICAL);
  pSizer2x2->Add(m_pButtonFG,0,wxALIGN_CENTER_VERTICAL);
  pSizer2x2->Add(m_pTextBG,0,wxALIGN_CENTER_VERTICAL);
  pSizer2x2->Add(m_pButtonBG,0,wxALIGN_CENTER_VERTICAL);

  pSizerColors = new wxBoxSizer(wxHORIZONTAL);
  pSizerColors->Add(pSizer2x2,0,wxALIGN_CENTER_VERTICAL);
  pSizerColors->Add(m_pButtonReverse,0,
    wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxLEFT, ID_BORDER);

  pTextAttributes = new wxStaticText(this,wxID_ANY,_T("Attributes"));
  m_pGridAttr = new CGridAttrGrid(this,wxID_ANY);


  m_pToggleBold = new wxToggleButton(this,wxID_ANY,_T("Bold"));
  m_pToggleItalic = new wxToggleButton(this,wxID_ANY,_T("Italic"));
  m_pToggleReverse = new wxToggleButton(this,wxID_ANY,_T("Reverse"));
  fnt = m_pToggleItalic->GetFont();
  fnt.SetStyle(wxFONTSTYLE_ITALIC);
  m_pToggleItalic->SetFont(fnt);
  fnt.SetStyle(wxFONTSTYLE_NORMAL);
  fnt.SetWeight(wxFONTWEIGHT_BOLD);
  m_pToggleBold->SetFont(fnt);

  pButtonReset = new wxButton(
    this,IDbuttonResetDefault, _T("Reset Defaults"));

  {
    CParmOsirisGlobal pParm;
    _SetupGridColoursAttr(pParm.Get());
  }

  m_nRowColor = -1;
  m_nRowAttr = -1;
  _UpdateButtons(0,0);

  m_pGridColor->SetGridCursor(0,0);
  m_pGridAttr->SetGridCursor(0,0);
  m_pGridColor->AutoSizeColumns(true);
  m_pGridAttr->AutoSizeColumns(true);
  m_pGridColor->AutoSizeRows(true);
  m_pGridAttr->AutoSizeRows(true);


  // do full layout

  sz =  _ComputeGridSize(m_pGridColor);
  sz2 = _ComputeGridSize(m_pGridAttr);
  nw = sz.GetWidth();
  nw2 = sz2.GetWidth();
  if(nw2 > nw)
  {
    sz.SetWidth(nw2);
    m_pGridColor->SetColSize(0,m_pGridAttr->GetColSize(0));
  }
  else
  {
    sz2.SetWidth(nw);
    m_pGridAttr->SetColSize(0,m_pGridColor->GetColSize(0));
  }
  m_pGridColor->SetSize(sz);
  m_pGridAttr->SetSize(sz2);

  pSizerAttributes = new wxBoxSizer(wxHORIZONTAL);
  pSizerAttributes->Add(m_pToggleBold,0,0,0);
  pSizerAttributes->Add(m_pToggleItalic,0,wxLEFT, ID_BORDER);
  pSizerAttributes->Add(m_pToggleReverse,0,wxLEFT, ID_BORDER);

  pSizerAll = new wxBoxSizer(wxVERTICAL);
  pSizerAll->Add(pTextTop,0,wxALL | wxALIGN_LEFT, ID_BORDER);
  pSizerAll->Add(m_pGridColor,0,wxEXPAND | (wxALL ^ wxTOP),ID_BORDER);
  pSizerAll->Add(pSizerColors,0,
    wxALIGN_CENTER_HORIZONTAL | (wxALL ^ wxTOP), ID_BORDER);
  pSizerAll->Add(pTextAttributes,0,wxEXPAND | wxALL , ID_BORDER);
  pSizerAll->Add(m_pGridAttr,0,wxEXPAND | (wxALL ^ wxTOP), ID_BORDER);
  pSizerAll->Add(pSizerAttributes,0,wxALIGN_CENTER_HORIZONTAL | wxALL, ID_BORDER);
  pSizerAll->Add(pButtonReset,0,wxALIGN_CENTER_HORIZONTAL | (wxALL ^ wxBOTTOM),ID_BORDER);


  pSizerButtons = CreateButtonSizer(wxOK | wxCANCEL);
  pSizerWin = new wxBoxSizer(wxVERTICAL);
  pSizerWin->Add(pSizerAll,1,wxEXPAND,0);
  pSizerWin->Add(pSizerButtons,0,wxALIGN_CENTER_HORIZONTAL | wxALL, ID_BORDER);
  SetSizer(pSizerWin);
  pSizerWin->Layout();
  Fit();
  CentreOnParent();
  m_pGridColor->SetFocus();
}
Пример #7
0
void
BAlert::_InitObject(const char* text, const char* button0, const char* button1,
	const char* button2, button_width buttonWidth, button_spacing spacing,
	alert_type type)
{
	fInvoker = NULL;
	fAlertSem = -1;
	fAlertValue = -1;
	fButtons[0] = fButtons[1] = fButtons[2] = NULL;
	fTextView = NULL;
	fKeys[0] = fKeys[1] = fKeys[2] = 0;
	fMsgType = type;
	fButtonWidth = buttonWidth;

	// Set up the "_master_" view
	TAlertView* view = new(std::nothrow) TAlertView(Bounds());
	if (view == NULL)
		return;

	AddChild(view);
	view->SetBitmap(_InitIcon());

	// Must have at least one button
	if (button0 == NULL) {
		debugger("BAlerts must have at least one button.");
		button0 = "";
	}

	// Set up the buttons

	int32 buttonCount = 1;
	view->AddChild(fButtons[0] = _CreateButton(0, button0));

	if (button1 != NULL) {
		view->AddChild(fButtons[1] = _CreateButton(1, button1));
		buttonCount++;
	}

	if (button2 != NULL) {
		view->AddChild(fButtons[2] = _CreateButton(2, button2));
		buttonCount++;
	}

	// Find the widest button only if the widest value needs to be known.

	if (fButtonWidth == B_WIDTH_FROM_WIDEST) {
		float maxWidth = 0;
		for (int i = 0; i < buttonCount; i++) {
			float width = fButtons[i]->Bounds().Width();
			if (width > maxWidth)
				maxWidth = width;
		}

		// resize buttons
		for (int i = 0; i < buttonCount; i++) {
			fButtons[i]->ResizeTo(maxWidth, fButtons[i]->Bounds().Height());
		}
	}

	float defaultButtonFrameWidth = -fButtons[buttonCount - 1]->Bounds().Width() / 2.0f;
	SetDefaultButton(fButtons[buttonCount - 1]);
	defaultButtonFrameWidth += fButtons[buttonCount - 1]->Bounds().Width() / 2.0f;

	// Layout buttons

	float fontFactor = be_plain_font->Size() / 11.0f;

	for (int i = buttonCount - 1; i >= 0; --i) {
		float x = -fButtons[i]->Bounds().Width();
		if (i + 1 == buttonCount)
			x += Bounds().right - kRightOffset + defaultButtonFrameWidth;
		else
			x += fButtons[i + 1]->Frame().left - kButtonSpacing;

		if (buttonCount > 1 && i == 0 && spacing == B_OFFSET_SPACING)
			x -= kButtonOffsetSpacing * fontFactor;

		fButtons[i]->MoveTo(x, fButtons[i]->Frame().top);
	}

	// Adjust the window's width, if necessary

	int32 iconLayoutScale = icon_layout_scale();
	float totalWidth = kRightOffset + fButtons[buttonCount - 1]->Frame().right
		- defaultButtonFrameWidth - fButtons[0]->Frame().left;
	if (view->Bitmap()) {
		totalWidth += (kIconStripeWidth + kWindowIconOffset) * iconLayoutScale;
	} else
		totalWidth += kWindowMinOffset;

	float width = (spacing == B_OFFSET_SPACING
		? kWindowOffsetMinWidth : kWindowMinWidth) * fontFactor;

	ResizeTo(max_c(totalWidth, width), Bounds().Height());

	// Set up the text view

	BRect textViewRect(kLeftOffset, kTopOffset,
		Bounds().right - kRightOffset,
		fButtons[0]->Frame().top - kTextButtonOffset);
	if (view->Bitmap())
		textViewRect.left = (kWindowIconOffset
			+ kIconStripeWidth) * iconLayoutScale - 2;

	fTextView = new(std::nothrow) BTextView(textViewRect, "_tv_",
		textViewRect.OffsetByCopy(B_ORIGIN),
		B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
	if (fTextView == NULL)
		return;

	fTextView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
	fTextView->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor);
	fTextView->SetText(text, strlen(text));
	fTextView->MakeEditable(false);
	fTextView->MakeSelectable(false);
	fTextView->SetWordWrap(true);
	view->AddChild(fTextView);

	// Now resize the TextView vertically so that all the text is visible
	float textHeight = fTextView->TextHeight(0, fTextView->CountLines());
	textViewRect.OffsetTo(0, 0);
	textHeight -= textViewRect.Height();
	ResizeBy(0, textHeight);
	fTextView->ResizeBy(0, textHeight);
	textViewRect.bottom += textHeight;
	fTextView->SetTextRect(textViewRect);

	AddCommonFilter(new(std::nothrow) _BAlertFilter_(this));

	MoveTo(AlertPosition(Frame().Width(), Frame().Height()));
}