void RadialMenu::create_parts() { CL_GraphicContext gc = get_gc(); CL_ResourceManager resources = get_resources(); part_component = CL_GUIThemePart(this); CL_GUIThemePart part_selected_item(this, "selected"); CL_GUIThemePartProperty prop_text_color("text-color"); CL_GUIThemePartProperty prop_pointer_image("pointer-image"); CL_GUIThemePartProperty prop_text_distance("text-distance"); normal_text_color = part_component.get_property(prop_text_color); normal_font = part_component.get_font(); normal_text_distance = CL_StringHelp::text_to_float(part_component.get_property(prop_text_distance)); normal_font_height = normal_font.get_font_metrics().get_height(); selected_text_color = part_selected_item.get_property(prop_text_color); selected_font = part_selected_item.get_font(); selected_text_distance = CL_StringHelp::text_to_float(part_selected_item.get_property(prop_text_distance)); selected_font_height = selected_font.get_font_metrics().get_height(); CL_String pointer_image_name = part_component.get_property(prop_pointer_image); image_pointer = CL_Sprite(gc, pointer_image_name, &resources); image_pointer.set_alignment(origin_center); }
void MainMenuScene::displayError(const CL_String& p_message) { CL_Font font(get_gc(), "helvetica", 14); CL_SpanLayout span; span.add_text(p_message, font, CL_Colorf::red); m_errorLabel.set_span(span); }
PushButton(CL_GUIManager &manager, CL_ResourceManager &application_resources) : CL_Window(&manager, CL_GUITopLevelDescription("PushButton", CL_Rect(256 + 16, 256 + 16, CL_Size(256, 180)), false)) { CL_GraphicContext gc = get_gc(); test_image = CL_Image(gc, "tux", &application_resources); set_draggable(true); CL_Rect client_area = get_client_area(); pushbutton1 = new CL_PushButton(this); pushbutton1->set_geometry(CL_Rect(client_area.left + 11, client_area.top + 10, CL_Size(128, 40))); pushbutton1->set_text("Push Button"); pushbutton1->set_flat(false); pushbutton1->func_clicked().set(this, &PushButton::on_clicked, pushbutton1); int label_xpos = client_area.left + 31; int yoffset = client_area.top + 80; CL_Size label_size(50, 15); const int gap = 16; checkbox_flat = new CL_CheckBox(this); checkbox_flat->set_geometry(CL_Rect(client_area.left + 11, yoffset, CL_Size(100, 15))); checkbox_flat->func_checked().set(this, &PushButton::on_checked_flat, checkbox_flat); checkbox_flat->func_unchecked().set(this, &PushButton::on_unchecked_flat, checkbox_flat); checkbox_flat->set_text("Flat"); yoffset+=gap; checkbox_icon = new CL_CheckBox(this); checkbox_icon->set_geometry(CL_Rect(client_area.left + 11, yoffset, CL_Size(100, 15))); checkbox_icon->func_checked().set(this, &PushButton::on_checked_icon, checkbox_icon); checkbox_icon->func_unchecked().set(this, &PushButton::on_unchecked_icon, checkbox_icon); checkbox_icon->set_text("Icon"); yoffset+=gap; checkbox_toggle = new CL_CheckBox(this); checkbox_toggle->set_geometry(CL_Rect(client_area.left + 11, yoffset, CL_Size(100, 15))); checkbox_toggle->func_checked().set(this, &PushButton::on_checked_toggle, checkbox_toggle); checkbox_toggle->func_unchecked().set(this, &PushButton::on_unchecked_toggle, checkbox_toggle); checkbox_toggle->set_text("Enable Toggle"); yoffset+=gap; checkbox_disable = new CL_CheckBox(this); checkbox_disable->set_geometry(CL_Rect(client_area.left + 11, yoffset, CL_Size(100, 15))); checkbox_disable->func_checked().set(this, &PushButton::on_checked_disable, checkbox_disable); checkbox_disable->func_unchecked().set(this, &PushButton::on_unchecked_disable, checkbox_disable); checkbox_disable->set_text("Disable"); int xoffset = client_area.left + 36; yoffset = client_area.top + 60; // info_clicked = new Info(this); // info_clicked->set(xoffset, yoffset, "Clicked"); }
GameViewBattle::GameViewBattle(GameView *view, Client *client) : CL_GUIComponent(view), view(view), client(client) { set_type_name("battle"); set_geometry(CL_Rect(view->get_width() - 400, 0, view->get_width(), 300)); set_visible(false); func_render().set(this, &GameViewBattle::on_render); func_process_message().set(this, &GameViewBattle::on_message); timer_hide.func_expired().set(this, &GameViewBattle::on_timer_hide_expired); CL_Texture texture_dice(get_gc(), "Resources/dices.png", CL_VirtualDirectory()); CL_SpriteDescription dice_description; dice_description.add_gridclipped_frames(texture_dice, 0, 0, 42, 45, 6, 1); sprite_dices = CL_Sprite(get_gc(), dice_description); font_large = CL_Font(get_gc(), "Accidental Presidency", -40); font_small = CL_Font(get_gc(), "Accidental Presidency", -30); }
void CL_DisplayWindow_OpenGL::flip(int interval) { CL_GLStateChecker::from_gc(get_gc())->flush(); if (interval != -1) { GLint param = interval; aglSetInteger(context, AGL_SWAP_INTERVAL, ¶m); } aglSwapBuffers(context); }
/* Initializes widget instance * * Parameters: * request - requested widget * w - the widget * args - arguments * num_args - number of arguments * */ static void initialize(Widget request, Widget w, ArgList args, Cardinal *num_args) { CtrlWidget cw = (CtrlWidget)w; CtrlPart *c = & cw->ctrl; // Display *dpy = XtDisplay(w); int i; Dimension width,height; TF(); c->draw = 0; CtrlWidget cw1 = (CtrlWidget)request; CtrlPart *c1 = & cw1->ctrl; // foreach state for(i=0;i<3;i++) { c->gc[i] = get_gc( w, c->pixel[3+i] ); alloc_xft_color( w, c->pixel[i], c->col+i ); } // foreach label for(i=0;i<MAX_CLABEL;i++) { Change_Font(w, i, c->fontnames[i] ); } c->msg.state = STATE_NORMAL; c->msg.cmd = MSG_UPDATE; c->msg.value = 0; if( IsEmpty( c->str[TEXT] )) c->str[TEXT] = cw->core.name; for(i=0;i<MAX_CLABEL;i++) { SafeStrcpy( c->clabel[i].str, c->str[i], MAX_CLABEL_STR ); c->clabel[i].position=0; } c->clabel[TEXT].position=1; calc_widget_size(w, &width,&height ); if (cw->core.height == 0) cw->core.height = height; if (cw->core.width == 0) cw->core.width = width; // (*XtClass(w)->superclass->core_class.resize)(w); }
void OpenGLWindowProvider::flip(int interval) { if (display == EGL_NO_DISPLAY || surface == EGL_NO_SURFACE) return; OpenGL::set_active(get_gc()); glFlush(); if (interval != -1 && interval != swap_interval) { swap_interval = interval; eglSwapInterval(display, swap_interval); } eglSwapBuffers(display, surface); OpenGL::check_error(); }
void CL_DisplayWindow_OpenGL::flip(int interval) { CL_GLStateChecker::from_gc(get_gc())->flush(); if (interval != -1) { typedef int (*ptr_glXSwapIntervalSGI)(int interval); ptr_glXSwapIntervalSGI glXSwapIntervalSGI = (ptr_glXSwapIntervalSGI) CL_OpenGL::get_proc_address("glXSwapIntervalSGI"); if (glXSwapIntervalSGI) { glXSwapIntervalSGI(interval); } } XSync(disp,False); glXSwapBuffers(disp, window); }
void CL_DisplayWindow_OpenGL::set_fullscreen(int width, int height, int bpp, int refresh_rate) { if(fullscreen) return; CGCaptureAllDisplays(); aglSetCurrentContext(fs_context); aglSetFullScreen(fs_context, width, height, refresh_rate, 0); context = fs_context; install_event_handler(GetApplicationEventTarget()); fullscreen = true; focus = true; //After toggling to the fullscreen context, nothing is going draw unless //we reapply the GL states/properties -mrfun 6-2-2006 CL_GLStateChecker::from_gc(get_gc())->reinitialize_asap(); }
void CL_OpenGLWindowProvider_GLX::flip(int interval) { CL_GraphicContext gc = get_gc(); CL_OpenGL::set_active(gc); glFlush(); if (interval != -1 && interval != swap_interval) { swap_interval = interval; if (glXSwapIntervalSGI) { glXSwapIntervalSGI(swap_interval); } else if (glXSwapIntervalMESA) { glXSwapIntervalMESA(swap_interval); } } glx.glXSwapBuffers(x11_window.get_display(), x11_window.get_window()); }
void CL_DisplayWindow_OpenGL::update(const CL_Rect &rect) { CL_OpenGLState state(get_gc()); state.set_active(); state.setup_2d(); CLboolean is_doublebuffered = CL_FALSE; clGetBooleanv(CL_DOUBLEBUFFER, &is_doublebuffered); if (is_doublebuffered) { clReadBuffer(CL_BACK); float raster_pos[4]; clGetFloatv(CL_CURRENT_RASTER_POSITION, raster_pos); clDrawBuffer(CL_FRONT); clRasterPos3f(rect.left, rect.bottom, raster_pos[2]); clCopyPixels(rect.top, rect.left, rect.get_width(), rect.get_height(), CL_COLOR); clDrawBuffer(CL_BACK); } }
void CL_DisplayWindow_OpenGL::update(const CL_Rect &rect) { CL_OpenGLState state(get_gc()); state.set_active(); state.setup_2d(); clReadBuffer(CL_BACK); if(clGetError() == CL_NO_ERROR) // Check if we got more than 1 buffer. { float raster_pos[4]; clGetFloatv(CL_CURRENT_RASTER_POSITION, raster_pos); clDrawBuffer(CL_FRONT); clRasterPos3f(rect.left, rect.bottom, raster_pos[2]); clCopyPixels(rect.top, rect.left, rect.get_width(), rect.get_height(), CL_COLOR); // Return to drawing to the back buffer clDrawBuffer(CL_BACK); } }
void CL_DisplayWindow_OpenGL::set_windowed() { if(!fullscreen) return; if (context == fs_context) { aglSetDrawable(fs_context, 0); } CGReleaseAllDisplays(); aglSetCurrentContext(win_context); aglUpdateContext(win_context); install_event_handler(GetWindowEventTarget(window_ref)); fullscreen = false; context = win_context; focus = IsWindowHilited(window_ref); //After toggling to the fullscreen context, nothing is going draw unless //we reapply the GL states/properties -mrfun 6-2-2006 CL_GLStateChecker::from_gc(get_gc())->reinitialize_asap(); }
void Canvas::reset_depth_stencil_state() { flush(); get_gc().reset_depth_stencil_state(); }
//execute context l_thread::type_return l_thread::execute(l_call_context& context) { //lock context context.lock(); //save context register3(R_CONTEXT) = l_variable( &context ); //pc... unsigned int pc = 0; l_function& function = m_vm->function(context.get_fun_id()); l_list_command& commands = function.m_commands; //macro #define raise(str)\ {\ push_error(str, pc, (unsigned int)commands[pc].m_line);\ return T_RETURN_ERROR;\ } #define vconst(c) function.m_costants[c] #define top_size (m_top+1) //for all commands for (pc = 0; pc < commands.size(); ++pc) { //current command l_command& cmp = commands[pc]; //opcodes switch (cmp.m_op_code) { case L_JMP: pc = cmp.m_arg - 1; break; case L_RETURN: //push return if(cmp.m_arg) { //get value register3(2) = pop(); //return... return T_RETURN_VALUE; } else { //came back return T_RETURN_VOID; } //.. break; case L_IF: if(top().is_true()) { pc = cmp.m_arg - 1; } pop(); break; case L_IF0: if(top().is_false()) { pc = cmp.m_arg - 1; } pop(); break; case L_IF_OR_POP: if(top().is_true()) { pc = cmp.m_arg - 1; } else { pop(); } break; case L_IF0_OR_POP: if(top().is_false()) { pc = cmp.m_arg - 1; } else { pop(); } break; case L_PUSH: push( stack(cmp.m_arg) ); break; case L_PUSH_NULL: push( l_variable() ); break; case L_PUSH_TRUE: push( l_variable(true) ); break; case L_PUSH_FALSE: push( l_variable(false) ); break; case L_PUSHK: push( vconst(cmp.m_arg) ); break; case L_CLOSER: { //get value l_variable& call_fun = vconst(cmp.m_arg); //... if(call_fun.is_function()) { //new context register3(0) = l_closer::gc_new(get_gc()); //init context register3(0).to<l_closer>()->init(call_fun.m_value.m_fid, this, l_variable(&context)); //push context push(register3(0)); } } break; //////////////////////////////////////////////////////////// case L_ADD: if(!stack(1).add(stack(0),stack(1))) raise("not valid operation"); pop(); break; case L_MUL: if(!stack(1).mul(stack(0),stack(1))) raise("not valid operation"); pop(); break; case L_SUB: if(!stack(1).sub(stack(0),stack(1))) raise("not valid operation"); pop(); break; case L_DIV: if(!stack(1).div(stack(0),stack(1))) raise("not valid operation"); pop(); break; case L_MOD: if(!stack(1).mod(stack(0),stack(1))) raise("not valid operation"); pop(); break; case L_UNM: if(!stack(0).unm(stack(0))) raise("not valid operation"); break; //////////////////////////////////////////////////////////// case L_EQ: if(!stack(1).equal(stack(0),stack(1))) raise("not valid operation"); pop(); break; case L_NEQ: if(!stack(1).not_equal(stack(0),stack(1))) raise("not valid operation"); pop(); break; case L_RT: if(!stack(1).rt(stack(0),stack(1))) raise("not valid operation"); pop(); break; case L_RE: if(!stack(1).re(stack(0),stack(1))) raise("not valid operation"); pop(); break; case L_LT: if(!stack(1).lt(stack(0),stack(1))) raise("not valid operation"); pop(); break; case L_LE: if(!stack(1).le(stack(0),stack(1))) raise("not valid operation"); pop(); break; //////////////////////////////////////////////////////////// case L_NOT: if(!stack(0).not_value(stack(0))) raise("not valid operation"); break; case L_OR: if(!stack(1).or_value(stack(0),stack(1))) raise("not valid operation"); pop(); break; case L_AND: if(!stack(1).and_value(stack(0),stack(1))) raise("not valid operation"); pop(); break; //////////////////////////////////////////////////////////// case L_GET_GLOBAL: push( global(context,cmp.m_arg) ); break; case L_SET_GLOBAL: global(context,cmp.m_arg) = pop(); break; //////////////////////////////////////////////////////////// case L_GET_LOCAL: push( strick_local(context,cmp.m_arg) ); break; case L_SET_LOCAL: strick_local(context,cmp.m_arg) = pop(); break; //////////////////////////////////////////////////////////// case L_SET_UP_VALUE: local(context,cmp.m_arg) = pop(); break; case L_GET_UP_VALUE: push( local(context,cmp.m_arg) ); break; //////////////////////////////////////////////////////////// case L_GET_THIS: push(context.this_field()); break; case L_SET_THIS: context.this_field() = pop(); break; case L_SET_THIS_NPOP: context.this_field() = stack(cmp.m_arg); break; //////////////////////////////////////////////////////////// case L_NEW_ARRAY: { register3(0) = l_array::gc_new(get_gc()); //init ? if( cmp.m_arg > 0 ) { //types l_array* vector = register3(0).array(); //put stack into vector for(int i = cmp.m_arg-1; i >= 0; --i) { vector->operator[](i) = pop(); } } //push array (n.b. gc run...) push( register3(0) ); } break; //alloc tablet case L_NEW_TABLE: { register3(0) = l_table::gc_new(get_gc()); //init ? if( cmp.m_arg > 0 ) { //types l_table* table = register3(0).table(); //assert assert(!(cmp.m_arg % 2)); //put stack into vector for(int i = (cmp.m_arg)-1; i >= 0; i-=2) { //push key and value table->operator[](stack(1)) = stack(0); //pop value pop(); //pop key pop(); } } //push table (n.b. gc run...) push( register3(0) ); } break; case L_GET_AT_VAL: { l_variable& r_b = stack(1); const l_variable& r_c = stack(0); //try if ( r_b.is_object() ) { //is a vector if(r_b.is_array()) { //types l_array* vector = r_b.array(); //to size int size_t index = 0; //cast if( r_c.is_int() ) index= (size_t)r_c.m_value.m_i; else if( r_c.is_float() )index= (size_t)r_c.m_value.m_f; else raise( "value isn't a valid key" ); //save last get_this() = stack(1); //get stack(1) = vector->operator[](index) ; } else if(r_b.is_table()) { //types l_table* table = r_b.table(); //is a string? if(!r_c.is_string()) raise( "value isn't a valid key" ); //save last get_this() = stack(1); //get and pop value stack(1) = table->operator[](r_c); } else { raise( "value isn't a vector/table, field not available" ); } } else { raise( "value isn't a vector/table/object, field not avaliable" ); } //pop index pop(); } break; case L_SET_AT_VAL: { //get table/array l_variable& r_a = stack(2); //get index const l_variable& r_b = stack(1); //try if ( r_a.is_object() ) { //is a vector if(r_a.is_array()) { //types l_array* vector = r_a.array(); //to size int size_t index = 0; //cast if( r_b.is_int() ) index= (size_t)r_b.m_value.m_i; else if( r_b.is_float() ) index= (size_t)r_b.m_value.m_f; else raise( "value isn't a valid key" ); //get and pop value vector->operator[](index) = pop(); } else if(r_a.is_table()) { //types l_table* table = r_a.table(); //is a string? if(!r_b.is_string()) raise( "value isn't a valid key" ); //get and pop value table->operator[](r_b) = pop(); } else { raise( "value isn't a vector/table, field not available" ); } } else { //pop value pop(); } //pop index pop(); //pop array/tablet pop(); } break; //for in case L_IT: { //get index l_variable& r_a = top(); //.. //try if ( r_a.is_object() ) { //get object l_obj* this_obj = (l_obj*)r_a.m_value.m_pobj; //is a vector if(r_a.is_array()) { //types l_array* vector = r_a.array(); //pop value pop(); //push it push( vector->get_it() ); } else if (r_a.is_table()) { //types l_table* table = r_a.table(); //pop value pop(); //push it push( table->get_it() ); } else if (r_a.to<l_xrange>()) { //types l_xrange* xrange = static_cast< l_xrange* > ( this_obj ); //pop value pop(); //push it push( xrange->get_it() ); } else { raise( "this value not have a iterator" ); } } else { //pop value pop(); //.. raise( "value isn't a table/array/object, iterator not supported" ); } } break; //for of case L_FOR_IN: case L_FOR_OF: { //get index l_variable& r_it = top(); //try if ( r_it.is_iterator() ) { //types l_iterator* l_it = r_it.iterator(); //is array it if(l_it) { //else assert assert(l_it); //push it if(l_it->valid()) { if(cmp.m_op_code == L_FOR_OF) { //get next push( l_it->get() ); } else //L_FOR_IN { //get next push( l_it->get_id() ); } //next l_it->self_next(); } else { //pop iterator pop(); //and jump pc = cmp.m_arg - 1; } } else { raise( "value isn't a valid iterator" ); } } else { //pop it pop(); //and jump pc = cmp.m_arg - 1; //... raise( "value isn't an iterator" ); } } break; case L_THIS_CALL: case L_CALL: { //get index register3(0) = pop(); //get args if( register3(0).is_cfunction() ) { //return size int n_return = register3(0).m_value.m_pcfun(this,cmp.m_arg); //assert (1 return) assert(n_return <= 1); //error if(n_return<0) { raise( "native call exception" ); } else if(n_return>1) { raise( "native call can't return more than a value" ); } //pop args for(int i=0; i < cmp.m_arg; ++i) { pop(); } //if return if(n_return) push(get_return()); } else if( register3(0).is_closer() ) { //get context l_closer* closer = register3(0).to<l_closer>(); //else assert if(!closer){ assert(0); }; //new function l_function& call_fun = m_vm->function(closer->get_fun_id()); //save last context l_variable last_ctx = register3(R_CONTEXT); //new context register3(1) = l_call_context::gc_new(get_gc()); l_call_context* new_ctx = register3(1).to<l_call_context>(); //this? if(cmp.m_op_code == L_THIS_CALL) { new_ctx->this_field() = get_this(); } //init new_ctx->init(*closer); //lock context new_ctx->lock(); //n args unsigned int n_fun_args = call_fun.m_args_size; //alloc array args..? if (call_fun.m_have_args_list) { //alloc array register3(3) = l_array::gc_new(get_gc()); } //put arguments for(unsigned int arg = 0; arg != cmp.m_arg; ++arg) { if (arg < n_fun_args) { new_ctx->variable( call_fun.constant(arg) ) = pop(); } else if (call_fun.m_have_args_list) { register3(3).array()->push(pop()); } else { pop(); } } //add var list if (call_fun.m_have_args_list) { //push array new_ctx->variable( call_fun.constant(n_fun_args) ) = register3(3); //to null register3(3) = l_variable(); } //save stack long stack_top_bf_call = m_top; //execute call type_return n_return = execute(*new_ctx); //error? if(n_return==T_RETURN_ERROR) { raise( "call exception" ); } //unlock context new_ctx->unlock(); //reset last context register3(R_CONTEXT) = last_ctx; //restore stack m_top = stack_top_bf_call; //return? if(n_return == T_RETURN_VALUE) { push(register3(2)); } } else { raise( "value isn't an function" ); } //dealloc if(cmp.m_op_code == L_THIS_CALL) { get_this() = l_variable(); } } break; default: break; } } return T_RETURN_VOID; }
PixelBuffer Canvas::get_pixeldata(TextureFormat texture_format, bool clamp) { flush(); return get_gc().get_pixeldata(texture_format, clamp); }
PixelBuffer Canvas::get_pixeldata(const Rect &rect2, TextureFormat texture_format, bool clamp) { flush(); return get_gc().get_pixeldata(rect2, texture_format, clamp); }
void Canvas::set_blend_state(const BlendState &state, const Colorf &blend_color, unsigned int sample_mask) { flush(); get_gc().set_blend_state(state, blend_color, sample_mask); }
void Canvas::set_rasterizer_state(const RasterizerState &state) { flush(); get_gc().set_rasterizer_state(state); }
void Canvas::set_depth_stencil_state(const DepthStencilState &state, int stencil_ref) { flush(); get_gc().set_depth_stencil_state(state, stencil_ref); }
void OpenGLWindowProvider::flip(int interval) { OpenGL::set_active(get_gc()); glFlush(); if (shadow_window) { int width = get_viewport().get_width(); int height = get_viewport().get_height(); if (using_gl3) { if (double_buffered) { glDrawBuffer(GL_BACK); glReadBuffer(GL_FRONT); } PixelBuffer pixelbuffer(width, height, tf_bgra8); glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelStorei(GL_PACK_ROW_LENGTH, pixelbuffer.get_pitch() / pixelbuffer.get_bytes_per_pixel()); glPixelStorei(GL_PACK_SKIP_PIXELS, 0); glPixelStorei(GL_PACK_SKIP_ROWS, 0); glReadPixels( 0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, pixelbuffer.get_data()); win32_window.update_layered(pixelbuffer); } else { GLint old_viewport[4], old_matrix_mode; GLfloat old_matrix_projection[16], old_matrix_modelview[16]; glGetIntegerv(GL_VIEWPORT, old_viewport); glGetIntegerv(GL_MATRIX_MODE, &old_matrix_mode); glGetFloatv(GL_PROJECTION_MATRIX, old_matrix_projection); glGetFloatv(GL_MODELVIEW_MATRIX, old_matrix_modelview); GLboolean blending = glIsEnabled(GL_BLEND); glDisable(GL_BLEND); glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMultMatrixf(Mat4f::ortho_2d(0.0f, (float)width, 0.0f, (float)height, handed_right, clip_negative_positive_w)); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); if (double_buffered) { glReadBuffer(GL_BACK); } glRasterPos2i(0, 0); glPixelZoom(1.0f, 1.0f); PixelBuffer pixelbuffer(width, height, tf_rgba8); glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelStorei(GL_PACK_ROW_LENGTH, pixelbuffer.get_pitch() / pixelbuffer.get_bytes_per_pixel()); glPixelStorei(GL_PACK_SKIP_PIXELS, 0); glPixelStorei(GL_PACK_SKIP_ROWS, 0); glReadPixels( 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixelbuffer.get_data()); win32_window.update_layered(pixelbuffer); if (blending) glEnable(GL_BLEND); glViewport(old_viewport[0], old_viewport[1], old_viewport[2], old_viewport[3]); glMatrixMode(GL_PROJECTION); glLoadMatrixf(old_matrix_projection); glMatrixMode(GL_MODELVIEW); glLoadMatrixf(old_matrix_modelview); glMatrixMode(old_matrix_mode); } } else { if (interval != -1 && interval != swap_interval) { swap_interval = interval; if (wglSwapIntervalEXT) wglSwapIntervalEXT(swap_interval); } BOOL retval = SwapBuffers(get_device_context()); if (dwm_layered) { int width = get_viewport().get_width(); int height = get_viewport().get_height(); glReadBuffer(GL_FRONT); PixelBuffer pixelbuffer(width, height, tf_r8); glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelStorei(GL_PACK_ROW_LENGTH, pixelbuffer.get_pitch() / pixelbuffer.get_bytes_per_pixel()); glPixelStorei(GL_PACK_SKIP_PIXELS, 0); glPixelStorei(GL_PACK_SKIP_ROWS, 0); glReadPixels( 0, 0, width, height, GL_ALPHA, GL_BYTE, // use GL_BITMAP here for even less transfer? pixelbuffer.get_data()); win32_window.update_layered(pixelbuffer); } } OpenGL::check_error(); }
void Canvas::set_program_object(StandardProgram standard_program) { flush(); get_gc().set_program_object(standard_program); }
void Canvas::reset_rasterizer_state() { flush(); get_gc().reset_rasterizer_state(); }
l_variable l_string::gc_merge_left(l_string* string) { return get_gc()->new_obj< l_string >(string->m_cpp_str+m_cpp_str); }
void CL_GUIComponent::load_css_layout(const CL_String &xml_filename, const CL_String &css_filename) { CL_CSSDocument2 css_document; css_document.add_sheet(css_filename); CL_File file(xml_filename); CL_DomDocument dom(file, false); CL_DomNode cur = dom.get_document_element().get_first_child(); std::vector<CL_CSSLayoutElement> element_stack; { CL_DomSelectNode select_node(dom.get_document_element()); impl->css_element.apply_properties(css_document.select(&select_node)); impl->css_element.apply_properties(dom.get_document_element().get_attribute("style")); impl->css_element.set_col_span(dom.get_document_element().get_attribute_int("colspan", 1)); impl->css_element.set_row_span(dom.get_document_element().get_attribute_int("rowspan", 1)); } element_stack.push_back(impl->css_element); while (!cur.is_null()) { CL_CSSLayoutElement child_css_element; if (cur.is_element()) { CL_DomElement cur_element = cur.to_element(); CL_DomSelectNode select_node(cur_element); child_css_element = element_stack.back().create_element(cur_element.get_tag_name()); child_css_element.apply_properties(css_document.select(&select_node)); child_css_element.apply_properties(cur_element.get_attribute("style")); child_css_element.set_col_span(cur_element.get_attribute_int("colspan", 1)); child_css_element.set_row_span(cur_element.get_attribute_int("rowspan", 1)); } else if (cur.is_text()) { CL_DomText cur_text = cur.to_text(); element_stack.back().create_text(cur_text.get_node_value()); } CL_DomNode next = cur.get_first_child(); if (next.is_null()) { next = cur.get_next_sibling(); if (next.is_null()) { next = cur.get_parent_node(); while (!next.is_null() && next.get_next_sibling().is_null()) next = next.get_parent_node(); if (!next.is_null()) next = next.get_next_sibling(); } } else { element_stack.push_back(child_css_element); } cur = next; } CL_GraphicContext gc = get_gc(); impl->css_layout.layout(gc, get_size()); }
void Canvas::reset_blend_state() { flush(); get_gc().reset_blend_state(); }
void Canvas::clear_stencil(int value) { flush(); get_gc().clear_stencil(value); }
void Canvas::clear_depth(float value) { flush(); get_gc().clear_depth(value); }
l_variable l_string::gc_merge_left(const std::string& str) { return get_gc()->new_obj< l_string >(str+m_cpp_str); }
MenuBar::MenuBar(CL_GUIManager &manager, CL_ResourceManager &application_resources) : CL_Window(&manager, CL_GUITopLevelDescription("Menu Bar & Status Bar", CL_Rect(512 + 24, 256 + 16, CL_Size(256, 180)), false)) { tux_image = CL_ImageProviderFactory::load("../CommonCode/Resources/tux.png"); CL_GraphicContext gc = get_gc(); tux_head = CL_Image(gc, "tux_head", &application_resources); set_draggable(true); CL_Rect client_area = get_client_area(); menubar1 = new CL_MenuBar(this); menubar1->set_geometry(CL_Rect(client_area.left, client_area.top, client_area.right, client_area.top + 25)); menu_file.insert_item("New").func_clicked().set(this, &MenuBar::on_item_selected); menu_file.insert_item("Open").func_clicked().set(this, &MenuBar::on_item_selected); menu_file.insert_item("Save").func_clicked().set(this, &MenuBar::on_item_selected); CL_PopupMenuItem tux_item = menu_file.insert_item("Tux"); tux_item.func_clicked().set(this, &MenuBar::on_item_selected); tux_item.set_icon(tux_image); menu_file.insert_item("Exit").func_clicked().set(this, &MenuBar::on_item_selected); menubar1->add_menu("File", menu_file); menu_edit.insert_item("Undo").func_clicked().set(this, &MenuBar::on_item_selected); CL_PopupMenuItem redo_item = menu_edit.insert_item("Redo"); redo_item.func_clicked().set(this, &MenuBar::on_item_selected); redo_item.set_enabled(false); menu_edit.insert_separator(); menu_edit.insert_item("Cut").func_clicked().set(this, &MenuBar::on_item_selected); menu_edit.insert_item("Copy").func_clicked().set(this, &MenuBar::on_item_selected); menu_edit.insert_separator(); item_submenu = menu_edit.insert_item("Submenu"); item_submenu.func_clicked().set(this, &MenuBar::on_item_selected); menu_edit.insert_separator(); menu_edit.insert_item("Paste").func_clicked().set(this, &MenuBar::on_item_selected); menu_edit.insert_item("Delete").func_clicked().set(this, &MenuBar::on_item_selected); menu_edit.insert_separator(); menu_edit.insert_item("Select All").func_clicked().set(this, &MenuBar::on_item_selected); menu_submenu.insert_item("foo").func_clicked().set(this, &MenuBar::on_item_selected); menu_submenu.insert_item("bar").func_clicked().set(this, &MenuBar::on_item_selected); menu_submenu.insert_item("foobar").func_clicked().set(this, &MenuBar::on_item_selected); CL_PopupMenuItem check_item1 = menu_submenu.insert_item("Checkable 1"); check_item1.func_clicked().set(this, &MenuBar::on_item_selected); check_item1.set_checkable(true); check_item1.set_checked(true); CL_PopupMenuItem check_item2 = menu_submenu.insert_item("Checkable 2"); check_item2.func_clicked().set(this, &MenuBar::on_item_selected); check_item2.set_checkable(true); check_item2.set_checked(false); CL_PopupMenuItem check_item3 = menu_submenu.insert_item("Disabled Checkable 1"); check_item3.func_clicked().set(this, &MenuBar::on_item_selected); check_item3.set_checkable(true); check_item3.set_checked(true); check_item3.set_enabled(false); CL_PopupMenuItem check_item4 = menu_submenu.insert_item("Disabled Checkable 2"); check_item4.func_clicked().set(this, &MenuBar::on_item_selected); check_item4.set_checkable(true); check_item4.set_checked(false); check_item4.set_enabled(false); item_submenu.set_submenu(menu_submenu); menubar1->add_menu("Edit", menu_edit); int xoffset = client_area.left + 80; int yoffset = client_area.top + 30; const int gap = 16; CL_Size label_size(50, 15); info_item_selected = new Info(this); info_item_selected->set(xoffset, yoffset, "Item Selected"); yoffset += gap; statusbar1 = new CL_StatusBar(this); int statusbar_height = statusbar1->get_preferred_height(); CL_Rect statusbar_rect(0, client_area.get_height() - statusbar_height, CL_Size(client_area.get_width(), statusbar_height)); statusbar_rect.translate(client_area.left, client_area.top); statusbar1->set_geometry(statusbar_rect); statusbar1->set_status_text("Status bar"); statusbar1->show_size_grip(true); pushbutton1 = new CL_PushButton(statusbar1); pushbutton1->set_icon(tux_head); pushbutton1->func_clicked().set(this, &MenuBar::on_clicked, pushbutton1); statusbar1->add_part(0, 48, pushbutton1); statusbar1->func_part_double_clicked(0).set(this, &MenuBar::on_part_double_clicked_0, statusbar1); component1 = new CL_GUIComponent(statusbar1); statusbar1->add_part(1, 48, component1); statusbar1->set_part_text(1, "ClanTest"); statusbar1->func_part_double_clicked(1).set(this, &MenuBar::on_part_double_clicked_1, statusbar1); CL_GUIComponent *component2 = (new CL_GUIComponent(statusbar1)); statusbar1->add_part(2, 48, component2); statusbar1->set_part_text(2, tux_head, ""); statusbar1->func_part_double_clicked(2).set(this, &MenuBar::on_part_double_clicked_2, statusbar1); xoffset = client_area.left + 5; yoffset = client_area.top + 40; label_status = new CL_Label(this); label_status->set_geometry(CL_Rect(xoffset, yoffset, label_size)); label_status->set_text("Status Bar:"); yoffset += gap; checkbox_status_size_grip = new CL_CheckBox(this); checkbox_status_size_grip->set_geometry(CL_Rect(xoffset, yoffset, CL_Size(150, 15))); checkbox_status_size_grip->func_checked().set(this, &MenuBar::on_checked_status_size_grip, checkbox_status_size_grip); checkbox_status_size_grip->func_unchecked().set(this, &MenuBar::on_unchecked_status_size_grip, checkbox_status_size_grip); checkbox_status_size_grip->set_text("Show Size Grip"); checkbox_status_size_grip->set_checked(true); yoffset += gap; checkbox_status_text = new CL_CheckBox(this); checkbox_status_text->set_geometry(CL_Rect(xoffset, yoffset, CL_Size(150, 15))); checkbox_status_text->func_checked().set(this, &MenuBar::on_checked_status_text, checkbox_status_text); checkbox_status_text->func_unchecked().set(this, &MenuBar::on_unchecked_status_text, checkbox_status_text); checkbox_status_text->set_text("Change Status Text"); checkbox_status_text->set_checked(true); yoffset += gap; checkbox_status_show_clantest = new CL_CheckBox(this); checkbox_status_show_clantest->set_geometry(CL_Rect(xoffset, yoffset, CL_Size(150, 15))); checkbox_status_show_clantest->func_checked().set(this, &MenuBar::on_checked_show_clantest, checkbox_status_show_clantest); checkbox_status_show_clantest->func_unchecked().set(this, &MenuBar::on_unchecked_show_clantest, checkbox_status_show_clantest); checkbox_status_show_clantest->set_text("Show ClanTest"); checkbox_status_show_clantest->set_checked(true); yoffset += gap; checkbox_status_remove_clantest = new CL_CheckBox(this); checkbox_status_remove_clantest->set_geometry(CL_Rect(xoffset, yoffset, CL_Size(150, 15))); checkbox_status_remove_clantest->func_checked().set(this, &MenuBar::on_checked_remove_clantest, checkbox_status_remove_clantest); checkbox_status_remove_clantest->func_unchecked().set(this, &MenuBar::on_unchecked_remove_clantest, checkbox_status_remove_clantest); checkbox_status_remove_clantest->set_text("Remove ClanTest"); checkbox_status_remove_clantest->set_checked(false); yoffset += gap; xoffset = client_area.left + 110; yoffset -= (gap*2); info_clicked = new Info(this); info_clicked->set(xoffset, yoffset, "Push Button Clicked"); yoffset += gap; info_part_clicked = new Info(this); info_part_clicked->set(xoffset, yoffset, "Part Dbl Clicked"); }