void CCameraHandler::UpdateController(CPlayer* player, bool fpsMode, bool fsEdgeMove, bool wnEdgeMove) { CCameraController& camCon = GetCurrentController(); FPSUnitController& fpsCon = player->fpsController; const bool fusEdgeMove = ( globalRendering->fullScreen && fsEdgeMove); const bool winEdgeMove = (!globalRendering->fullScreen && wnEdgeMove); // We have to update transition both before and after updating the controller: // before: if the controller makes a new begincam, it needs to take into account previous transitions // after: apply changes made by the controller with 0 time transition. UpdateTransition(); if (fpsCon.oldDCpos != ZeroVector) { camCon.SetPos(fpsCon.oldDCpos); fpsCon.oldDCpos = ZeroVector; } if (!fpsMode) UpdateController(camCon, true, true, fusEdgeMove || winEdgeMove); camCon.Update(); UpdateTransition(); }
GuiControl::GuiControl(IStyleController* _styleController) :styleController(_styleController) ,boundsComposition(_styleController->GetBoundsComposition()) ,focusableComposition(0) ,eventReceiver(_styleController->GetBoundsComposition()->GetEventReceiver()) ,isEnabled(true) ,isVisuallyEnabled(true) ,isVisible(true) ,activatingAltHost(0) ,parent(0) ,tooltipControl(0) ,tooltipWidth(50) { boundsComposition->SetAssociatedControl(this); VisibleChanged.SetAssociatedComposition(boundsComposition); EnabledChanged.SetAssociatedComposition(boundsComposition); VisuallyEnabledChanged.SetAssociatedComposition(boundsComposition); AltChanged.SetAssociatedComposition(boundsComposition); TextChanged.SetAssociatedComposition(boundsComposition); FontChanged.SetAssociatedComposition(boundsComposition); font=GetCurrentController()->ResourceService()->GetDefaultFont(); styleController->SetFont(font); styleController->SetText(text); styleController->SetVisuallyEnabled(isVisuallyEnabled); sharedPtrDestructorProc = &GuiControl::SharedPtrDestructorProc; }
GuiTableSplitterCompositionBase::GuiTableSplitterCompositionBase() :tableParent(0) , dragging(false) { SetAssociatedCursor(GetCurrentController()->ResourceService()->GetSystemCursor(INativeCursor::SizeNS)); GetEventReceiver()->leftButtonDown.AttachMethod(this, &GuiTableSplitterCompositionBase::OnLeftButtonDown); GetEventReceiver()->leftButtonUp.AttachMethod(this, &GuiTableSplitterCompositionBase::OnLeftButtonUp); }
void GuiDocumentCommonInterface::OnMouseMove(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments) { if(documentControl->GetVisuallyEnabled()) { switch(editMode) { case ViewOnly: { Point point(arguments.x, arguments.y); Ptr<DocumentHyperlinkRun> hyperlink=documentElement->GetHyperlinkFromPoint(point); vint hyperlinkParagraph=hyperlink?documentElement->CalculateCaretFromPoint(point).row:-1; if(dragging) { if(activeHyperlink) { ActivateActiveHyperlink(activeHyperlink==hyperlink); } } else { SetActiveHyperlink(hyperlink, hyperlinkParagraph); } if(activeHyperlink && activeHyperlink==hyperlink) { INativeCursor* cursor=GetCurrentController()->ResourceService()->GetSystemCursor(INativeCursor::Hand); documentComposition->SetAssociatedCursor(cursor); } else { documentComposition->SetAssociatedCursor(0); } } break; case Selectable: case Editable: if(dragging) { TextPos caret=documentElement->CalculateCaretFromPoint(Point(arguments.x, arguments.y)); TextPos oldCaret=documentElement->GetCaretBegin(); Move(caret, true, (oldCaret==caret?documentElement->IsCaretEndPreferFrontSide():caret<oldCaret)); } break; } } }
Ptr<ShortcutBuilder> ParseInternal(const WString& text, collections::List<Ptr<ParsingError>>& errors)override { Ptr<RegexMatch> match=regexShortcut.MatchHead(text); if (match && match->Result().Length() != text.Length()) { errors.Add(new ParsingError(L"Failed to parse a shortcut \"" + text + L"\".")); return 0; } Ptr<ShortcutBuilder> builder = new ShortcutBuilder; builder->text = text; builder->ctrl = match->Groups().Contains(L"ctrl"); builder->shift = match->Groups().Contains(L"shift"); builder->alt = match->Groups().Contains(L"alt"); WString name = match->Groups()[L"key"][0].Value(); builder->key = GetCurrentController()->InputService()->GetKey(name); return builder->key == VKEY::_UNKNOWN ? nullptr : builder; }
INativeCursor* INativeCursor_Constructor2(INativeCursor::SystemCursorType type) { return GetCurrentController()->ResourceService()->GetSystemCursor(type); }
INativeCursor* INativeCursor_Constructor1() { return GetCurrentController()->ResourceService()->GetDefaultSystemCursor(); }
Ptr<INativeImage> INativeImage_Constructor(const WString& path) { return GetCurrentController()->ImageService()->CreateImageFromFile(path); }
CustomTemplateWindowStyle() :window(0) { Color borderColor(0, 122, 204); Color titleBackgroundColor(45, 45, 48); Color backgroundColor(30, 30, 30); Color titleColor(153, 153, 153); boundsComposition=new GuiTableComposition; boundsComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); boundsComposition->SetRowsAndColumns(4, 7); boundsComposition->SetRowOption(0, GuiCellOption::AbsoluteOption(5)); boundsComposition->SetRowOption(1, GuiCellOption::MinSizeOption()); boundsComposition->SetRowOption(2, GuiCellOption::PercentageOption(1.0)); boundsComposition->SetRowOption(3, GuiCellOption::AbsoluteOption(5)); boundsComposition->SetColumnOption(0, GuiCellOption::AbsoluteOption(5)); boundsComposition->SetColumnOption(1, GuiCellOption::MinSizeOption()); boundsComposition->SetColumnOption(2, GuiCellOption::PercentageOption(1.0)); boundsComposition->SetColumnOption(3, GuiCellOption::MinSizeOption()); boundsComposition->SetColumnOption(4, GuiCellOption::MinSizeOption()); boundsComposition->SetColumnOption(5, GuiCellOption::MinSizeOption()); boundsComposition->SetColumnOption(6, GuiCellOption::AbsoluteOption(5)); { GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); element->SetColor(borderColor); boundsComposition->SetOwnedElement(element); } AddBorderCell(0, 0, 1, 1, INativeWindowListener::BorderLeftTop); AddBorderCell(0, 6, 1, 1, INativeWindowListener::BorderRightTop); AddBorderCell(3, 0, 1, 1, INativeWindowListener::BorderLeftBottom); AddBorderCell(3, 6, 1, 1, INativeWindowListener::BorderRightBottom); AddBorderCell(1, 0, 2, 1, INativeWindowListener::BorderLeft); AddBorderCell(1, 6, 2, 1, INativeWindowListener::BorderRight); AddBorderCell(0, 1, 1, 5, INativeWindowListener::BorderTop); AddBorderCell(3, 1, 1, 5, INativeWindowListener::BorderBottom); { { iconComposition=AddTitleCell(1, INativeWindowListener::Icon, titleBackgroundColor); iconComposition->SetAlignmentToParent(Margin(3, 3, 3, 3)); Ptr<INativeImage> icon=GetCurrentController()->ImageService()->CreateImageFromFile(GetApplication()->GetExecutableFolder()+L"..\\Resources\\BigDoc.png"); iconElement=GuiImageFrameElement::Create(); iconElement->SetImage(icon, 0); iconElement->SetStretch(true); iconComposition->SetOwnedElement(iconElement); } { titleComposition=AddTitleCell(2, INativeWindowListener::Title, titleBackgroundColor); titleComposition->SetAlignmentToParent(Margin(0, 3, 3, 3)); titleElement=GuiSolidLabelElement::Create(); titleElement->SetColor(titleColor); titleElement->SetAlignments(Alignment::Left, Alignment::Center); titleComposition->SetOwnedElement(titleElement); } { minimumButton=AddTitleButton(3, titleBackgroundColor, titleColor); minimumButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 3, 3, 3)); minimumButton->Clicked.AttachMethod(this, &CustomTemplateWindowStyle::minimumButton_Clicked); } { maximumButton=AddTitleButton(4, titleBackgroundColor, titleColor); maximumButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 3, 3, 3)); maximumButton->Clicked.AttachMethod(this, &CustomTemplateWindowStyle::maximumButton_Clicked); } { closeButton=AddTitleButton(5, titleBackgroundColor, titleColor); closeButton->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 3, 3, 3)); closeButton->Clicked.AttachMethod(this, &CustomTemplateWindowStyle::closeButton_Clicked); } } { GuiCellComposition* cell=new GuiCellComposition; boundsComposition->AddChild(cell); cell->SetSite(2, 1, 1, 5); cell->SetAssociatedHitTestResult(INativeWindowListener::Client); containerComposition=new GuiBoundsComposition; containerComposition->SetAlignmentToParent(Margin(0, 0, 0, 0)); cell->AddChild(containerComposition); GuiSolidBackgroundElement* element=GuiSolidBackgroundElement::Create(); element->SetColor(backgroundColor); containerComposition->SetOwnedElement(element); } }
GuiColumnSplitterComposition::GuiColumnSplitterComposition() :columnsToTheLeft(0) { SetAssociatedCursor(GetCurrentController()->ResourceService()->GetSystemCursor(INativeCursor::SizeWE)); GetEventReceiver()->mouseMove.AttachMethod(this, &GuiColumnSplitterComposition::OnMouseMove); }
void comboSelector_SelectedIndexChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments) { comboSelector->SetEnabled(false); this->GetBoundsComposition()->SetAssociatedCursor(GetCurrentController()->ResourceService()->GetSystemCursor(INativeCursor::LargeWaiting)); GetApplication()->InvokeAsync(Curry<void(TextBoxColorizerWindow*)>([](TextBoxColorizerWindow* window) { Ptr<GuiTextBoxColorizerBase> colorizer; WString text; switch(window->comboSelector->GetSelectedIndex()) { case 0: text= L";This is a comment\r\n" L"[Section1]\r\n" L"Name=John Smith\r\n" L"ID=008\r\n" L"\r\n" L"[Section2]\r\n" L"Name=Kyon\r\n" L"ID=009\r\n" ; break; case 1: text= L"<books>\r\n" L"\t<!--Comment-->\r\n" L"\t<book name=\"C++Primer\">\r\n" L"\t\tContent\r\n" L"\t</book>\r\n" L"\t<![CDATA[<xml/>]]>\r\n" L"</books>\r\n" ; break; case 2: text= L"#include <iostream>\r\n" L"using namespace std;\r\n" L"\r\n" L"int main()\r\n" L"{\r\n" L"\t//This is a comment\r\n" L"\t/**This*is/another\r\n" L"\tcomment**/\r\n" L"\tcout<<\"Hello, world!\"<<endl;\r\n" L"\treturn 0;\r\n" L"}\r\n" ; break; } GetApplication()->InvokeInMainThreadAndWait([text, window]() { window->textBox->SetColorizer(0); window->textBox->SetText(text); }); switch(window->comboSelector->GetSelectedIndex()) { case 0: colorizer=new IniColorizer; break; case 1: colorizer=new XmlColorizer; break; case 2: colorizer=new CppColorizer; break; } GetApplication()->InvokeInMainThreadAndWait([colorizer, window]() { window->textBox->SetColorizer(colorizer); window->GetBoundsComposition()->SetAssociatedCursor(GetCurrentController()->ResourceService()->GetDefaultSystemCursor()); window->comboSelector->SetEnabled(true); }); })(this)); }
Ptr<text::DocumentModel> BuildDocumentModel(const WString& fileName, List<Ptr<GifRun>>& animations) { HDC dc=CreateCompatibleDC(NULL); int dpi=GetDeviceCaps(dc, LOGPIXELSY); DeleteDC(dc); Ptr<text::DocumentModel> document=new text::DocumentModel; WString rawDocument; { FileStream fileStream(fileName, FileStream::ReadOnly); BomDecoder decoder; DecoderStream decoderStream(fileStream, decoder); StreamReader reader(decoderStream); rawDocument=reader.ReadToEnd(); } WString regexTag_s=L"<(<tag>s)>(<font>[^:]+):(<bold>[^:]+):(<color>[^:]+):(<size>[^:]+):(<text>/.*?)<//s>"; WString regexTag_i=L"<(<tag>i)>(<cx>[^:]+),(<cy>[^:]+):(<b>[^:]+):(<file>/.*?)<//i>"; WString regexTag_p=L"<(<tag>p)//>"; Regex regexTag(regexTag_s+L"|"+regexTag_i+L"|"+regexTag_p); Regex regexLine(L"\r\n"); RegexMatch::List matches; regexTag.Search(rawDocument, matches); Ptr<text::DocumentParagraph> paragraph=0; Ptr<text::DocumentLine> line=0; for(int i=0;i<matches.Count();i++) { Ptr<RegexMatch> match=matches[i]; if(match->Groups()[L"tag"].Get(0).Value()==L"p") { paragraph=0; line=0; } else if(match->Groups()[L"tag"].Get(0).Value()==L"i") { int cx=wtoi(match->Groups()[L"cx"].Get(0).Value()); int cy=wtoi(match->Groups()[L"cy"].Get(0).Value()); int b=wtoi(match->Groups()[L"b"].Get(0).Value()); WString file=match->Groups()[L"file"].Get(0).Value(); if(!paragraph) { paragraph=new text::DocumentParagraph; document->paragraphs.Add(paragraph); line=0; } if(!line) { line=new text::DocumentLine; paragraph->lines.Add(line); } Ptr<text::DocumentImageRun> run=new text::DocumentImageRun; run->size=Size(cx, cy); run->baseline=b; run->image=GetCurrentController()->ImageService()->CreateImageFromFile(L"..\\Resources\\"+file); run->frameIndex=0; line->runs.Add(run); if(run->image->GetFrameCount()>1) { Ptr<GifRun> gifRun=new GifRun; gifRun->imageRun=run; gifRun->paragraphIndex=document->paragraphs.Count()-1; animations.Add(gifRun); } } else if(match->Groups()[L"tag"].Get(0).Value()==L"s") { FontProperties fontStyle; Color fontColor; RegexMatch::List lines; { WString font=match->Groups()[L"font"].Get(0).Value(); WString bold=match->Groups()[L"bold"].Get(0).Value(); WString color=match->Groups()[L"color"].Get(0).Value(); WString size=match->Groups()[L"size"].Get(0).Value(); WString text=match->Groups()[L"text"].Get(0).Value(); fontStyle.fontFamily=font; fontStyle.bold=bold==L"true"; fontStyle.size=(int)(wtof(size)*dpi/72); fontColor=ConvertColor(color); regexLine.Split(text, true, lines); } for(int j=0;j<lines.Count();j++) { WString lineText=lines[j]->Result().Value(); if(!paragraph) { paragraph=new text::DocumentParagraph; document->paragraphs.Add(paragraph); line=0; } if(!line || j>0) { line=new text::DocumentLine; paragraph->lines.Add(line); } Ptr<text::DocumentTextRun> run=new text::DocumentTextRun; run->style=fontStyle; run->color=fontColor; run->text=lineText; line->runs.Add(run); } } } return document; }
void SetImage(GuiToolstripCommand* command, const WString& imagePath) { command->SetImage(new GuiImageData(GetCurrentController()->ImageService()->CreateImageFromFile(imagePath), 0)); }