示例#1
0
void bsglWidget::MouseAt(float x, float y, MouseState state) {
    static float ox;
    static float oy;
    bool post = false;
    switch (state) {
        case MouseState_Default: {
            this->OnOver(x, y);
            post = true;
        }break;
        case MouseState_Down: {
            if (TestAt(x, y)) {
                bool inKids = false;
                std::list<bsglWidget*>::iterator itr = kids_.begin();
                bsglWidget* w;
                for (; itr!=kids_.end(); ++itr) {
                    w = *itr;
                    if (w->TestAt(x-x_, y-y_)) {
                        inKids = true;
                        break;
                    }
                }
                if (inKids) {
                    focus_ = false;
                    w->MouseAt(x-x_, y-y_, state);
                }else {
                    focus_ = true;
                    ox = x;
                    oy = y;
                    this->OnDown();
                }
            }
            post = false;
        }break;
        case MouseState_Passing: {
            if (focus_) {
                this->OnMove(x-ox, y-ox);
                ox = x;
                ox = y;
            }
            post = true;
        }break;
        case MouseState_Up: {
            if (focus_) {
                this->OnUp(TestAt(x, y));
                focus_ = false;
            }
            post = true;
        }break;
        default: break;
    }
    if (post) {
        std::list<bsglWidget*>::iterator itr = kids_.begin();
        for (; itr!=kids_.end(); ++itr) {
            bsglWidget* w = *itr;
            w->MouseAt(x-x_, y-y_, state);
        }
    }
}
示例#2
0
文件: vectortest.c 项目: JuDa-hku/ACM
static void SimpleTest()
{
  fprintf(stdout, " ------------------------- Starting the basic test...\n");
  vector alphabet;
  VectorNew(&alphabet, sizeof(char), NULL, 4);
  TestAppend(&alphabet);
  TestSortSearch(&alphabet);
  TestAt(&alphabet);
  TestInsertDelete(&alphabet);
  TestReplace(&alphabet);
  VectorDispose(&alphabet);
}