예제 #1
0
파일: panel.cpp 프로젝트: mael15/wxWidgets
bool wxRibbonPanel::ShowExpanded()
{
    if(!IsMinimised())
    {
        return false;
    }
    if(m_expanded_dummy != NULL || m_expanded_panel != NULL)
    {
        return false;
    }

    wxSize size = GetBestSize();

    // Special case for flexible panel layout, where GetBestSize doesn't work
    if (GetFlags() & wxRIBBON_PANEL_FLEXIBLE)
    {
        size = GetBestSizeForParentSize(wxSize(400, 1000));
    }

    wxPoint pos = GetExpandedPosition(wxRect(GetScreenPosition(), GetSize()),
        size, m_preferred_expand_direction).GetTopLeft();

    // Need a top-level frame to contain the expanded panel
    wxFrame *container = new wxFrame(NULL, wxID_ANY, GetLabel(),
        pos, size, wxFRAME_NO_TASKBAR | wxBORDER_NONE);

    m_expanded_panel = new wxRibbonPanel(container, wxID_ANY,
        GetLabel(), m_minimised_icon, wxPoint(0, 0), size, (m_flags /* & ~wxRIBBON_PANEL_FLEXIBLE */));

    m_expanded_panel->SetArtProvider(m_art);
    m_expanded_panel->m_expanded_dummy = this;

    // Move all children to the new panel.
    // Conceptually it might be simpler to reparent this entire panel to the
    // container and create a new panel to sit in its place while expanded.
    // This approach has a problem though - when the panel is reinserted into
    // its original parent, it'll be at a different position in the child list
    // and thus assume a new position.
    // NB: Children iterators not used as behaviour is not well defined
    // when iterating over a container which is being emptied
    while(!GetChildren().IsEmpty())
    {
        wxWindow *child = GetChildren().GetFirst()->GetData();
        child->Reparent(m_expanded_panel);
        child->Show();
    }

    // Move sizer to new panel
    if(GetSizer())
    {
        wxSizer* sizer = GetSizer();
        SetSizer(NULL, false);
        m_expanded_panel->SetSizer(sizer);
    }

    m_expanded_panel->Realize();
    Refresh();
    container->SetMinClientSize(size);
    container->Show();
    m_expanded_panel->SetFocus();

    return true;
}
예제 #2
0
void wxGridCellBoolRenderer::Draw(wxGrid& grid,
                                  wxGridCellAttr& attr,
                                  wxDC& dc,
                                  const wxRect& rect,
                                  int row, int col,
                                  bool isSelected)
{
    wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);

    // draw a check mark in the centre (ignoring alignment - TODO)
    wxSize size = GetBestSize(grid, attr, dc, row, col);

    // don't draw outside the cell
    wxCoord minSize = wxMin(rect.width, rect.height);
    if ( size.x >= minSize || size.y >= minSize )
    {
        // and even leave (at least) 1 pixel margin
        size.x = size.y = minSize;
    }

    // draw a border around checkmark
    int vAlign, hAlign;
    attr.GetAlignment(&hAlign, &vAlign);

    wxRect rectBorder;
    if (hAlign == wxALIGN_CENTRE)
    {
        rectBorder.x = rect.x + rect.width / 2 - size.x / 2;
        rectBorder.y = rect.y + rect.height / 2 - size.y / 2;
        rectBorder.width = size.x;
        rectBorder.height = size.y;
    }
    else if (hAlign == wxALIGN_LEFT)
    {
        rectBorder.x = rect.x + 2;
        rectBorder.y = rect.y + rect.height / 2 - size.y / 2;
        rectBorder.width = size.x;
        rectBorder.height = size.y;
    }
    else if (hAlign == wxALIGN_RIGHT)
    {
        rectBorder.x = rect.x + rect.width - size.x - 2;
        rectBorder.y = rect.y + rect.height / 2 - size.y / 2;
        rectBorder.width = size.x;
        rectBorder.height = size.y;
    }

    bool value;
    if ( grid.GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL) )
    {
        value = grid.GetTable()->GetValueAsBool(row, col);
    }
    else
    {
        wxString cellval( grid.GetTable()->GetValue(row, col) );
        value = wxGridCellBoolEditor::IsTrueValue(cellval);
    }

    int flags = 0;
    if (value)
        flags |= wxCONTROL_CHECKED;

    wxRendererNative::Get().DrawCheckBox( &grid, dc, rectBorder, flags );
}
예제 #3
0
void ctlSQLGrid::OnLabelDoubleClick(wxGridEvent &event)
{
	int maxHeight, maxWidth;
	GetClientSize(&maxWidth, &maxHeight);
	int row = event.GetRow();
	int col = event.GetCol();

	int extent, extentWant = 0;

	if (row >= 0)
	{
		for (col = 0 ; col < GetNumberCols() ; col++)
		{
			extent = GetBestSize(row, col).GetHeight();
			if (extent > extentWant)
				extentWant = extent;
		}

		extentWant += EXTRAEXTENT_HEIGHT;
		extentWant = wxMax(extentWant, GetRowMinimalAcceptableHeight());
		extentWant = wxMin(extentWant, maxHeight * 3 / 4);
		int currentHeight = GetRowHeight(row);

		if (currentHeight >= maxHeight * 3 / 4 || currentHeight == extentWant)
			extentWant = GetRowMinimalAcceptableHeight();
		else if (currentHeight < maxHeight / 4)
			extentWant = wxMin(maxHeight / 4, extentWant);
		else if (currentHeight < maxHeight / 2)
			extentWant = wxMin(maxHeight / 2, extentWant);
		else if (currentHeight < maxHeight * 3 / 4)
			extentWant = wxMin(maxHeight * 3 / 4, extentWant);

		if (extentWant != currentHeight)
		{
			BeginBatch();
			if(IsCellEditControlShown())
			{
				HideCellEditControl();
				SaveEditControlValue();
			}

			SetRowHeight(row, extentWant);
			EndBatch();
		}
	}
	else if (col >= 0)
	{
		for (row = 0 ; row < GetNumberRows() ; row++)
		{
			if (CheckRowPresent(row))
			{
				extent = GetBestSize(row, col).GetWidth();
				if (extent > extentWant)
					extentWant = extent;
			}
		}

		extentWant += EXTRAEXTENT_WIDTH;
		extentWant = wxMax(extentWant, GetColMinimalAcceptableWidth());
		extentWant = wxMin(extentWant, maxWidth * 3 / 4);
		int currentWidth = GetColumnWidth(col);

		if (currentWidth >= maxWidth * 3 / 4 || currentWidth == extentWant)
			extentWant = GetColMinimalAcceptableWidth();
		else if (currentWidth < maxWidth / 4)
			extentWant = wxMin(maxWidth / 4, extentWant);
		else if (currentWidth < maxWidth / 2)
			extentWant = wxMin(maxWidth / 2, extentWant);
		else if (currentWidth < maxWidth * 3 / 4)
			extentWant = wxMin(maxWidth * 3 / 4, extentWant);

		if (extentWant != currentWidth)
		{
			BeginBatch();
			if(IsCellEditControlShown())
			{
				HideCellEditControl();
				SaveEditControlValue();
			}
			SetColumnWidth(col, extentWant);
			EndBatch();
		}
	}
}
예제 #4
0
bool wxCheckBox::MSWOnDraw(WXDRAWITEMSTRUCT *item)
{
    DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)item;

    if ( !IsOwnerDrawn() || dis->CtlType != ODT_BUTTON )
        return wxCheckBoxBase::MSWOnDraw(item);

    // calculate the rectangles for the check mark itself and the label
    HDC hdc = dis->hDC;
    RECT& rect = dis->rcItem;
    RECT rectCheck,
         rectLabel;
    rectCheck.top =
        rectLabel.top = rect.top;
    rectCheck.bottom =
        rectLabel.bottom = rect.bottom;
    const int checkSize = GetBestSize().y;
    const int MARGIN = 3;

    const bool isRightAligned = HasFlag(wxALIGN_RIGHT);
    if ( isRightAligned )
    {
        rectCheck.right = rect.right;
        rectCheck.left = rectCheck.right - checkSize;

        rectLabel.right = rectCheck.left - MARGIN;
        rectLabel.left = rect.left;
    }
    else // normal, left-aligned checkbox
    {
        rectCheck.left = rect.left;
        rectCheck.right = rectCheck.left + checkSize;

        rectLabel.left = rectCheck.right + MARGIN;
        rectLabel.right = rect.right;
    }

    // show we draw a focus rect?
    const bool isFocused = m_isPressed || FindFocus() == this;


    // draw the checkbox itself
    wxDCTemp dc(hdc);

    int flags = 0;
    if ( !IsEnabled() )
        flags |= wxCONTROL_DISABLED;
    switch ( Get3StateValue() )
    {
    case wxCHK_CHECKED:
        flags |= wxCONTROL_CHECKED;
        break;

    case wxCHK_UNDETERMINED:
        flags |= wxCONTROL_PRESSED;
        break;

    default:
        wxFAIL_MSG( wxT("unexpected Get3StateValue() return value") );
    // fall through

    case wxCHK_UNCHECKED:
        // no extra styles needed
        break;
    }

    if ( wxFindWindowAtPoint(wxGetMousePosition()) == this )
        flags |= wxCONTROL_CURRENT;

    wxRendererNative::Get().
    DrawCheckBox(this, dc, wxRectFromRECT(rectCheck), flags);

    // draw the text
    const wxString& label = GetLabel();

    // first we need to measure it
    UINT fmt = DT_NOCLIP;

    // drawing underlying doesn't look well with focus rect (and the native
    // control doesn't do it)
    if ( isFocused )
        fmt |= DT_HIDEPREFIX;
    if ( isRightAligned )
        fmt |= DT_RIGHT;
    // TODO: also use DT_HIDEPREFIX if the system is configured so

    // we need to get the label real size first if we have to draw a focus rect
    // around it
    if ( isFocused )
    {
        if ( !::DrawText(hdc, label.wx_str(), label.length(), &rectLabel,
                         fmt | DT_CALCRECT) )
        {
            wxLogLastError(wxT("DrawText(DT_CALCRECT)"));
        }
    }

    if ( !IsEnabled() )
    {
        ::SetTextColor(hdc, ::GetSysColor(COLOR_GRAYTEXT));
    }

    if ( !::DrawText(hdc, label.wx_str(), label.length(), &rectLabel, fmt) )
    {
        wxLogLastError(wxT("DrawText()"));
    }

    // finally draw the focus
    if ( isFocused )
    {
        rectLabel.left--;
        rectLabel.right++;
        if ( !::DrawFocusRect(hdc, &rectLabel) )
        {
            wxLogLastError(wxT("DrawFocusRect()"));
        }
    }

    return true;
}
예제 #5
0
void wxGridCellStringRenderer::Draw(wxGrid& grid,
                                    wxGridCellAttr& attr,
                                    wxDC& dc,
                                    const wxRect& rectCell,
                                    int row, int col,
                                    bool isSelected)
{
    wxRect rect = rectCell;
    rect.Inflate(-1);

    // erase only this cells background, overflow cells should have been erased
    wxGridCellRenderer::Draw(grid, attr, dc, rectCell, row, col, isSelected);

    int hAlign, vAlign;
    attr.GetAlignment(&hAlign, &vAlign);

    int overflowCols = 0;

    if (attr.GetOverflow())
    {
        int cols = grid.GetNumberCols();
        int best_width = GetBestSize(grid,attr,dc,row,col).GetWidth();
        int cell_rows, cell_cols;
        attr.GetSize( &cell_rows, &cell_cols ); // shouldn't get here if <= 0
        if ((best_width > rectCell.width) && (col < cols) && grid.GetTable())
        {
            int i, c_cols, c_rows;
            for (i = col+cell_cols; i < cols; i++)
            {
                bool is_empty = true;
                for (int j=row; j < row + cell_rows; j++)
                {
                    // check w/ anchor cell for multicell block
                    grid.GetCellSize(j, i, &c_rows, &c_cols);
                    if (c_rows > 0)
                        c_rows = 0;
                    if (!grid.GetTable()->IsEmptyCell(j + c_rows, i))
                    {
                        is_empty = false;
                        break;
                    }
                }

                if (is_empty)
                {
                    rect.width += grid.GetColSize(i);
                }
                else
                {
                    i--;
                    break;
                }

                if (rect.width >= best_width)
                    break;
            }

            overflowCols = i - col - cell_cols + 1;
            if (overflowCols >= cols)
                overflowCols = cols - 1;
        }

        if (overflowCols > 0) // redraw overflow cells w/ proper hilight
        {
            hAlign = wxALIGN_LEFT; // if oveflowed then it's left aligned
            wxRect clip = rect;
            clip.x += rectCell.width;
            // draw each overflow cell individually
            int col_end = col + cell_cols + overflowCols;
            if (col_end >= grid.GetNumberCols())
                col_end = grid.GetNumberCols() - 1;
            for (int i = col + cell_cols; i <= col_end; i++)
            {
                clip.width = grid.GetColSize(i) - 1;
                dc.DestroyClippingRegion();
                dc.SetClippingRegion(clip);

                SetTextColoursAndFont(grid, attr, dc,
                        grid.IsInSelection(row,i));

                grid.DrawTextRectangle(dc, grid.GetCellValue(row, col),
                        rect, hAlign, vAlign);
                clip.x += grid.GetColSize(i) - 1;
            }

            rect = rectCell;
            rect.Inflate(-1);
            rect.width++;
            dc.DestroyClippingRegion();
        }
    }

    // now we only have to draw the text
    SetTextColoursAndFont(grid, attr, dc, isSelected);

    grid.DrawTextRectangle(dc, grid.GetCellValue(row, col),
                           rect, hAlign, vAlign);
}
예제 #6
0
파일: checkbox.cpp 프로젝트: 252525fb/rpcs3
bool wxCheckBox::MSWOnDraw(WXDRAWITEMSTRUCT *item)
{
    DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)item;

    if ( !IsOwnerDrawn() || dis->CtlType != ODT_BUTTON )
        return wxCheckBoxBase::MSWOnDraw(item);

    // calculate the rectangles for the check mark itself and the label
    HDC hdc = dis->hDC;
    RECT& rect = dis->rcItem;
    RECT rectCheck,
         rectLabel;
    rectCheck.top =
    rectLabel.top = rect.top;
    rectCheck.bottom =
    rectLabel.bottom = rect.bottom;
    const int checkSize = GetBestSize().y;
    const int MARGIN = 3;

    const bool isRightAligned = HasFlag(wxALIGN_RIGHT);
    if ( isRightAligned )
    {
        rectCheck.right = rect.right;
        rectCheck.left = rectCheck.right - checkSize;

        rectLabel.right = rectCheck.left - MARGIN;
        rectLabel.left = rect.left;
    }
    else // normal, left-aligned checkbox
    {
        rectCheck.left = rect.left;
        rectCheck.right = rectCheck.left + checkSize;

        rectLabel.left = rectCheck.right + MARGIN;
        rectLabel.right = rect.right;
    }

    // show we draw a focus rect?
    const bool isFocused = m_isPressed || FindFocus() == this;


    // draw the checkbox itself: note that this should really, really be in
    // wxRendererNative but unfortunately we can't add a new virtual function
    // to it without breaking backwards compatibility

    // classic Win32 version -- this can be useful when we move this into
    // wxRendererNative
#if defined(__WXWINCE__) || !wxUSE_UXTHEME
    UINT state = DFCS_BUTTONCHECK;
    if ( !IsEnabled() )
        state |= DFCS_INACTIVE;
    switch ( Get3StateValue() )
    {
        case wxCHK_CHECKED:
            state |= DFCS_CHECKED;
            break;

        case wxCHK_UNDETERMINED:
            state |= DFCS_PUSHED;
            break;

        default:
            wxFAIL_MSG( _T("unexpected Get3StateValue() return value") );
            // fall through

        case wxCHK_UNCHECKED:
            // no extra styles needed
            break;
    }

    if ( wxFindWindowAtPoint(wxGetMousePosition()) == this )
        state |= DFCS_HOT;

    if ( !::DrawFrameControl(hdc, &rectCheck, DFC_BUTTON, state) )
    {
        wxLogLastError(_T("DrawFrameControl(DFC_BUTTON)"));
    }
#else // XP version
    wxUxThemeEngine *themeEngine = wxUxThemeEngine::GetIfActive();
    if ( !themeEngine )
        return false;

    wxUxThemeHandle theme(this, L"BUTTON");
    if ( !theme )
        return false;

    int state;
    switch ( Get3StateValue() )
    {
        case wxCHK_CHECKED:
            state = CBS_CHECKEDNORMAL;
            break;

        case wxCHK_UNDETERMINED:
            state = CBS_MIXEDNORMAL;
            break;

        default:
            wxFAIL_MSG( _T("unexpected Get3StateValue() return value") );
            // fall through

        case wxCHK_UNCHECKED:
            state = CBS_UNCHECKEDNORMAL;
            break;
    }

    if ( !IsEnabled() )
        state += CBS_DISABLED_OFFSET;
    else if ( m_isPressed )
        state += CBS_PRESSED_OFFSET;
    else if ( m_isHot )
        state += CBS_HOT_OFFSET;

    HRESULT hr = themeEngine->DrawThemeBackground
                              (
                                theme,
                                hdc,
                                BP_CHECKBOX,
                                state,
                                &rectCheck,
                                NULL
                              );
    if ( FAILED(hr) )
    {
        wxLogApiError(_T("DrawThemeBackground(BP_CHECKBOX)"), hr);
    }
#endif // 0/1

    // draw the text
    const wxString& label = GetLabel();

    // first we need to measure it
    UINT fmt = DT_NOCLIP;

    // drawing underlying doesn't look well with focus rect (and the native
    // control doesn't do it)
    if ( isFocused )
        fmt |= DT_HIDEPREFIX;
    if ( isRightAligned )
        fmt |= DT_RIGHT;
    // TODO: also use DT_HIDEPREFIX if the system is configured so

    // we need to get the label real size first if we have to draw a focus rect
    // around it
    if ( isFocused )
    {
        if ( !::DrawText(hdc, label, label.length(), &rectLabel,
                         fmt | DT_CALCRECT) )
        {
            wxLogLastError(_T("DrawText(DT_CALCRECT)"));
        }
    }

    if ( !IsEnabled() )
    {
        ::SetTextColor(hdc, ::GetSysColor(COLOR_GRAYTEXT));
    }

    if ( !::DrawText(hdc, label, label.length(), &rectLabel, fmt) )
    {
        wxLogLastError(_T("DrawText()"));
    }

    // finally draw the focus
    if ( isFocused )
    {
        rectLabel.left--;
        rectLabel.right++;
        if ( !::DrawFocusRect(hdc, &rectLabel) )
        {
            wxLogLastError(_T("DrawFocusRect()"));
        }
    }

    return true;
}
예제 #7
0
파일: listbox.cpp 프로젝트: hgwells/tive
bool wxListBox::Create(wxWindow *parent, wxWindowID id,
                       const wxPoint& pos,
                       const wxSize& size,
                       int n, const wxString choices[],
                       long style,
                       const wxValidator& validator,
                       const wxString& name)
{
    if( !wxControl::CreateControl( parent, id, pos, size, style,
                                   validator, name ) )
        return false;

    m_noItems = (unsigned int)n;
    m_backgroundColour = * wxWHITE;

    Widget parentWidget = (Widget) parent->GetClientWidget();
    Display* dpy = XtDisplay(parentWidget);

    Arg args[4];
    int count = 0;
    XtSetArg( args[count], XmNlistSizePolicy, XmCONSTANT ); ++count;
    XtSetArg( args[count], XmNselectionPolicy,
              ( m_windowStyle & wxLB_MULTIPLE ) ? XmMULTIPLE_SELECT :
              ( m_windowStyle & wxLB_EXTENDED ) ? XmEXTENDED_SELECT :
                                                  XmBROWSE_SELECT );
    ++count;
    if( m_font.Ok() )
    {
        XtSetArg( args[count],
                  (String)wxFont::GetFontTag(), m_font.GetFontTypeC(dpy) );
        ++count;
    }
    if( m_windowStyle & wxLB_ALWAYS_SB )
    {
        XtSetArg( args[count], XmNscrollBarDisplayPolicy, XmSTATIC );
        ++count;
    }

    Widget listWidget =
        XmCreateScrolledList(parentWidget,
                             wxConstCast(name.c_str(), char), args, count);

    m_mainWidget = (WXWidget) listWidget;

    Set(n, choices);

    XtManageChild (listWidget);

    wxSize best = GetBestSize();
    if( size.x != -1 ) best.x = size.x;
    if( size.y != -1 ) best.y = size.y;

    XtAddCallback (listWidget,
                   XmNbrowseSelectionCallback,
                   (XtCallbackProc) wxListBoxCallback,
                   (XtPointer) this);
    XtAddCallback (listWidget,
                   XmNextendedSelectionCallback,
                   (XtCallbackProc) wxListBoxCallback,
                   (XtPointer) this);
    XtAddCallback (listWidget,
                   XmNmultipleSelectionCallback,
                   (XtCallbackProc) wxListBoxCallback,
                   (XtPointer) this);
    XtAddCallback (listWidget,
                   XmNdefaultActionCallback,
                   (XtCallbackProc) wxListBoxCallback,
                   (XtPointer) this);

    AttachWidget (parent, m_mainWidget, (WXWidget) NULL,
                  pos.x, pos.y, best.x, best.y);

    ChangeBackgroundColour();

    return true;
}
예제 #8
0
    wxRichToolTipPopup(wxWindow* parent,
                       const wxString& title,
                       const wxString& message,
                       const wxIcon& icon,
                       wxTipKind tipKind,
                       const wxFont& titleFont_) :
        m_timer(this)
    {
        Create(parent, wxFRAME_SHAPED);


        wxBoxSizer* const sizerTitle = new wxBoxSizer(wxHORIZONTAL);
        if ( icon.IsOk() )
        {
            sizerTitle->Add(new wxStaticBitmap(this, wxID_ANY, icon),
                            wxSizerFlags().Centre().Border(wxRIGHT));
        }
        //else: Simply don't show any icon.

        wxStaticText* const labelTitle = new wxStaticText(this, wxID_ANY, "");
        labelTitle->SetLabelText(title);

        wxFont titleFont(titleFont_);
        if ( !titleFont.IsOk() )
        {
            // Determine the appropriate title font for the current platform.
            titleFont = labelTitle->GetFont();

#ifdef __WXMSW__
            // When using themes MSW tooltips use larger bluish version of the
            // normal font.
            wxUxThemeEngine* const theme = GetTooltipTheme();
            if ( theme )
            {
                titleFont.MakeLarger();

                COLORREF c;
                if ( FAILED(theme->GetThemeColor
                                   (
                                        wxUxThemeHandle(parent, L"TOOLTIP"),
                                        TTP_BALLOONTITLE,
                                        0,
                                        TMT_TEXTCOLOR,
                                        &c
                                    )) )
                {
                    // Use the standard value of this colour as fallback.
                    c = 0x993300;
                }

                labelTitle->SetForegroundColour(wxRGBToColour(c));
            }
            else
#endif // __WXMSW__
            {
                // Everything else, including "classic" MSW look uses just the
                // bold version of the base font.
                titleFont.MakeBold();
            }
        }

        labelTitle->SetFont(titleFont);
        sizerTitle->Add(labelTitle, wxSizerFlags().Centre());

        wxBoxSizer* const sizerTop = new wxBoxSizer(wxVERTICAL);
        sizerTop->Add(sizerTitle,
                        wxSizerFlags().DoubleBorder(wxLEFT|wxRIGHT|wxTOP));

        // Use a spacer as we don't want to have a double border between the
        // elements, just a simple one will do.
        sizerTop->AddSpacer(wxSizerFlags::GetDefaultBorder());

        wxTextSizerWrapper wrapper(this);
        wxSizer* sizerText = wrapper.CreateSizer(message, -1 /* No wrapping */);

#ifdef __WXMSW__
        if ( icon.IsOk() && GetTooltipTheme() )
        {
            // Themed tooltips under MSW align the text with the title, not
            // with the icon, so use a helper horizontal sizer in this case.
            wxBoxSizer* const sizerTextIndent = new wxBoxSizer(wxHORIZONTAL);
            sizerTextIndent->AddSpacer(icon.GetWidth());
            sizerTextIndent->Add(sizerText,
                                    wxSizerFlags().Border(wxLEFT).Centre());

            sizerText = sizerTextIndent;
        }
#endif // !__WXMSW__
        sizerTop->Add(sizerText,
                        wxSizerFlags().DoubleBorder(wxLEFT|wxRIGHT|wxBOTTOM)
                                      .Centre());

        SetSizer(sizerTop);

        const int offsetY = SetTipShapeAndSize(tipKind, GetBestSize());
        if ( offsetY > 0 )
        {
            // Offset our contents by the tip height to make it appear in the
            // main rectangle.
            sizerTop->PrependSpacer(offsetY);
        }

        Layout();
    }
예제 #9
0
wxBitmap FbSearchCombo::RenderButtonBitmap()
{
	wxSize sizeText = GetBestSize();
	int y  = sizeText.y - 4;
	int x = sizeText.y - 4;

	//===============================================================================
	// begin drawing code
	//===============================================================================
	// image stats

	// force width:height ratio
	if ( 14*x > y*20 )
	{
		// x is too big
		x = y*20/14;
	}
	else
	{
		// y is too big
		y = x*14/20;
	}

	// glass 11x11, top left corner
	// handle (9,9)-(13,13)
	// drop (13,16)-(19,6)-(16,9)

	int multiplier = GetMultiplier();
	int penWidth = multiplier * 1;

	penWidth = penWidth * x / 20;

	wxBitmap bitmap( multiplier*x, multiplier*y );
	wxMemoryDC mem;

	wxColour bg = GetBackgroundColour();
	wxColour fg = mem.GetTextForeground();

	bg = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);

	mem.SelectObject(bitmap);

	// clear background
	mem.SetBrush( wxBrush(bg) );
	mem.SetPen( wxPen(bg) );
	mem.DrawRectangle(0,0,bitmap.GetWidth(),bitmap.GetHeight());

	// draw drop glass
	mem.SetBrush( wxBrush(fg) );
	mem.SetPen( wxPen(fg) );
	int glassBase = 5 * x / 20;
	int glassFactor = 2*glassBase + 1;
	int radius = multiplier*glassFactor/2;
	mem.DrawCircle(radius,radius,radius);
	mem.SetBrush( wxBrush(bg) );
	mem.SetPen( wxPen(bg) );
	mem.DrawCircle(radius,radius,radius-penWidth);

	penWidth = penWidth * 2;

	// draw handle
	int lineStart = radius + (radius-penWidth/2) * 707 / 1000; // 707 / 1000 = 0.707 = 1/sqrt(2);

	mem.SetPen( wxPen(fg) );
	mem.SetBrush( wxBrush(fg) );
	int handleCornerShift = penWidth * 707 / 1000 / 2; // 707 / 1000 = 0.707 = 1/sqrt(2);
	handleCornerShift = handleCornerShift > 0 ? handleCornerShift : 1;
	int handleBase = 4 * x / 20;
	int handleLength = 2*handleBase+1;
	wxPoint handlePolygon[] =
	{
		wxPoint(-handleCornerShift,+handleCornerShift),
		wxPoint(+handleCornerShift,-handleCornerShift),
		wxPoint(multiplier*handleLength/2+handleCornerShift,multiplier*handleLength/2-handleCornerShift),
		wxPoint(multiplier*handleLength/2-handleCornerShift,multiplier*handleLength/2+handleCornerShift),
	};
	mem.DrawPolygon(WXSIZEOF(handlePolygon),handlePolygon,lineStart,lineStart);

	//===============================================================================
	// end drawing code
	//===============================================================================

	if ( multiplier != 1 )
	{
		wxImage image = bitmap.ConvertToImage();
		image.Rescale(x,y);
		bitmap = wxBitmap( image );
	}

	mem.SelectObject(wxNullBitmap);

	// Finalize transparency with a mask
	wxMask *mask = new wxMask(bitmap, bg);
	bitmap.SetMask(mask);

	bitmap = bitmap.GetSubBitmap(wxRect(0,0, y,y));

	return bitmap;
}
예제 #10
0
void wxBitmapComboBox::RecreateControl()
{
    //
    // Recreate control so that WM_MEASUREITEM gets called again.
    // Can't use CBS_OWNERDRAWVARIABLE because it has odd
    // mouse-wheel behaviour.
    //
    wxString value = GetValue();
    wxPoint pos = GetPosition();
    wxSize size = GetSize();
    size.y = GetBestSize().y;
    wxArrayString strings = GetStrings();

    wxComboBox::DoClear();

    HWND hwnd = GetHwnd();
    DissociateHandle();
    ::DestroyWindow(hwnd);

    if ( !MSWCreateControl(wxT("COMBOBOX"), wxEmptyString, pos, size) )
        return;

    // initialize the controls contents
    for ( unsigned int i = 0; i < strings.size(); i++ )
    {
        wxComboBox::Append(strings[i]);
    }

    // and make sure it has the same attributes as before
    if ( m_hasFont )
    {
        // calling SetFont(m_font) would do nothing as the code would
        // notice that the font didn't change, so force it to believe
        // that it did
        wxFont font = m_font;
        m_font = wxNullFont;
        SetFont(font);
    }

    if ( m_hasFgCol )
    {
        wxColour colFg = m_foregroundColour;
        m_foregroundColour = wxNullColour;
        SetForegroundColour(colFg);
    }

    if ( m_hasBgCol )
    {
        wxColour colBg = m_backgroundColour;
        m_backgroundColour = wxNullColour;
        SetBackgroundColour(colBg);
    }
    else
    {
        SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
    }

    ::SendMessage(GetHwnd(), CB_SETITEMHEIGHT, 0, MeasureItem(0));

    // Revert the old string value
    if ( !HasFlag(wxCB_READONLY) )
        ChangeValue(value);
}
예제 #11
0
MyDialog::MyDialog( wxWindow *parent, const wxString& title,
                    const wxPoint& pos, const wxSize& size, const long WXUNUSED(style) ) :
    wxDialog(parent, VALIDATE_DIALOG_ID, title, pos, size, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
{
    // setup the flex grid sizer
    // -------------------------

    wxFlexGridSizer *flexgridsizer = new wxFlexGridSizer(3, 2, 5, 5);

    // Create and add controls to sizers. Note that a member variable
    // of g_data is bound to each control upon construction. There is
    // currently no easy way to substitute a different validator or a
    // different transfer variable after a control has been constructed.

    // Pointers to some of these controls are saved in member variables
    // so that we can use them elsewhere, like this one.
    m_text = new wxTextCtrl(this, VALIDATE_TEXT, wxEmptyString,
                            wxDefaultPosition, wxDefaultSize, 0,
                            wxTextValidator(wxFILTER_ALPHA, &g_data.m_string));
    m_text->SetToolTip("uses wxTextValidator with wxFILTER_ALPHA");
    flexgridsizer->Add(m_text, 1, wxGROW);


    // Now set a wxTextValidator with an explicit list of characters NOT allowed:
    wxTextValidator textVal(wxFILTER_EMPTY|wxFILTER_EXCLUDE_LIST, &g_data.m_string2);
    textVal.SetCharExcludes("bcwyz");
    wxTextCtrl* txt2 =
             new wxTextCtrl(this, VALIDATE_TEXT2, wxEmptyString,
                            wxDefaultPosition, wxDefaultSize, 0, textVal);
    txt2->SetToolTip("uses wxTextValidator with wxFILTER_EMPTY|wxFILTER_EXCLUDE_LIST (to exclude 'bcwyz')");
    flexgridsizer->Add(txt2, 1, wxGROW);

    flexgridsizer->Add(new wxListBox((wxWindow*)this, VALIDATE_LIST,
                        wxDefaultPosition, wxDefaultSize,
                        3, g_listbox_choices, wxLB_MULTIPLE,
                        wxGenericValidator(&g_data.m_listbox_choices)),
                       1, wxGROW);

    m_combobox = new wxComboBox(this, VALIDATE_COMBO, wxEmptyString,
                                wxDefaultPosition, wxDefaultSize,
                                3, g_combobox_choices, 0L,
                                MyComboBoxValidator(&g_data.m_combobox_choice));
    m_combobox->SetToolTip("uses a custom validator (MyComboBoxValidator)");
    flexgridsizer->Add(m_combobox, 1, wxALIGN_CENTER);

    // This wxCheckBox* doesn't need to be assigned to any pointer
    // because we don't use it elsewhere--it can be anonymous.
    // We don't need any such pointer to query its state, which
    // can be gotten directly from g_data.
    flexgridsizer->Add(new wxCheckBox(this, VALIDATE_CHECK, wxT("Sample checkbox"),
                        wxDefaultPosition, wxDefaultSize, 0,
                        wxGenericValidator(&g_data.m_checkbox_state)),
                       1, wxALIGN_CENTER|wxALL, 15);

    flexgridsizer->AddGrowableCol(0);
    flexgridsizer->AddGrowableCol(1);
    flexgridsizer->AddGrowableRow(1);


    // setup the button sizer
    // ----------------------

    wxStdDialogButtonSizer *btn = new wxStdDialogButtonSizer();
    btn->AddButton(new wxButton(this, wxID_OK));
    btn->AddButton(new wxButton(this, wxID_CANCEL));
    btn->Realize();

    // setup a sizer with the controls for numeric validators
    // ------------------------------------------------------

    wxIntegerValidator<int> valInt(&g_data.m_intValue,
                                   wxNUM_VAL_THOUSANDS_SEPARATOR |
                                   wxNUM_VAL_ZERO_AS_BLANK);
    valInt.SetMin(0); // Only allow positive numbers

    m_numericTextInt = new wxTextCtrl
                           (
                                this,
                                wxID_ANY,
                                "",
                                wxDefaultPosition,
                                wxDefaultSize,
                                wxTE_RIGHT,
                                valInt
                            );
    m_numericTextInt->SetToolTip("uses wxIntegerValidator to accept positive "
                                 "integers only");

    m_numericTextDouble = new wxTextCtrl
                              (
                                this,
                                wxID_ANY,
                                "",
                                wxDefaultPosition,
                                wxDefaultSize,
                                wxTE_RIGHT,
                                wxMakeFloatingPointValidator
                                (
                                    3,
                                    &g_data.m_doubleValue,
                                    wxNUM_VAL_THOUSANDS_SEPARATOR |
                                    wxNUM_VAL_NO_TRAILING_ZEROES
                                )
                              );
    m_numericTextDouble->SetToolTip("uses wxFloatingPointValidator with 3 decimals");
    wxBoxSizer *numSizer = new wxBoxSizer( wxHORIZONTAL );
    numSizer->Add( m_numericTextInt, 1, wxALL, 10 );
    numSizer->Add( m_numericTextDouble, 1, wxALL, 10 );



    // setup the main sizer
    // --------------------

    wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL );

    mainsizer->Add(flexgridsizer, 1, wxGROW | wxALL, 10);

    mainsizer->Add(new wxRadioBox((wxWindow*)this, VALIDATE_RADIO, wxT("Pick a color"),
                                    wxDefaultPosition, wxDefaultSize,
                                    3, g_radiobox_choices, 1, wxRA_SPECIFY_ROWS,
                                    wxGenericValidator(&g_data.m_radiobox_choice)),
                   0, wxGROW | wxLEFT|wxBOTTOM|wxRIGHT, 10);

    mainsizer->Add( numSizer, 0, wxGROW | wxALL );

    mainsizer->Add(btn, 0, wxGROW | wxALL, 10);

    SetSizer(mainsizer);
    mainsizer->SetSizeHints(this);

    // make the dialog a bit bigger than its minimal size:
    SetSize(GetBestSize()*1.5);
}
예제 #12
0
wxFlatButton::wxFlatButton(wxWindow* parent,
    const wxString& label,
    const wxFlatButton::eTheme theme,
    const wxBitmap& bmp,
    const wxSize& size,
    int style)
    : wxFlatButtonBase(parent)
    , m_theme(theme)
    , m_state(kStateNormal)
    , m_text(label)
    , m_bmp(bmp)
    , m_accelIndex(wxNOT_FOUND)
    , m_kind(kKindNormal)
    , m_isChecked(false)
    , m_contextMenu(NULL)
    , m_isDisabled(false)
    , m_style(style)
{
    SetBackgroundStyle(wxBG_STYLE_PAINT);

    // Parse the label
    wxString tmpLabel;
    m_text.Replace("&&", "@@");
    // Parse the label
    for(size_t i = 0; i < m_text.length(); ++i) {
        if(m_accelIndex == wxNOT_FOUND && m_text.GetChar(i) == '&') {
            m_accelIndex = i;
            continue;
        } else {
            tmpLabel << m_text.GetChar(i);
        }
    }

    tmpLabel.Replace("@@", "&");
    m_text.swap(tmpLabel);

    // Colours - dark theme
    if(m_theme == kThemeDark) {
        SetPenNormalColour("rgb(48, 48, 48)");
        SetPenPressedColour("rgb(125, 125, 125)");
        SetBgPressedColour("rgb(48, 48, 48)");
        SetBgHoverColour("rgb(80, 80, 80)");
        SetBgColour("rgb(65, 65, 65)");
        m_penHoverColourInner = "rgb(160, 160, 160)";
        m_penHoverOuterColour = GetPenNormalColour();
        SetTextColour("rgb(248, 248, 242)");
        SetTextColourDisabled("rgb(109, 109, 109)");
        if(m_bmp.IsOk()) {
            m_bmpDisabled = ConvertToDisabled(m_bmp);
        }

    } else {
        wxColour paneColour = DrawingUtils::GetButtonBgColour();
        wxColour bgColour = paneColour;
        wxColour penColour = paneColour.ChangeLightness(90);

        SetPenNormalColour(penColour);
        SetBgColour(bgColour);

        SetPenPressedColour("rgb(90, 90, 90)");
        SetBgPressedColour("rgb(120, 120, 120)");

        SetBgHoverColour(bgColour);
        m_penHoverColourInner = "WHITE";
        m_penHoverOuterColour = "TURQUOISE";
        SetTextColour("rgb(15, 15, 15)");
        SetTextColourDisabled(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
        if(m_bmp.IsOk()) {
            m_bmpDisabled = ConvertToDisabled(m_bmp);
        }
    }

    SetTextFont(DrawingUtils::GetDefaultGuiFont());
    if(size != wxDefaultSize) {
        SetMinSize(size);
    } else {
        SetMinSize(GetBestSize());
    }
}
예제 #13
0
void wxChoice::DoSetSize(int x, int y,
                         int width, int height,
                         int sizeFlags)
{
    const int heightBest = GetBestSize().y;

    // we need the real height below so get the current one if it's not given
    if ( height == wxDefaultCoord )
    {
        // height not specified, use the same as before
        DoGetSize(NULL, &height);
    }
    else if ( height == heightBest )
    {
        // we don't need to manually manage our height, let the system use the
        // default one
        m_heightOwn = wxDefaultCoord;
    }
    else // non-default height specified
    {
        // set our new own height but be careful not to make it too big: the
        // native control apparently stores it as a single byte and so setting
        // own height to 256 pixels results in default height being used (255
        // is still ok)
        m_heightOwn = height;

        if ( m_heightOwn > UCHAR_MAX )
            m_heightOwn = UCHAR_MAX;
        // nor too small: see MSWUpdateVisibleHeight()
        else if ( m_heightOwn < COMBO_HEIGHT_ADJ )
            m_heightOwn = COMBO_HEIGHT_ADJ;
    }


    // the height which we must pass to Windows should be the total height of
    // the control including the drop down list while the height given to us
    // is, of course, just the height of the permanently visible part of it so
    // add the drop down height to it

    // don't make the drop down list too tall, arbitrarily limit it to 30
    // items max and also don't make it too small if it's currently empty
    size_t nItems = GetCount();
    if (!HasFlag(wxCB_SIMPLE))
    {
        if ( !nItems )
            nItems = 9;
        else if ( nItems > 30 )
            nItems = 30;
    }

    const int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0);
    int heightWithItems = 0;
    if (!HasFlag(wxCB_SIMPLE))
        // The extra item (" + 1") is required to prevent a vertical
        // scrollbar from appearing with comctl32.dll versions earlier
        // than 6.0 (such as found in Win2k).
        heightWithItems = height + hItem*(nItems + 1);
    else
        heightWithItems = SetHeightSimpleComboBox(nItems);


    // do resize the native control
    wxControl::DoSetSize(x, y, width, heightWithItems, sizeFlags);


    // make the control itself of the requested height: notice that this
    // must be done after changing its size or it has no effect (apparently
    // the height is reset to default during the control layout) and that it's
    // useless to do it when using the deferred sizing -- in this case it
    // will be done from MSWEndDeferWindowPos()
#if wxUSE_DEFERRED_SIZING
    if ( m_pendingSize == wxDefaultSize )
    {
        // not using deferred sizing, update it immediately
        MSWUpdateVisibleHeight();
    }
    else // in the middle of deferred sizing
    {
        // we need to report the size of the visible part of the control back
        // in GetSize() and not height stored by DoSetSize() in m_pendingSize
        m_pendingSize = wxSize(width, height);
    }
#else // !wxUSE_DEFERRED_SIZING
    // always update the visible height immediately
    MSWUpdateVisibleHeight();
#endif // wxUSE_DEFERRED_SIZING
}
예제 #14
0
void wxSheetCellBoolRendererRefData::Draw(wxSheet& sheet,
        const wxSheetCellAttr& attr,
        wxDC& dc, const wxRect& rect,
        const wxSheetCoords& coords,
        bool isSelected)
{
    wxSheetCellRendererRefData::Draw(sheet, attr, dc, rect, coords, isSelected);

    // draw a check mark in the centre (ignoring alignment - TODO)
    wxSize size = GetBestSize(sheet, attr, dc, coords);

    // don't draw outside the cell
    wxCoord minSize = wxMin(rect.width, rect.height) - 1;
    if ((size.x >= minSize) || (size.y >= minSize))
        size.x = size.y = minSize - 2; // leave (at least) 1 pixel margin

    // draw a border around checkmark
    int align = attr.GetAlignment();

    wxRect rectBorder(rect.GetPosition(), size);

    if ((align & wxALIGN_RIGHT) != 0)
        rectBorder.x += rect.width - size.x - 2;
    else if ((align & wxALIGN_CENTRE_HORIZONTAL) != 0)
        rectBorder.x += rect.width/2 - size.x/2;
    else // wxALIGN_LEFT
        rectBorder.x += 2;

    if ((align & wxALIGN_BOTTOM) != 0)
        rectBorder.y += rect.height - size.y - 2;
    else if ((align & wxALIGN_CENTRE_VERTICAL) != 0)
        rectBorder.y += rect.height/2 - size.y/2;
    else // wxALIGN_TOP
        rectBorder.y += 2;

    bool value = false;
    if ( sheet.GetTable() && sheet.GetTable()->CanGetValueAs(coords, wxSHEET_VALUE_BOOL) )
        value = sheet.GetTable()->GetValueAsBool(coords);
    else
    {
        wxString strValue( sheet.GetCellValue(coords) );
        value = !( strValue.IsEmpty() || (strValue == wxT("0")) ||
                   (strValue.Lower() == wxT("f")) || (strValue.Lower() == wxT("false")));
    }

    if ( value )
    {
        wxRect rectMark = rectBorder;
#ifdef __WXMSW__
        // MSW DrawCheckMark() is weird (and should probably be changed...)
        rectMark.Inflate(-wxSHEET_CHECKMARK_MARGIN/2);
        rectMark.x++;
        rectMark.y++;
#else // !MSW
        rectMark.Inflate(-wxSHEET_CHECKMARK_MARGIN);
#endif // MSW/!MSW

        dc.SetTextForeground(attr.GetForegroundColour());
        dc.DrawCheckMark(rectMark);
    }

    dc.SetBrush(*wxTRANSPARENT_BRUSH);
    dc.SetPen(wxPen(attr.GetForegroundColour(), 1, wxSOLID));
    dc.DrawRectangle(rectBorder);
}
예제 #15
0
void WXAppBar::SetAutohideModeStep ()
{
	//CheckCreateWindow();

	//
	// Get X11 display
	//
	Display* dd= (Display *) wxGetDisplay(); assert (dd);
	
	//
	// Get desktop working area dimensions
	//
	int xDesktop, yDesktop, widthDesktop, heightDesktop, screenWidth, screenHeight;
	GetDesktopDimensions (dd, xDesktop, yDesktop, widthDesktop, heightDesktop, screenWidth, screenHeight);
	
	//
	// As we need to dock the window disable decorations
	//
	m_dialogHadBorderDecorations= GetBorderDecorations();
	SetBorderDecorations(false);
	
	//
	// Get X11 handle for our window
	//
	GtkWidget *gtkWidget= (GtkWidget *) this->GetHandle();
	Window w= GDK_WINDOW_XWINDOW (gtkWidget->window);
	
	// Get original dimensions of the bar
	wxSize proposedSize= GetBestSize();

	// Compute bar position and size depending on docking mode
	m_Width= proposedSize.GetWidth();
	m_Height= proposedSize.GetHeight();
	
	switch (m_currentDockingMode) {
		case TOP_DOCKED:
			m_X= (screenWidth - proposedSize.GetWidth())/2;
			m_Y= 0 - proposedSize.GetHeight() + AUTOHIDE_FLANGE;
			break;
		case BOTTOM_DOCKED:
			m_X= (screenWidth - proposedSize.GetWidth())/2;
			m_Y= screenHeight - AUTOHIDE_FLANGE;
			break;
		case LEFT_DOCKED:
			m_X= 0 - proposedSize.GetWidth() + AUTOHIDE_FLANGE;
			m_Y= (screenHeight - proposedSize.GetHeight())/2;
			break; 
		case RIGHT_DOCKED:
			m_X= screenWidth - AUTOHIDE_FLANGE;
			m_Y= (screenHeight - proposedSize.GetHeight())/2;
			break;
		case NON_DOCKED:
		default:
			assert (false);
	}
	
	
	//
	// Functional type of the window (_NET_WM_WINDOW_TYPE)
	//
	Atom atomTmp= XInternAtom (dd, "_NET_WM_WINDOW_TYPE", False);
	Atom atom_NET_WM_WINDOW_TYPE_DOCK= XInternAtom (dd, "_NET_WM_WINDOW_TYPE_DOCK", False);
	Atom atom_NET_WM_WINDOW_TYPE_NORMAL= XInternAtom (dd, "_NET_WM_WINDOW_TYPE_NORMAL", False);
	unsigned long propInfo[2];
	propInfo[0]= atom_NET_WM_WINDOW_TYPE_DOCK;
	propInfo[1]= atom_NET_WM_WINDOW_TYPE_NORMAL;		
	XChangeProperty (dd, w, atomTmp, XA_ATOM, 32, PropModeReplace, (unsigned char *) &propInfo[0], 2);
	SetSticky(true);
	XSync(dd, False);

	// Set desired location and dimensions
	SetSize(m_X, m_Y, m_Width, m_Height);	
}
예제 #16
0
void ShareProperties::CreateControls()
{    
    ////@begin ShareProperties content construction
    if (!wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_DIALOG_SHARE_ADD")))
        wxLogError(wxT("Missing wxXmlResource::Get()->Load() in OnInit()?"));
    m_pCtrlLocalShares = XRCCTRL(*this, "ID_COMBOBOX_SHARE_LOCALNAME", wxBitmapComboBox);
    m_pCtrlSmbPrintOptions = XRCCTRL(*this, "ID_PANEL_SMB_PRINTER", wxPanel);
    m_pCtrlSmbDriver = XRCCTRL(*this, "ID_COMBOBOX_SMBDRIVER", wxComboBox);
    m_pCtrlSmbPrivate = XRCCTRL(*this, "ID_RADIOBUTTON_SMB_PRIVATE", wxRadioButton);
    m_pCtrlSmbPublic = XRCCTRL(*this, "ID_RADIOBUTTON_SMB_PUBLIC", wxRadioButton);
    m_pCtrlSmbPrintUsername = XRCCTRL(*this, "ID_TEXTCTRL_SMBPRINT_USERNAME", wxTextCtrl);
    m_pCtrlSmbPrintPassword = XRCCTRL(*this, "ID_TEXTCTRL_SMBPRINT_PASSWORD", wxTextCtrl);
    m_pCtrlCupsOptions = XRCCTRL(*this, "ID_PANEL_CUPSOPTIONS", wxPanel);
    m_pCtrlCupsPrivate = XRCCTRL(*this, "ID_RADIOBUTTON_CUPS_PRIVATE", wxRadioButton);
    m_pCtrlCupsPublic = XRCCTRL(*this, "ID_RADIOBUTTON_CUPS_PUBLIC", wxRadioButton);
    m_pCtrlUsbOptions = XRCCTRL(*this, "ID_PANEL_USBIP", wxPanel);
    m_pCtrlSmbDiskOptions = XRCCTRL(*this, "ID_PANEL_SMBOPTIONS", wxPanel);
    m_pCtrlMountPoint = XRCCTRL(*this, "ID_TEXTCTRL_SHARE_MOUNTPOINT", wxTextCtrl);
    m_pCtrlUsername = XRCCTRL(*this, "ID_TEXTCTRL_SHARE_USERNAME", wxTextCtrl);
    m_pCtrlPassword = XRCCTRL(*this, "ID_TEXTCTRL_SHARE_PASSWORD", wxTextCtrl);
    // Set validators
    if (FindWindow(XRCID("ID_COMBOBOX_SMBDRIVER")))
        FindWindow(XRCID("ID_COMBOBOX_SMBDRIVER"))->SetValidator( wxGenericValidator(& m_sSmbDriver) );
    if (FindWindow(XRCID("ID_RADIOBUTTON_SMB_PUBLIC")))
        FindWindow(XRCID("ID_RADIOBUTTON_SMB_PUBLIC"))->SetValidator( wxGenericValidator(& m_bSmbPublic) );
    if (FindWindow(XRCID("ID_TEXTCTRL_SMBPRINT_USERNAME")))
        FindWindow(XRCID("ID_TEXTCTRL_SMBPRINT_USERNAME"))->SetValidator( MyValidator(& m_sSmbPrintUsername) );
    if (FindWindow(XRCID("ID_TEXTCTRL_SMBPRINT_PASSWORD")))
        FindWindow(XRCID("ID_TEXTCTRL_SMBPRINT_PASSWORD"))->SetValidator( MyValidator(& m_sSmbPrintPassword) );
    if (FindWindow(XRCID("ID_COMBOBOX_CUPSDRIVER")))
        FindWindow(XRCID("ID_COMBOBOX_CUPSDRIVER"))->SetValidator( wxGenericValidator(& m_sCupsDriver) );
    if (FindWindow(XRCID("ID_RADIOBUTTON_CUPS_PUBLIC")))
        FindWindow(XRCID("ID_RADIOBUTTON_CUPS_PUBLIC"))->SetValidator( wxGenericValidator(& m_bCupsPublic) );
    if (FindWindow(XRCID("ID_TEXTCTRL_SHARE_MOUNTPOINT")))
        FindWindow(XRCID("ID_TEXTCTRL_SHARE_MOUNTPOINT"))->SetValidator( MyValidator(& m_sMountPoint) );
    if (FindWindow(XRCID("ID_TEXTCTRL_SHARE_USERNAME")))
        FindWindow(XRCID("ID_TEXTCTRL_SHARE_USERNAME"))->SetValidator( MyValidator(& m_sSmbDiskUsername) );
    if (FindWindow(XRCID("ID_TEXTCTRL_SHARE_PASSWORD")))
        FindWindow(XRCID("ID_TEXTCTRL_SHARE_PASSWORD"))->SetValidator( MyValidator(& m_sSmbDiskPassword) );
    ////@end ShareProperties content construction

    // Create custom windows not generated automatically here.

    ////@begin ShareProperties content initialisation
    ////@end ShareProperties content initialisation

    int minw = 0;
    int minh = 0;
    int w, h;
    m_pCtrlSmbDiskOptions->Show(false);
    m_pCtrlSmbPrintOptions->Show(true);
    m_pCtrlCupsOptions->Show(false);
    InvalidateBestSize();
    Layout();
    m_pCtrlSmbPrintOptions->SetMinSize(m_pCtrlSmbPrintOptions->GetBestSize());
    GetBestSize(&minw, &minh);

    m_pCtrlSmbDiskOptions->Show(false);
    m_pCtrlSmbPrintOptions->Show(false);
    m_pCtrlCupsOptions->Show(true);
    InvalidateBestSize();
    Layout();
    m_pCtrlCupsOptions->SetMinSize(m_pCtrlSmbDiskOptions->GetBestSize());
    GetBestSize(&w, &h);
    if (w > minw)
        minw = w;
    if (h > minh)
        minh = h;

    m_pCtrlCupsOptions->Show(false);
    m_pCtrlSmbDiskOptions->Show(true);
    m_pCtrlSmbPrintOptions->Show(false);
    InvalidateBestSize();
    Layout();
    m_pCtrlSmbDiskOptions->SetMinSize(m_pCtrlSmbPrintOptions->GetBestSize());
    GetBestSize(&w, &h);
    if (w > minw)
        minw = w;
    if (h > minh)
        minh = h;
    SetMinSize(wxSize(minw, minh));

    if (m_iCurrentShare != -1) {
        ShareGroup sg = m_pCfg->aGetShareGroups().Item(m_iCurrentShare);
        wxBitmap bm = wxNullBitmap;
        m_pCtrlLocalShares->Append(sg.m_sShareName, bm, &sg);
        m_pCtrlLocalShares->SetSelection(0);
        m_pCtrlLocalShares->Enable(false);
        SetTitle(_("Modify shared resource - OpenNX"));
        switch (sg.m_eType) {
            case SharedResource::SHARE_UNKNOWN:
                break;
            case SharedResource::SHARE_SMB_DISK:
                m_pCtrlCupsOptions->Show(false);
                m_pCtrlSmbPrintOptions->Show(false);
                m_pCtrlSmbDiskOptions->Show(true);
                m_sMountPoint = sg.m_sAlias;
                m_sSmbDiskUsername = sg.m_sUsername;
                if (m_sSmbDiskUsername.IsEmpty())
                    m_sSmbDiskUsername = ::wxGetUserId();
                m_sSmbDiskPassword = sg.m_sPassword;
                Layout();
                break;
            case SharedResource::SHARE_SMB_PRINTER:
                m_pCtrlCupsOptions->Show(false);
                m_pCtrlSmbDiskOptions->Show(false);
                m_pCtrlSmbPrintOptions->Show(true);
                m_sSmbDriver = sg.m_sDriver;
                m_sSmbPrintUsername = sg.m_sUsername;
                if (m_sSmbPrintUsername.IsEmpty())
                    m_sSmbPrintUsername = ::wxGetUserId();
                m_sSmbPrintPassword = sg.m_sPassword;
                if (sg.m_bPublic)
                    m_pCtrlSmbPublic->SetValue(true);
                else
                    m_pCtrlSmbPrivate->SetValue(true);
                Layout();
                break;
            case SharedResource::SHARE_CUPS_PRINTER:
                m_pCtrlSmbPrintOptions->Show(false);
                m_pCtrlSmbDiskOptions->Show(false);
                m_pCtrlCupsOptions->GetSizer()->Layout();
                m_pCtrlCupsOptions->Show(true);
                if (sg.m_bPublic)
                    m_pCtrlCupsPublic->SetValue(true);
                else
                    m_pCtrlCupsPrivate->SetValue(true);
                Layout();
                break;
        }
        m_pCtrlMountPoint->SetValue(m_sMountPoint);
    } else {
        // Fetch list of shares
        if (m_bUseSmb) {
            SmbClient sc;
            m_aShares = sc.GetShares();
        }
        if (m_bUseCups) {
            CupsClient cc;
            ArrayOfShares cupsShares = cc.GetShares();
            WX_APPEND_ARRAY(m_aShares, cupsShares);
        }
        // Apparently, wxGTK (perhaps GTK itself) has a bug which
        // results in data pointers not being associated properly to the
        // ComboBox, if that ComboBox is sorted (wxCB_SORT attribute).
        // As a woraround, we use an *unsorted* ComboBox and sort the
        // shares before adding them to the ComboBox.
        m_aShares.Sort(cmpshares);

        // Build ComboBox content
        for (size_t i = 0; i < m_aShares.GetCount(); i++) {
            wxBitmap bm;
            switch (m_aShares[i].sharetype) {
                case SharedResource::SHARE_SMB_DISK:
                    bm = GetBitmapResource(wxT("res/smbfolder.png"));
                    break;
                case SharedResource::SHARE_SMB_PRINTER:
                    bm = GetBitmapResource(wxT("res/smbprinter.png"));
                    break;
                case SharedResource::SHARE_CUPS_PRINTER:
                    bm = GetBitmapResource(wxT("res/cupsprinter.png"));
                    break;
                default:
                    bm = wxNullBitmap;
                    break;
            }
            m_pCtrlLocalShares->Append(m_aShares[i].name, bm, m_aShares[i].GetThisVoid());
        }

        if (m_aShares.GetCount() > 0) {
            // Select first element of ComboBox
            m_pCtrlLocalShares->SetSelection(0);
            SharedResource *res = wxDynamicCast(m_pCtrlLocalShares->GetClientData(0), SharedResource);
            wxASSERT(res);
            switch (res->sharetype) {
                case SharedResource::SHARE_UNKNOWN:
                    break;
                case SharedResource::SHARE_SMB_DISK:
                    m_pCtrlSmbPrintOptions->Show(false);
                    m_pCtrlCupsOptions->Show(false);
                    m_pCtrlSmbDiskOptions->Show(true);
                    m_sMountPoint = wxT("$(SHARES)/") + res->name;
                    Layout();
                    break;
                case SharedResource::SHARE_SMB_PRINTER:
                    m_pCtrlSmbDiskOptions->Show(false);
                    m_pCtrlCupsOptions->Show(false);
                    m_pCtrlSmbPrintOptions->Show(true);
                    m_sSmbDriver = wxT("laserjet");
                    Layout();
                    break;
                case SharedResource::SHARE_CUPS_PRINTER:
                    m_pCtrlSmbDiskOptions->Show(false);
                    m_pCtrlSmbPrintOptions->Show(false);
                    m_pCtrlCupsOptions->Show(true);
                    Layout();
                    break;
            }
        } else {
            wxLogMessage(_("No shares found"));
            m_pCtrlLocalShares->Enable(false);
            m_pCtrlMountPoint->Enable(false);
            m_pCtrlUsername->Enable(false);
            m_pCtrlPassword->Enable(false);
        }
    }
}