1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

I need help with xwindows!

Discussion in 'C' started by Johnathanx, Nov 26, 2007.

  1. Johnathanx

    Johnathanx New Member

    Joined:
    Nov 26, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi!

    I am really having trouble with xwindows.

    I have managed to create a colour chooser, that creates a rectangle and allows the user to change the colour by typing in values accordingly.

    I want to be able to create a moving rectangle that will rotate clock-wise on the same window as my previous changing colour box.

    The code i have so far is as follows.

    Code:
     
    
    
    #include "mywin.h"
    #include "button.h"
    #include "textwin.h"
    #include <stdio.h>
    
    Button B1, B2;       /* Buttons must be declared, then Created */
                     /* before they become live */
    
    Textwin red, green, blue;
    
    char mousestr[100];
    
    
    Colour makeColour(int red, int green, int blue)
    {
    	return((red&0xff)<<16|(green&0xff)<<8|(blue&0xff));
    }
    
    void move()
    {
    
    }
    
    void draw2()
    {
        XClearWindow  (display, main_win);
        XFillRectangle(display, main_win, gc_1, 50, 50, 100, 100);
        XSetForeground(display, gc_1, makeColour (atoi(red.text), atoi(green.text), atoi(blue.text)));
        XFlush(display);
    }
    
    void B1fn()
    {
        draw2();
    }
    
    void B2fn()
    {
    	move();
    }
    
    void draw()       /* AKA FormPaint */
    {
        XClearWindow  (display, main_win);
        XFillRectangle(display, main_win, gc_1, 50, 50, 100, 100);
    }
    
    int main()
    {
        setupX();
        make_window(600, 400, "Colour Chooser");    
        Textwin_Create(&red, 10, 200, 170, 28, "Red", "red");
        Textwin_Create(&green, 10, 250, 170, 28, "Green", "green");
        Textwin_Create(&blue, 10, 300, 170, 28, "Blue", "blue");
        Button_Create( &B1, 10, 350, 170, 28, "Double-Click to update", &B1fn);
    	Button_Create( &B2, 200, 200, 170, 28, "Start Revolving Square", &B2fn);
        event_loop(subwindowlist);
        return -1;
    }
    
    
    Anybody have any idea at all how i can make the move() function create a rotating rectangle?!

    Any help on this at all is greatly appreciated
     

Share This Page