void PrintText(Vec2& screenSize, Vec2& pos, const char* text, Vec4& colour) { if (!textInitialised) { glGetError(); glGetError(); SetupText(); } glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, fontTex); int numChars = strlen(text); int numInts = (numChars / 4) + 1; if (numInts > 256) numChars = 1024; memcpy(uniformArray, text, numChars); textDraw->Use(); textDraw->Uniforms["textLength"].SetValue(numChars); textDraw->Uniforms["text[0]"].SetArrayValue(uniformArray, numInts); //NVidia textDraw->Uniforms["text"].SetArrayValue(uniformArray, numInts); //ATI FFUUUUUU textDraw->Uniforms["basePosition"].SetValue(pos); textDraw->Uniforms["colour"].SetValue(colour); textDraw->Uniforms["screenSize"].SetValue(screenSize); textDraw->Uniforms["fontTexture"].SetValue(0); textDraw->Uniforms["baseTex"].SetValue(0); QuadDrawer::DrawQuads(numChars); //QuadDrawer::DrawQuad(Vec2(-1.0, -1.0), Vec2(1.0, 1.0), Vec2(1 / 800.0f, 1 / 600.0f)); }
void CTooltip::Draw() { float z = 900.f; // TODO: Find a nicer way of putting the tooltip on top of everything else if (GetGUI()) { CGUISpriteInstance *sprite; GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite); // Normally IGUITextOwner will handle this updating but since SetupText can modify the position // we need to call it now *before* we do the rest of the drawing if (!m_GeneratedTextsValid) { SetupText(); m_GeneratedTextsValid = true; } GetGUI()->DrawSprite(*sprite, 0, z, m_CachedActualSize); CColor color; GUI<CColor>::GetSetting(this, "textcolor", color); // Draw text IGUITextOwner::Draw(0, color, m_CachedActualSize.TopLeft(), z+0.1f); } }
BOOL DlgWaitDB::OnInitDialog() { CDialog::OnInitDialog(); g_ending = false; SetupText(); SetTimer(1, 20, NULL); return TRUE; }
void D3DProxyDevice::Init(ProxyHelper::ProxyConfig& cfg) { OutputDebugString("D3D ProxyDev Init"); stereoView = StereoViewFactory::Get(cfg); SetupMatrices(cfg); SetupOptions(cfg); SetupText(); }
HRESULT CLR_RT_XmlState_InValue::ProcessOthersWhitespace( CLR_RT_XmlState* st, CLR_UINT8*& buffer, bool& isDone ) { TINYCLR_HEADER(); _ASSERTE(isDone == true); if(st->State.docState != XmlDocState_MainDocument) { TINYCLR_SET_AND_LEAVE(XML_E_INVALID_ROOT_DATA); } SetupText( st, buffer, true ); TINYCLR_NOCLEANUP(); }
void DlgWaitDB::OnBnClickedButtonChange() { bool changes = false; CString client_ip = DB_connection_info.m_server_ip; CString conv_ip = CONV_connection_info.m_server_ip; CString serv_ip = SERV_connection_info.m_server_ip; WORD client_port = DB_connection_info.m_server_port; WORD conv_port = CONV_connection_info.m_server_port; WORD serv_port = SERV_connection_info.m_server_port; CString name_db = DB_connection_info.m_db_name; CString serv_db = DB_connection_info.m_db_server; CString login = DB_connection_info.m_login; CString password = DB_connection_info.m_password; if (g_dlg_net.DoModal() == IDOK) changes = true; if (!g_ending) { if (g_dlg_db.DoModal() == IDOK) changes = true; } if (g_ending) { DB_connection_info.m_server_ip = client_ip; CONV_connection_info.m_server_ip = conv_ip; SERV_connection_info.m_server_ip = serv_ip; DB_connection_info.m_server_port = client_port; CONV_connection_info.m_server_port = conv_port; SERV_connection_info.m_server_port = serv_port; DB_connection_info.m_db_name = name_db; DB_connection_info.m_db_server = serv_db; DB_connection_info.m_login = login; DB_connection_info.m_password = password; return; } if (changes) { SERV_ShutDownConnection(true); SERV_InitConnection(); CONV_ShutDownConnection(true); CONV_InitConnection(); DB_ShutDownConnection(true); DB_InitConnection(); SetupText(); } }
void CList::AddItem(const CStrW& str, const CStrW& data) { CGUIList *pList, *pListData; GUI<CGUIList>::GetSettingPointer(this, "list", pList); GUI<CGUIList>::GetSettingPointer(this, "list_data", pListData); CGUIString gui_string; gui_string.SetValue(str); pList->m_Items.push_back( gui_string ); CGUIString data_string; data_string.SetValue(data); pListData->m_Items.push_back( data_string ); // TODO Temp SetupText(); }
bool HUD::Init( const std::string & texturepath, ContentManager & content, FONT & lcdfont, FONT & sansfont, FONT & sansfont_noshader, float displaywidth, float displayheight, bool debugon, std::ostream & error_output) { const float opacity = 0.8; const float screenhwratio = displayheight / displaywidth; const float barheight = 64.0 / displayheight; const float barwidth = 256.0 / displaywidth; TEXTUREINFO texinfo; texinfo.mipmap = false; texinfo.repeatu = false; texinfo.repeatv = false; float timerbox_lowery = 0; { timernode = hudroot.AddNode(); SCENENODE & timernoderef = hudroot.GetNode(timernode); float timerboxdimx = 96.0 / displaywidth; float timerboxdimy = 64.0 / displayheight; timerboxdraw = AddDrawable(timernoderef); DRAWABLE & timerboxdrawref = GetDrawable(timernoderef, timerboxdraw); TEXTUREINFO timerboxtexinfo; timerboxtexinfo.mipmap = false; timerboxtexinfo.repeatu = true; timerboxtexinfo.repeatv = false; std::tr1::shared_ptr<TEXTURE> timerboxtex; if (!content.load(texturepath, "timerbox.png", timerboxtexinfo, timerboxtex)) return false; float totalsizex = timerboxdimx * 6.05; float totalsizey = timerboxdimy * 2.0; float x = totalsizex * 0.5 - timerboxdimx * 0.65; float y = totalsizey * 0.5 - timerboxdimy * 0.25; float w = totalsizex - timerboxdimx * 2; float h = totalsizey - timerboxdimy * 2; timerboxverts.SetTo2DBox(x, y, w, h, timerboxdimx, timerboxdimy); timerbox_lowery = y + timerboxdimy * 0.5; timerboxdrawref.SetDiffuseMap(timerboxtex); timerboxdrawref.SetVertArray(&timerboxverts); timerboxdrawref.SetCull(false, false); timerboxdrawref.SetColor(1, 1, 1, opacity); timerboxdrawref.SetDrawOrder(0.1); float fontscaley = timerboxdimy * 0.4; float fontscalex = fontscaley * screenhwratio; float startx = timerboxdimx * 0.45 - timerboxdimx * 0.15; float xinc = timerboxdimx * 1.5; laptime_label.Init(timernoderef, sansfont, "Lap time:", startx, timerboxdimy*0.9-timerboxdimy*0.3, fontscalex, fontscaley); laptime_label.SetDrawOrder(timernoderef, 0.2); lastlaptime_label.Init(timernoderef, sansfont, "Last lap:", startx+xinc, timerboxdimy*.9-timerboxdimy*0.3, fontscalex, fontscaley); lastlaptime_label.SetDrawOrder(timernoderef, 0.2); bestlaptime_label.Init(timernoderef, sansfont, "Best lap:", startx+xinc*2.0, timerboxdimy*.9-timerboxdimy*0.3, fontscalex, fontscaley); bestlaptime_label.SetDrawOrder(timernoderef, 0.2); laptime.Init(timernoderef, lcdfont, "", startx, timerboxdimy*1.2-timerboxdimy*0.3, fontscalex, fontscaley); laptime.SetDrawOrder(timernoderef, 0.2); lastlaptime.Init(timernoderef, lcdfont, "", startx+xinc, timerboxdimy*1.2-timerboxdimy*0.3, fontscalex, fontscaley); lastlaptime.SetDrawOrder(timernoderef, 0.2); bestlaptime.Init(timernoderef, lcdfont, "", startx+xinc*2.0, timerboxdimy*1.2-timerboxdimy*0.3, fontscalex, fontscaley); bestlaptime.SetDrawOrder(timernoderef, 0.2); } { float fontscaley = barheight * 0.5; float fontscalex = screenhwratio * fontscaley; float x = fontscalex * 0.25; float y = timerbox_lowery + fontscaley; driftscoreindicator.Init(hudroot, sansfont, "", x, y, fontscalex, fontscaley); driftscoreindicator.SetDrawOrder(hudroot, 0.2); } { float fontscaley = barheight * 0.5; float fontscalex = screenhwratio * fontscaley; float x = fontscalex * 0.25; float y = timerbox_lowery + fontscaley * 2; lapindicator.Init(hudroot, sansfont, "", x, y, fontscalex, fontscaley); lapindicator.SetDrawOrder(hudroot, 0.2); } { float fontscaley = barheight * 0.5; float fontscalex = screenhwratio * fontscaley; float x = fontscalex * 0.25; float y = timerbox_lowery + fontscaley * 3; placeindicator.Init(hudroot, sansfont, "", x, y, fontscalex, fontscaley); placeindicator.SetDrawOrder(hudroot, 0.2); } { float fontscaley = barheight * 0.5; float fontscalex = screenhwratio * fontscaley; float x = 0.5; float y = 0.5; raceprompt.Init(hudroot, sansfont, "", x, y, fontscalex, fontscaley); raceprompt.SetDrawOrder(hudroot, 1.0); raceprompt.SetColor(hudroot, 1, 0, 0); } { float fontscaley = 0.02; float fontscalex = screenhwratio * fontscaley; debugnode = hudroot.AddNode(); SCENENODE & debugnoderef = hudroot.GetNode(debugnode); debugtextdraw1 = SetupText(debugnoderef, sansfont, debugtext1, "", 0.01, fontscaley, fontscalex, fontscaley, 1, 1, 1, 10); debugtextdraw2 = SetupText(debugnoderef, sansfont, debugtext2, "", 0.25, fontscaley, fontscalex, fontscaley, 1, 1, 1, 10); debugtextdraw3 = SetupText(debugnoderef, sansfont, debugtext3, "", 0.5, fontscaley, fontscalex, fontscaley, 1, 1, 1, 10); debugtextdraw4 = SetupText(debugnoderef, sansfont, debugtext4, "", 0.75, fontscaley, fontscalex, fontscaley, 1, 1, 1, 10); } #ifndef GAUGES std::tr1::shared_ptr<TEXTURE> bartex, progbartex; if (!content.load(texturepath, "hudbox.png", texinfo, bartex)) return false; if (!content.load(texturepath, "progressbar.png", texinfo, progbartex)) return false; rpmbar = AddDrawable(hudroot); rpmredbar = AddDrawable(hudroot); rpmbox = AddDrawable(hudroot); DRAWABLE & rpmboxref = GetDrawable(hudroot, rpmbox); rpmboxref.SetDiffuseMap(progbartex); rpmboxref.SetVertArray(&rpmboxverts); rpmboxref.SetDrawOrder(2); rpmboxref.SetCull(false, false); rpmboxref.SetColor(0.3, 0.3, 0.3, 0.4); DRAWABLE & rpmbarref = GetDrawable(hudroot, rpmbar); rpmbarref.SetDiffuseMap(progbartex); rpmbarref.SetVertArray(&rpmbarverts); rpmbarref.SetDrawOrder(3); rpmbarref.SetCull(false, false); rpmbarref.SetColor(1.0, 1.0, 1.0, 0.7); DRAWABLE & rpmredbarref = GetDrawable(hudroot, rpmredbar); rpmredbarref.SetDiffuseMap(progbartex); rpmredbarref.SetVertArray(&rpmredbarverts); rpmredbarref.SetColor(1.0, 0.2, 0.2, 0.7); rpmredbarref.SetDrawOrder(3); rpmredbarref.SetCull(false, false); //lower left bar bars.push_back(HUDBAR()); bars.back().Set(hudroot, bartex, 0.0 + barwidth * 0.5, 1.0-barheight*0.5, barwidth, barheight, opacity, false); //lower right bar bars.push_back(HUDBAR()); bars.back().Set(hudroot, bartex, 1.0 - barwidth * 0.175, 1.0-barheight*0.5, barwidth, barheight, opacity, false); { float fontscaley = barheight * 0.5; float fontscalex = screenhwratio * fontscaley; float y = 1.0 - fontscaley * 0.5; float x0 = screenhwratio * 0.02; float x1 = 1.0 - screenhwratio * 0.02; geartextdraw = SetupText(hudroot, lcdfont, geartext, "N", x0, y, fontscalex, fontscaley, 1, 1, 1, 4); mphtextdraw = SetupText(hudroot, lcdfont, mphtext, "0", x1, y, fontscalex, fontscaley, 1, 1, 1, 4); } { float fontscaley = barheight * 0.25; float fontscalex = screenhwratio * fontscaley; float x0 = 1 - barwidth * 0.6; float x1 = 1 - barwidth * 0.7; float y0 = 1 - fontscaley * 1.25; float y1 = 1 - fontscaley * 0.5; abs.Init(hudroot, sansfont, "ABS", x0, y0, fontscalex, fontscaley); abs.SetDrawOrder(hudroot, 4); abs.SetColor(hudroot, 0, 1, 0); tcs.Init(hudroot, sansfont, "TCS", x0, y1, fontscalex, fontscaley); tcs.SetDrawOrder(hudroot, 4); tcs.SetColor(hudroot, 1, 0.77, 0.23); gas.Init(hudroot, sansfont, "GAS", x1, y0, fontscalex, fontscaley); gas.SetDrawOrder(hudroot, 4); gas.SetColor(hudroot, 1, 0, 0); nos.Init(hudroot, sansfont, "NOS", x1, y1, fontscalex, fontscaley); nos.SetDrawOrder(hudroot, 4); nos.SetColor(hudroot, 0, 1, 0); } #else { FONT & gaugefont = sansfont_noshader; // gauge texture char white[] = {255, 255, 255, 255}; TEXTUREINFO tinfo; tinfo.data = white; tinfo.width = 1; tinfo.height = 1; tinfo.bytespp = 4; tinfo.mipmap = false; std::tr1::shared_ptr<TEXTURE> texture; content.load("", "white1x1", tinfo, texture); float r = 0.12; float x0 = 0.15; float x1 = 0.85; float y0 = 0.85; float h0 = r * 0.25; float w0 = screenhwratio * h0; float angle_min = 315.0 / 180.0 * M_PI; float angle_max = 45.0 / 180.0 * M_PI; rpmgauge.Set(hudroot, texture, gaugefont, screenhwratio, x0, y0, r, angle_min, angle_max, 0, maxrpm * 0.001, 1); speedgauge.Set(hudroot, texture, gaugefont, screenhwratio, x1, y0, r, angle_min, angle_max, 0, maxspeed * speedscale, 10); float w = w0; float h = h0; float x = x0 - gaugefont.GetWidth("rpm") * w * 0.5; float y = y0 - r * 0.5; DRAWABLE & rpmd = GetDrawable(hudroot, AddDrawable(hudroot)); rpmlabel.Set(rpmd, gaugefont, "rpm", x, y, w, h, 1, 1, 1); w = w0 * 0.65; h = h0 * 0.65; x = x0 - gaugefont.GetWidth("x1000") * w * 0.5; y = y0 - r * 0.5 + h; DRAWABLE & x1000d = GetDrawable(hudroot, AddDrawable(hudroot)); rpmxlabel.Set(x1000d, gaugefont, "x1000", x, y, w, h, 1, 1, 1); w = w0; h = h0; x = x1 - gaugefont.GetWidth("kph") * w * 0.5; y = y0 - r * 0.5; DRAWABLE & spdd = GetDrawable(hudroot, AddDrawable(hudroot)); speedlabel.Set(spdd, gaugefont, "kph", x, y, w, h, 1, 1, 1); w = w0 * 2; h = h0 * 2; x = x0 - w * 0.25; y = y0 + r * 0.64; geartextdraw = SetupText(hudroot, gaugefont, geartext, "N", x, y, w, h, 1, 1, 1); w = w0 * 1.5; h = h0 * 1.5; x = x1 - w * 0.3; y = y0 + r * 0.68; mphtextdraw = SetupText(hudroot, gaugefont, mphtext, "0", x, y, w, h, 1, 1, 1); } { float fontscaley = barheight * 0.25; float fontscalex = screenhwratio * fontscaley; float x0 = 1 - barwidth * 0.6; float x1 = 1 - barwidth * 0.7; float y0 = 1 - fontscaley * 1.25; float y1 = 1 - fontscaley * 0.5; abs.Init(hudroot, sansfont, "ABS", x0, y0, fontscalex, fontscaley); abs.SetDrawOrder(hudroot, 4); abs.SetColor(hudroot, 0, 1, 0); tcs.Init(hudroot, sansfont, "TCS", x0, y1, fontscalex, fontscaley); tcs.SetDrawOrder(hudroot, 4); tcs.SetColor(hudroot, 1, 0.77, 0.23); gas.Init(hudroot, sansfont, "GAS", x1, y0, fontscalex, fontscaley); gas.SetDrawOrder(hudroot, 4); gas.SetColor(hudroot, 1, 0, 0); nos.Init(hudroot, sansfont, "NOS", x1, y1, fontscalex, fontscaley); nos.SetDrawOrder(hudroot, 4); nos.SetColor(hudroot, 0, 1, 0); } #endif SetVisible(false); debug_hud_info = debugon; return true; }
void CDropDown::HandleMessage(SGUIMessage& Message) { // Important switch (Message.type) { case GUIM_SETTINGS_UPDATED: { // Update cached list rect if (Message.value == "size" || Message.value == "absolute" || Message.value == "dropdown_size" || Message.value == "dropdown_buffer" || Message.value == "scrollbar_style" || Message.value == "button_width") { SetupListRect(); } break; } case GUIM_MOUSE_MOTION: { if (!m_Open) break; CPos mouse = GetMousePos(); if (!GetListRect().PointInside(mouse)) break; bool scrollbar; CGUIList* pList; GUI<bool>::GetSetting(this, "scrollbar", scrollbar); GUI<CGUIList>::GetSettingPointer(this, "list", pList); float scroll = 0.f; if (scrollbar) scroll = GetScrollBar(0).GetPos(); CRect rect = GetListRect(); mouse.y += scroll; int set = -1; for (int i = 0; i < (int)pList->m_Items.size(); ++i) { if (mouse.y >= rect.top + m_ItemsYPositions[i] && mouse.y < rect.top + m_ItemsYPositions[i+1] && // mouse is not over scroll-bar !(mouse.x >= GetScrollBar(0).GetOuterRect().left && mouse.x <= GetScrollBar(0).GetOuterRect().right)) { set = i; } } if (set != -1) { m_ElementHighlight = set; //UpdateAutoScroll(); } break; } case GUIM_MOUSE_ENTER: { bool enabled; GUI<bool>::GetSetting(this, "enabled", enabled); if (!enabled) break; CStrW soundPath; if (g_SoundManager && GUI<CStrW>::GetSetting(this, "sound_enter", soundPath) == PSRETURN_OK && !soundPath.empty()) g_SoundManager->PlayAsUI(soundPath.c_str(), false); break; } case GUIM_MOUSE_LEAVE: { GUI<int>::GetSetting(this, "selected", m_ElementHighlight); bool enabled; GUI<bool>::GetSetting(this, "enabled", enabled); if (!enabled) break; CStrW soundPath; if (g_SoundManager && GUI<CStrW>::GetSetting(this, "sound_leave", soundPath) == PSRETURN_OK && !soundPath.empty()) g_SoundManager->PlayAsUI(soundPath.c_str(), false); break; } // We can't inherent this routine from CList, because we need to include // a mouse click to open the dropdown, also the coordinates are changed. case GUIM_MOUSE_PRESS_LEFT: { bool enabled; GUI<bool>::GetSetting(this, "enabled", enabled); if (!enabled) { CStrW soundPath; if (g_SoundManager && GUI<CStrW>::GetSetting(this, "sound_disabled", soundPath) == PSRETURN_OK && !soundPath.empty()) g_SoundManager->PlayAsUI(soundPath.c_str(), false); break; } if (!m_Open) { CGUIList* pList; GUI<CGUIList>::GetSettingPointer(this, "list", pList); if (pList->m_Items.empty()) return; m_Open = true; GetScrollBar(0).SetZ(GetBufferedZ()); GUI<int>::GetSetting(this, "selected", m_ElementHighlight); // Start at the position of the selected item, if possible. GetScrollBar(0).SetPos(m_ItemsYPositions.empty() ? 0 : m_ItemsYPositions[m_ElementHighlight] - 60); CStrW soundPath; if (g_SoundManager && GUI<CStrW>::GetSetting(this, "sound_opened", soundPath) == PSRETURN_OK && !soundPath.empty()) g_SoundManager->PlayAsUI(soundPath.c_str(), false); return; // overshadow } else { CPos mouse = GetMousePos(); // If the regular area is pressed, then abort, and close. if (m_CachedActualSize.PointInside(mouse)) { m_Open = false; GetScrollBar(0).SetZ(GetBufferedZ()); CStrW soundPath; if (g_SoundManager && GUI<CStrW>::GetSetting(this, "sound_closed", soundPath) == PSRETURN_OK && !soundPath.empty()) g_SoundManager->PlayAsUI(soundPath.c_str(), false); return; // overshadow } if (!(mouse.x >= GetScrollBar(0).GetOuterRect().left && mouse.x <= GetScrollBar(0).GetOuterRect().right) && mouse.y >= GetListRect().top) { m_Open = false; GetScrollBar(0).SetZ(GetBufferedZ()); } } break; } case GUIM_MOUSE_WHEEL_DOWN: { bool enabled; GUI<bool>::GetSetting(this, "enabled", enabled); // Don't switch elements by scrolling when open, causes a confusing interaction between this and the scrollbar. if (m_Open || !enabled) break; GUI<int>::GetSetting(this, "selected", m_ElementHighlight); if (m_ElementHighlight + 1 >= (int)m_ItemsYPositions.size() - 1) break; ++m_ElementHighlight; GUI<int>::SetSetting(this, "selected", m_ElementHighlight); break; } case GUIM_MOUSE_WHEEL_UP: { bool enabled; GUI<bool>::GetSetting(this, "enabled", enabled); // Don't switch elements by scrolling when open, causes a confusing interaction between this and the scrollbar. if (m_Open || !enabled) break; GUI<int>::GetSetting(this, "selected", m_ElementHighlight); if (m_ElementHighlight - 1 < 0) break; m_ElementHighlight--; GUI<int>::SetSetting(this, "selected", m_ElementHighlight); break; } case GUIM_LOST_FOCUS: { if (m_Open) { CStrW soundPath; if (g_SoundManager && GUI<CStrW>::GetSetting(this, "sound_closed", soundPath) == PSRETURN_OK && !soundPath.empty()) g_SoundManager->PlayAsUI(soundPath.c_str(), false); } m_Open = false; break; } case GUIM_LOAD: SetupListRect(); break; default: break; } // Important that this is after, so that overshadowed implementations aren't processed CList::HandleMessage(Message); // As HandleMessage functions return void, we need to manually verify // whether the child list's items were modified. if (CList::GetModified()) SetupText(); }
void CList::HandleMessage(SGUIMessage& Message) { IGUIScrollBarOwner::HandleMessage(Message); //IGUITextOwner::HandleMessage(Message); <== placed it after the switch instead! m_Modified = false; switch (Message.type) { case GUIM_SETTINGS_UPDATED: if (Message.value == "list") SetupText(); // If selected is changed, call "SelectionChange" if (Message.value == "selected") { // TODO: Check range // TODO only works if lower-case, shouldn't it be made case sensitive instead? ScriptEvent("selectionchange"); } if (Message.value == "scrollbar") SetupText(); // Update scrollbar if (Message.value == "scrollbar_style") { CStr scrollbar_style; GUI<CStr>::GetSetting(this, Message.value, scrollbar_style); GetScrollBar(0).SetScrollBarStyle(scrollbar_style); SetupText(); } break; case GUIM_MOUSE_PRESS_LEFT: { bool enabled; GUI<bool>::GetSetting(this, "enabled", enabled); if (!enabled) { CStrW soundPath; if (g_SoundManager && GUI<CStrW>::GetSetting(this, "sound_disabled", soundPath) == PSRETURN_OK && !soundPath.empty()) g_SoundManager->PlayAsUI(soundPath.c_str(), false); break; } bool scrollbar; CGUIList* pList; GUI<bool>::GetSetting(this, "scrollbar", scrollbar); GUI<CGUIList>::GetSettingPointer(this, "list", pList); float scroll = 0.f; if (scrollbar) scroll = GetScrollBar(0).GetPos(); CRect rect = GetListRect(); CPos mouse = GetMousePos(); mouse.y += scroll; int set = -1; for (int i = 0; i < (int)pList->m_Items.size(); ++i) { if (mouse.y >= rect.top + m_ItemsYPositions[i] && mouse.y < rect.top + m_ItemsYPositions[i+1] && // mouse is not over scroll-bar !(mouse.x >= GetScrollBar(0).GetOuterRect().left && mouse.x <= GetScrollBar(0).GetOuterRect().right)) { set = i; } } if (set != -1) { GUI<int>::SetSetting(this, "selected", set); UpdateAutoScroll(); CStrW soundPath; if (g_SoundManager && GUI<CStrW>::GetSetting(this, "sound_selected", soundPath) == PSRETURN_OK && !soundPath.empty()) g_SoundManager->PlayAsUI(soundPath.c_str(), false); } break; } case GUIM_LOAD: { CStr scrollbar_style; GUI<CStr>::GetSetting(this, "scrollbar_style", scrollbar_style); GetScrollBar(0).SetScrollBarStyle(scrollbar_style); break; } default: break; } IGUITextOwner::HandleMessage(Message); }
cMenuSetupPage *cMainMenuShortcut::SetupMenu() { return new cMainMenuShortcutSetupPage(SetupText(), SETUPENTRY, &_mainMenuEntryEnabled); }
void CList::HandleMessage(SGUIMessage &Message) { IGUIScrollBarOwner::HandleMessage(Message); //IGUITextOwner::HandleMessage(Message); <== placed it after the switch instead! switch (Message.type) { case GUIM_SETTINGS_UPDATED: if (Message.value == "list") { SetupText(); } // If selected is changed, call "SelectionChange" if (Message.value == "selected") { // TODO: Check range // TODO only works if lower-case, shouldn't it be made case sensitive instead? ScriptEvent("selectionchange"); } if (Message.value == "scrollbar") { SetupText(); } // Update scrollbar if (Message.value == "scrollbar_style") { CStr scrollbar_style; GUI<CStr>::GetSetting(this, Message.value, scrollbar_style); GetScrollBar(0).SetScrollBarStyle( scrollbar_style ); SetupText(); } break; case GUIM_MOUSE_PRESS_LEFT: { bool enabled; GUI<bool>::GetSetting(this, "enabled", enabled); if (!enabled) break; bool scrollbar; CGUIList *pList; GUI<bool>::GetSetting(this, "scrollbar", scrollbar); GUI<CGUIList>::GetSettingPointer(this, "list", pList); float scroll=0.f; if (scrollbar) { scroll = GetScrollBar(0).GetPos(); } CRect rect = GetListRect(); CPos mouse = GetMousePos(); mouse.y += scroll; int set=-1; for (int i=0; i<(int)pList->m_Items.size(); ++i) { if (mouse.y >= rect.top + m_ItemsYPositions[i] && mouse.y < rect.top + m_ItemsYPositions[i+1] && // mouse is not over scroll-bar !(mouse.x >= GetScrollBar(0).GetOuterRect().left && mouse.x <= GetScrollBar(0).GetOuterRect().right)) { set = i; } } if (set != -1) { GUI<int>::SetSetting(this, "selected", set); UpdateAutoScroll(); } } break; case GUIM_MOUSE_WHEEL_DOWN: { GetScrollBar(0).ScrollPlus(); // Since the scroll was changed, let's simulate a mouse movement // to check if scrollbar now is hovered SGUIMessage msg(GUIM_MOUSE_MOTION); HandleMessage(msg); break; } case GUIM_MOUSE_WHEEL_UP: { GetScrollBar(0).ScrollMinus(); // Since the scroll was changed, let's simulate a mouse movement // to check if scrollbar now is hovered SGUIMessage msg(GUIM_MOUSE_MOTION); HandleMessage(msg); break; } case GUIM_LOAD: { CStr scrollbar_style; GUI<CStr>::GetSetting(this, "scrollbar_style", scrollbar_style); GetScrollBar(0).SetScrollBarStyle( scrollbar_style ); } break; default: break; } IGUITextOwner::HandleMessage(Message); }
static int DrwText(Engine *engine, GpReal x0, GpReal y0, const char *text) { PSEngine *psEngine= (PSEngine *)engine; int ix, iy, nlines; GpReal width, height, lineHeight; GpXYMap *map= &engine->map; GpBox *wind= &engine->transform.window; GpReal xmin, xmax, ymin, ymax; int xll, yll, xur, yur, alignH, alignV; int count, nchars, firstPass; char *now, c; const char *t; int state= 0; /* zero size text can confuse postscript interpreters */ if ((int)(gistA.t.height*NDC_TO_PS+0.5) <= 0) return 0; if (CheckClip(psEngine) || SetupText(psEngine)) return 1; alignH= psEngine->curAlignH; alignV= psEngine->curAlignV; /* Compute text location in PostScript coordinates. */ x0= map->x.scale*x0 + map->x.offset; y0= map->y.scale*y0 + map->y.offset; /* handle multi-line strings */ nlines= GtTextShape(text, &gistA.t, (WidthFunction)0, &width); lineHeight= gistA.t.height * NDC_TO_PS; width*= 0.6*lineHeight; height= lineHeight*(GpReal)nlines; /* Reject if and only if the specified point is off of the current page by more than the approximate size of the text. Note that the entire block of text is either accepted or rejected -- PostScript does the clipping. */ if (wind->xmax>wind->xmin) { xmin= wind->xmin; xmax= wind->xmax; } else { xmin= wind->xmax; xmax= wind->xmin; } if (wind->ymax>wind->ymin) { ymin= wind->ymin; ymax= wind->ymax; } else { ymin= wind->ymax; ymax= wind->ymin; } if (gistA.t.orient==TX_RIGHT || gistA.t.orient==TX_LEFT) { if (x0<xmin-width || x0>xmax+width || y0<ymin-height || y0>ymax+height) return 0; } else { if (x0<xmin-height || x0>xmax+height || y0<ymin-width || y0>ymax+width) return 0; } /* Adjust y0 (or x0) to represent topmost line */ if (nlines > 1) { if (gistA.t.orient==TX_RIGHT) { if (alignV==TV_BASE || alignV==TV_BOTTOM) y0+= height-lineHeight; if (alignV==TV_HALF) y0+= 0.5*(height-lineHeight); } else if (gistA.t.orient==TX_LEFT) { if (alignV==TV_BASE || alignV==TV_BOTTOM) y0-= height-lineHeight; if (alignV==TV_HALF) y0-= 0.5*(height-lineHeight); } else if (gistA.t.orient==TX_UP) { if (alignV==TV_BASE || alignV==TV_BOTTOM) x0-= height-lineHeight; if (alignV==TV_HALF) x0-= 0.5*(height-lineHeight); } else { if (alignV==TV_BASE || alignV==TV_BOTTOM) x0+= height-lineHeight; if (alignV==TV_HALF) x0+= 0.5*(height-lineHeight); } } ix= (int)x0; iy= (int)y0; /* Guess at the bounding box for the text */ if (!psEngine->curClip) { GpReal dx=0.0, dy=0.0; if (alignH==TH_CENTER) dx= 0.5*width; else if (alignH==TH_RIGHT) dx= width; if (alignV==TV_TOP || alignV==TV_CAP) dy= height; else if (alignV==TV_HALF) dy= height-0.4*lineHeight; else if (alignV==TV_BASE) dy= height-0.8*lineHeight; else if (alignV==TV_BOTTOM) dy= height-lineHeight; if (gistA.t.orient==TX_RIGHT) { x0-= dx; y0-= dy; } else if (gistA.t.orient==TX_LEFT) { x0+= dx; y0+= dy; } else if (gistA.t.orient==TX_UP) { x0-= dy; y0+= dx; } else { x0+= dy; y0-= dx; } if (x0>xmin) xmin= x0; if (x0+width<xmax) xmax= x0+width; if (y0>ymin) ymin= y0; if (y0+height<ymax) ymax= y0+height; xll= (int)xmin; xur= (int)xmax; yll= (int)ymin; yur= (int)ymax; if (xll<psEngine->pageBB.xll) psEngine->pageBB.xll= xll; if (xur>psEngine->pageBB.xur) psEngine->pageBB.xur= xur; if (yll<psEngine->pageBB.yll) psEngine->pageBB.yll= yll; if (yur>psEngine->pageBB.yur) psEngine->pageBB.yur= yur; } if (nlines>1 || gistA.t.orient!=TX_RIGHT) { if (Append(psEngine, "[")) return 1; } nchars= psEngine->nchars; now= psEngine->line+nchars; firstPass= 1; while ((t= GtNextLine(text, &count, gistA.t.orient)) || firstPass) { text= t; firstPass= 0; state= 0; if (nchars > 70) { psEngine->nchars= nchars; if (PutLine(psEngine)) return 1; nchars= 0; now= psEngine->line; } *now++= ' '; *now++= '('; nchars+= 2; while (count--) { if (nchars>72 && break_line_now(psEngine, &now, &nchars)) return 1; c= *text; if (c>=32 && c<127) { if (gtDoEscapes) { if (c=='!' && count) { c= text[1]; /* peek at next char */ if (c=='!' || c=='^' || c=='_') { count--; text++; goto normal; } if (nchars>68 && break_line_now(psEngine, &now, &nchars)) return 1; strcpy(now, "\\024"); /* DC4 is ps.ps escape char */ now+= 4; nchars+= 4; psEngine->fonts|= (1<<T_SYMBOL); /* symbol font used */ if (c==']') { *now++= '^'; /* !] means ^ (perp) in symbol font */ nchars++; text+= 2; count--; continue; } goto escape; } else if (c=='^') { if (state!=0) { /* terminate current super or subscript escape */ strcpy(now, "\\021"); /* DC1 is ps.ps escape char */ now+= 4; nchars+= 4; } if (state!=1) { /* intialize superscript escape */ if (nchars>64 && break_line_now(psEngine, &now, &nchars)) return 1; strcpy(now, "\\021\\022"); /* DC1DC2 is ps.ps escape seq */ now+= 8; nchars+= 8; state= 1; } else { state= 0; } goto escape; } else if (c=='_') { if (state!=0) { /* terminate current super or subscript escape */ if (nchars>68 && break_line_now(psEngine, &now, &nchars)) return 1; strcpy(now, "\\021"); /* DC1 is ps.ps escape char */ now+= 4; nchars+= 4; } if (state!=2) { /* intialize subscript escape */ if (nchars>64 && break_line_now(psEngine, &now, &nchars)) return 1; strcpy(now, "\\021\\023"); /* DC1DC3 is ps.ps escape seq */ now+= 8; nchars+= 8; state= 2; } else { state= 0; } goto escape; } } /* ordinary printing character */ if (c=='(' || c==')' || c=='\\') { *now++= '\\'; nchars++; } normal: *now++= c; nchars++; } else { /* non-printing characters rendered as \ooo */ if (c=='\t') { *now++= '\\'; *now++= 't'; nchars+= 2; } else if (c<'\021' || c>'\024') { /* DC1 through DC4 have special meaning in ps.ps, skip them */ sprintf(now, "\\%03o", (int)((unsigned char)c)); now+= 4; nchars+= 4; } } escape: text++; } if (state!=0) { /* terminate current super or subscript escape */ strcpy(now, "\\021"); /* DC1 is ps.ps escape char */ now+= 4; nchars+= 4; } *now++= ')'; nchars++; *now= '\0'; } psEngine->nchars= nchars; if (gistA.t.orient==TX_RIGHT) { sprintf(line, nlines>1? "] %d %d TA" : "%d %d T", ix, iy); } else { int angle; if (gistA.t.orient==TX_LEFT) angle= 180; else if (gistA.t.orient==TX_UP) angle= 90; else angle= 270; sprintf(line, "] %d %d %d TR", angle, ix, iy); } if (Append(psEngine, line)) return 1; return 0; }