Exemplo n.º 1
0
LRESULT MBMessageBoxImpl::GripWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	WNDPROC oldWndProc = (WNDPROC)::GetProp(hwnd, RSZ_GRIP_OBJ);

	switch (msg)
	{
	case WM_NCHITTEST:

		// choose proper cursor shape
		if (IsRTL(hwnd))
			return HTBOTTOMLEFT;
		else
			return HTBOTTOMRIGHT;

	case WM_DESTROY:
		
		// unsubclass
		::RemoveProp(hwnd, RSZ_GRIP_OBJ);
		::SetWindowLong(hwnd, GWL_WNDPROC, (LONG)oldWndProc);

		break;
	}

	return ::CallWindowProc(oldWndProc, hwnd, msg, wParam, lParam);
}
Exemplo n.º 2
0
Arquivo: rtl.cpp Projeto: sharperM/UI
    bool AdjustStringForLocaleDirection(const string16& text,
        string16* localized_text)
    {
        if(!IsRTL() || text.empty())
        {
            return false;
        }

        // TODO: 根据IsRTL()实际值进行处理.
        *localized_text = text;
        return true;
    }
Exemplo n.º 3
0
void PoeditListCtrl::ReadCatalog()
{
    wxWindowUpdateLocker no_updates(this);

    // clear the list and its sort order too:
    SetItemCount(0);
    m_mapListToCatalog.clear();
    m_mapCatalogToList.clear();

    if (m_catalog == NULL)
    {
        Refresh();
        return;
    }

    auto lang = m_catalog->GetLanguage();
    auto isRTL = lang.IsRTL();
#ifdef __WXMSW__
    // a quirk of wx API: if the current locale is RTL, the meaning of L and R is reversed
    if (m_appIsRTL)
        isRTL = !isRTL;
#endif
    m_isRTL = isRTL;

    wxString langname = lang.IsValid() ? lang.DisplayName() : _("unknown language");
    wxListItem colInfo;
    colInfo.SetMask(wxLIST_MASK_TEXT);
    colInfo.SetText(wxString::Format(_(L"Translation — %s"), langname));
    colInfo.SetAlign(isRTL ? wxLIST_FORMAT_RIGHT : wxLIST_FORMAT_LEFT);
    SetColumn(1, colInfo);

    // sort catalog items, create indexes mapping
    CreateSortMap();

    // now that everything is prepared, we may set the item count
    SetItemCount(m_catalog->GetCount());

    // scroll to the top and refresh everything:
    if ( m_catalog->GetCount() )
    {
        SelectOnly(0);
        RefreshItems(0, m_catalog->GetCount()-1);
    }
    else
    {
        Refresh();
    }
}
Exemplo n.º 4
0
int main(int argc, char **argv) {

	OpenScreen();
	// SetOrientation

	int sw = ScreenWidth();
	int sh = ScreenHeight();
	fprintf(stderr, "[%ix%i]\n", sw, sh);

	if (sw >= 1200 || sh >= 1200) {
		cpar = &params[1];
	} else {
		cpar = &params[0];
	}

	cal_title_font = OpenFont(DEFAULTFONTB, cpar->tfontsize, 1);
	cal_month_font = OpenFont(DEFAULTFONTB, cpar->mfontsize, 1);
	cal_day_font = OpenFont(DEFAULTFONTB, cpar->dfontsize - (IsRTL() ? 2 : 0), 1);
	cal_date_font = OpenFont(DEFAULTFONT, cpar->dfontsize, 1);
	cal_date2_font = OpenFont(DEFAULTFONTB, cpar->dfontsize, 1);

 	CurTime=time(NULL);
 	CurDate=localtime(&CurTime);
 	if (year>CurDate->tm_year+1900)
 		step=-step;
 	FirstDay=MilleniumFirstDay;
 	while (year!=CurDate->tm_year+1900)
 		{
 		 if (year%4==0)
 		 	LongYear=1;
 		 	else
 		 	LongYear=0;
 		 if (LongYear && year%100==0 && year%400!=0)
 		 	LongYear=0;
 		 FirstDay=(FirstDay+365*(1-LongYear)+366*LongYear)%7;
 		 year+=step;
 		}
	InkViewMain(calendar_handler);
	return 0;

}
Exemplo n.º 5
0
void SuggestionsSidebarBlock::UpdateSuggestions(const SuggestionsList& hits)
{
    wxWindowUpdateLocker lock(m_parent);

    for (auto& h: hits)
    {
        // empty entries screw up menus (treated as stock items), don't use them:
        if (!h.text.empty())
            m_suggestions.push_back(h);
    }

    std::stable_sort(m_suggestions.begin(), m_suggestions.end());

    // create any necessary controls:
    while (m_suggestions.size() > m_suggestionsWidgets.size())
    {
        auto w = new SuggestionWidget(m_parent);
        m_suggestionsSizer->Add(w, wxSizerFlags().Expand());
        m_suggestionsWidgets.push_back(w);
    }
    m_innerSizer->Layout();

    // update shown suggestions:
    auto lang = m_parent->GetCurrentLanguage();
    bool isRTL = lang.IsRTL();
    for (size_t i = 0; i < m_suggestions.size(); ++i)
    {
        auto s = m_suggestions[i];
        m_suggestionsWidgets[i]->SetValue((int)i, s, lang, isRTL, GetIconForSuggestion(s), GetTooltipForSuggestion(s));
    }

    m_innerSizer->Layout();
    UpdateVisibility();
    m_parent->Layout();

    UpdateSuggestionsMenu();
}
Exemplo n.º 6
0
Arquivo: rtl.cpp Projeto: sharperM/UI
 int GetExtendedTooltipStyles() {
     return !IsRTL() ? 0 : WS_EX_LAYOUTRTL;
 }
Exemplo n.º 7
0
Arquivo: rtl.cpp Projeto: sharperM/UI
 int GetExtendedStyles() {
     return !IsRTL() ? 0 : WS_EX_LAYOUTRTL | WS_EX_RTLREADING;
 }
Exemplo n.º 8
0
/*
*  CLine::CchFromXPos
*
*  Purpose:
*      Computes cp corresponding to a x position in a line
*
*  Arguments:
*      me                  measurer position at start of line
*      x                   xpos to search for
*      y                   ypos to search for
*      pdx                 returns adjustment to x at returned cp
*      fRTLDisplay         Is the display right-to-left?
*      fExactFit           Do we need to fit exactly?
*      pyHeightRubyBase    Support for ruby
*
*      HACKHACK (t-ramar): This function calls DiscardLine() at the 
*              end, but we would like to keep information about Ruby Base
*              heights around for hit testing purposes.  Thus, there is an
*              optional parameter:
*                  ppRubyInfo (out):  is the information pertaining to
*                                     ruby object that contains the cp
*                                     (NULL by default)
*              It's also important to note that this value is ignored if
*              line flag FLAG_HAS_RUBY is not set.  In this case the 
*              value pointed to by ppRubyInfo will remain unchanged.
*  Returns
*      cp of character found
*
*  Note:
*      me is moved to returned cp
*
*  TKTK CF
*      this should probably be done by a CRenderer to allow
*      left - right justification
*/
LONG CLine::CchFromXpos(
                        CLSMeasurer& me,
                        LONG    x,
                        LONG    y,
                        LONG*   pdx,
                        BOOL    fRTLDisplay,
                        BOOL    fExactFit,
                        LONG*   pyHeightRubyBase) const
{
    CMarginInfo marginInfo;
    LONG dx = 0;
    LONG cpStart = me.GetCp();
    LONG cp = cpStart;
    DWORD uiFlags = 0;
    BOOL fReverseFlow = FALSE;

    // Bail out if the line has no charaters in it.
    if(_cch == 0)
    {
        return 0;
    }

    if(me._pFlowLayout->IsDisplayNone())
    {
        return 0;
    }

    if(me._pFlowLayout->GetDisplay()->GetWordWrap() && 
        me._pFlowLayout->GetDisplay()->GetWrapLongLines())
    {
        uiFlags |= MEASURE_BREAKLONGLINES;
    }

    // Determine where x is relative to the line. LTR lines have their origin
    // at the left edge of the text in the line and progress positively to the
    // right; RTL lines have their origin at the  right edge of the text and
    // progress positively to the left.
    if(!fRTLDisplay)
    {
        // X is a positive value relative to the left edge of the display.
        if(!_fRTL)
        {
            x = x - (_xLeftMargin + _xLeft);
        }
        else
        {
            x = -(x - (_xLeftMargin + _xLeft + _xWidth - 1));
        }
    }
    else
    {
        // X is a negative value relative to the right edge of the display.
        x = -x;
        if(_fRTL)
        {
            x = x - (_xRightMargin + _xRight);
        }
        else
        {
            x = -(x - (_xRightMargin + _xRight + _xWidth - 1));
        }
    }


    me._li._cch = 0; // Default zero count

    if(x > 0) // In between right & left margins
    {
        {
            CLine* pliFirstFrag;
            LONG cpStartContainerLine;
            LSERR lserr = lserrNone;

            lserr = me.PrepAndMeasureLine((CLine*)this, &pliFirstFrag, &cpStartContainerLine, &marginInfo, _cch, uiFlags);

            if(lserr == lserrNone)
            {
                if(me._pLS->_plsline)
                {
                    LONG xTrailEdge;

                    Assert(pliFirstFrag->_fRTL == _fRTL);
                    if(!_fRTL)
                    {
                        x += (_xLeft + _xLeftMargin) -
                            (pliFirstFrag->_xLeft + pliFirstFrag->_xLeftMargin);
                    }
                    else
                    {
                        x += (_xRight + _xRightMargin) -
                            (pliFirstFrag->_xRight + pliFirstFrag->_xRightMargin);
                    }

                    if(pliFirstFrag != this)
                    {
                        long durWithTrailing, duIgnore;
                        HRESULT hr = me._pLS->GetLineWidth(&durWithTrailing, &duIgnore);
                        if(hr)
                        {
                            goto Cleanup;
                        }
                        xTrailEdge = durWithTrailing;
                    }
                    else
                    {
                        xTrailEdge = _xWidth + _xWhite;
                    }

                    // If our point is past the end of the line, the return value of
                    // LsQueryLinePointPcp is invalid.
                    if(x < xTrailEdge)
                    {
                        HRESULT hr;
                        LSTEXTCELL lsTextCell;
                        LSTFLOW kTFlow;

                        // FUTURE: (paulnel) If we find we need any more information
                        // from the LSQSUBLINEINFO we can pass it back here.
                        hr = me._pLS->QueryLinePointPcp(x, y, &kTFlow, &lsTextCell);

                        if(hr)
                        {
                            AssertSz(0, "QueryLinePointPcp failed.");
                            goto Cleanup;
                        }

                        dx = lsTextCell.pointUvStartCell.u - x;
                        fReverseFlow = (IsRTL() == !(kTFlow&fUDirection));
                        // FUTURE: (mikejoch) Do we still need to test for a ruby here?
                        Assert(me._pLS->_lineFlags.GetLineFlags(cp)&FLAG_HAS_RUBY ||
                            ((!fReverseFlow)?-dx:dx)>=0);
                        cp = me._pLS->CPFromLSCP(lsTextCell.cpStartCell);

                        if(!fExactFit)
                        {
                            // It is possible to have lsTextCell flowing against
                            // the line. If this is the case dx is positive and
                            // we will need to subtract dupCell from dx if we
                            // advance the cp.
                            if(((!fReverseFlow)?-dx:dx) >= lsTextCell.dupCell/2)
                            {
                                cp += lsTextCell.cCharsInCell;
                                dx += (!fReverseFlow) ? lsTextCell.dupCell : -lsTextCell.dupCell;
                            }
                        }
                    }
                    else
                    {
                        cp = cpStart + _cch;
                        // BUGBUG (mikejoch) Shouldn't this be (_xWidth + _xWhite) - x?
                        dx = _xWidth - x;
                    }
                }
                else
                {
                    // If _plsline is NULL, we didn't measure.  This usually
                    // means we had no text to measure, or we had no width.
                    dx = _xWidth - x;
                    cp = cpStart;
                }
            }
        }
        me._li._cch = cp - cpStart;
    }
    else
    {
        CTreePos* ptp;

        me._pdp->FormattingNodeForLine(me.GetCp(), me.GetPtp(), _cch, &me._cchPreChars, &ptp, NULL);

        me._li._cch = me._cchPreChars;
        dx = -x;
    }

    if(pdx)
    {
        *pdx = (!fReverseFlow ? dx : -dx);
    }

Cleanup:
    if(cpStart != long(me.GetCp()))
    {
        me.SetCp(cpStart, NULL);
    }
    me.Advance(me._li._cch);

    if(me.CurrBranch()->GetCharFormat()->_fIsRubyText && pyHeightRubyBase)
    {
        RubyInfo* pRubyInfo = me._pLS->GetRubyInfoFromCp(me.GetCp());
        if(pRubyInfo) 
        {
            *pyHeightRubyBase = pRubyInfo->yHeightRubyBase;
        }
    }

    me._pLS->DiscardLine();

    return me._li._cch;
}
Exemplo n.º 9
0
void DrawCalendar()
{
 int i, j, k;
 char s[100];

	if (GetOrientation() == 0 || GetOrientation() == 3) {
		months_by_x = 3;
		months_by_y = 4;
		dx = cpar->dx_p;
		dy = cpar->dy_p;
		sx = cpar->sx_p;
		sy = cpar->sy_p;
		aw = cpar->aw;
		lh = cpar->lh;
	} else {
		months_by_x = 4;
		months_by_y = 3;
		dx = cpar->dx_l;
		dy = cpar->dy_l;
		sx = cpar->sx_l;
		sy = cpar->sy_l;
		aw = cpar->aw;
		lh = cpar->lh;
	}

 ClearScreen();
 //FillArea(0, 0, 600, 800, BLACK);
 //FillArea(10, 10, 580, 780, WHITE);
 SetFont(cal_title_font, BLACK);
 sprintf(s, "\x11    %d    \x12", year);
 DrawTextRect(0, 5, ScreenWidth(), 30, s, ALIGN_CENTER);
 HeaderWidth = StringWidth(s);
 SymbolWidth = CharWidth('A');

 for (i=0; i<months_by_y; i++)
 	for (j=0; j<months_by_x; j++)
 		{
		 int mn = i*months_by_x + j;
 		 SetFont(cal_month_font, BLACK);
 		 DrawTextRect(sx+dx*j, sy-(lh*3)/2+dy*i, dx, 1, GetLangText(MonthName[mn]), ALIGN_CENTER);
 		 SetFont(cal_day_font, BLACK);
 		 for (k=0; k<6; k++)
	 		DrawTextRect(sx+4+dx*j-(IsRTL() ? 10 : 0), sy+lh*k+dy*i, 50, 1, GetLangText(WeekName[k]), ALIGN_LEFT | RTLAUTO);
  		 SetFont(cal_day_font, DGRAY);
		 DrawTextRect(sx+4+dx*j-(IsRTL() ? 10 : 0), sy+lh*6+dy*i, 50, 1, GetLangText(WeekName[6]), ALIGN_LEFT | RTLAUTO);
	 	 for (k=1; k<43; k++)
	 	 	 if (calendar[mn][k]>0)
	 	 	 	{
	 	 		 if (k%7!=0) 
	 	 		 	SetFont(cal_date_font, BLACK);
	 	 		 	else
	 	 		 	SetFont(cal_date2_font, DGRAY);
 		 	 	 sprintf(s, "%d", calendar[mn][k]);
				 DrawTextRect(sx+(aw*8)/5+( (int) ((k-1)/7) )*aw+dx*j, sy+lh*((k-1)%7)+dy*i, aw, 1, s, ALIGN_CENTER);
				}
 		}
 if (year==CurDate->tm_year+1900)
 	{
 	 k=1;
 	 while (calendar[CurDate->tm_mon][k]!=CurDate->tm_mday) k++;
 	 InvertArea(sx+(aw*8)/5+1+( (int) ((k-1)/7) )*aw+dx*(CurDate->tm_mon%months_by_x), sy+lh*((k-1)%7)+dy*(CurDate->tm_mon/months_by_x), aw-2, lh-1);
 	 DrawRect(sx+(aw*8)/5+( (int) ((k-1)/7) )*aw+dx*(CurDate->tm_mon%months_by_x), sy+lh*((k-1)%7)+dy*(CurDate->tm_mon/months_by_x)+1, aw, lh-3, BLACK);
 	}
// SetFont(cour32, BLACK);
// sprintf(s, "%d %s %d", CurDate->tm_mday, GetLangText(MonthName[CurDate->tm_mon]), CurDate->tm_year+1900);
// DrawTextRect(50, 720, 500, 30, s, ALIGN_CENTER);
// DitherArea(0, 0, 600, 800, 4, 1);
 DrawPanel(NULL, CurrentDateStr(), NULL, -1);
 FullUpdate();
}
Exemplo n.º 10
0
LRESULT CResizableGrip::CSizeGrip::WindowProc(UINT message,
											  WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_GETDLGCODE:
		// fix to prevent the control to gain focus, using arrow keys
		// (standard grip returns DLGC_WANTARROWS, like any standard scrollbar)
		return DLGC_STATIC;

	case WM_SETFOCUS:
		// fix to prevent the control to gain focus, if set directly
		// (for example when it's the only one control in a dialog)
		return 0;

	case WM_NCHITTEST:
		// choose proper cursor shape
		if (IsRTL())
			return HTBOTTOMLEFT;
		else
			return HTBOTTOMRIGHT;
		break;

	case WM_SETTINGCHANGE:
		{
			// update grip's size
			CSize sizeOld = m_size;
			m_size.cx = GetSystemMetrics(SM_CXVSCROLL);
			m_size.cy = GetSystemMetrics(SM_CYHSCROLL);

			// resize transparency bitmaps
			if (m_bTransparent)
			{
				CClientDC dc(this);

				// destroy bitmaps
				m_bmGrip.DeleteObject();
				m_bmMask.DeleteObject();

				// re-create bitmaps
				m_bmGrip.CreateCompatibleBitmap(&dc, m_size.cx, m_size.cy);
				m_bmMask.CreateBitmap(m_size.cx, m_size.cy, 1, 1, NULL);
			}

			// re-calc shape
			if (m_bTriangular)
				SetTriangularShape(m_bTriangular);

			// reposition the grip
			CRect rect;
			GetWindowRect(rect);
			rect.InflateRect(m_size.cx - sizeOld.cx, m_size.cy - sizeOld.cy, 0, 0);
			::MapWindowPoints(NULL, GetParent()->GetSafeHwnd(), (LPPOINT)&rect, 2);
			MoveWindow(rect, TRUE);
		}
		break;

	case WM_DESTROY:
		// perform clean up
		if (m_bTransparent)
			SetTransparency(FALSE);
		break;

	case WM_PAINT:
	case WM_PRINTCLIENT:
		if (m_bTransparent)
		{
			PAINTSTRUCT ps;
			CDC* pDC = (message == WM_PAINT && wParam == 0) ?
				BeginPaint(&ps) : CDC::FromHandle((HDC)wParam);

			// select bitmaps
			CBitmap *pOldGrip, *pOldMask;

			pOldGrip = m_dcGrip.SelectObject(&m_bmGrip);
			pOldMask = m_dcMask.SelectObject(&m_bmMask);

			// obtain original grip bitmap, make the mask and prepare masked bitmap
			CScrollBar::WindowProc(message, (WPARAM)m_dcGrip.GetSafeHdc(), lParam);
			m_dcGrip.SetBkColor(m_dcGrip.GetPixel(0, 0));
			m_dcMask.BitBlt(0, 0, m_size.cx, m_size.cy, &m_dcGrip, 0, 0, SRCCOPY);
			m_dcGrip.BitBlt(0, 0, m_size.cx, m_size.cy, &m_dcMask, 0, 0, 0x00220326);
			
			// draw transparently
			pDC->BitBlt(0, 0, m_size.cx, m_size.cy, &m_dcMask, 0, 0, SRCAND);
			pDC->BitBlt(0, 0, m_size.cx, m_size.cy, &m_dcGrip, 0, 0, SRCPAINT);

			// unselect bitmaps
			m_dcGrip.SelectObject(pOldGrip);
			m_dcMask.SelectObject(pOldMask);

			if (message == WM_PAINT && wParam == 0)
				EndPaint(&ps);
			return 0;
		}
		break;
	}

	return CScrollBar::WindowProc(message, wParam, lParam);
}